General Algorithms Flashcards
1
Q
What does it mean for an algorithm to be stable
A
two items of the same value are not swapped
2
Q
what does it mean for an algorithm to be inplace
A
it uses no extra memory
3
Q
explain the Partition step in quick sort
A
Set a variable i for the index of the most recently found value lower than the pivot (update everytime you find a new value lower)
loop through the list placing items lower at i+1 and update i
leave items larger alone
then swap the value at i+1 with the pivot (typically the last value)
4
Q
what is sterlings approximation
A
n! = sqrt(2pi n)(n/e)^n