• 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

Linked List V/S Binary Search Tree

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

FizzBuzz Solution C C++

Printing intermediate Integers between one element & next element of array

Closed Parentheses checker

Adobe Interview Questions 8 month Exp

Reliance Jio Software Developer Interview Experience

Test Cases for Round Function

Maximum path sum between two leaves

Search element in a matrix with all rows and columns in sorted order

SAP Off Campus Hiring_ March 2015 Verbal Skills

Trapping Rain Water

Apriori algorithm C Code Data Mining

Leetcode: Merge Intervals

Client Server C program

System Design: Designing a LLD for Hotel Booking

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

Implement LRU Cache

Find min element in Sorted Rotated Array (With Duplicates)

Microsoft BING Interview Experience

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

Python String and numbers

Knight Tour Problem (Graph – Breadth First Search)

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

Connect n ropes with minimum cost

Skiing on Mountains Matrix

Calculate price of parking from parking start end time prices

Introduction To Number Theory ( Part 1 )

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

Length of the longest substring without repeating characters

Copyright © 2026 · Genesis Framework · WordPress · Log in