• 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

ADOBE Aptitude C Language Test

Templates in C++

1014 Practice Question of New GRE – Princeton

Reverse a Linked List in groups of given size

Inorder and Preorder traversals of a Binary Tree given. Output the Postorder traversal of it.

Common Ancestor in a Binary Tree or Binary Search Tree

Diagonal Traversal of Binary Tree

Check Binary Tree is Binary Search Tree or not

BlueStone E-commerce Interview Experience

Find if two rectangles overlap

Maximum difference between two elements s.t larger element appears after the smaller number

Maximum sum contiguous subarray of an Array

Microsoft BING Interview Experience

Python Dictionaries

Add Sub Multiply very large number stored as string

Calculate price of parking from parking start end time prices

How Radix sort works

Length of the longest substring without repeating characters

Difference between a LinkedList and a Binary Search Tree BST

Find two non repeating elements in an array of repeating elements

LeetCode : Word Search

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

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

Print vertical sum of all the axis in the given binary tree

FizzBuzz Solution C C++

Edit Distance ( Dynamic Programming )

Find and print longest consecutive number sequence in a given sequence in O(n)

Handle duplicates in Binary Search Tree

‘N’ Story Building, with 1,2,3 steps how many ways can a person reach top of building.

Maximum path sum between two leaves

Copyright © 2025 · Genesis Framework · WordPress · Log in