Write down the procedure to reverse a singly linked list. , Data Structure & Algorithms

Ans:

A procedure to reverse the singly linked list:

reverse(struct node **st)

{

struct node *p, *q, *r;

p = *st;

q = NULL;

while(p != NULL)

{

r =q;

q = p;

p = p        link;

q        link = r;

}

*st = q;

}

Posted Date: 7/11/2012 1:18:08 AM | Location : United States







Related Discussions:- Write down the procedure to reverse a singly linked list. , Assignment Help, Ask Question on Write down the procedure to reverse a singly linked list. , Get Answer, Expert's Help, Write down the procedure to reverse a singly linked list. Discussions

Write discussion on Write down the procedure to reverse a singly linked list.
Your posts are moderated
Related Questions
Conversion of Forest into Tree A binary tree may be used to show an entire forest, since the next pointer in the root of a tree can be used to point to the next tree of the for

Q. Devise a representation for a given list where insertions and deletions can be made at both the ends. Such a structure is called Deque (which means Double ended queue). Write fu

pseudo code for fibonnaci series

Define an array. Array is made up of same data structure that exists in any language. Array is set of same data types. Array is the collection of same elements. These same elem

Count Scorecards(30 points) In a tournament, N players play against each other exactly once. Each game results in either of the player winning. There are no ties. You have given a

How memory is freed using Boundary tag method in the context of Dynamic memory management? Boundary Tag Method to free Memory To delete an arbitrary block from the free li

Krushkal's algorithm uses the concept of forest of trees. At first the forest contains n single node trees (and no edges). At each of the step, we add on one (the cheapest one) edg

What is Access Restrictions Structured containers with access restrictions only allow clients to add, remove and examine elements at certain locations in their structure. For


give any example of page replacement using fifo and use your own reference string