outline of algorithm

still need to figure out DFS/recursion part