{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Trees_Part_4 - Array-Based Representation of Binary Trees...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Last Updated: 12-01-24 11:27 AM CSE 2011 Prof. J. Elder - 25 - Array-Based Representation of Binary Trees Øඏ nodes are stored in an array, using a level-numbering scheme. let rank(node) be defined as follows: rank(root) = 1 if node is the left child of parent(node), rank(node) = 2*rank(parent(node)) if node is the right child of parent(node), rank(node) = 2*rank(parent(node))+1 1 2 3 6 7 4 5 10 11 A H G F E D C B J
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Last Updated: 12-01-24 11:27 AM CSE 2011 Prof. J. Elder - 26 - Comparison Linked Structure Øඏ Requires explicit representation of 3 links per position: parent, left child, right child Øඏ Data structure grows as needed – no wasted space. Array Øඏ Parent and children are implicitly represented: Lower memory requirements per position Øඏ Memory requirements determined by height of tree. If tree is sparse , this is highly inefficient.
Background image of page 2
Last Updated: 12-01-24 11:27 AM CSE 2011 Prof. J. Elder - 27 - Inorder Traversal of Binary Trees Øඏ In an inorder traversal a node is visited after its left subtree and
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}