CC4 Lec 4 Flashcards
A stack is also known as a ___ list
Last-In-First-Out (LIFO)
(T) A stack is a linear structure in which items are added or removed only at one end the top.
(T) The depth of stack is the number of elements it contains.
(T) An empty stack has depth zero.
(T) Elements are ordered
(T) Stack user cannot have direct access to data items inside the stack
(T) Only topmost item can be retrieved
(T) Can hold any number of data items (in principle), however, there is an upper limit to stack size depending on the memory space
A list with the restriction that insertion and deletion can be performed only from one end, called the top.
STACK ADT (Abstract Data Type)
Insert or push some item “x” onto the stack.
Push (x)
Before this operation, the stack if often checked if it has enough ______ to accommodate the new item
If stack is full, an _____would occur
capacity, overflow
Removing the most recent item or element from the stack.
Pop( )
Must ensure that the stack is not ___ before this operation
If stack contains no item, popping would cause an ____ error
empty, underflow
Returns the copy of the item or element at the TOP of the stack.
TOP
This operation is also called PEEK
TOP