• 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 the element that appears once others appears thrice

SAP Off Campus Hiring_ March 2015 Sample Questions

Walmart Labs Interview Experience

Urban Ladder Written Test.

Client Server C program

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

Hackerearth : Counting Subarrays

Length of the longest substring without repeating characters

Binary Tree in Java

Leetcode: Merge Intervals

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

Generic Object Oriented Stack with Template

Linked List V/S Binary Search Tree

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

Apriori algorithm C Code Data Mining

Adobe Interview Questions 8 month Exp

Implement a generic binary search algorithm for Integer Double String etc

SAP Hiring Off-Campus General Aptitude

Find min element in Sorted Rotated Array (With Duplicates)

VMWare Openings

Circular Linked List

Binary Tree in Java

Possible sizes of bus to carry n groups of friends

Regular Expression Matching

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

Maximum occurred Smallest integer in n ranges

Minimum insertions to form a palindrome

Search element in a matrix with all rows and columns in sorted order

Convert Decimal to Roman numbers / Romanizer HackerEarth Code

Copyright © 2026 · Genesis Framework · WordPress · Log in