Quick Sort + Divide and conquer Flashcards
(9 cards)
How does Quick Sort work?
Selects an element, usually the central element and divides the input around it.
Elements smaller than the the pivot are put on the left of the pivot and larger on the right.
process repeated recursively
What is the pivot
The element selected in quicksort
Downsides of quicksort
Not very fast
same time complexity as bubble sort with 0(n^2)
What is divide and conquer?
Problem solving technique to break a problem down into smaller more managable sub problems and then reassemble the full solution.
Divide (Divide and conquer)
Halving the size of the problem with every iteration
Conquer
Where each sub problem is solved ofter recursively.
Merge
All teh solutions to the subproblems are recombined during this stage.
Where is it used?
In binary search
quick sort
merge sort
Divide and conquer advantages
Simplifies very complex problems
the time take to solve the problem does not increase at the rate of the difficulty of the problem
0(logn)