• 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

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

Stock Buy Sell to Maximize Profit

SAP Off Campus Hiring_ March 2015 Analytical Aptitude

Hackerearth : Counting Subarrays

Edit Distance ( Dynamic Programming )

LeetCode : Word Search

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

simple sql injection

Code Chef PRGIFT Solution

CodeChef Code SGARDEN

Daughter’s Age VeryGood Puzzle

25 horses 5 tracks Find 3 fastest puzzle

Check Binary Tree is Binary Search Tree or not

Calculate price of parking from parking start end time prices

Find Percentage of Words matching in Two Strings

Find position of the only set bit

Coin Collection Dynamic Programming

K’th Largest Element in BST when modification to BST is not allowed

Add Sub Multiply very large number stored as string

Find Pythagorean Triplets in an array in O(N)

Printing intermediate Integers between one element & next element of array

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

Binary Tree in Java

Connect n ropes with minimum cost

ADOBE Aptitude C Language Test

Find Nearest Minimum number in left side in O(n)

SAP Off Campus Hiring_ March 2015 Verbal Skills

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

Longest Increasing Subsequence

Binary Tree in Java

Copyright © 2026 · Genesis Framework · WordPress · Log in