A stack is a data structure that follows the LIFO (Last In First Out) principle. Common stack operations include push to add an element to the top, pop to remove an element from the top, peek to view the top element without removing it, and checks for empty and full. Implementing a stack using an array involves storing elements in the array and tracking the top with an index variable. Key steps are initializing an empty stack, pushing to add to the top, popping to remove from the top, and checking for empty or full.
A stack is a data structure that follows the LIFO (Last In First Out) principle. Common stack operations include push to add an element to the top, pop to remove an element from the top, peek to view the top element without removing it, and checks for empty and full. Implementing a stack using an array involves storing elements in the array and tracking the top with an index variable. Key steps are initializing an empty stack, pushing to add to the top, popping to remove from the top, and checking for empty or full.
• Stack is a data structure that follows the Last In, First
Out (LIFO) principle, meaning that the last element added to the stack is the first one to be removed. Stack operations are the basic manipulations that can be performed on a stack. STACK OPERATIONS
• Push: Add an element to the top of a stack
• Pop: Remove an element from the top of a stack • IsEmpty: Check if the stack is empty • IsFull: Check if the stack is full • Peek: Get the value of the top element without removing it IMPLEMENTATION OF STACKS AS ARRAYS
• Implementing a stack using an
array involves using an array to stack = [1, 2, 3, 4, 5, 6] store the elements of the stack print(stack) and a variable to keep track of Output: the top of the stack. [1, 2, 3, 4, 5, 6] INITIALIZE STACK
• Initializing a stack involves setting up the stack = []
necessary data structures and variables required to represent an empty stack. In the context of an array-based implementation of a stack, you typically create an array and initialize the top index to a value indicating an empty stack. PUSH
• Push operation is used to add an
element to the top of the stack. POP
• The pop operation is used to
remove and return the element from the top of the stack. RETURN THE TOP ELEMENT / PEEK
• Returning the top element of a
stack without removing it is often called the peek operation. This operation allows you to inspect the element at the top of the stack without modifying the stack itself. EMPTY STACK
• Checking whether a stack is
empty involves determining whether it contains any elements or not. If the stack is empty, it means there are no elements to pop or peek. FULL STACK
• Checking whether a stack is full
involves determining whether it has reached its maximum capacity, especially in fixed-size stack implementations. STACK IMPLEMENTATION
• A stack implementation involves
combining the various stack operations (Initialize, Push, Pop, Peek, Empty, Full) to create a functional stack STACK IMPLEMENTATION MEMBERS
Jilian Mar M. Sierra
Harvey S. Adorco Ken Zeldrix Geronimo Harold Stephen Garcia