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
How EVA granules manufactured (I wanted to know the manufacturing process). (Virgin Granules) and what are the Raw Materials used.
sir/medam i had completed my B-TECH(CSE)2011 with 61%.i have to go USA for futhure studies.i dnt know what is steps for do futhure studies in USA so could you please tell me
Hi, what is the meaning of DOCUMENTUM,how and what testers have to do with it?
hi friends i am b-tech in computer science having interview of State bank of india clerk day on 30 th april. I want to know the answer of question:"you r B.tech in C.S. why do u want to become a bank clerk?" please help.Its my humble request.
what is mean by tranducer
what is static identifier in c language?
i am going to give interview for the post of ibps po..so there is a question in my mind which is "Being an electonics and communication engineer how can you help in banks, I mean whats the application of your education in banking."
what is the definition(body) of a default constructor in c++?
dam,rivers,states capt,
how will u recieve idoc
. Give the C language equivalents of the following a)Function returning an int pointer b)Function pointer returning an int pointer c)Function pointer returning an array of integers d)Array of function pointer returning an array of integers
a steel bar 1' inch square 6' long is to be used as a column.ends are free to rotate put may not be displaced.stress is limited to 30,000 PSI
what is different between static block and public static void main??
What is the difference between a gun and a rifle and what advantage does a spinning bullet have?
How we calculate the recovery of steam as per coal in a boiler if we know the calorific value of coal?