Algorithms Flashcards
Fizzbuzz
Print Numbers 1 to N. If a Number is divisible by 3 print fizz, if a number is divisible by 5 print buzz, if a number is divisible by 15 print fizz buzz
Pascals Triangle
Triangle of rows of arrays where each cell is the sum of the two cells above it
Needle in Haystack
Return the index where needle starts in haystack if it is a substring
Pivot Index of Array
Return the index where the sum of the left is equal to the sum of the right
Fibonacci w Memoization
Return the nth fib digit in linear time
Reverse a LL
single or double
SLL
push, pop, get(index), insert(index, val), delete(index)
DLL
push, pop, get(index), insert(index, val), delete(index)
Binary Search Tree
Insert(val), find(val)
Merge Sort
Merge function O(n+m), sort O(logn)
Quick Sort
O(nlogn)
Stack
LIFO
Binary Heap
Min or Max, compact as possible, all left children are filled, then all right children are filled
Priority Queue
Min Binary Heap w Priority for nodes
BFS Graph Traversal
use a queue, shift()