Saturday, September 10, 2022

Array Implementation of Binary Trees

One of the ways to represent a tree using an array is to store the nodes level-by-level, starting from the level 0.


Let us consider the complete binary tree



Disadvantages

The various demerits when representing binary trees using arrays are as follows:


1. Other than full binary trees, majority of the array entries may be empty.


2. Dynamic resizing of array is not possible.


3. Insertion and deletions of new nodes is inefficient. ( Requires considerable data movement up and down the array, which demand excessive amount of processing time.)


Advantages


The various merits of representing binary trees using arrays are as follows:


1. Any node can be accessed from any other node by calculating the index.


2. No use of pointers.


0 comments:

Post a Comment

Data Structures with C++



NET/SET/CS PG



Operating Systems



Computer Networks



JAVA



Design and Analysis of Algorithms



Programming in C++

Top