unit 5 - 8 Flashcards

1
Q

fibonacci algo

A

returns f(n - 1) + f(n - 2) if n > 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

fibonacci algo: runtime

A

O(2^n) without memoization; O(n) with memoization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

fibonacci algo: memoization

A

checks for n in array; if not in, compute and store array[n] = f(n - 1) + f(n - 2); returns f(n - 1) + f(n - 2) if n > 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

tabulation

A

bottom-up; solve small problems first, then the original problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

dynamic programming

A

storing previously calculated values for better runtime and allow for quick retrievals as well as using smaller values to solve for even larger ones

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

bubble sort algo

A

quadratic / O(n^2); swap two items if the next item is larger thsn the previous

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

bubble sort; iterating over i and j

A

the algorithm iterates over both i and j to check multiple times and sort the entire list, not just items in relation to each other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

selection sort algo

A

quadratic, O(n) best case; sets a ‘largest’ index, checks for larger values while iterating. picks smallest (2nd, 3rd smallest, etc,) value and places it at the beginning

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

merge sort

A

cuts a list in half while len >= 2; separates them to be sorted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

merge

A

end of mergesort algorithm; checks which items are bigger before sorting items from smaller lists into a bigger one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

binary search

A

O(logn); a list is broken in half. the median is checked. if != target value, search the sides depending on if the target is < or > than the median

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

tail recursion

A

the recursive call is the last statement executed by the function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

recursion

A

breaking problems into subproblems, combining solutions;
function call within a function, using a base case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

factorial algo

A

returns x * fact(x - 1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

factorial algo; runtime

A

O(n) without memoization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

memoization

A

top-down; function checks to see if a value has been calculated and stored already or not. if not, perform recursive call

17
Q

quicksort pivot

A

+- 1/2 of largest element

18
Q

naive partition

A

store elements < pivot, then store elements > pivot

19
Q

partition

A

ensures elements from 0 - i-1 are < pivot
ensures elements from I - j are => pivot

20
Q

quicksort

A

matches the pivot’s value to its index, then switches the first, next, etc lowest value to the front

21
Q

naive fibonacci: calls made

A

T(0), T(1),
T(n) = T(n1) + T(n2) + 1