This repository provides a comprehensive guide to Data Structures and Algorithms (DSA) implemented in Java. It covers foundational Java concepts, core data structures, sorting and searching algorithms, recursion, backtracking, problem-solving patterns, and LeetCode practice — all organized with theory notes and code implementations.
- Java Basics
- Methods (Functions)
- Object-Oriented Programming (OOPs)
- Data Structures
- Sorting Algorithms
- Searching Algorithms
- Recursion & Backtracking
- Key Concepts & Problem Solving Patterns
- Dynamic Programming
- Time & Space Complexity
- Collections Framework
- Predefined Classes in Java
- Roadmap
- Resources
Fundamental Java syntax and constructs for getting started.
| Topic | Description |
|---|---|
| Datatype and Variables | Primitive types, variable declaration, naming conventions |
| Operators | Arithmetic, relational, logical, bitwise, assignment operators |
| Conditional Statements | If-else, else-if ladder, ternary operator |
| Switch-Case Statements | Switch-case syntax, fall-through, default case |
| Iterative Statements | For, while, do-while, foreach, nested loops, break/continue |
| Patterns | Star patterns and number patterns (Patterns 1–11) |
Introduction to methods in Java — definition, parameters, return types, overloading, and recursion.
| File / Folder | Concepts |
|---|---|
CalculatorUsingFunction.java |
Static methods, Scanner I/O, basic arithmetic |
MethodWithParameters.java |
Methods accepting parameters |
MethodWithReturnValue.java |
Methods returning values |
OverloadedMethod.java |
Method overloading |
RecursiveMethod.java |
Recursive factorial |
Basics/ |
Parameterless methods, factorial, multiplication |
Core OOP principles and their practical implementations in Java.
| Topic | Concepts |
|---|---|
| Basics | Classes, objects, fields, methods, getters/setters, encapsulation |
| Constructors | Constructor definition, super(), constructor overloading |
| Inheritance | Single, multilevel, hierarchical inheritance, super keyword |
| Polymorphism | Method overloading (compile-time), method overriding (runtime) |
| Abstract Classes | Abstract classes, abstract methods |
| Interfaces | Interface definition, implementation, default methods, multiple inheritance |
| Key Concepts | Dynamic method dispatch, this vs super, access modifiers |
| Assessment | Number guessing game, Rock-Paper-Scissors game using OOPs |
Custom implementations and practical usage of fundamental data structures using Java Collections and from scratch.
| Structure | Topics Covered |
|---|---|
| Arrays | 1D and 2D arrays, reversal, max subarray sum, diagonal sum, spiral matrix |
| ArrayList | Dynamic arrays, sorting, multi-dimensional lists, subList, synchronization |
| Linked List | Singly linked list, iterative & recursive reversal, middle element, LeetCode top questions |
| Stack | Stack using ArrayList, LinkedList, Collections; applications (parenthesis checker, encoder) |
| Queue | Queue using Array, LinkedList, Collections; circular queue, dynamic queue |
| String | String comparison, manipulation, StringBuilder operations, LeetCode string problems |
| Structure | Topics Covered |
|---|---|
| HashMap | Hashing, load factor, rehashing, iteration, operations (Group Anagrams, Subarray Sum) |
| HashSet | Set basics, iteration, duplicate removal |
| Heap (PriorityQueue) | Min/Max heap, custom heap implementation, heap sort |
| Trees | Tree building, DFS/BFS traversals, BST, AVL trees, segment tree, diameter, height, node count |
| Graphs | Adjacency list & matrix, BFS/DFS, Dijkstra, Bellman-Ford, Kosaraju, Prim, Tarjan, topological sort |
Implementation and analysis of major sorting algorithms.
| Algorithm | Complexity | Description |
|---|---|---|
| Bubble Sort | O(n²) | Repeatedly swaps adjacent elements |
| Selection Sort | O(n²) | Selects minimum element and places it |
| Insertion Sort | O(n²) | Builds sorted array one element at a time |
| Merge Sort | O(n log n) | Divide and conquer, stable sort |
| Quick Sort | O(n log n) avg | Partition-based recursive sort |
| Heap Sort | O(n log n) | Uses heap/priority queue |
| Counting Sort | O(n+k) | Non-comparison sort for integers |
| Bucket Sort | O(n+k) | Distributes elements into buckets |
Searching techniques with varying time complexities.
| Algorithm | Complexity | Description |
|---|---|---|
| Linear Search | O(n) | Scans each element sequentially |
| Binary Search | O(log n) | Divide and conquer on sorted arrays |
| Order Agnostic Binary Search | O(log n) | Works on ascending or descending sorted arrays |
Recursion fundamentals, recursive sorting, and backtracking problems.
- Base cases, recursion stack visualization, tail recursion
- Recursive Bubble Sort, Selection Sort, Merge Sort, Quick Sort
- Sum of digits, reverse number, product of digits, count zeros
- Patterns using recursion
- Subsets of array (with/without duplicates)
- String subsequences
- String permutations
- Maze problems (2-direction, 3-direction, 4-direction, path restrictions)
- N-Queens problem
- N-Knights problem
- Sudoku solver
Essential algorithmic techniques and patterns used in competitive programming and interviews.
| Concept | Topics Covered |
|---|---|
| BIT Manipulation | Get/Set/Clear/Update bits, fast exponentiation, odd/even optimization |
| Sliding Window | Max sum of subarray of size k |
| Two Pointer Approach | Move zeros, remove duplicates (I & II), find middle of list, palindrome check |
| Kadane's Algorithm | Maximum subarray sum (1D) |
| Prefix Sum | Placeholder for upcoming content |
| Divide and Conquer | Merge sort, quick sort, rotated binary search |
| Important Algorithms | Variable swapping, frequency counter using HashMap, ASCII code lookup |
Coming Soon
This section is under development and will cover DP patterns, tabulation, memoization, and common DP problems.
Detailed theory and reference material for complexity analysis.
- Best, worst, and average case analysis
- Complexity classes: O(1), O(log n), O(n), O(n²), O(2ⁿ), O(n!)
- Time complexity of arrays, linked lists, stacks, queues, hash tables, BSTs, AVL trees
- Reference PDFs:
TimeComplexityAnalysis.pdf,Space Complexity Analysis.pdf
Practical usage of Java's Collections Framework for data structures.
| Component | Methods & Usage |
|---|---|
| List | Collections.sort(), reverse(), shuffle(), swap(), fill(), copy(), frequency(), addAll(), nCopies(), synchronizedList() |
| Stack | Stack using java.util.Stack |
| Queue | Queue using LinkedList / PriorityQueue |
| LinkedList | LinkedList operations, reversal using Collections |
| Set / Map | HashMap and HashSet operations with Collections |
Reference notes for Java wrapper and utility classes.
| Class | Methods Covered |
|---|---|
| Arrays | sort(), equals(), toString(), binarySearch(), asList(), fill() |
| Integer | parseInt(), valueOf(), toString(), compareTo(), bitCount(), reverse() |
| Character | isLetter(), isDigit(), toUpperCase(), toLowerCase(), charValue() |
A visual DSA learning roadmap is available in the Roadmap/ directory (roadmap.pdf) to guide your study progression.
For questions or support, please contact:
- Email: atharvkote3@gmail.com
- GitHub: Atharvkote
