Question: An algorithm has the following running time: T (n) = 1 + 1/2 + 1/3 + 1/4 + 1/5 + ... + 1/n Assume that
An algorithm has the following running time: T (n) = 1 + 1/2 + 1/3 + 1/4 + 1/5 + ... + 1/n
Assume that n = 2k1 for some k > 0
A) If we group the terms (from left to right) using group sizes 1,2,4,8,16,32, .., how many groups will there be as a function of k and n (need the exact number of groups)
B) Show that T(n) is O(logn)
C) Using the similar idea of grouping (the sizes of the groups are power of 2s), show that T(n) is (logn), and therefore (logn)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
