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
What is nonlinear data?
What is stack explain with diagram?
What are the different binary tree traversal techniques?
How do we search a specific element in an array?
Which is the parent class of linkedlist class?
Explain pre-order and in-order tree traversal.
Define linked list data structure.
What is the quickest sorting algorithm?
Is bubble sort adaptive?
Can nsarray contain nil?
Is json a data structure?
What do you mean by 2-3-4 tree?
What is sorted map?
What is difference between list and array list?
What is difference between set and map?