• 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

Calculate price of parking from parking start end time prices

Binary Tree Isomorphic to each other

25 horses 5 tracks Find 3 fastest puzzle

Linked List V/S Binary Search Tree

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

Find shortest distances between every pair of vertices ( Dynamic Programming Floyd Warshall Algorithm)

LeetCode : Word Search

Closed Parentheses checker

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

SAP Off Campus Hiring_ March 2015 Verbal Skills

Trapping Rain Water

Maximum path sum between two leaves

strtok()

Find min element in Sorted Rotated Array (With Duplicates)

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

CodeChef’ RRCOPY

Find if a binary tree is height balanced ?

Common Ancestor in a Binary Tree or Binary Search Tree

LeetCode: Container With Most Water

Check a String is SUBSEQUENCE of another String Find Minimum length for that ( DNA Matching )

DFS (Depth First Search)

Right view of Binary tree

Walmart Labs Interview Experience

Maximum occurred Smallest integer in n ranges

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

Mirror of Tree

Templates in C++

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

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

Microsoft BING Interview Experience

Copyright © 2026 · Genesis Framework · WordPress · Log in