CSE 214 Lecture 10: Stacks
Document Summary
With tail - o(n) since there is no tail reference which must point to the node before the tail since to remove the node, you must set the link or the next item to null. A stack is a sequence of data elements (of the same type) arranged one after another conceptually. An element can be added to the top of the stack only. (push) An element can be removed from the top of the stack only. (pop) They are last in first out (lifo) or first in last out (filo). Some real life examples include plates, paper cups, etc or anything with a pile. Peek() - see what item is on top without altering the stack. Push() - shift everything over after adding an item. 49