Embercode
✕
Binary Search TreesQuick quiz

Kth with sizes

7 questions. Covers Kth smallest with subtree sizes.

Questions 1 to 5 of 7

  1. 1. Let n be the number of keys in the tree. Which formula gives the position, counted from the smallest, of the kth largest key?
  2. 2. In the tree built by inserting 50, 30, 70, 20, 40, 60 and 80 in that order, what size does node 30 store?
  3. 3. Build the tree from the previous question, then erase 70. Node 70 has two children, so the tree copies its successor into the node and removes the old copy. What size does the root store afterwards?

    Type a number.

  4. 4. On the tree built by inserting 50, 30, 70, 20, 40, 60 and 80, how many nodes does the loop in kth_smallest visit when k is 7?

    Type a number.

  5. 5. The tree is built by inserting 50, 30, 70, 20, 40, 60 and 80 in that order. What does this print? ``cpp std::cout << show(kth_smallest(root.get(), 4)) << ' ' << show(kth_largest(root.get(), 2)) << ' ' << show(kth_largest(root.get(), 7)) << '\n'; ``

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.