# Heap’s Algorithm

Find All the Permutations of a Set of Elements

A classic technical interview question is finding the permutations of characters in a string. This is a subset of a larger problem of finding all the permutations of elements in a set. One of the most common algorithms to tackle this problem is Heap’s Algorithm. Heap’s is a relatively young algorithm being first proposed by B. R. Heap in 1963.

I’ve laid out the algorithm's pseudocode with explanation below:

`PROCEDURE HEAP(S,N)`

IF n == 1 THEN

process S

ELSE

FOR i := 0 TO n - 1

Heap(S, n …