add algorithms to reversing a singly linked list in C++