Time & Space Complexity

Quick Sort: 

Time complexity: best case O(n*lgn), worst case O(n^2)

Space complexity: Best case O(lgn) -> call stack height

                          Worse case O(n^2) -> call stack height

Merge Sort

Time complexity: always O(n*lgn) because we always divide the array in halves.

Space complexity: O(lgn +  n)

posted @ 2019-09-09 07:51  北叶青藤  阅读(142)  评论(0编辑  收藏  举报