Question: Augmenting binary search tree. In Josephus problem we start with a set of integers {1,...,n} and we perform a series of operations of the form

Augmenting binary search tree. In Josephus problem we start with a set of integers {1,...,n} and we perform a series of operations of the form DEL (k) which delete the integer with position k in the current sorted order. For example DEL(3), DEL(3), DEL(4) deletes 3, then 4 and then 6. Because we only delete (no insertions) we can use an implicit binary search tree: the squareroot is the largest 2^k such that 2^k lessthanorequalto n, this is a node of rank k; a node m of rank k has two children of rank k - 1; m - 2^k-1 and m + 2^k-1. For each node m we store Present [m], the number of the nodes in its subtree that are present, i.e. not greater than n and not deleted yet. Draw the implicit tree of n = 10 and write what are the values of present [] after DEL(8). Write pseudocode that uses this array to perform FIND (k) which returns numberodes. This should take time O(log n)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
