

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This assignment was given by Manju Nripendra at West Bengal State University for Theory of Complexity and Algorithms course. It includes: Divide, Conquer, Algorithm, Psuedo, Code, Array, Paradigm, Asymptotic, Expression, Master, Method
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Divide-and-conquer
(Only a divide-and-conquer algorithm will be accepted here. Of course you can find the minimum in time O(n), but the point is to understand the divide-and-conquer paradigm.)
What is the running time of your algorithm?
(a) T (n) = 2T (n/2) + log n (b) T (n) = 7T (n/3) + n^2 (c) T (n) = 9T (n/3) + n^3 log n (d) T (n) = 16T (n/2) + (n log n)^4 (e) T (n) = 4T (n/2) + n^2 (f) T (n) = 2T (n/2) + 10n (g) T (n) = 8T (n/2) + 1000n^2 (h) T (n) = 3T (n/3) +
n (i) T (n) = 2T (n/2) + n log n (j) T (n) = 3T (n/2) + n^2 (k) T (n) = T (n/2) + 2n
Hints:
(a) First consider the case where one of P and R is equal to 1, i.e. the tallest person is standing at one end of the line. Find an expression for Q(N, P, 1) in terms of N and P. (First figure out for what values of N and P is this non-zero?)
(b) Second, note that Q(N, P, R) = Q(N, R, P ), i.e. it doesn’t matter what you consider the “front” and “rear” of the queue. (c) What happens when both P ≥ 2 and R ≥ 2? This means that the tallest person in the group is somewhere in the “middle” of the queue (i.e. is not on the end). This effectively divides the queue into two parts (which overlap on this common tallest person). In this case you want to find an expression for Q(N, P, R) in terms of (various values of) Q(N ′, P, 1) and Q(N ′′, 1 , R)(= Q(N ′′, R, 1) from the second hint) for appropriate values of N ′^ and N ′′. This last part is why this problem has a “divide-and-conquer” style of solution to it, if not exactly fitting into the Divide-and- Conquer type of problems we have discussed.