What is the time complexity T(n) of the nested loops
below? For simplicity, you may assume that n is a power of
2. That is, n = 2k for some positive integer k.
:
i = n;
while (i >= 1){
j = i;
while (j <= n) {
<body of the inner while loop > //
Needs &#61553;(1).
j = 2 * j;
}
i = &#61675;i/2&#61691;;
}
:

Answer Posted / muhammad ijaz khan

The outer loop divides the working area in half in each
iteration. So the running time of this algorithm is
proportional to the number of times n can be divided by 2.
The inner loop will be executed unlimitted time. So
the time complexity of the outer loop will be the function
of ln and the total time is: T(n)= n*ln n

Is This Answer Correct ?    10 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

if we give you the job AS A PETROLEUM ENGINEER WHAT WILL YOU DO(that is extraordinary) for our company

3068


what books to prepare for atc please

1767


How to Shut-down the system through QTP Script?

1589


How would Nvidia increase the core clock speed anymore?

1905


Hai friends this is Dara s. solanki, i done in B.Sc.(IT) i have an 2.3 years of exp in Manufacturing company in MIS giving support in SAP , 1 year back i did Sap course In MM Module. am trying from the day one to enter into the sap field but i was not.i kindly requesting all, please suggest me how to enter in to the SAP field. Looking for a job . i please help me and having any thing please let me know . i am in bangalore. my mail id is Dara.solanki@gmail.com. 8431455753

1906


need tcs questn papers from 2007 to 2009 plzzzmail to 9015.rama@gmail.com its urgent

1769


plz plz help me "how can i face dell varcent round"....? plzzzzzzzz help me friends.....?

1783


how to count number of 3's in 100

2029


What is the pressure in co2 cartridge in a DCP 5 kg extinguisher.

3090


what is a Additional domain ? what is a child domain?

2595


A polynomials in mamory can be represented by____________

1784


what is c dot

1726


how can read number 1 to 100,without use anyloop.

1511


what is the pri request of binary search

1511


I have done BE ( computer science) i secleted in sbi clerical written exam. so what questions they asked according to my subject please send me the answer

1782