Analysis of Quick Sort Quick Sort

Quick Sort

A quick sort of stack space required to implement recursion.

Best case: each reference homing, just fall in the middle of the sequence, the sequence is divided evenly into two subsequences of equal or similar length. The maximum depth of stack space log (n + 1), 1 represents the outermost parameters into the stack
time complexity: n · log (n)
Complexity Space: log (n)

Worst case: already ordered or substantially original sequence order, the sorting after each trip falls end reference sequence, compared to the worst case. The maximum depth of stack space n
time complexity: n ^ 2
space complexity: n

Select reference: taking in three

Guess you like

Origin www.cnblogs.com/ldy-miss/p/12026865.html