• 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

Test Cases for Round Function

Printing each word reverse in string

‘N’ Story Building, with 1,2,3 steps how many ways can a person reach top of building.

Leetcode: Edit Distance

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

Doubly linked list

TicTacToe Game As Asked in Flipkart

CodeChef Code SGARDEN

Coin Collection Dynamic Programming

Find position of the only set bit

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

Maximum difference between two elements s.t larger element appears after the smaller number

Find loop in Singly linked list

K’th Largest Element in BST when modification to BST is not allowed

Find if two rectangles overlap

Apriori algorithm C Code Data Mining

Find an index i such that Arr [i] = i in array of n distinct integers sorted in ascending order.

25 horses 5 tracks Find 3 fastest puzzle

Python Array String

Python List

Binary Tree Isomorphic to each other

Number of Islands BFS/DFS

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

Printing Longest Common Subsequence

Word Break Problem

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

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

Fibonacci Hashing & Fastest Hashtable

Skiing on Mountains Matrix

Knight Tour Problem (Graph – Breadth First Search)

Copyright © 2026 · Genesis Framework · WordPress · Log in