• 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

Print all nodes that are at distance k from a leaf node

Find if a binary tree is height balanced ?

Binary Tree Isomorphic to each other

Find two non repeating elements in an array of repeating elements

SAP Off Campus Hiring_ March 2015 Sample Questions

Common Ancestor in a Binary Tree or Binary Search Tree

DFS (Depth First Search)

SAP Off Campus Hiring_ March 2015 Analytical Aptitude

Mirror of Tree

Given Set of words or A String find whether chain is possible from these words or not

Fibonacci Hashing & Fastest Hashtable

Count number of ways to reach a given score in a game

HackeEarth Flipkart’s Drone

VMWare SDEII Interview

simple sql injection

Facebook Interview Question : Interleave List

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

Singly linked list

Stock Buy Sell to Maximize Profit

C++ OOPs Part2

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

ADOBE Aptitude C Language Test

Daughter’s Age VeryGood Puzzle

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

How Radix sort works

Find shortest distances between every pair of vertices ( Dynamic Programming Floyd Warshall Algorithm)

robot standing at first cell of an M*N matrix. It can move only in two directions, right and down. In how many ways, it can reach to the last cell i.e. (M, N) Code it

Convert Decimal to Roman numbers / Romanizer HackerEarth Code

Given a sorted array and a number x, find the pair in array whose sum is closest to x

The Magic HackerEarth Nirvana solutions Hiring Challenge

Copyright © 2025 · Genesis Framework · WordPress · Log in