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...

how to calculate the time complexity of a given algorithm?
pls give exaples..mainly for the coplexities such as O(log
n),O(n log n)...

Answer Posted / s v s pradeep

Generally 0(log n) and 0(n log(n)) will come into picture
if u are dealing with the programs that have for loops
(where the increment is divided or multiplied), functional
blocks.

Eg. for(i=0;i<n;i=i++)
for(j=0;j<n;j=j*2)
......
Here in this case the inner loop complexity is 3n+2 where
the outer loop complexity will be in logarithm terms
because every time when we increment i value the, i is
multiplied by 2 so the no of iterations will be reduced ..
so when the iterations are reduced then we will get log(n)


so, for the above example the complexity will be 0(n log(n))
n-- for the outer loop and log(n) is for inner loop.

so multiply the no of times innerloop will be executed for
the outer loop. so n*log(n).
So the time complexity will be 0(n log(n)).

..

Is This Answer Correct ?    14 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is non linear data structure in c?

1074


When should you use a type cast?

1189


Write a program to print fibonacci series using recursion?

1135


Describe the header file and its usage in c programming?

1107


Explain about block scope in c?

1149


What is the difference between far and near in c?

1121


Is fortran still used today?

1150


The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this

3661


What is c value paradox explain?

1165


What are structural members?

1066


Write a program to find factorial of a number using recursive function.

1182


what is the height of tree if leaf node is at level 3. please explain

2202


What are extern variables in c?

1042


can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......

1971


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

2184