• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to secondary sidebar

GoHired

Interview Questions asked in Google, Microsoft, Amazon

Join WeekEnd Online Batch from 4-April-2020 on How to Crack Coding Interview in Just 10 Weeks : Fees just 20,000 INR

  • Home
  • Best Java Books
  • Algorithm
  • Internship
  • Certificates
  • About Us
  • Contact Us
  • Privacy Policy
  • Array
  • Stack
  • Queue
  • LinkedList
  • DP
  • Strings
  • Tree
  • Mathametical
  • Puzzles
  • Graph

Reversal of LinkedList

February 20, 2014 by Dhaval Dave

Reversal of linked list simplified With Three Pointer Without Recursion

/* Link list node */
struct node
{
    int data;
    struct node* next;
};
 
/* Function to reverse the linked list */
static void reverse(struct node** head_ref)
{
    struct node* prev   = NULL;
    struct node* current = *head_ref;
    struct node* next;
    while (current != NULL)
    {
        next  = current->next;  
        current->next = prev;   
        prev = current;
        current = next;
    }
    *head_ref = prev;
} 
 
static void reverse(struct node** head_ref)
{
    struct node* prev   = NULL;
    struct node* current = *head_ref;
    struct node* next;
    while (current != NULL)
    {
        next  = current->next;  
        current->next = prev;   
        prev = current;
        current = next;
    }
    *head_ref = prev;
} 

 

Similar Articles

Filed Under: problem Tagged With: Linked List

Reader Interactions

Primary Sidebar

Join WeekEnd Online/Offline Batch from 4-April-2020 on How to Crack Coding Interview in Just 10 Weeks : Fees just 20,000 INR

Join WeekEnd Online/Offline Batch from 4-April-2020

WhatsApp us

Secondary Sidebar

Custom Search

  • How I cracked AMAZON
  • LeetCode
  • Adobe
  • Amazon
  • Facebook
  • Microsoft
  • Hacker Earth
  • CSE Interview

Top Rated Questions

System Design: Designing a LLD for Hotel Booking

Find and print longest consecutive number sequence in a given sequence in O(n)

25 horses 5 tracks Find 3 fastest puzzle

Find the number ABCD such that when multipled by 4 gives DCBA.

Facebook Interview Question : Interleave List

Right view of Binary tree

Wrong Directions given find minimum moves so that he can reach to the destination

Common Ancestor in a Binary Tree or Binary Search Tree

Knight Tour Problem (Graph – Breadth First Search)

TicTacToe Game As Asked in Flipkart

Doubly linked list

Test Cases for Round Function

Find min element in Sorted Rotated Array (With Duplicates)

In Given LinkedList Divide LL in N Sub parts and delete first K nodes of each part

Coin Collection Dynamic Programming

Find if a binary tree is height balanced ?

Diagonal Traversal of Binary Tree

Reverse a Linked List in groups of given size

Binary Tree in Java

Implement a generic binary search algorithm for Integer Double String etc

C++ OOPs Part1

Find position of the only set bit

SAP Hiring Off-Campus General Aptitude

Printing Longest Common Subsequence

Maximum sum contiguous subarray of an Array

Serialise Deserialise N-ary Tree

Advanced SQL Injection

Handle duplicates in Binary Search Tree

Length of the longest substring without repeating characters

Code Chef PRGIFT Solution

Copyright © 2025 · Genesis Framework · WordPress · Log in