reset password
Author Message
G190852562
Posts: 162
Posted 21:15 Dec 06, 2014 |

For the running time questions, we don't necessarily need the detailed running time of the code, correct? As long as we know the dominant term, the rest do not matter. For instance, if there are two nested loops, the upperbound would be O(n^2). Any extra detail does not matter. For number 5, the correct answer is A * N^2 + B * N + C. I got this answer due to the two nested loops yielding n^2. However, I don't really understand why the B*n term is there.

rabbott
Posts: 1649
Posted 21:33 Dec 06, 2014 |

Big-Oh notation is concerned about the dominant term. The formula you quoted is derived more directly from the code before asking about Big-Oh.

G190852562
Posts: 162
Posted 21:45 Dec 06, 2014 |

I see. So am I giving it the right approach? Or am I supposed to know what every single term correspond to in the code (when given an answer selection such as that).

Last edited by G190852562 at 21:46 Dec 06, 2014.