Implemented recursive algorithms