[prev] [index] [next]

Insertion at Root

Previous description of BSTs inserted at leaves.

Different approach: insert new value at root.

Method for inserting at root (recursive):

  • base case:
    • tree is empty; make new node and make it root
  • recursive case:
    • insert new node as root of L/R subtree
    • lift new node to root by R/L rotation