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 nonlinear data?

485


What is stack explain with diagram?

507


What are the different binary tree traversal techniques?

602


How do we search a specific element in an array?

551


Which is the parent class of linkedlist class?

444






Explain pre-order and in-order tree traversal.

535


Define linked list data structure.

571


What is the quickest sorting algorithm?

537


Is bubble sort adaptive?

511


Can nsarray contain nil?

455


Is json a data structure?

516


What do you mean by 2-3-4 tree?

563


What is sorted map?

494


What is difference between list and array list?

468


What is difference between set and map?

503