program to Reverse a linked list

Answer Posted / mbm

/* Reverse linked list by recursion */

if(head)
head = _ReverseLinkedList(NULL, head, head->next);

NodeStr *_ReverseLinkedList(
NodeStr *preNode,
NodeStr *node1,
NodeStr *node2
)
{
NodeStr *next_node;

if(!node2)
return node1;

next_node = node2->next;
node2->next = node1;
node1->next = preNode;
return _ReverseLinkedList(node1, node2, next_node);
}

Is This Answer Correct ?    11 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

3337


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

2345


Write a program to model an exploding firecracker in the xy plane using a particle system

3859


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

3067


Cluster head selection in Wireless Sensor Network using C programming language.

3368






Develop a routine to reflect an object about an arbitrarily selected plane

3268


#include int main(void) { int a=4, b=2; a=b<>2 ; printf("%d",a); return 0; }

1287


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2559


How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?

2248


write a function to give demostrate the functionality of 3d in 1d. function prototye: change(int value,int indexX,int indexY,int indexZ, int [] 1dArray); value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored??

4379


What is full form of PEPSI

2114


Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??

2123


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

4066


why nlogn is the lower limit of any sort algorithm?

2535


write a simple calculator c program to perform addition, subtraction, mul and div.

3378