| | | | <- prev | |

Vector Representation of Complete Binary Tree

Tree Data
  • Vector elements carry data
Illustration
Tree Structure
  • Vector indices carry tree structure
  • Index order = levelorder (beginning with 0)  
  • Tree structure is implicit
  • Uses integer arithmetic for tree navigation
Tree Navigation
  • Parent of v[k] = v[(k-1)/2]
  • Left child of v[k] = v[2*k+1]
  • Right child of v[k] = v[2*k+2]

<- prev | | Top of Page | 10. Generic Heap Algorithms, Priority Queues, Heap Sort - 1 of 12