Peek
The Peek function is used to retrieve or fetch the first element of the Stack or the element present at the top of the Stack.
Syntax :
Peek(Stack)
Parameters | Description |
---|---|
stack | Data type that serves as a collection of elements. |
Example :
pen
pencil
paper
eraser
ipeek = peek()
Result :
ipeek = pen