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. n let rank(node) be defined as follows: n rank(root) = 1 n if node is the left child of parent(node), rank(node) = 2*rank(parent(node)) n 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 DocumentRight 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: q parent, left child, right child Ø Data structure grows as needed – no wasted space. Array Ø Parent and children are implicitly represented: q 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 before its right subtree
Background image of page 3

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

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

This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

Page1 / 8

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

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online