GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Keys 1 to 5 are inserted into an empty BST in a uniformly random order of the 120 possible orders. In how many of the orders does key 3 end up at depth 1 (a child of the root)?

  1. A. 28
  2. B. 24
  3. C. 48
  4. D. 40

Correct answer: A. 28

Building the BST for each of the 120 orders and recording the depth of key 3 gives depth 0: 24, depth 1: 28, depth 2: 38, depth 3: 24, depth 4: 6 orders.

More Programming and Data Structures (GATE) questions

Exams that ask this topic