# Algorithmic analysis using log [duplicate]

How would I solve the following.

An algorithm that is O(Lg_2 n) takes 10 seconds to execute on a particular computer when n=100, how long would you expect to take it when n=500?

An algorithm that is O(n lg_2 n) takes 10 seconds to execute on a particular computer when n=100, how long would you expect to take it when n=500?

For the first one would I do

10/ln(100)/ln(2) times ln(500)/(ln2)?

• you had a very similar question somewhere else. – AJed May 5 '13 at 0:19
• It is a bit different from my previous question becames it is a log order of magnitude. – Fernando Martinez May 5 '13 at 16:43

Let's do the first one. The running time of the algorithm is roughly $C\log n$ for some $C$ (we can "swallow" the base of the logarithm into $C$). When $n = 100$ you know that $C\log n = 10s$. Determine $C$, and then compute $C\log 500$. (You can also use a "shortcut" like the one you're trying to do, but it's more helpful to do it this way, since such a shortcut is harder to come by in the second part of the question.)

• How would I do the second one however kind sir. – Fernando Martinez May 5 '13 at 16:57
• In the same way that you did the first. Don't expect me to solve the question for you. Once you really understand the first part, you will be able to solve the second part on your own. – Yuval Filmus May 5 '13 at 17:02
• Hmm I see I understand the first one but not the second would I do C lg=10 sec and n is 100 and the do C ln(500) would this be correct, if not would you kindly tell me how to solve it? – Fernando Martinez May 5 '13 at 17:11
• I think at this stage it is better if you tried solving the question on your own, using the guidance in my answer if you find it helpful. You only truly understand the subject if you can be confident in your own solution. – Yuval Filmus May 5 '13 at 17:32