Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

“int a[] = new int[3]{1, 2, 3}” – This a legal way of defining the arrays?

1146


Tell us the difference between merge and quick sort. Which one would you prefer and why?

957


What are the applications of stack?

850


What are the 3 types of variables?

839


an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(n-square).

863


Is hashset a collection?

859


Write an algorithm for inserting and deleting an element from doubly linked list?

868


Write the stack overflow condition.

991


Tell me about circular linked list?

887


What is time complexity of binary search?

842


What does arrays tostring do?

807


Define shortest path?

961


Can you make an arraylist of arrays?

1025


What is sequential mapping in data structure?

885


What is tree and its properties?

844