• 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

Number of Islands BFS/DFS

BFS (Breath First Search)

Generate next palindrome number

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

Find if a binary tree is height balanced ?

Word Break Problem

Find min element in Sorted Rotated Array (Without Duplicates)

Print Power Set of a Set

write a c program that given a set a of n numbers and another number x determines whether or not there exist two elements in s whose sum is exactly x

HackeEarth Flipkart’s Drone

Calculate price of parking from parking start end time prices

Leetcode: Edit Distance

25 horses 5 tracks Find 3 fastest puzzle

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

Find if two rectangles overlap

Amazon Interview Experience – SDE Chennai

Amazon Interview On-Campus For Internship – 1

Coin Collection Dynamic Programming

Leetcode: Merge Intervals

Binary Tree in Java

Edit Distance ( Dynamic Programming )

Knight Tour Problem (Graph – Breadth First Search)

Advanced SQL Injection

How strtok() Works

1014 Practice Question of New GRE – Princeton

Serialise Deserialise N-ary Tree

Common Ancestor in a Binary Tree or Binary Search Tree

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

Find an index i such that Arr [i] = i in array of n distinct integers sorted in ascending order.

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

Copyright © 2026 · Genesis Framework · WordPress · Log in