Skip to content
Related Articles

Related Articles

GATE | GATE-CS-2015 (Mock Test) | Question 10

Improve Article
Save Article
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!