Data Flashcards

1
Q

Topological Sort

A

topological

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

Recursive Function

A
Will call it's self automatically or on demand
MUST HAVE BREAK VALUE
i.e. factorial(n-l, n*accumulator) {
if (n===0) {
return accumulator }
{
return factorial(n — 1, n * accumulator)
}
factorial(5, 1) //==>> 120
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Merge Sort

A

Divide and sort
O(nLogn)
Fast but requires space

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

Quick sort

A

Pick a pivot and move items: smaller (left), larger (right)
Repeat
Normally O(n*logN)
Worst case O(N2)

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

Bubble Sort

A

Swaps 2 and moves

typically impractical

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

Binary Search

A

find the midpoint and determine if >=, <=, or =
Then repeat
MUST BE SORTED
O(LogN)

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

Depth First Search

A

Goes DEEP first
Starts by searching down one side of the path
Must have VISITED FLAG

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

Breadth First Search

A

Starts by searching all children before going down

Create a queue and then check

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

Insertion Sort

A

starting index, sort everything to the left, then move over. Repeat.
O(N)

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

Heap Sort

A
Create a tree, swap parents to find the largest, remove and repeat. Sorts in ascending order
Always n(LogN)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly