top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How do you reverse LinkedList in place in Java?

+1 vote
420 views
How do you reverse LinkedList in place in Java?
posted Jun 29, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

There can be two solution for reversing linked list
1. Iterative
2. Recursive

Iterative:

Logic for this would be:
Have three nodes i.e previousNode,currentNode and nextNode
When currentNode is starting node, then previousNode will be null
Assign currentNode.next to previousNode to reverse the link.
In each iteration move currentNode and previousNode by 1 node.

Read more at http://www.java2blog.com/2014/07/how-to-reverse-linked-list-in-java.html

answer Jun 30, 2015 by Karthick.c
Similar Questions
0 votes

How to implement a circular linked list in Java? Please provide all necessary functions?

+1 vote

Given a singly linked list of integers, write a function in java that returns true if the given list is palindrome, else returns false

...