Run Time Analysis Flashcards
What are we analysing when we do runtime notation?
The growth of the main function, as (for large inputs) constants do not matter
What does “f=O(g)” represent?
f grows at most as fast as g
What does “f=Ω(g)” represent?
f grows at least as fast as g
What does “f=Θ(g)” represent?
f grows equally as fast as g
What does “f=o(g)” represent?
f grows slower than g
What does “f=ω(g)” represent?
f grows faster than g
What are the two parts to a quick sort?
- Partition
- Recursive Sorting
What are the steps for partitioning?
- Pick an element
- Rearrange so that everything to left is < the chosen element
- Therefore everything to right is > the element
How is the sorting of the elements done after partitioning?
We need to look at both sides of the array, and look for two that are out of place.
What is important about the pivot?
We must always know where it is, as it can move.
How do we ensure that a quick sort is efficient?
We must always sort the shorter side of the array first
What is the worst case for a Quick sort if the sides are vastly different?
theta(n^2)
What is the worst case for a Quick sort if the sides are equal?
theta(n log n)