0

I have two running time functions here. TA(n)= n^2+n+8 TB(n)= n+4

I suppose I need to use big O notation here. The first one is O(n^2) and the second one is O(n). Tnen I need to compare these two algorithms, however, I do not know how I can find the value of n, when two algorithms are the same fast, and when TA is faster then TB and when TB is faster than TA.

The correct answer is when n=2, two algorithms are the same fast, but i do not know how to get n. Can anyone help?

  • I don't understand your question: If you set n=2 in your case, TA(2)=14 and TB(2)=6. How can they have the same speed? – Reinhard Männer Feb 13 '23 at 16:19
  • that is why I asked this question because I do not know either why the answer is 2. – RicardoMLu Feb 13 '23 at 16:22
  • 2
    n²+n+8=n+4 has no solution. Your problem statement must be wrong. –  Feb 13 '23 at 18:06
  • if `TA(n),TB(n)` are really time functions and not complexities then `TB(n)` is always faster than `TA(n)` no matter what (non negative integer) `n` you use ... If they are complexities then you are missing constant time factor in both expressions which can be ["measured" / fit](https://stackoverflow.com/a/64784308/2521214) and then solved ... however you might hit any barrier/bottleneck/glitch in time/n dependence related to use computing HW and program implementation specifics – Spektre Feb 15 '23 at 12:02

0 Answers0