educative.io

Educative

Instructions and pseudocode are most helpful

I find it helpful when a site lays out pseudocode before presenting various languages. I think the trick is to memorize and understand the algorithms, and translate them into a language during an interview. Once I understand the algo inside and out, I’m ready for curveballs such as variations on a problem, ambiguous language, and implications that can be inferred from example input/output.

Here is an example topic “Inorder Traversal”. I’d consider the first block to be English instructions describing the approach. The last block is the sort of pseudocode I like.

(L) Recursively traverse L subtree.
(N) Process n itself (ROOT).
® Recursively traverse its R subtree.

Iterative Inorder Traversal

s = empty stack
while (not s.isEmpty() or node != null)
    if (node != null)
        s.push(node)
        node = node.left
    else
        node = s.pop()
        visit(node)
        node = node.right