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
Given are the definitions of some important terms: 1) Field: This is an elementary data item characterized by its size, length and type. For instance, Name

In this project you will write a program to produce a discrete time simulation of a queue as shown in Fig. 1. Time is slotted on the input and the output. Each input packet follows

Containers Introduction Simple abstract data types are useful for manipulating simple sets of values, such as integers or real numbers however more complex abstract data t

how to write a pseudo code using Kramer''s rule

how we can convert a graph into tree

What do you understand by tree traversal? The algorithm walks by the tree data structure and performs some computation at everynode in the tree. This process of walking by the

An advertising project manager developed the network diagram shown below for a new advertising campagign.  In addition, the manager gathered the time information for each activity,

write an algorithm for stack using array performing the operations as insertion ,deletion , display,isempty,isfull.

Let us assume a sparse matrix from storage view point. Assume that the entire sparse matrix is stored. Then, a significant amount of memory that stores the matrix consists of zeroe

The following formula is used to calculate n: n = x * x/(1 - x) . Value x = 0 is used to stop algorithm. Calculation is repeated using values of x until value x = 0 is input. There