• 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

Facebook Interview Question : Interleave List

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

Print Power Set of a Set

LeetCode : Word Search

Print vertical sum of all the axis in the given binary tree

Maximum path sum between two leaves

Password Predictor

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

Count number of ways to reach a given score in a game

Find if a binary tree is height balanced ?

Knight Tour Problem (Graph – Breadth First Search)

SAP Interview Questions

Convert number to words java

SAP Hiring Off-Campus General Aptitude

Common Ancestor in a Binary Tree or Binary Search Tree

Naurki.com Security Breach

Regular Expression Matching

Given a sorted array and a number x, find the pair in array whose sum is closest to x

BFS (Breath First Search)

How strtok() Works

25 horses 5 tracks Find 3 fastest puzzle

Stickler thief

Sequence Finder Dynamic Programming

Subset Sum Problem Dynamic programming

Find the element that appears once others appears thrice

Cisco Hiring Event 21st – 22nd Feb 2015

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

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

Puzzle : 100 doors in a row Visit and Toggle the door. What state the door will be after nth pass ?

HackeEarth Flipkart’s Drone

Copyright © 2026 · Genesis Framework · WordPress · Log in