Use this problem description for Problems 1-2.
Let A = [ a1, a2, ... an ] be an array of integers. We would like to find d, the distance between the two closest numbers in the array. The distance between any two numbers ai and aj is |ai - aj|. For example, if A = [9, 14, 25, 6, 16], then d = 2.
You may use either a tree implementation or an array implementation for your heap. Be sure to use a parental dominance rule where a node is ≤ all of its children, not strictly <. You will receive partial credit for using the bottom-up algorithm to construct the heap.
To help us help them solve this problem, they have created a large number of data files, one for each day of the year. Each file contains an even number of integers, in pairs that correspond to the login time and session length for every lab user on campus on that day. For example, a file that contains:
0115 47 0737 3 1104 78 1852 422
records four users. The first logged in at 1:15 AM and worked for 47 minutes. The last logged in at 6:52 PM and worked for 7 hours, 2 minutes. (He must have had an algorithms project to do!)
Use the Sliding Delta pattern to design an algorithm to find the maximum number of users at any point in time last year.