Need help finding running time of algorithm

0 views
Skip to first unread message

Crystal A.

unread,
Dec 11, 2010, 2:35:09 PM12/11/10
to Design and Analysis of Algorithms
Hi guys, do any of you have the solution to this problem?

COMP 3000 April/May 2008

Q2. e) (i) Give the order of the running time in terms of n...

read(n);
w=0;
a=1;
while (a<=n){
for (b=1; b<=a; b++) w++;
a= a*2;
}

emacs ray

unread,
Dec 26, 2010, 7:00:10 PM12/26/10
to Design and Analysis of Algorithms
w is finally 1+2+4+...=Θ(n)
Reply all
Reply to author
Forward
0 new messages