- Assume Class Dnode Friend Class Dll String S As Opposed To Int Data Dnode Next Dnode Prev Assume You Hav 1 (100.23 KiB) Viewed 46 times
Assume: class DNode { friend class DLL; string s; // as opposed to int data; DNode *next; DNode *prev; }; Assume you hav
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Assume: class DNode { friend class DLL; string s; // as opposed to int data; DNode *next; DNode *prev; }; Assume you hav
Assume: class DNode { friend class DLL; string s; // as opposed to int data; DNode *next; DNode *prev; }; Assume you have the following linked list: sh->li->ev->d->i-> If you run the following function, then print out the linked list, what do you get? void DLL::f3() { } DNode *tmp3= first->next; DNode *tmp2; while (tmp3 != NULL) { } Answer: DNode *tmp = tmp3; tmp2= tmp->prev; while (tmp2 != NULL && tmp2->s> tmp->s) { tmp2= tmp2->prev; } tmp3= tmp3->next; if (tmp->prev != tmp2) { } if (tmp->next == NULL) { last tmp->prev; } if (tmp->next != NULL) { } else { } if (tmp2 != NULL) { } else { tmp->prev->next = tmp->next; tmp->next->prev= tmp->prev; } tmp->prev->next = NULL; tmp->next = tmp2->next; tmp->prev= tmp2; tmp2->next = tmp; tmp->next->prev = tmp; tmp->next = first; first->prev = tmp; first = tmp; first->prev = NULL;