• 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

Edit Distance ( Dynamic Programming )

write a c program that given a set a of n numbers and another number x determines whether or not there exist two elements in s whose sum is exactly x

Length of the longest substring without repeating characters

Trapping Rain Water

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

Urban Ladder Written Test.

Python List

Introduction To Number Theory ( Part 1 )

LeetCode : Word Search

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

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

Top 10 Interviews Techniqes for Campus Interview in IIT NIT BITS for MTech

Given a float number convert it into the string WITHOUT using any inbuilt Function

Leetcode: Edit Distance

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

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

How strtok() Works

Possible sizes of bus to carry n groups of friends

Right view of Binary tree

Find position of the only set bit

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

Templates in C++

Walmart Labs Interview Experience

Hackerearth : Counting Subarrays

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

In Given LinkedList Divide LL in N Sub parts and delete first K nodes of each part

Find Percentage of Words matching in Two Strings

Leetcode: Merge Intervals

LeetCode: Binary Tree Maximum Path Sum

Closed Parentheses checker

Copyright © 2025 · Genesis Framework · WordPress · Log in