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 sort algorithm is best?
What is the application of queue?
Define root?
Which are the sorted collections?
What is the best complexity of bubble sort?
State the merit of linked representation of binary trees?
Is python good for freshers?
Why quicksort is faster?
What are the advantages of bubble sort?
Does mentioning the array name gives the base address in all the contexts?
Do all declaration statements result in a fixed reservation in memory?
Which is faster array or linked list?
What is hashing with example?
which notations are used in evaluation of arithmetic expressions using prefix and postfix forms?
Will this code give error if I try to add two heterogeneous elements in the arraylist? And why?