Final Exam Flashcards
(34 cards)
running times of insertion sort
o Best case: O(n)
o Worst case: O(n^2)
o Average case: O(n^2)
running times of bubble sort
o Best case: O(n)
o Worst case: O(n^2)
o Average case: O(n^2)
running times of heap sort
o Best case: O(n log n)
o Worst case: O(n log n)
o Average case: O(n log n)
running times of merge sort
o Best case: O(n log n)
o Worst case: O(n log n)
o Average case: O(n log n)
recurrence relationship for merge sort
T(n) = 2T(n/2) + O(n) n > 1
O(1) n = 1
running times for quick sort
o Best case: O(n log n)
o Worst case: O(n^2)
o Average case: O(n log n)
running time and recurrence for quick sort with a 8 to 3 split
RT = O(n log n)
T(n) = T(8n/11) + T(3n/11) + O(n) n > 1
O(1) n = 1
recurrence relationship for worst case of quick sort
T(n) = T(n-1) + O(n) n > 1
O(1) n = 1
Djikstras priority queue implemented with array: running times for insert, decrease key, and delete min
insert: O(1)
decreasekey: O(1)
deletemin: O(n)
Djikstras priority queue implemented with binary heap: running times for insert, decrease key, and delete min
insert: O(log n)
decreasekey: O(log n)
deletemin: O(log n)
running times for search, insert, and delete on regular binary search tree with n nodes
O(h) where h is the height of the tree . . . or O(n)
running times for search, insert, and delete in a red-black tree with n internal nodes
O(log n)
running time for topological ordering (linearization) algorithm
O(|V| + |E|)
running time for longest common string
O(n * 2^m)
running time for edit distance
O(n * m)
definition for Asymptotic / Big O Notation
f(n) = O(g(n)) if there exist positive constants c and n0 such at 0 <= f(n) <= c*g(n) for n >= n0
worst case / lower bound
height of heap with n nodes
O(log n)
height of red-black tree with n internal nodes
O(log n)
definition of master theorem
T(n) = aT(n/b)+(n^d) for a > 0, b > 1, d >= 0
then,
O(n^d) if d > log_b a
T(n) = O(n^d * log n) if d = log_b a
O(n^log_b a) if d < log_b a
definition of big omega notation
best case RT / lower bound
definition of big theta notation
is both big O and big omega
True or False: If f(n) = Θ(g(n)) and g(n) = Θ(h(n)), then h(n) = Θ(f(n)).
True
True or False: If f(n) = O(g(n)) and g(n) = O(f(n)) then f(n) = g(n).
False
True or False: 𝑛/100 = Ω(n).
True