• 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

Get Minimum element in O(1) from input numbers or Stack

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

SAP Hiring Off-Campus General Aptitude

Reverse a Linked List in groups of given size

Python Dictionaries

Find loop in Singly linked list

Maximum sum contiguous subarray of an Array

Printing intermediate Integers between one element & next element of array

Coin Collection Dynamic Programming

Linked List V/S Binary Search Tree

Diagonal Traversal of Binary Tree

simple sql injection

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 ?

Sequence Finder Dynamic Programming

SAP Off Campus Hiring_ March 2015 Computer Skills

Rectangular chocolate bar Create at least one piece which consists of exactly nTiles tiles

The Magic HackerEarth Nirvana solutions Hiring Challenge

Add Sub Multiply very large number stored as string

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

Printing each word reverse in string

Leetcode: Edit Distance

Find if a binary tree is height balanced ?

1014 Practice Question of New GRE – Princeton

Subset Sum Problem Dynamic programming

Stickler thief

Find two non repeating elements in an array of repeating elements

flattens 2 D linked list to a single sorted link list

Doubly linked list

Find position of the only set bit

building with N steps, we can take 1,2,3 steps calculate number of ways to reach at top of building

Copyright © 2026 · Genesis Framework · WordPress · Log in