• 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

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

Find two non repeating elements in an array of repeating elements

C++ OOPs Part2

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 Pythagorean Triplets in an array in O(N)

Length of the longest substring without repeating characters

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

Maximum path sum between two leaves

flattens 2 D linked list to a single sorted link list

Level order traversal in Spiral form

Get K Max and Delete K Max in stream of incoming integers

Implement LRU Cache

Convert number to words java

Best Java Book | Top Java Programming Book for Beginners

Edit Distance ( Dynamic Programming )

Connect n ropes with minimum cost

Stickler thief

Find if a binary tree is height balanced ?

Reverse a Linked List in groups of given size

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

Coin Collection Dynamic Programming

Interfaces in C++ (Abstract Classes in C++)

Binary Tree in Java

C Program for TAIL command of UNIX

Maximum sum contiguous subarray of an Array

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

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

Minimum insertions to form a palindrome

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

Apriori algorithm C Code Data Mining

Copyright © 2025 · Genesis Framework · WordPress · Log in