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 (1).
j = 2 * j;
}
i = i/2;
}
:
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
if we give you the job AS A PETROLEUM ENGINEER WHAT WILL YOU DO(that is extraordinary) for our company
what books to prepare for atc please
How to Shut-down the system through QTP Script?
How would Nvidia increase the core clock speed anymore?
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
need tcs questn papers from 2007 to 2009 plzzzmail to 9015.rama@gmail.com its urgent
plz plz help me "how can i face dell varcent round"....? plzzzzzzzz help me friends.....?
how to count number of 3's in 100
What is the pressure in co2 cartridge in a DCP 5 kg extinguisher.
what is a Additional domain ? what is a child domain?
A polynomials in mamory can be represented by____________
what is c dot
how can read number 1 to 100,without use anyloop.
what is the pri request of binary search
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