create an singly linked lists and reverse the lists by
interchanging the links and not the data?
Answer Posted / kushal bagaria
struct node
{
int data;
struct node *list;
};
reverse(&p) /* p is the pointer to the 1st node of ll*/
function reverse:-
reverse(struct node **q)
{
struct node *r,*t,*prev;
r=*q;
prev= NULL;
while(r!=NULL)
{
t=prev;
prev=r;
r=r->link;
prev->link=t;
}
*q=prev; /* last node bcoms d root of ll */
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
“int a[] = new int[3]{1, 2, 3}” – This a legal way of defining the arrays?
Tell us the difference between merge and quick sort. Which one would you prefer and why?
What are the applications of stack?
What are the 3 types of variables?
an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(n-square).
Is hashset a collection?
Write an algorithm for inserting and deleting an element from doubly linked list?
Write the stack overflow condition.
Tell me about circular linked list?
What is time complexity of binary search?
What does arrays tostring do?
Define shortest path?
Can you make an arraylist of arrays?
What is sequential mapping in data structure?
What is tree and its properties?