How to calculate order (big O) for more complex algorithms (eg quicksort)

后端 未结 6 622
春和景丽
春和景丽 2021-01-30 02:54

I know there are quite a bunch of questions about big O notation, I have already checked:

  • Plain english explanation of Big O
  • Big O, how do you calculate/a
6条回答
  •  时光说笑
    2021-01-30 03:03

    Check out the "phone book" example given here: What is a plain English explanation of "Big O" notation?

    Remember that Big-O is all about scale: how much more operation will this algorithm require as the data set grows?

    O(log n) generally means you can cut the dataset in half with each iteration (e.g. binary search)

    O(n log n) means you're performing an O(log n) operation for each item in your dataset

    I'm pretty sure 'O(n log log n)' doesn't make any sense. Or if it does, it simplifies down to O(n log n).

提交回复
热议问题