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
write a program to accept name & sort them?
What is the difference between hashmap and linkedhashmap?
State the difference between primitive and non-primitive data types?
List the basic operations carried out in a linked list?
Does linkedhashset allow null values?
What happens if we try to insert duplicate key in hashmap?
What is a data structure? What are the types of data structures? Briefly explain them
What is the difference between arraylist and linkedlist?
How do you reference all the elements in a one-dimension array?
Mention a few applications of linked lists?
What are different methods of collision resolution in hashing.
Is array part of collection framework?
Write is a binary search tree? Write an algorithm and tell complexity?
What is list and its types?
What is data structure geeksforgeeks?