Vous êtes sur la page 1sur 4

Algorithm quick sort bad case

1 Pivot is 1 1

Bad pivot mean that a selection elements must be 5 until 12, to get a balance algo.

The time is N , where it decreasing n-1 per loop so (n-1) will loop til 3, 2 , 1 if we sum up together , they are Nsquare

. Because if we want to solve n-1 , we keep on calling t(n) putting n-1 , until it reach a number , we expect it to be n1,n-2.. until 3 ,2,1 total sum of these number by using arithmetic series , we can get nsquare. Best case

X If X is middle , we say we have equal size of problem , which is n/2 , 2 (n/2)

Balanced

Because we need sum of the intersection to get cn , observe when n split to 1/10 and 9/10 , their sum is 1. 1/10 path will finish first, after it finish, only left 9/10 , 9/10 is <=1 , cn

Vous aimerez peut-être aussi