Skip to content
Related Articles

Related Articles

Improve Article
GATE | GATE-CS-2015 (Mock Test) | Question 10
  • Last Updated : 25 Jan, 2015

Select the correct asymptotic complexity of an algorithm with runtime T(n, n) where

T(x, c) = Θ(x) for c <= 2,
T(c, y) = Θ(y) for c <= 2, and
T(x, y) = Θ(x+y) + T(x/2, y/2) 

(A) Θ(nLogn)
(B) Θ(n2)
(C) Θ(n)
(D) Θ(n2Logn)

Answer: (C)

Explanation: The recurrence is

T(x, y) = Θ(x+y) + T(x/2, y/2) 

It can be written as below.

T(x, y) = Θ(x+y) + Θ((x+y)/2) + Θ((x+y)/4) +  Θ((x+y)/8)  .....
T(x, y) = Θ((x+y) + (x+y)/2 + (x+y)/4 + (x+y)/8  ..... )

The above expression forms a geometric series with ratio as 2 and starting element as (x+y)/2

T(x, y) is upper bounded by Θ(x+y) as sum of infinite series is 2(x+y). It is lower bounded by (x+y)


Quiz of this Question

Attention reader! Don’t stop learning now. Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :