I would love some help with memorizing CS algorithms. I’m currently taking the Coursera algorithms specialization. I would like to be able to recall all the algorithms from memory by the end of the course. (There are probably only going to be about 20 or so in total). I was using Anki to quiz myself, but my answers are always wrong somehow because my memory of each algorithm is fuzzy and vague. Also, pulling out a text editor and writing out 6 lines of code doesn’t lend itself well to Anki. It seems self-quizzing from a memory palace would be better.
I need help coming up with a good method, then probably I could stuff each algorithm mnemonic in a memory palace at the end of each class.
Here are two examples.
Ex 1. Random Contraction Algo (pseudocode)
given Given graph G=(V,E)
while there are more than 2 edges pick a remaining edge (u,v) uniformly at random merge u and v into one vertex remove any self-loops return the cut represented by the final 2 vertices
Ex 2. Partition Function
def partition(A, l, r): p = A[l] # naïve emplementation i = l+1 for j in range(l+1,r+1): if A[j] < p: swap(A[j], A[i]) i += 1 swap(A[l], A[i -1])
Ex. 3 Quicksort (pseudocode)
- Select a pivot element p
- Partition the array around p such that first < p < last
- recurively sort array halves “first” and “last”