Skip to content

Latest commit

 

History

History
376 lines (283 loc) · 10.7 KB

File metadata and controls

376 lines (283 loc) · 10.7 KB

DSA Practice Ground 🚀

A comprehensive Data Structures and Algorithms learning platform built in Java. This project provides skeleton implementations with extensive tests and detailed wiki guides to help you learn and practice DSA concepts.

📚 Overview

This is a practice-oriented DSA repository where:

  • Each algorithm/data structure has a skeleton implementation with TODO markers
  • Comprehensive JUnit tests are provided (commented out until you implement)
  • Wiki guides explain the problem without giving away the solution
  • You learn by implementing, not just reading

🎯 Philosophy

"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin

This project follows a hands-on learning approach:

  1. Read the wiki guide to understand the problem
  2. Implement the algorithm/data structure
  3. Uncomment and run tests to verify
  4. Iterate until all tests pass

🏗️ Project Structure

src/
├── main/java/com/dsa/
│   ├── algorithms/
│   │   ├── searching/
│   │   │   ├── LinearSearch.java
│   │   │   ├── BinarySearch.java
│   │   │   ├── Depth_First_Search.java
│   │   │   └── Breadth_First_Search.java
│   │   ├── sorting/
│   │   │   ├── BubbleSort.java
│   │   │   ├── SelectionSort.java
│   │   │   ├── InsertionSort.java
│   │   │   ├── MergeSort.java
│   │   │   └── QuickSort.java
│   │   ├── Traversal/
│   │   │   ├── In_Order_Traversal.java
│   │   │   ├── Pre_Order_Traversal.java
│   │   │   └── Post_Order_Traversal.java
│   │   ├── graph/
│   │   │   ├── Dijkstra.java
│   │   │   └── TopologicalSort.java
│   │   └── dynamic_programming/
│   │       ├── Fibonacci.java
│   │       ├── Knapsack.java
│   │       └── LongestCommonSubsequence.java
│   └── data_structures/
│       ├── ArrayList.java
│       ├── LinkedList.java
│       ├── Stack.java
│       ├── Queue.java
│       ├── Graph.java
│       ├── LRUCache.java
│       ├── HashMap.java
│       ├── Heap/
│       │   ├── MinHeap.java
│       │   └── MaxHeap.java
│       └── Tree/
│           ├── Tree.java (BST)
│           └── Trie.java
├── test/java/com/dsa/
│   └── [Comprehensive JUnit tests for all implementations]
└── wiki/
    └── [Detailed guides for each algorithm/data structure]

🚀 Getting Started

Prerequisites

  • Java 23 or higher
  • Maven 3.6+
  • Your favorite IDE (IntelliJ IDEA, Eclipse, VS Code)

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd data-structures-self-learning
  1. Build the project:
mvn clean install
  1. Run tests:
mvn test

📖 How to Use This Repository

Step 1: Choose a Topic

Browse the available algorithms and data structures. Start with simpler ones like:

  • Linear Search
  • Bubble Sort
  • Stack
  • Queue

Step 2: Read the Wiki Guide

Each topic has a comprehensive wiki guide in the wiki/ directory:

  • Problem description
  • Complexity analysis
  • How it works
  • Hints (NO direct solutions!)
  • Test cases to consider
  • Common pitfalls

Example:

# Read the Linear Search guide
cat wiki/LinearSearch.md

Step 3: Implement

Open the corresponding Java file and implement the methods marked with TODO:

public int search(int[] arr, int target) {
    // TODO: Implement linear search
    
}

Step 4: Test

Uncomment the tests in the corresponding test file and run them:

# Run specific test class
mvn test -Dtest=LinearSearchTest

# Run all tests
mvn test

Step 5: Iterate

Keep refining your implementation until all tests pass!

📊 Available Data Structures

Data Structure Difficulty Wiki Guide
ArrayList ⭐ Beginner wiki/ArrayList.md
LinkedList ⭐ Beginner wiki/LinkedList.md
Stack ⭐ Beginner wiki/Stack.md
Queue ⭐ Beginner wiki/Queue.md
Binary Search Tree ⭐⭐ Intermediate wiki/BinarySearchTree.md
Min/Max Heap ⭐⭐ Intermediate wiki/MinHeap.md
Trie ⭐⭐ Intermediate wiki/Trie.md
Graph ⭐⭐ Intermediate wiki/Graph.md
HashMap ⭐⭐ Intermediate wiki/HashMap.md
LRU Cache ⭐⭐⭐ Advanced wiki/LRUCache.md

🔍 Available Algorithms

Searching Algorithms

Algorithm Difficulty Time Complexity Wiki Guide
Linear Search ⭐ Beginner O(n) wiki/LinearSearch.md
Binary Search ⭐ Beginner O(log n) wiki/BinarySearch.md
DFS ⭐⭐ Intermediate O(V + E) wiki/DepthFirstSearch.md
BFS ⭐⭐ Intermediate O(V + E) wiki/BreadthFirstSearch.md

Sorting Algorithms

Algorithm Difficulty Time Complexity Wiki Guide
Bubble Sort ⭐ Beginner O(n²) wiki/BubbleSort.md
Selection Sort ⭐ Beginner O(n²) wiki/SelectionSort.md
Insertion Sort ⭐ Beginner O(n²) wiki/InsertionSort.md
Merge Sort ⭐⭐ Intermediate O(n log n) wiki/MergeSort.md
Quick Sort ⭐⭐ Intermediate O(n log n) wiki/QuickSort.md

Graph Algorithms

Algorithm Difficulty Time Complexity Wiki Guide
Dijkstra's ⭐⭐⭐ Advanced O((V+E) log V) wiki/Dijkstra.md
Topological Sort ⭐⭐ Intermediate O(V + E) wiki/TopologicalSort.md

Dynamic Programming

Algorithm Difficulty Time Complexity Wiki Guide
Fibonacci ⭐ Beginner O(n) wiki/Fibonacci.md
0/1 Knapsack ⭐⭐ Intermediate O(nW) wiki/Knapsack.md
LCS ⭐⭐ Intermediate O(mn) wiki/LongestCommonSubsequence.md

🧪 Testing

All implementations come with comprehensive JUnit 5 tests:

# Run all tests
mvn test

# Run tests with coverage
mvn test jacoco:report

# Run specific test class
mvn test -Dtest=BinarySearchTest

# Run specific test method
mvn test -Dtest=BinarySearchTest#testIterativeSearchFound

Test Structure

Tests are initially commented out with TODO markers. As you implement each method:

  1. Uncomment the corresponding tests
  2. Run the tests
  3. Fix issues until tests pass
  4. Move to the next method

💡 Learning Path

For Absolute Beginners

  1. Week 1-2: Basic Data Structures

    • ArrayList
    • LinkedList
    • Stack
    • Queue
  2. Week 3-4: Basic Algorithms

    • Linear Search
    • Binary Search
    • Bubble Sort
    • Insertion Sort

For Intermediate Learners

  1. Week 1-2: Advanced Data Structures

    • Binary Search Tree
    • Heap
    • Trie
    • Graph
  2. Week 3-4: Advanced Algorithms

    • DFS/BFS
    • Merge Sort
    • Quick Sort
    • Dijkstra's Algorithm

For Advanced Learners

  1. Week 1-2: Complex Structures

    • LRU Cache
    • HashMap (from scratch)
    • Graph with advanced operations
  2. Week 3-4: Advanced Algorithms

    • Dynamic Programming problems
    • Topological Sort
    • Advanced graph algorithms

🤝 Contributing

This is a learning project! Contributions are welcome:

  1. Fork the repository
  2. Create a feature branch
  3. Add new algorithms/data structures with:
    • Skeleton implementation
    • Comprehensive tests
    • Wiki guide (problem only, no solution!)
  4. Submit a pull request

📝 Best Practices

  1. Read the wiki guide first - Don't peek at solutions online immediately
  2. Think about edge cases - Empty inputs, single elements, large inputs
  3. Consider time/space complexity - Try to match the target complexity
  4. Write clean code - Use meaningful variable names, add comments
  5. Test thoroughly - Make sure all test cases pass
  6. Understand, don't memorize - Focus on understanding the concept

🔧 IDE Setup

IntelliJ IDEA

  1. Open the project
  2. Right-click on test file → Run 'TestName'
  3. Use Ctrl+Shift+F10 (Windows) or Cmd+Shift+R (Mac) to run tests

VS Code

  1. Install Java Extension Pack
  2. Install Test Runner for Java
  3. Click "Run Test" above test methods

Eclipse

  1. Import as Maven project
  2. Right-click test file → Run As → JUnit Test

📚 Additional Resources

⚠️ Common Mistakes to Avoid

  1. Skipping the wiki guide - Always understand the problem first
  2. Copy-pasting solutions - You won't learn that way!
  3. Ignoring test cases - Tests are there to help you
  4. Not considering edge cases - Think about null, empty, single element
  5. Giving up too early - Struggle is part of learning!

📈 Progress Tracking

Create a personal progress tracker:

## My Progress

### Data Structures
- [x] ArrayList
- [x] LinkedList
- [ ] Stack
- [ ] Queue
...

### Algorithms
- [x] Linear Search
- [ ] Binary Search
...

🎓 Learning Tips

  1. Start simple - Don't jump to advanced topics
  2. Practice daily - Consistency beats intensity
  3. Draw it out - Visualize the algorithm
  4. Explain to others - Teaching solidifies understanding
  5. Time yourself - Practice coding under time pressure

📧 Support

If you're stuck:

  1. Re-read the wiki guide
  2. Check the test cases for hints
  3. Draw the problem on paper
  4. Take a break and come back
  5. Ask for help in discussions (explain what you've tried!)

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🌟 Acknowledgments

  • Created as a comprehensive DSA learning platform
  • Inspired by various coding interview preparation resources
  • Built with ❤️ for learners

Remember: The goal is not to finish quickly, but to understand deeply. Take your time, struggle with the problems, and enjoy the learning journey! 🚀

Happy Coding! 💻