Stack (abstract data type) - Wikipedia#Non-essential_operations
Non-essential operations
In many implementations, a stack has more operations than the essential “push” and “pop” operations. An example of a non-essential operation is “top of stack”, or “peek”, which observes the top element without removing it from the stack.1 Since this can be broken down into a “pop” followed by a “push” to return the same data to the stack, it is not considered an essential operation. If the stack is empty, an underflow condition will occur upon execution of either the “peek” or “pop” operation. Additionally, many implementations include convenience operations that handle common tasks, such as checking if the stack is empty or returning its size.
Printed 2026-07-08.
(echo:: @ ᯤ)
Footnotes
-
Horowitz, Ellis (1984). Fundamentals of Data Structures in Pascal. Computer Science Press. p. 67. ↩