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
Which sorting algorithm has minimum number of swaps?
Which sorting is best for large data?
Are dictionaries mutable?
Define adjacent nodes?
Is vector synchronized?
What are the disadvantages of circular list?
What is a minimum spanning tree?
How is a queue works?
What is the minimization factor and time complexity of b-tree?
What is array traversing?
Tell me is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What is circular linked list?
What is mean by merge sort?
How expression trees are gets represented in data structure?
Is it possible to make an array volatile in java?