






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







class Node { public : int Info ; Node * next , * prev ; Node ( int el , Node * n = NULL , Node * p = NULL ) { Info = el ; next = n ; prev = p ; } };
void DoublyLinkedList :: addToTail ( int el ) { if ( tail != NULL ) // if list is not empty { tail = new Node ( el , NULL , tail ) ; tail - > prev - > next = tail ; } else // if list is empty head = tail = new Node ( el ) ; Size ++ ; }
int DoublyLinkedList :: deleteFromTail () { int el = tail - > Info ; if ( head == tail ) // if only one node in the list { delete head ; head = tail = NULL ; } else // if more than one node in the list { tail = tail - > prev ; delete tail - > next ; tail - > next = NULL ; } Size -- ; return el ; }