The Many Ways of Reversing a Linked List

Esha Wang
Human in a Machine World
1 min readFeb 27, 2016

A linked list is a data structure that consists of a set of data elements, called nodes. Each node then has an object (integer, string, etc…) and a pointer to the next node as its attributes.

Example of a linked list consisting of four nodes

Here is a simple implementation of a linked list in C++:

Method 1: Iteration

Method 2: Recursion (with two input parameters)

Method 3: Recursion (with one input parameter)

Thanks for reading! If you find an error in this post, please feel free to comment below and I will do my best to address any issues.

--

--