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

后端 未结 6 678
春和景丽
春和景丽 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:18

    When applying a divide-and-conquer algorithm where you partition the problem into sub-problems until it is so simple that it is trivial, if the partitioning goes well, the size of each sub-problem is n/2 or thereabout. This is often the origin of the log(n) that crops up in big-O complexity: O(log(n)) is the number of recursive calls needed when partitioning goes well.

提交回复
热议问题