Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Representation of binary tree in memory

24,472 views

Published on

  • Be the first to comment

Representation of binary tree in memory

  1. 1. Representation of Binary treein memoryLet T be a binary.There are two ways for representing binarytree in memory.Sequential RepresentationLinked Representation
  2. 2. Sequential Representation Suppose T is a complete binary tree. Then only single linear array TREE is used as follows.
  3. 3.  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.
  4. 4. 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.
  5. 5. A sample representation is shownin fig.

×