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
Tell me the difference between structure and array?
Define dynamic data structures?
In rdbms, explain what is the efficient data structure used in the internal storage representation?
Which is faster hashmap or treemap?
Can we put null key in hashmap?
What does list clear do?
Which sorting algorithm is best for large data?
What are skew trees? For a tree with 4 nodes draw all possible binary? Generalize for n nodes how many binary trees can be drawn?
Explain the Stack
What is linear and non linear structure?
How many links are there in a binary tree of N nodes?
Run time memory allocation is known as ?
Does treemap allow null values?
Why is data structure important?
What is a minimum spanning tree?