It looks like this is a teaching exercise more than anything, but it should be noted that the implementations are not great. For instance, the set uses an array based implementation instead of hash based.
In JavaScript the hash based implementation is pretty trivial to write and some quick testing in node shows that it is dramatically faster.
In JavaScript the hash based implementation is pretty trivial to write and some quick testing in node shows that it is dramatically faster.