• 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

Sort Stack in place

Find next greater number with same set of digits

FizzBuzz Solution C C++

Print Power Set of a Set

Doubly linked list

Knight Tour Problem (Graph – Breadth First Search)

DFS (Depth First Search)

ADOBE Aptitude C Language Test

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

Generate largest number arranging a no. of given non negative integer numbers

Introduction To Number Theory ( Part 1 )

The Magic HackerEarth Nirvana solutions Hiring Challenge

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

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

Check if an array has duplicate numbers in O(n) time and O(1) space

VMWare SDEII Interview

Given a string, find the first character which is non-repetitive

Level order traversal in Spiral form

Serialise Deserialise N-ary Tree

Code Chef PRGIFT Solution

Diagonal Traversal of Binary Tree

C++ OOPs Part2

Hackerearth : Counting Subarrays

BFS (Breath First Search)

Edit Distance ( Dynamic Programming )

Find loop in Singly linked list

Find position of the only set bit

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

Printing Longest Common Subsequence

Coin Collection Dynamic Programming

Copyright © 2025 · Genesis Framework · WordPress · Log in