Data Structure Linked list Question: Download Linked list PDF

How to reverse a singly linked list?

Tweet Share WhatsApp

Answer:

First off, in case you don't already know, the word 'iterative' when used in problems like these basically means that we use some sort of loop to solve the problem - whether it's a while loop, a for loop, or whatever type of loop you desire to use. We choose to use a while loop to come up with a solution.
Let's assume that we are going to start reversing the linked list starting from the very first node - the head node. What it basically comes down to is changing pointers from one node to the next so that the entire linked list becomes reversed. There is definitely a process - an algorithm - that we will want to follow in order to do that.

Download Linked list PDF Read All 22 Linked list Questions
Previous QuestionNext Question
Given an unsorted linked list, and without using a temporary buffer, write a method that will delete any duplicates from the linked list?How to reverse a linked list iterative algorithm?