• 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

strtok()

Level order traversal in Spiral form

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

Generate largest number arranging a no. of given non negative integer numbers

LeetCode: Container With Most Water

SAP Hiring Off-Campus General Aptitude

Rectangular chocolate bar Create at least one piece which consists of exactly nTiles tiles

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

Longest Increasing Subsequence

Microsoft BING Interview Experience

Find Pythagorean Triplets in an array in O(N)

Python List

SAP Off Campus Hiring_ March 2015 Computer Skills

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

Stickler thief

Common Ancestor in a Binary Tree or Binary Search Tree

Fibonacci Hashing & Fastest Hashtable

Generate next palindrome number

Binary Tree Isomorphic to each other

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

FizzBuzz Solution C C++

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

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

SAP Off Campus Hiring_ March 2015 Sample Questions

Introduction To Number Theory ( Part 1 )

Number of Islands BFS/DFS

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

Top 10 Interviews Techniqes for Campus Interview in IIT NIT BITS for MTech

Implement a generic binary search algorithm for Integer Double String etc

Serialise Deserialise N-ary Tree

Copyright © 2026 · Genesis Framework · WordPress · Log in