PROJECT REPORT ON
STACK DATA STRUCTURE
DYNAMIC IMPLEMENTATION USING LINKED LISTS
SUBMITTED BY:
Asit panigrahy Roll No: 202556121
Bighneswara Sahu Roll No: 202556115
Subham pradhan Roll No: 202556690
Adala pradeep Roll No: 202556083
Academic Year: 2025-2026
Date of Submission: May9, 2026
OUR VISION:-
Our vision as a [Link] student is to evolve into a globally competent and socially responsible engineer who
leverages cutting-edge technology to solve complex real-world challenges while contributing to sustainable global
progress. I aspire to become a versatile professional and an innovative problem-solver in the field of engineering,
bridging the gap between theoretical concepts and practical industrial applications. To achieve this, my mission is
to maintain a relentless pursuit of academic excellence and technical proficiency, staying updated with emerging
trends and multidisciplinary advancements. I am committed to developing high-quality software and hardware
solutions by participating in hands-on projects, research initiatives, and industrial internships that demand creative
thinking. Beyond technical skills, I aim to cultivate strong leadership qualities, effective communication, and a
collaborative mindset through teamwork and professional networking. I also pledge to uphold the highest
standards of ethics and integrity in every project I undertake, ensuring that my contributions promote the
betterment of society and the environment. By fostering a habit of lifelong learning and adapting to the rapidly
changing technological landscape, I strive to transform from a student into a visionary technocrat capable of
driving meaningful digital and structural transformation in the modern world.
Introduction to Stack Data Structure
A Stack is a fundamental linear data structure that operates on the LIFO (Last-In-First-Out) principle. In this
model, the element that is added most recently is the first one to be removed. This behavior is analogous to a
physical stack of items, such as books or plates, where you can only add or remove the top item.
While stacks can be implemented using arrays, the Linked List implementation is often preferred in dynamic
environments. In an array-based stack, the size must be declared upfront, leading to either "Stack Overflow" if the
limit is reached or memory wastage if the stack remains mostly empty. The linked list approach uses pointers to
link nodes, allowing the stack to grow or shrink as needed during the program's execution.
Real-World and Technical Applications
Stacks are indispensable in computer science and software engineering. Their primary applications include:
Function Call Management (Call Stack)
The most critical use of a stack is in the execution of programs. When a function is called, its local variables,
parameters, and return address are pushed onto the System Call Stack. When the function finishes execution,
these details are popped, returning control to the caller. This is essential for handling recursion.
Expression Evaluation and Syntax Parsing
Compilers use stacks to evaluate mathematical expressions (Infix, Prefix, and Postfix). For example, to convert an
infix expression like A + B to postfix AB+, a stack is used to manage the precedence of operators.
Undo/Redo Mechanisms
Almost every modern text editor or graphics software uses stacks to implement Undo functionality. Every action
the user takes is pushed onto an "Undo Stack." When the user clicks "Undo," the most recent action is popped
and reversed.
Backtracking in Algorithms
Algorithms that explore multiple paths, such as searching through a maze or solving a Sudoku puzzle, use stacks
to "remember" the path taken. If a dead end is reached, the algorithm pops the last move to backtrack to the
previous decision point.
Browser History Management
Web browsers maintain a stack of visited URLs. When you click the "Back" button, the browser pops the current
URL and takes you to the URL immediately below it in the stack.
Structural Design
In a linked list implementation, each element is represented as a Node. Each node contains:
Data Field: Stores the actual information (integer, char, etc.).
Next Pointer: Stores the address of the node below it in the stack.
Algorithm for Implementation
Algorithm for PUSH
Create a new node N.
If memory allocation fails, output "Stack Overflow".
Set N->data = value.
Set N->next = top (Link new node to current top).
Update top = N (New node becomes the top).
Algorithm for POP
If top == NULL, output "Stack Underflow".
Create a temporary pointer T = top.
Update top = top->next.
Free the memory occupied by T.
1. Programming & Compiler Design
Function Call Management: The operating system uses a stack to store return addresses and local variables
whenever a function is called. Once the function finishes, the top element is "popped" to return control to the
previous point.
Recursion: Stacks track each nested function call (like calculating a factorial), storing a "snapshot" of local data so
the program can backtrack accurately.
Syntax Parsing: Compilers use stacks to check for balanced parentheses, braces, and brackets in code. [
2. Mathematical & Logic Operations
Expression Conversion: Stacks are used to convert Infix (human-readable) expressions to Postfix or Prefix
formats, which computers can process more easily.
Expression Evaluation: Calculators use stacks to evaluate postfix expressions (e.g., 3 4 +) by pushing operands
and popping them for calculation once an operator is encountered.
3. Software Features (Real-World)
Undo/Redo Mechanisms: In text editors (like MS Word) or image software, every action is pushed onto a stack.
When you press "Undo," the most recent action is popped to revert the state.
Browser History: Web browsers maintain a stack of visited URLs. Clicking the "Back" button pops the current page
to load the previous one.
#include #include
struct Node {
int data;
struct Node* next;
};
struct Node* top = NULL; void push(int x) {
struct Node* newNode = (struct Node*)malloc(sizeof(struct Node)); if (newNode == NULL) {
printf("Memory Error: Stack Overflow\n"); return;
newNode->data = x; newNode->next = top; top = newNode;
printf("Successfully pushed %d\n", x);
void pop() {
if (top == NULL) {
printf("Error: Stack Underflow (Stack is empty)\n"); return;
struct Node* temp = top; int val = top->data;
top = top->next; free(temp);
printf("Successfully popped %d\n", val);
}
void peek() {
if (top != NULL)
printf("Top element is: %d\n", top->data);
else
printf("Stack is empty\n");
void display() {
struct Node* temp = top; if (temp == NULL) {
printf("Stack is empty.\n"); return;
printf("Stack State: ");
Performance Summary
The linked list implementation provides a robust framework for stack operations. The time complexity for Push,
Pop, and Peek is consistently O(1), making it ideal for high-performance systems. The space complexity is O(n),
which is more efficient than static arrays in cases where the stack size fluctuates significantly.
The implementation of a Stack using a Linked List in C demonstrates the power of dynamic memory management
in engineering applications. Unlike array-based stacks, this approach eliminates fixed-size constraints, allowing
the data structure to grow and shrink according to real-time requirements. Mastering this concept is a critical
milestone for any [Link] student, as it bridges the gap between basic syntax and complex algorithmic efficiency.
Ultimately, this project reinforces the core engineering objective of creating scalable, memory-efficient solutions to
handle data in modern software development.