Peek, Isempty, Isfull in Stacks and Queues
Peek, Isempty, Isfull in Stacks and Queues
1. peek - This function allows you to look at the element at the top of the
stack. It's a way to inspect the next item that would be removed if a pop
operation were to be performed.
For a stack: Peek would return the last item added (since stacks follow
Last In, First Out order).
3. isFull - This function is typically relevant for a fixed size stack. It allows you
to determine if the data structure has reached its maximum capacity.
Task
You are given implementation of peek,isEmpty and isFull function of stack
Peek function return the element present in the peek of stack in case stack
is empty it returns -1.
isFull fuction return 1 if the stack is full and return 0, if the stack is not full.
Fill the dash present in the function and submit the code.
https://www.codechef.com/learn/course/stacks-and-queues/LSTACKS/problems/STACK12 1/1