Representation of binary tree in memory

36,245 views 8 slides Feb 15, 2013
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

No description available for this slideshow.


Slide Content

Representation of Binary tree in memory Let T be a binary. There are two ways for representing binary tree in memory. Sequential Representation Linked Representation

Sequential Representation Suppose T is a complete binary tree. Then only single linear array TREE is used as follows.

The root R is stored in TREE[0]. If a node n occupies TREE[K], then its left child in TREE[2*K] & right child TREE [2*K+1]. If TREE[1]=NULL then it is empty tree.

Linked Representation The linked representation uses three parallel arrays,INFO,LEFT & RIGHT & a pointer variable ROOT.Each node N of Y will correspond to a location K such that: 1) INFO[K] contains the data at node N. 2) LEFT[K] contains the location of left child of node N. 3) RIGHT[K] contains the location of right child of node N. ROOT will contain location of root R of T.

A sample representation is shown in fig.
Tags