Algorithm Implementation

Having some trouble implementing it fully, but will get it soon