• 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

Python String and numbers

Given a sorted array and a number x, find the pair in array whose sum is closest to x

Fibonacci Hashing & Fastest Hashtable

SAP Off Campus Hiring_ March 2015 Analytical Aptitude

Given array of 0’s and 1’s. All 0’s are coming first followed by 1’s. find the position of first 1

Python Array String

Length of the longest substring without repeating characters

Search element in a matrix with all rows and columns in sorted order

Templates in C++

Memory Efficient LinkedList

Spanning Tree

Maximum difference between two elements s.t larger element appears after the smaller number

Closed Parentheses checker

Generate largest number arranging a no. of given non negative integer numbers

Common Ancestor in a Binary Tree or Binary Search Tree

Possible sizes of bus to carry n groups of friends

Given Set of words or A String find whether chain is possible from these words or not

SAP Off Campus Hiring_ March 2015 Computer Skills

C Program for TAIL command of UNIX

Stickler thief

Printing each word reverse in string

FizzBuzz Solution C C++

CodeChef’ RRCOPY

Subset Sum Problem Dynamic programming

Find loop in Singly linked list

Flipkart Set 1 On Campus with Answers

LeetCode : Word Search

C++ OOPs Part1

Skiing on Mountains Matrix

System Design: Designing a LLD for Hotel Booking

Copyright © 2026 · Genesis Framework · WordPress · Log in