• 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

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

Trie Dictionary

System Design: Designing a LLD for Hotel Booking

DFS (Depth First Search)

Stock Buy Sell to Maximize Profit

Find if two rectangles overlap

Practo Hiring Experience

SAP Hiring Off-Campus General Aptitude

Wrong Directions given find minimum moves so that he can reach to the destination

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

LeetCode : Word Search

Find the kth number with prime factors 3, 5 and 7

Get Minimum element in O(1) from input numbers or Stack

Urban Ladder Written Test.

Closed Parentheses checker

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

Walmart Labs Interview Experience

Difference between a LinkedList and a Binary Search Tree BST

Max Sum in circularly situated Values

Adobe Interview Questions 8 month Exp

Code Chef PRGIFT Solution

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

How strtok() Works

Find min element in Sorted Rotated Array (With Duplicates)

Find two non repeating elements in an array of repeating elements

SAP Off Campus Hiring_ March 2015 Sample Questions

Flipkart SDET Interview Experience

Advanced SQL Injection

Templates in C++

Copyright © 2025 · Genesis Framework · WordPress · Log in