This article was automatically translated from the original Turkish version.
Stack
Data Structure Type | Linear | ||||||||
|---|---|---|---|---|---|---|---|---|---|
Basic Operations | push() pop() peek() isEmpty() isFull() | ||||||||
Application Area(s) | Artificial Intelligence and Automation Systems Software Development and Programming Languages Data Processing and Algorithms Operating Systems Game Development | ||||||||
A stack is a linear data structure that follows the LIFO (Last In First Out) principle, where the last element added is the first one removed. This means that both insertion and deletion operations occur at only one end.
Some real-world examples of LIFO:

1. Fixed-Size Stack: As the name implies, a fixed-size stack has a predetermined size and cannot grow or shrink dynamically. If the stack is full and an attempt is made to add an element, an overflow error occurs. If the stack is empty and an attempt is made to remove an element, an underflow error occurs.
2. Dynamic-Size Stack: A dynamic-size stack can grow or shrink dynamically. When the stack becomes full, it automatically increases its size to accommodate a new element, and when it becomes empty, it reduces its size. This type of stack is implemented using a linked list because it allows easy resizing of the stack.

Push operation in a stack structure (Source: geeksforgeeks.com)

Pop operation in a stack structure (Source: geeksforgeeks.com)

Peek operation in a stack structure (Credit: geeksforgeeks.com)

isEmpty operation in a stack structure (Source: geeksforgeeks.com)

isFull operation in a stack structure (Source: geeksforgeeks.com)
1. Dynamic memory allocation: The size of the stack can be dynamically increased or decreased by adding or removing nodes from the linked list, without requiring pre-allocation of a fixed amount of memory.
2. Efficient memory usage: Nodes in a singly linked list use less memory than nodes in a doubly linked list because they contain only a pointer to the next node and not to the previous one.
3. Simple implementation: Implementing a stack using a singly linked list is straightforward and can be done with just a few lines of code.
4. Versatility: Singly linked lists can also be used to implement other data structures such as queues, linked lists, and trees.
GeeksforGeeks. "What is Stack Data Structure? A Complete Tutorial." (2024).Accessed Adresi.
Geeksforgeeks. "Applications, Advantages and Disadvantages of Stack." (2024).Accessed Adresi.
Geeksforgeeks. "Implement a Stack Using Singly Linked List." (2024).Accessed Adresi.
Programiz. "Stack Data Structure."
TpointTech. "What is a Stack?"
Tutorialspoint. "Stack Data Structure."
W3schools. "DSA Stacks."

Stack
Data Structure Type | Linear | ||||||||
|---|---|---|---|---|---|---|---|---|---|
Basic Operations | push() pop() peek() isEmpty() isFull() | ||||||||
Application Area(s) | Artificial Intelligence and Automation Systems Software Development and Programming Languages Data Processing and Algorithms Operating Systems Game Development | ||||||||
No Discussion Added Yet
Start discussion for "Heap Data Structure" article
LIFO (Last In First Out) Principle
Types of Stacks
Basic Stack Operations
Advantages of Implementing a Stack Using a Linked List