top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How do you reverse LinkedList in place in Java?

+1 vote
41 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 Google+ Share Button LinkedIn Share Button Multiple Social 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

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...