• 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

Maximum occurred Smallest integer in n ranges

Hackerearth : Counting Subarrays

Find position of the only set bit

ADOBE Aptitude C Language Test

Find the smallest window in a string containing all characters of another string

Apriori algorithm C Code Data Mining

1014 Practice Question of New GRE – Princeton

Python Array String

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

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

Length of the longest substring without repeating characters

Flipkart Set 1 On Campus with Answers

Trie Dictionary

Count Possible Decodings of a given Digit Sequence

Python Dictionaries

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

Amazon Interview Experience – SDE Chennai

Generic Object Oriented Stack with Template

Closed Parentheses checker

Maximum of all subarrays of size k

C++ OOPs Part1

Longest Increasing Subsequence

Number of Islands BFS/DFS

Python String and numbers

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

Find min element in Sorted Rotated Array (With Duplicates)

Test Cases for Round Function

Reverse a Linked List in groups of given size

Binary Tree in Java

Diagonal Traversal of Binary Tree

Copyright © 2026 · Genesis Framework · WordPress · Log in