This project provides custom implementations of fundamental data structures and collections in Java. The goal is to mimic the behavior and structure of the Java Collections Framework, providing a deeper understanding of how these data structures work under the hood.
The aim of this project is to fully understand the most common data structures and algorithms. I believe that to be successful in Java, a clear understanding of the extensive Java Collections Framework is essential. This project will help leverage my expertise in Java by delving into the intricate details of these fundamental components. I try to keep
This project is developed using Test-Driven Development (TDD) and is fully tested to ensure the correctness and reliability of the implementations. I strive to keep the code as optimized as possible, continuously improving as I learn better solutions.
- Introduction
- Project Structure
- Implemented Interfaces
- Implemented Classes
- How to Use
- Running Tests
- Contributing
- License
This project includes custom implementations of key data structures such as lists, queues, and sets. It also includes various interfaces to define the behavior of these data structures, similar to the Java Collections Framework.
DataStructuresAlgorithms/
│
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ ├── com/
│ │ │ │ ├── jethroau/
│ │ │ │ │ ├── dsa/
│ │ │ │ │ │ ├── datastructures/ // Data structure implementations
│ │ │ │ │ │ │ ├── collections/ // Collection interfaces
│ │ │ │ │ │ │ │ ├── Collection.java
│ │ │ │ │ │ │ │ ├── List.java
│ │ │ │ │ │ │ │ ├── Queue.java
│ │ │ │ │ │ │ │ ├── Set.java
│ │ │ │ │ │ │ │ ├── Deque.java
│ │ │ │ │ │ │ │ ├── SortedSet.java
│ │ │ │ │ │ │ │ ├── NavigableSet.java
│ │ │ │ │ │ │ │ ├── SortedMap.java
│ │ │ │ │ │ │ │ ├── NavigableMap.java
│ │ │ │ │ │ │ │ ├── Iterator.java
│ │ │ │ │ │ │ │ ├── Iterable.java
│ │ │ │ │ │ │ │ ├── Tree.java
│ │ │ │ │ │ │ │ └── Comparable.java
│ │ │ │ │ │ │ ├── lists/ // List implementations
│ │ │ │ │ │ │ │ ├── ArrayList.java
│ │ │ │ │ │ │ │ └── LinkedList.java
│ │ │ │ │ │ │ ├── queues/ // Queue implementations
│ │ │ │ │ │ │ │ └── LinkedQueue.java
│ │ │ │ │ │ │ ├── stacks/ // Stack implementations
│ │ │ │ │ │ │ │ └── LinkedStack.java
│ │ │ │ │ │ │ ├── trees/ // Tree implementations
│ │ │ │ │ │ │ │ ├── BinaryTree.java
│ │ │ │ │ │ │ │ └── BinarySearchTree.java
│ │ │ │ │ │ │ └── util/ // Utility classes (if any)
│ │ │ │ │ │ ├── algorithms/ // Algorithms
│ │ │ │ │ │ │ ├── BubbleSort.java
│ │ │ │ │ │ │ ├── InsertionSort.java
│ │ │ │ │ │ │ ├── SelectionSort.java
│ │ │ │ │ │ │ └── QuickSort.java
│ │ ├── resources/ // Resources such as configuration files
│ ├── test/
│ │ ├── java/
│ │ │ ├── com/
│ │ │ │ ├── jethroau/
│ │ │ │ │ ├── dsa/
│ │ │ │ │ │ ├── datastructures/ // Data structure tests
│ │ │ │ │ │ │ ├── collections/ // Collection interfaces tests
│ │ │ │ │ │ │ │ ├── CollectionTest.java
│ │ │ │ │ │ │ │ └── ListTest.java
│ │ │ │ │ │ │ ├── lists/ // List implementations tests
│ │ │ │ │ │ │ │ ├── ArrayListTest.java
│ │ │ │ │ │ │ │ └── LinkedListTest.java
│ │ │ │ │ │ │ ├── queues/ // Queue implementations tests
│ │ │ │ │ │ │ │ └── LinkedQueueTest.java
│ │ │ │ │ │ │ ├── stacks/ // Stack implementations tests
│ │ │ │ │ │ │ │ └── LinkedStackTest.java
│ │ │ │ │ │ │ ├── trees/ // Tree implementations tests
│ │ │ │ │ │ │ │ ├── BinaryTreeTest.java
│ │ │ │ │ │ │ │ └── BinarySearchTreeTest.java
│ │ │ │ │ │ ├── algorithms/ // Algorithms tests
│ │ │ │ │ │ │ ├── BubbleSortTest.java
│ │ │ │ │ │ │ ├── InsertionSortTest.java
│ │ │ │ │ │ │ ├── SelectionSortTest.java
│ │ │ │ │ │ │ └── QuickSortTest.java
│ │ │ │ │ │ └── util/ // Utility classes tests
│ ├── resources/ // Test resources
- Collection
- List
- Queue
- Set
- Deque
- SortedSet
- NavigableSet
- SortedMap
- NavigableMap
- Iterator
- Iterable
- Tree
- Comparable
- Array List
- Linked List
- Linked Stack
- Linked Queue
- Binary Tree
- Binary Search Tree (BST)
- More coming soon..
- BubbleSort
- InsertionSort
- SelectionSort
- QuickSort
- More coming soon..
To use the custom data structures, you can create instances of the implemented classes and interact with them using the methods defined in their respective interfaces.
Example:
import com.jethroau.dsa.lists.ArrayList;
import com.jethroau.dsa.collections.List;
public class Main {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("apple");
list.add("banana");
System.out.println(list.get(0)); // Outputs: apple
System.out.println(list.get(1)); // Outputs: banana
}
}
To run the tests for the implemented data structures, you can use a testing framework like JUnit. The test classes are located in the src/test/java/com/jethroau/dsa/ directory.
If you are using Maven, you can run the tests using the following command:
mvn testContributions are welcome! If you find a bug or want to add a new feature, feel free to open an issue or submit a pull request.
- Fork the repository.
- Create a new branch (git checkout -b feature-branch).
- Make your changes.
- Commit your changes (git commit -am 'Add new feature').
- Push to the branch (git push origin feature-branch).
- Create a new Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.