CUET PG 2026 — DSA PYQ
CUET PG | DSA | 2026Find the asymptotic complexity for the recurrence relation T(n)=2T(n)+n.
Choose the correct answer:
- A.
Θ(n)
(Correct Answer) - B.
Θ(nlogn)
- C.
Θ(n2)
- D.
Θ(logn)
Θ(n)
Explanation
To solve the recurrence T(n)=2T(n)+n, we apply domain transformation:
Step 1: Change of variable
Let n=2m, so m=log2n.
Since n=n1/2=(2m)1/2=2m/2, substitute this into the equation:
T(2m)=2T(2m/2)+2m
Step 2: Rename the function
Let S(m)=T(2m). The recurrence becomes:
S(m)=2S(m/2)+2m
Step 3: Apply Master Theorem on S(m)
For S(m)=aS(m/b)+f(m):
a=2
b=2
f(m)=2m
Calculate mlogba:
mlog22=m1=m
Since f(m)=2m grows exponentially faster than mlogba=m, Case 3 of the Master Theorem applies:
S(m)=Θ(f(m))=Θ(2m)
Step 4: Substitute back to n
Since 2m=n:
T(n)=Θ(n)
Correct Answer: (A) Θ(n)
Explanation
To solve the recurrence T(n)=2T(n)+n, we apply domain transformation:
Step 1: Change of variable
Let n=2m, so m=log2n.
Since n=n1/2=(2m)1/2=2m/2, substitute this into the equation:
T(2m)=2T(2m/2)+2m
Step 2: Rename the function
Let S(m)=T(2m). The recurrence becomes:
S(m)=2S(m/2)+2m
Step 3: Apply Master Theorem on S(m)
For S(m)=aS(m/b)+f(m):
a=2
b=2
f(m)=2m
Calculate mlogba:
mlog22=m1=m
Since f(m)=2m grows exponentially faster than mlogba=m, Case 3 of the Master Theorem applies:
S(m)=Θ(f(m))=Θ(2m)
Step 4: Substitute back to n
Since 2m=n:
T(n)=Θ(n)
Correct Answer: (A) Θ(n)
