| | | | | |

Navigator-based Iterators

  • Requires "3-way" nodes
  • Define Navigator class
  • Define Iterators in terms of Navigators

Facilitating Navigation

  2-D Binary Tree Design

  • Similar to dynamic memory implementation of List
  • Use a structural class Node
  • Node has two pointers:
    • lchild
    • rchild
  • Node has one data field:
    • value
  • The two pointer fields allow navigation down the tree only
    • down-left
    • down-right

  3-D Alternative Facilitates Navigators

  • Node has three pointers:
    • parent
    • lchild
    • rchild
  • Node has one data field:
    • value
  • The three pointer fields allow navigation throughout the tree 
    • up
    • down-left
    • down-right

| | Top of Page | 14. BST Iterators - 11 of 41