Limit method

Questions:

  1. [8 marks] Prove the following two identities using the limit method. Recall that lgn =log2 n.

(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.

  1. [12 marks] For each of the following recurrences, use the “master theorem” and give the solution using big-Θ notation. Explain your reasoning. If the “master theorem” does not apply to a recurrence, show your reasoning, but you need not give a solution.

You are required to use the version of the master theorem taught in class (also posted in the online notes), which is the same as the master theorem in the 4th edition 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

  1. [10 marks] A problem database people are often interested in is the following: Consider a set of hotels of acceptable ratings. For each hotel, we know how far away it is from the beach and how much a room costs a night. Ideally, we want to book a room in the cheapest hotel that is closest to the beach, but probably such a hotel will be impossible to find. Therefore, we are willing to compromise. Whether we are willing to trade distance from the beach for price depends very much on our personal preferences, but we would like to avoid booking in a hotel A if there exists a hotel B that is both cheaper and closer to the beach than hotel A.

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 i 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.

2Output: 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