Questions:
(i) [4 marks] n/lgn = o(n/lglgn).
(ii) [4 marks] √nlgn = o(n/lgn).
Give sufficient details in your solutions. For example, to show lim = 0, give the steps of applying l’Hopital’s Rule.
You are required to use the version of the master theorem taught in class (also posted of the textbook. Do NOT use the master theorem in the third edition of the textbook, which covers fewer cases.
(a) T(n) = 8T(n/2) + n2
(b) T(n) = 16T(n/2) + (n/lgn)
4
(c) T(n) = 8T(n/3) + Θ(n2)
(d) T(n) = 3T(⌈n/3⌉) + nlgn
For a hotel H, let dH be its distance from the beach and dH its price. Then, according to the discussion above, we consider a hotel A a candidate for booking a room if there is no hotel B that satisfies the following conditions:
(a) dB ≤ dA,
(b) pB ≤ pA, and
(c) at least one of these two inequalities is strict.
Given a set S of n hotels, your goal in this assignment is to develop an algorithm that finds all the candidate hotels in O(nlgn) time using divide-and-conquer, listed in increasing distance to the beach.
You are not allowed to using any sorting algorithms in your solution.
You can make the following assumptions about the input and the output:
Input: An array S[1..n] of pairs of integers (d,p), in which S[i].d stores the distance of hotel to the beach and S[i].p stores the price of hotel i. Note that two hotels may have the same distances and/or prices.
2
Output: An array C of pairs of integers such that its elements C[1],C[2],… give the distances and prices of all the candidate hotels, listed from the candidate hotel closest to the beach to the one farthest away from the beach.
Important: In all of the assignments of this course, when you are asked to give an algorithm for a problem, you are (unless otherwise indicated) expected to
(i) describe the idea behind your algorithm in English;
(ii) provide pseudocode;
(iii) argue that your algorithm is correct; and
(iv) analyze its running time.. Since these requirements apply to all the assignments in this course, this reminder will not be repeated for future assignment questions