| | | | | |

Binary Search Revisited

  • Binary search -- tree version
  • Assumes totally ordered binary tree
    • begin at root node
    • descend using comparison to make left/right decision
      • if (search_value < node_value) go to node_left_child
      • else if (search_value > node_value) go to node_right_child
      • else return true (success)
    • until descending move is impossible
    • return false (failure)
  • Run time <= descending path length <= depth of tree
  • If tree has enough branching, runtime <= O(log size)

| | Top of Page | 12. Binary Search Trees - 3 of 27