Algorithm A
Algorithm B