[prev] 28 [next]

Exercise 5: Randomized Insertion

Incorporate insertRandom() into TreeLab
  • add function into Tree ADT
  • use it as insertion method for n command
  • try a variety of random chances
    • 1/(N+1) chance of insertAtRoot()
    • 3/(N+1) chance of insertAtRoot()
    • every third insert is insertAtRoot()
    • every tenth insert is insertAtRoot()