English 中文(简体)
Worst case running time (Big O)
原标题:

I have this question, and I don t know how to solve it, because I don t understand it. :(

The question is:

Programs A and B are analyzed and are found to have worst case running times no greater than 150n log n and n2, respectively. Answer the following questions:

i) Which program has the better guarantee on the running time for large values of n (n > 10000)?

ii) Which program has the better guarantee on the running time for small values of n (n < 100)?

Can any one help me and explain it for me?

问题回答

You re given two formulae and two different values of n to plug into them. Then you re asked which formula has the larger value in each case.

I suggest plugging the two values of n into the formulae and figuring out which is larger in each case.

Worst case run time means the absolute longest the program will run given an input of length n. So the two formulas you were given are their worst case run times. Mathematically, both formulas behave differently at different sizes of n. Experiment with the size of n and see how they respond. That will help you understand and find your answers.

See yourself at WolframAlpha. The point where the worst cases are equal is circa at 1042. That should answer your question.

If the actual question is O(n^2), ii is a trick question.

In Big-O notation, you can drop constants, so O(10000n^2) is the same as O(n^2). If you haven t removed the O() from the question, then just fill in the equations, that shouldn t be hard to work out.





相关问题
What are the differences between NP, NP-Complete and NP-Hard?

What are the differences between NP, NP-Complete and NP-Hard? I am aware of many resources all over the web. I d like to read your explanations, and the reason is they might be different from what s ...

Implementation Detail for Graph Analysis Algorithms

Let s say I have a graph with "heavy" nodes, that is each node is an object that is already carrying a lot of data. I want to do a graph transformation that requires me to calculate a special ...

Worst case running time (Big O)

I have this question, and I don t know how to solve it, because I don t understand it. :( The question is: Programs A and B are analyzed and are found to have worst case running times no ...

RSA cryptosystem

Hi i am trying to set up an RSA cryptosystem i have all the values except d selected prime numbers: p=1889, q=2003, n=3783667, phi=3779776, e= 61 i got stuck finding d could anyone help me to figure ...

BNF Grammar Derivation

I want to apply rules of BNF Grammar to produce derivation for : a_Num

热门标签