3.8.2 Stack

Knowledge Base > Algorithm > Data Structure


Overview

Stack is a very commonly used LIFO (Last-In-First-Out) data structure of which elements are placed in ordered such that elements can only be inserted or removed at one end, called top. In other words, since data is piled up in a stack, whenever an operation is being performed, element on the topmost comes off first. Therefore, in stack operations, we always handle the toppest element in stack at a time.

Basic Operation

Source Code

Usually, a stack can be implemented by array or linked-list.

Related Topics