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
Ruby implementation of the Symbol ADT Ruby implementation of the Symbol ADT, as mentioned, hinges on making Symbol class instances immutable that corresponds to the relative la

explain the prims''s algorithm with suitable example?

The best average behaviour is shown by  Quick Sort

1.  Using the traditional method of CPM: a.  What activities are on the critical path? b.  What is the expected total lead time of the project? 2.  Using CCPM: a.  What

that will determine the volume of the sphere or the volume of cone or volume of pyramid depending on the choice of the user

#questWrite an algorithm for multiplication of two sparse matrices using Linked Lists.ion..

How to measure the algorithm's efficiency? It is logical to examine the algorithm's efficiency as a function of some parameter n showing the algorithm's input size. Instance

A binary tree is a special tree where each non-leaf node can have atmost two child nodes. Most important types of trees which are used to model yes/no, on/off, higher/lower, i.e.,

A representation of an array structure is a mapping of the (abstract) array with elements of type T onto the store which is an array with elements of type BYTE. The array could be

Explain about greedy technique The  greedy  method  suggests  constructing  a   solution  to  an  optimization  problem   by  a sequence of steps, every expanding a partially c