+1 (229) 255-3712
glass
pen
clip
papers
heaphones

  

the first problem is:

You are given an array A with n elements and an integer k < n. Each element in A is at most k away from
its target position. For example, if k = 2, an element at index 7 in the sorted array can be at indexes 5, 6, 7,
8, and 9 in the given array. Implement an algorithm that uses a heap to sorts A in O(n log k) time.

The second problem is:

The company Magic Memories produces magic hard drives. Once a drive with capacity c is used for the
first time, it magically creates a new drive with capacity ?c/2?. The newly created drive is as magical as the
old one. You were able to obtain n such drives with different capacities. Unfortunately, you can only use k
of them at once. Implement an algorithm that determines in O(n log n) time the maximum capacity you
can use.