From the course: Get Ready for Your Coding Interview

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Evaluating time complexity using big O

Evaluating time complexity using big O

From the course: Get Ready for Your Coding Interview

Evaluating time complexity using big O

- Let's see how we can use what we've learned so far to evaluate the time complexity of a function using big O. To do this. We first need to go back to the concept that we covered at the end of the last video. We saw that two times big O of n is still O of n. Now what if we multiplied O of n by n. One way to think about it, is this. Big O of n might represent an expression like an plus b. If we multiply by n we would have half an squared plus bn. Taking the fastest growing term here an squared and ignoring the coefficient we get n squared. So n times big O of n is big O of n squared. In general, if you multiply a big O expressional with n you just need to put it inside the big O expression. For example, n times big O of x is equal to big O and nx, whatever x might be, whether it's one n or n squared. Or if you multiply a big O expression with anything, say y, you can just put it inside the big O expression as…

Contents