Data Structures

The most basic data structures and when to use them.

Create any Data Structure you can dream of. Here are the common ones.

Recursion

Recursion is the best way to solve any problem. Just write the solution using itself.

All the standard ways of walking through Trees.

Quickly search through sorted data in O(log n) time.

The same as Trees, but you need to avoid cycles.

Avoid making redundant calls in your recursion by storing past results.

Avoid wasting time and space in your recursion by making the inputs global.

Iteration

Find a trick to do one pass - you can't do better than that!

Problems that are just asking you to find the "trick". Many of these are Greedy algorithms.

Heaps let you view smallest element quickly. Just like BSTs, they deal with sorted order, so think O(log n).

Here's how to implement any Recursion "without using Recursion".