• 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

Python Dictionaries

Flipkart SDET Interview Experience

LeetCode: Container With Most Water

Daughter’s Age VeryGood Puzzle

building with N steps, we can take 1,2,3 steps calculate number of ways to reach at top of building

How strtok() Works

Minimum insertions to form a palindrome

Apriori algorithm C Code Data Mining

Best Java Book | Top Java Programming Book for Beginners

Flipkart Set 1 On Campus with Answers

Reverse a Linked List in groups of given size

Length of the longest substring without repeating characters

Maximum path sum between two leaves

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

There are N nuts and N bolts, u have to find all the pairs of nuts and bolts in minimum no. of iteration

Singly linked list

Skiing on Mountains Matrix

Print Power Set of a Set

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

C Program for TAIL command of UNIX

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

CodeChef Code SGARDEN

Spanning Tree

TicTacToe Game As Asked in Flipkart

Sequence Finder Dynamic Programming

Code Chef PRGIFT Solution

Microsoft BING Interview Experience

SAP Interview Questions

Stock Buy Sell to Maximize Profit

Cisco Hiring Event 21st – 22nd Feb 2015

Copyright © 2025 · Genesis Framework · WordPress · Log in