ITEC33 (Ma'am Pamintuan) Flashcards
is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).
Stack
insertion operation
PUSH
removal operation
POP
STACK
Pushing (storing) an element on the stack.
push()
STACK
Removing (accessing) an element from the stack.
pop()
STACK
get the top data element of the stack, without removing it.
peek()
STACK
check if stack is full.
isFull()
STACK
check if stack is empty
isEmpty()
pointer provides top value of the stack without actually removing it.
top
The process of putting a new data element onto stack is known as a Push Operation. Push operation involves a series of steps −
Step 1− Checks if the stack is full.
Step 2− If the stack is full, produces an error
and exit.
Step 3− If the stack is not full, incrementstopto
point next empty space.
Step 4− Adds data element to the stack
location, where top is pointing.
Step 5− Returns success.
PUSH OPERATION
Accessing the content while removing it from the stack, is known as a Pop Operation. In an array implementation of pop() operation, the data element is not actually removed, insteadtopis decremented to a lower position in the stack to point to the next value. But in linked-list implementation, pop() actually removes data element and deallocates memory space.
Step 1− Checks if the stack is empty.
Step 2− If the stack is empty, produces an error and
exit.
Step 3− If the stack is not empty, accesses the data
element at whichtopis pointing.
Step 4− Decreases the value of top by 1.
Step 5− Returns success.
Pop Operation
The way to write arithmetic expression
notation
An arithmetic expression can be written in three different but equivalent notations
Infix Notation
Prefix (Polish) Notation
Postfix (Reverse-Polish) Notation
where operators are usedin-between operands. It is easy for us humans to read, write, and speak in infix notation but the same does not go well with computing devices.
Infix Notation
In this notation, operator isprefixed to operands, i.e. operator is written ahead of operands.
Prefix Notation
Prefix notation is also known as
Polish Notation.
the operator is written after the operands.
Postfix Notation
This notation style is known asReversed Polish Notation.
Postfix Notation