• 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

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

Circular Linked List

Sort an array according to the order defined by another array

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

1014 Practice Question of New GRE – Princeton

Regular Expression Matching

Find Pythagorean Triplets in an array in O(N)

SAP Off Campus Hiring_ March 2015 Analytical Aptitude

Best Java Book | Top Java Programming Book for Beginners

Given a float number convert it into the string WITHOUT using any inbuilt Function

The greedy coins game Dynamic Programming

Templates in C++

simple sql injection

Binary Tree Isomorphic to each other

Coin Collection Dynamic Programming

Add Sub Multiply very large number stored as string

SAP Off Campus Hiring_ March 2015 Verbal Skills

N Petrol bunks or City arranged in circle. You have Fuel and distance between petrol bunks. Is it possible to find starting point so that we can travel all Petrol Bunks

Connect n ropes with minimum cost

Generate next palindrome number

flattens 2 D linked list to a single sorted link list

Check Binary Tree is Binary Search Tree or not

Python String and numbers

Code Chef PRGIFT Solution

N teams are participating. each team plays twice with all other teams. Some of them will go to the semi final. Find Minimum and Maximum number of matches that a team has to win to qualify for finals ?

Find if two rectangles overlap

Count Possible Decodings of a given Digit Sequence

TicTacToe Game As Asked in Flipkart

Trapping Rain Water

Implement a generic binary search algorithm for Integer Double String etc

Copyright © 2026 · Genesis Framework · WordPress · Log in