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


Please Help Members By Posting Answers For Below Questions

Which is faster list or set?

493


What sort of serious problems have you experienced, and how have you handled them?

615


Is a hashset ordered?

510


Can arraylist be resized?

572


What is complete binary tree in data structure?

525






What is the difference between static and dynamic data?

495


Is hashmap faster than arraylist?

475


How do arrays work?

525


Why might quick sort might be better than merge sort?

458


What is dynamic array how is it created?

478


In rdbms, explain what is the efficient data structure used in the internal storage representation?

540


When will you use array over arraylist?

537


In depth questions regarding the data structures and the Databases used in the Projects developed.

562


Differentiate between file and structure storage structure.

525


How does threaded binary tree represented in data structure?

591