Why does QuickSort use O(log(n)) extra space?

后端 未结 5 891
刺人心
刺人心 2020-12-13 17:39

I have implemented the below quicksort algorithm. Online I\'ve read that it has a space requirement of O(log(n)). Why is this the case? I\'m not creating any extra data stru

5条回答
  •  [愿得一人]
    2020-12-13 18:12

    To get rid of the recursive call you would have to use a stack data structure in your code, and it would still occupy log(n) space.

提交回复
热议问题