Figures 1 to 5: First algorithm
Figures 6 to 10: Second algorithm