CS 107 - 7/31/15 Top&Pop operation - modify the existing Pop operation remove a value and return that value from the stack // if the stack is not empty decrement the value of top // and return the last value added to the stack int toppop ( stack & s ) { if ( isEmpty ( s ) == false ) { int rvalue; rvalue = s.arr[s.top-1] ; s.top--; return rvalue; } else return -999; // return this error value if stack is empty } Primary stack operations isEmpty push pop top Additional operations init top&pop isFull -------------------- Dynamic Array require the availabilty of consectutive memory However, depending on the RAM size of the machine, the total size of the data set (and a few other factors we will ignore for now), consectutive memory may not be a real option. In these cases, linked lists are needed. We will keep the majority of our linked list operations focused on linked lists stacks. A linked list contains zero or more nodes each node contains data (1 data item/set) and the memory address of the next item in the list. often a varaible called head store the address of the first node in the list head -> 5 -> 10 -> 15 . Push operation - adds a new node to the beginning of the list Top operation - returns the value in the first node of the list Pop operation - remove the first node from the list isEmpty () - returns true if the address stored in head is NULL