create an singly linked lists and reverse the lists by
interchanging the links and not the data?

Answer Posted / sumit garg( jmit mca)

\\HELLO FRIENDS CHEK THIS...IT IS TESTED\\
struct node
{
int info;
struct node * next;
};
struct node * ptr=NULL,* old=NULL,*save=NULL;
void reverse()
{
old=ptr=start;
while (ptr!=NULL)
{
ptr=ptr->next;
old->next=save;
push(old);
save=old;
old=ptr;
}
}
void push(struct node * p)
{
top++;
stack [top]=p;
}
struct node * pop()
{
struct node * ret=NULL;
ret=stack[top];
top=top-1;
return ret;
}
display(struct node * disp)
{
disp=stack[top];
while (disp->next!=NULL)
{
disp=pop();
printf("%d",disp->info);
}

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the time complexity of hashmap get () and put () method?

466


State the properties of a binary tree?

575


What does the dummy header in the linked list contain?

754


Why it is said that searching a node in a binary search tree is efficient than that of a simple binary tree?

616


What are the advantages of data structure?

534






How many types of data structures are there?

535


Define shortest path?

573


Define biconnectivity?

524


State the demerits of linked representation of binary trees?

544


What is type structure?

489


What does arrays tostring do?

480


List the types of tree.

531


What is peek in stack?

453


What is the difference between array sort () and array sort t >()?

462


Differentiate stack from array?

522