• 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

Add Sub Multiply very large number stored as string

Hackerearth : Counting Subarrays

Sort an array according to the order defined by another array

Find next greater number with same set of digits

SAP Hiring Off-Campus General Aptitude

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

Printing each word reverse in string

simple sql injection

Count Possible Decodings of a given Digit Sequence

Check Binary Tree is Binary Search Tree or not

Implement a generic binary search algorithm for Integer Double String etc

VMWare Openings

C++ OOPs Part1

write a c program that given a set a of n numbers and another number x determines whether or not there exist two elements in s whose sum is exactly x

Maximum of all subarrays of size k

Given a string, find the first character which is non-repetitive

Practo Hiring Experience

Microsoft BING Interview Experience

Find Nearest Minimum number in left side in O(n)

Common Ancestor in a Binary Tree or Binary Search Tree

Linked List V/S Binary Search Tree

Diagonal Traversal of Binary Tree

Binary Tree in Java

FizzBuzz Solution C C++

Printing intermediate Integers between one element & next element of array

TicTacToe Game As Asked in Flipkart

Find loop in Singly linked list

Sort Stack in place

Leetcode: Merge Intervals

HackeEarth Flipkart’s Drone

Copyright © 2026 · Genesis Framework · WordPress · Log in