2

An algorithm decomposes (divides) a problem of size n into b sub-problems each of size n/b where b is an integer. The cost of decomposition is n, and C(1)=1. Show, using repeated substitution, that for all values of 2≥b, the complexity of the algorithm is O(n lg n).

This is what I use for my initial equation C(n) = C(n/b) + n and after k-steps of substituting I get C(n) = C(n/b^k) + n [summation(from i=0 to k-1) of (1/b)^i]

k = log(base b) n

I'm not sure I'm getting all of this right because when I finish doing this i don't get n lgn, anybody can help me figure out what to do?

1 Answer 1

1

I think your recurrence is wrong. Since there are b separate subproblems of size n/b, there should be a coefficient of b in front of the C(n / b) term. The recurrence should be

C(1) = 1

C(n) = b C(n/b) +O(n).

Using the Master Theorem, this solves to O(n log n). Another way to see this is that after expanding the recurrence k times, we get

C(n) = bk C(n / bk) + kn

This terminates when k = logb n. Plugging in that value of k and simplifying yields a value that is O(n log n).

Hope this helps!

Sign up to request clarification or add additional context in comments.

2 Comments

wouldn't the recurrence be b^k C(n / b^k) + b^k *(n + n/b + ... + n/b^k)
or rather something like this i mean C(n) = b^k * C(n / b^k) + k*n

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.