• 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

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

VMWare SDEII Interview

Serialise Deserialise N-ary Tree

Reliance Jio Software Developer Interview Experience

CodeChef Code SGARDEN

Doubly linked list

Binary Tree in Java

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

Knight Tour Problem (Graph – Breadth First Search)

Find next greater number with same set of digits

Maximum path sum between two leaves

Python String and numbers

Check a String is SUBSEQUENCE of another String Find Minimum length for that ( DNA Matching )

CodeChef’ RRCOPY

Find the smallest window in a string containing all characters of another string

How strtok() Works

Longest Increasing Subsequence

Maximum of all subarrays of size k

Maximum size of square sub matrix with all 1’s in a binary matrix

Check if an array has duplicate numbers in O(n) time and O(1) space

Memory Efficient LinkedList

Find Pythagorean Triplets in an array in O(N)

Templates in C++

Diagonal Traversal of Binary Tree

Naurki.com Security Breach

Printing each word reverse in string

Amazon Interview Experience – SDE Chennai

Number of Islands BFS/DFS

Trapping Rain Water

Find min element in Sorted Rotated Array (With Duplicates)

Copyright © 2026 · Genesis Framework · WordPress · Log in