Added implementation of algorithm B (recursive swapping). This one was very "delicate" to get correct.
Added tests for new algorithm.