Skip to content

abdelhalimyasser/Data-Structures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Data Structures

πŸ“Œ Overview

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.


πŸš€ Features

  • 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 and Java, 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.

πŸ“‚ Project Structure

β”œβ”€β”€ 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

πŸ“Œ Data Structures Overview

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.
  • 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.
  • 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 both iterative and recursive implementations.

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.


🌐 Try it Online

Explore interactive visualizations for the data structures:


πŸ› οΈ Setup Instructions

Prerequisites

  • C: A C compiler (e.g., gcc).
  • Java: Java Development Kit (JDK) 8 or higher.
  • Git: For cloning the repository.

Clone the Repository

git clone https://github.com/abdelhalimyasser/data-structures.git
cd data-structures

Run C Implementations

  1. Navigate to the desired subfolder (e.g., Linked List/Linked Queue/Implementation in C).
  2. Compile and run:
    gcc main.c <SourceFile>.c -o main
    ./main
    Note: Ensure the corresponding header file (e.g., LinkedQueue.h) is included.

Run Java Implementations

  1. Navigate to the desired subfolder (e.g., Linked List/Linked Queue/Implementation in Java).
  2. Compile and run:
    javac *.java
    java Main
    Note: Ensure all Java files (e.g., 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.


πŸ“ Notes

  • 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.
  • 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.

πŸ“œ License

This project is licensed under the terms specified in the LICENSE file.


πŸ“¬ Contact

For questions, suggestions, or collaboration, reach out via:

LinkedInΒ  GmailΒ  InstagramΒ  XΒ  DiscordΒ  WechatΒ  Vk


πŸš€ Happy Learning!

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!


IF THERE IS ANY ISSUE OR BUG PLEASE GIVE PULL REQUEST THE PROJECT MAY HAVE MISSING FILE AS IT IS UNDER CONSTRACTION AND IT WILL BE THERE ADVANCED DATA STRUCTURES WILL BE UPLOADED LIKE AVL TREES, GRAPHS, ETC...