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

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

    You can usually claim log n for algorithms where it halves the space/time each time it runs. A good example of this is any binary algorithm (e.g., binary search). You pick either left or right, which then axes the space you're searching in half. The pattern of repeatedly doing half is log n.

提交回复
热议问题