This repository is a comprehensive collection of fundamental data structures implemented in C and Java, designed for educational purposes. It includes implementations of Linked Lists, Queues, Stacks, Trees, and Binary Heaps, each organized into subfolders with detailed code, documentation, and test programs. The repository aims to provide clear, efficient, and well-documented implementations to help learners understand the mechanics of data structures and their applications in computer science, such as searching, sorting, and task scheduling.
Each data structure is implemented iteratively (and recursively where applicable, e.g., Binary Search Tree), with a focus on clarity and performance. The repository includes both C (using pointers and manual memory management) and Java (using object-oriented principles and garbage collection) implementations to cater to different programming paradigms.
- Multiple Data Structures: Includes Linked Lists (
Singly
,Doubly
,Queue
,Stack
), Queues (Array-based
,Circular
,Deque
), Stacks, Trees (Binary
,BST
), and Binary Heaps (Max Heap
,Min Heap
). - Dual Implementations: Each data structure is implemented in both
C
andJava
, showcasing language-specific approaches. - Educational Focus: Well-commented code, detailed READMEs in each subfolder, and test programs to demonstrate functionality.
- Interactive Visualizations: Links to online tools for visualizing data structure operations.
- Open Source: Licensed under the included LICENSE file.
βββ Binary Heap
βββ Max Heap
β βββ Implementation in C
β β βββ main.c
β β βββ maxHeap.c
β β βββ maxHeap.h
β βββ Implementation in Java
β β βββ Main.java
β β βββ MaxHeap.java
β βββ README.md
βββ Min Heap
β βββ Implementation in C
β β βββ README.md
β β βββ main.c
β β βββ minHeap.c
β β βββ minHeap.h
β βββ Implementation in Java
β β βββ Main.java
β β βββ MinHeap.java
β β βββ README.md
β βββ README.md
βββ README.md
βββ LICENSE
βββ Linked List
βββ Doubly Linked List
β βββ README.md
βββ Linked List
β βββ Implementation of Linked List in C
β β βββ Readme.md
β βββ Implementation of Linked List in Java
β β βββ LinkedList.java
β β βββ Main.java
β β βββ Readme.md
β βββ README.md
βββ Linked Queue
β βββ Implementation in C
β β βββ LinkedQueue.c
β β βββ LinkedQueue.h
β β βββ README.md
β β βββ main.c
β βββ Implementation in Java
β β βββ LinkedQueue.java
β β βββ Main.java
β β βββ Node.java
β β βββ README.md
β βββ README.md
βββ Linked Stack
β βββ Implementation in C
β β βββ LinkedStack.c
β β βββ LinkedStack.h
β β βββ README.md
β β βββ main.c
β βββ Implementation in Java
β β βββ LinkedStack.java
β β βββ Main.java
β β βββ Node.java
β β βββ README.md
β βββ README.md
βββ Readme.md
βββ Queue
βββ Circular Queue
β βββ Implementation of Circular Queue in C
β β βββ Circular Queue.c
β β βββ Circular Queue.h
β β βββ Main.c
β β βββ Readme.md
β βββ Implementation of Circular Queue in Java
β β βββ Circular Queue.java
β β βββ Main.java
β β βββ Readme.md
β βββ README.md
βββ Double Ended Queue(Deque)
β βββ Implementation of Queue in C
β β βββ Deque.c
β β βββ Deque.h
β β βββ Main.c
β β βββ README.md
β βββ Implementation of Queue in Java
β β βββ Deque.java
β β βββ Main.java
β β βββ Readme.md
β βββ Readme.md
βββ Queue
β βββ Implementation of Queue in C
β β βββ Queue.c
β β βββ Queue.h
β β βββ Readme.md
β β βββ main.c
β βββ Implementation of Queue in Java
β β βββ Main.java
β β βββ Queue.java
β β βββ Readme.md
β βββ Readme.md
βββ README.md
βββ Stack
βββ Implementation of Stack in C
β βββ Readme.md
β βββ Stack.c
β βββ Stack.h
β βββ main.c
βββ Implementation of Stack in Java
β βββ Main.java
β βββ Readme.md
β βββ Stack.java
βββ Readme.md
βββ Trees
βββ Binary Search Tree (BST)
βββ Implementation in C
β βββ Iterative Implementation
β β βββ BST.c
β β βββ BST.h
β β βββ main.c
β βββ README.md
β βββ Recursive Implementation
β β βββ BST.c
β β βββ BST.h
β β βββ main.c
βββ Implementation in Java
β βββ Iterative Implementation
β βββ BST.java
β βββ Main.java
β βββ Node.java
β βββ README.md
β βββ Recursive Implementation
β βββ BST.java
β βββ Main.java
β βββ Node.java
βββ Binary Tree
βββ Implementation in C
β βββ README.md
β βββ Tree.c
β βββ Tree.h
β βββ main.c
βββ Implementation in Java
β βββ Main.java
β βββ Node.java
β βββ README.md
β βββ Tree.java
βββ README.md
βββ README.md
This repository organizes data structures into five main categories, each with multiple implementations:
- Binary Heap: A complete binary tree used for priority queues.
- Max Heap: Parent nodes are greater than or equal to children.
- Min Heap: Parent nodes are less than or equal to children.
- Linked List: Linear data structures using nodes with dynamic memory allocation.
- Singly Linked List:
Nodes
link to the next node, optimized for sequential access. - Doubly Linked List:
Nodes
link to both next and previous nodes for bidirectional traversal. - Linked Queue: A
FIFO
queue implemented using a singly linked list. - Linked Stack: A
LIFO
stack implemented using a singly linked list.
- Singly Linked List:
- Queue:
FIFO
data structures for ordered processing.- Array-based Queue: A fixed-size queue using an
array
. - Circular Queue: An
array-based
queue with wrap-around for efficient space usage. - Double Ended Queue (Deque): Allows insertion and deletion at both ends.
- Array-based Queue: A fixed-size queue using an
- Stack:
LIFO
data structure for applications like function call stacks.- Implemented using arrays in both C and Java.
- Trees: Hierarchical data structures for efficient searching and organization.
- Binary Tree:
Nodes
with at most two children for general hierarchical data. - Binary Search Tree (BST):
Nodes
organized by value for efficient searching, with bothiterative
andrecursive
implementations.
- Binary Tree:
Each subfolder contains C
and Java
implementations (where applicable), with source code, header/class files, test programs (main.c
or Main.java
), and a dedicated README.md
for detailed documentation.
Explore interactive visualizations for the data structures:
- π Linked List Visualizer
- π Queue Visualizer
- π Stack Visualizer
- π Binary Search Tree Visualizer
- C: A C compiler (e.g.,
gcc
). - Java: Java Development Kit (JDK) 8 or higher.
- Git: For cloning the repository.
git clone https://github.com/abdelhalimyasser/data-structures.git
cd data-structures
- Navigate to the desired subfolder (e.g.,
Linked List/Linked Queue/Implementation in C
). - Compile and run:
Note: Ensure the corresponding header file (e.g.,
gcc main.c <SourceFile>.c -o main ./main
LinkedQueue.h
) is included.
- Navigate to the desired subfolder (e.g.,
Linked List/Linked Queue/Implementation in Java
). - Compile and run:
Note: Ensure all Java files (e.g.,
javac *.java java Main
LinkedQueue.java
,Node.java
,Main.java
) are compiled together.
π Or You Can also Download it from πhere, and Download The Visualizers To Understand Well from πhere.
- Implementations: Most data structures are implemented in both C (using pointers and manual memory management) and Java (using object-oriented principles). Some subfolders may currently have partial implementations; check subfolder READMEs for details.
- Performance: Core operations (e.g., insert, delete, search) are designed for efficiency, typically O(1) for stack/queue operations and O(log n) or O(n) for tree operations, depending on the structure.
- Error Handling:
- C: Handles underflow/overflow with error messages and return values (e.g., -1 or -999 for empty dequeue).
- Memory Management:
- C: Uses
free
functions to prevent memory leaks. - Java: Relies on garbage collection, with explicit
clear
methods where applicable.
- C: Uses
- Extensibility: Implementations use integers for simplicity but can be extended to generic types.
- Subfolder Documentation: Each implementation folder contains a
README.md
with specific details, example usage, and output.
This project is licensed under the terms specified in the LICENSE file.
For questions, suggestions, or collaboration, reach out via:
This repository is a resource for students, educators, and developers to explore and master data structures. Contributions are welcome feel free to fork, submit pull requests, or open issues!