Data Flashcards
1
Q
Topological Sort
A
topological
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
3
Q
Merge Sort
A
Divide and sort
O(nLogn)
Fast but requires space
4
Q
Quick sort
A
Pick a pivot and move items: smaller (left), larger (right)
Repeat
Normally O(n*logN)
Worst case O(N2)
5
Q
Bubble Sort
A
Swaps 2 and moves
typically impractical
6
Q
Binary Search
A
find the midpoint and determine if >=, <=, or =
Then repeat
MUST BE SORTED
O(LogN)
7
Q
Depth First Search
A
Goes DEEP first
Starts by searching down one side of the path
Must have VISITED FLAG
8
Q
Breadth First Search
A
Starts by searching all children before going down
Create a queue and then check
9
Q
Insertion Sort
A
starting index, sort everything to the left, then move over. Repeat.
O(N)
10
Q
Heap Sort
A
Create a tree, swap parents to find the largest, remove and repeat. Sorts in ascending order Always n(LogN)