The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+3 votes
363 views

Solve the recurrence equations:

  • $T(n)= T( \frac{n}{2})+1$
  • $T(1)=1$
asked in Algorithms by Veteran (112k points) | 363 views

5 Answers

+4 votes
Best answer
$T(n) = T(n/2) + 1$

$=T(n/4) + 2$

$= T(n/8) + 3$

$\vdots$

$=T(n/{2^k}) + k.$

Recurrence stops when $2^k >= n$.

When $2^k = n,k = \lg n$

So, $T(n) = T(1) + \lg n \\= 1 + \lg n$

PS: Unless explicitly asked for asymptotic bound, we should give exact answers for solutions of recurrence equations.
answered by Veteran (369k points)
selected by
+1 vote
T(n)=T(n/2)+1

Using Master Theorem :

a=1,b=2,k=0,p=0

T(n)=O(logn)
answered by Active (2.9k points)
+1 vote

It is a standard Recurrence for Binary Search :
T(n) = T(n/2) + Θ(1).

T(n)=T(n/2k)+k
base case T(1)=1
k=logn
T(n)= logn+1
 

answered by Boss (11.9k points)
0 votes

T(n)=T(n2)+1
use master theorem we get answer as logn

answered by Boss (20.7k points)
0 votes
It is easy to solve it by using master theoram. apply condition a=b rasied to power k.
answered by Active (1.4k points)

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

44,337 questions
49,834 answers
164,731 comments
65,874 users