You are given an unsorted array A[1..n] containing n = 2<sup>k</sup> distinct integers for some positive
integer k. Design an O(n) expected time algorithm that takes as input the array A, and outputs
an array B of size k such that B[i] contains the element of rank 2<sup>i</sup> in A, where 0 ? i ? k - 1.
For example, if k = 3 and the elements in the array
A are {3, 9, 6, 7, 12, 15, 4, 18}, then you should
output an array B with B[0] = 3, B[1] = 4, and
B[2] = 7.
You may assume the existence of the algorithm Quickselect which has the following guarantee:
given an array A with n elements and an integer r ? [1..n], Quickselect returns the element of
rank r in A (i.e., the r<sup>th</sup> smallest element in A) and runs in O(n) expected time.