Implement all gather algorithm

- also moved all algorithms to an algorithm folder.