Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Write a program to input 10 elements in an array and seperate even and odd numbers, positive and negative between them ?

1851


requirement:To move display statements in a cobol program to a dataset.These display statements were not in main program but in calling program and we were not allowed to move these info via sysout dd dsn='dataset.name' . please let me know the ways this can be handled

2024


What are the input documents to 1.Functional testing,2.System testing and 3.Integration testing. Whether there will be separate test cases for regression testing or functional testing?

2317


difference between a for loop and a while loop? what are its uses in c language?

2395


hi, please send me "state bank of india", last 5 years question paper with answers to my mail id.

2120


what two ways you can use to ensure that visual basic does not allow uncleared variables?

2296


what is b tree

2230


i m doing my 3rd yr with only 6 month left to complete it..within this 6 months which is the best nd useful oracle certification program should i do??pls help me out!!

1692


Can have i call constructor in interface?

2211


What would be the difficulties with building a bridge that connects the UK and Canada?

1263


Qatar petroleum will call me for an technical phone interview as safety officer Please let me know what kind of question they asked ? any idea about this written test ?

6655


Explain power?

1344


which/why unix commands are simpler rather than complex tasks

2559


How will a tester be sure that He’s covered the entire functionality in his Test case and not missed out anything?

1976


What are the differences between 1 dimensional RAM and 2 dimensional RAM?

2723