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
How do you find the space complexity of a bubble sort?
What is the Difference between treemap and hashmap?
What is integer max_value?
What you mean by sorting?
What is difference between arraylist and linkedlist?
Is treeset sorted?
Questions related to arrays, such as given a 2 integer array, find the common elements.
Explain exception filter?
What do you mean by Logical Error
Explain pre-order and in-order tree traversal.
Tell me how to find middle element of linked list in one pass?
What is dynamic array how is it created?
Does linked list allow duplicates?
Is it possible to increase size of array?
What is bubble insertion selection sort?