A binary tree data structure is represented using two methods. Those methods are as follows...
- Array Representation
- Linked List Representation
Array Representation of Binary Tree
In array representation of a binary tree, we use one-dimensional array (1-D Array) to represent a binary tree.
Consider the above example of a binary tree and it is represented as follows...
To represent a binary tree of depth 'n' using array representation, we need one dimensional array with a maximum size of 2n + 1.
Linked List Representation of Binary Tree
We use a double linked list to represent a binary tree. In a double linked list, every node consists of three fields. First field for storing left child address, second for storing actual data and third for storing right child address.
The above example of the binary tree represented using Linked list representation is shown as follows...
No comments:
Post a Comment