5.1.7+Construct+algorithms+using+the+access+methods+of+a+stack

=__**5.1.7 Construct algorithms using the access methods of a stack.**__=

=** __Stacks:__ **=
 * abstract data type
 * collection
 * order based on length of time in collection
 * Last-In-First-Out (LIFO) data structure
 * last element added, also first to be removed
 * only addition or removing
 * addition & deleting only at top of data structure
 * push ( addition of an entity to the collection)
 * pop ( removal of an entity)
 * restricted data structure
 * small # of operations
 * natural order
 * elements removed in reverse order of elements being added
 * lower elements on stack for longest
 * push and pop only occurs in one end of structure
 * given that data linear/sequential
 * called: “**top of stack**”
 * opposite of top is “**base**”
 * peek/top operations outputs value of top element without removing
 * if set capacity and can’t collect more data → overflow state
 * pop removes data
 * either reveals items or creates empty stack
 * no items present in stack → underflow → stack is removed
 * used to reverse order of items



__** Vocabulary: **__
 * **push**: add new item to top of stack
 * **pop**: take away item from top of stack
 * **isEmpty**: check whether stack empty
 * **size**: number of items in stack

__** Errors: **__
 * **overflow**: when trying to push item into full stack
 * either stack has fixed size or computer runs out of memory
 * mainly caused by recursion
 * **underflow**: when trying to pop an empty stack
 * use isempty to counteract
 * usually sign that computation is complete


 * Code: **
 * ** Stack: ** creates new stack
 * ** push(item): ** adds new item to top
 * ** pop: ** removes to item
 * ** peek: ** returns top item without removing
 * ** isEmpty: ** tests if stack empty
 * ** size: ** counts number of items

__Example: __ Checking whether all lines of code contain an opening and a corresponding closing parenthesis. 

Created By: Lucie Magister Last update: 18/11/2014

Sources: >
 * "Notes on Stacks." CS 367-3. N.p., n.d. Web. 18 Nov. 2014. <[]>.
 * "Stack (abstract Data Type)." Wikipedia. Wikimedia Foundation, 18 Nov. 2014. Web. 18 Nov. 2014. <[]>.
 * "Stacks." Stacks — Problem Solving with Algorithms and Data Structures. N.p., n.d. Web. 18 Nov. 2014. <[|http://interactivepython.org/runestone/static/pythonds/BasicDS/stacks.htm]l>.