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
Briefly describe an experience of yours that illustrates your ability to clearly articulate and explain technical issues in a nontechnical manner
compair and contrast procedrual and object oriented programming language
why view is created in database
WAP in Java to print the format: ABC BCD CDE EFG
Apply Newton?s method to compute the approximate value of root 2. Start the iteration from x0=1, and obtain two iterations.
How to Shut-down the system through QTP Script?
model question papers of GrayOrange company
Write steps of retrieving data using ado.net?
i want to knw about what is lead,survey, oppertuinty , questionary,sales order,quotation,marketng conecpts in deatil and how it works in SAP CRM. Please send to my email- id as soon as possible. Thanks in Advance . :) nimi.nimisha1@gmail.com
sir ,,kindly provide me 10 year old solved question papers of gate ,i am from CS. branch...
What is candidate key ? What is Alter net key ? & What is foreign key ?
10. Write a program in āCā language that will perform the following operation on double link list. Each node of this list contains the address of previous as well as next node. The previous pointer of first node & next pointer of last node should contain null. 1. Creation of list with as many records as user want 2. Search a node in the list 3. Deletion at last position 4. Display 5. Exit Create separate functions for each operation. The create () will be used to create the list. It should accept no argument & return the address of the starting node. Search() will search a node in the list. It receives rollno as argument & return that node if found otherwise return null. The delete () function will delete the last node. It does not receive any argument & return structure type value at last position. The starting node of the double list must be declared as external pointer variable. Each element of double link list will contain the following information Roll No, Std Name, Course. Use do-while loop & switch case for generating the above menu. The format of the output should is given below: S.No. Roll No. Student Name Course 1 cse01 Anil Singh B.Tech
hi... i just want to know that how could join the AAI with an B.E back ground??? please help me out.
how to find out the name of the users who are currently working starting with the same characters in unix os
Write a program to input 10 elements in an array and seperate even and odd numbers, positive and negative between them ?