• 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

Find min element in Sorted Rotated Array (Without Duplicates)

There are N nuts and N bolts, u have to find all the pairs of nuts and bolts in minimum no. of iteration

BFS (Breath First Search)

Find the number ABCD such that when multipled by 4 gives DCBA.

Max Sum in circularly situated Values

Hackerearth : Counting Subarrays

Possible sizes of bus to carry n groups of friends

Flipkart SDET Interview Experience

Stock Buy Sell to Maximize Profit

Inorder and Preorder traversals of a Binary Tree given. Output the Postorder traversal of it.

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

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

The Magic HackerEarth Nirvana solutions Hiring Challenge

Number of Islands BFS/DFS

Right view of Binary tree

Find and print longest consecutive number sequence in a given sequence in O(n)

Maximum sum contiguous subarray of an Array

Microsoft BING Interview Experience

Python Dictionaries

Skiing on Mountains Matrix

Interfaces in C++ (Abstract Classes in C++)

Coin Collection Dynamic Programming

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

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

DFS (Depth First Search)

Fibonacci Hashing & Fastest Hashtable

TicTacToe Game As Asked in Flipkart

Difference between a LinkedList and a Binary Search Tree BST

Python String and numbers

Find Pythagorean Triplets in an array in O(N)

Copyright © 2026 · Genesis Framework · WordPress · Log in