• 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

strtok()

Get K Max and Delete K Max in stream of incoming integers

Find Percentage of Words matching in Two Strings

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

Practo Hiring Experience

Password Predictor

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

ADOBE Aptitude C Language Test

Microsoft BING Interview Experience

LeetCode: Binary Tree Maximum Path Sum

Max Sum in circularly situated Values

Length of the longest substring without repeating characters

The greedy coins game Dynamic Programming

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 ?

BFS (Breath First Search)

HackeEarth Flipkart’s Drone

Binary Tree in Java

Generate next palindrome number

Generic Object Oriented Stack with Template

Singly linked list

Doubly linked list

Common Ancestor in a Binary Tree or Binary Search Tree

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

SAP Off Campus Hiring_ March 2015 Analytical Aptitude

Serialise Deserialise N-ary Tree

Subset Sum Problem Dynamic programming

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

Python String and numbers

Advanced SQL Injection

Python List

Copyright © 2025 · Genesis Framework · WordPress · Log in