3 min read

    Java for DSA — Syllabus

    JavaDsaSyllabusRoadmap

    Java for DSA — Syllabus

    Note

    Goal: Learn Java only as needed for Data Structures & Algorithms — LeetCode, competitive programming, and technical interviews. No OOP deep dives, no Spring, no Android. Just what you need to write correct, efficient solutions.


    1. Basics 🔗 Notes

    • Primitive types (int, long, double, char, boolean)
    • Variables, constants (final)
    • Type conversion — widening, narrowing, Integer.parseInt(), String.valueOf()
    • Input / Output (Scanner, System.out.println, printf)

    2. Strings 🔗 Notes

    • Creating & accessing (charAt, length, substring)
    • Useful methods (.indexOf(), .contains(), .replace(), .split(), .trim())
    • StringBuilder — why + in loops is O(n²) and how to fix it
    • Common DSA patterns — reverse, palindrome, anagram, character frequency

    3. Control Flow 🔗 Notes

    • if / else if / else, ternary operator
    • switch statement
    • for, enhanced-for, while, do-while
    • break / continue
    • Common DSA loop patterns — reverse loop, nested loop, two-pointer skeleton

    4. Functions 🔗 Notes

    • Defining static methods — parameters, return types
    • Method overloading (Java's answer to default arguments)
    • Recursion — the foundation of trees, graphs & backtracking
    • Math class — abs, min, max, pow, sqrt, floor, ceil

    5. Arrays & Collections 🔗 Notes

    • Fixed arrays — declaration, Arrays.sort(), Arrays.fill(), 2D arrays
    • ArrayList — dynamic array, O(1) get/set, O(n) insert
    • HashMap — O(1) key-value lookups, frequency counter pattern
    • HashSet — O(1) membership, duplicate detection
    • When to use which structure

    6. Stack, Queue & Deque 🔗 Notes

    • ArrayDeque as Stack (LIFO) — push, pop, peek
    • ArrayDeque as Queue (FIFO) — offer, poll, peek
    • Deque — double-ended, sliding window & monotonic queue patterns
    • PriorityQueue — min-heap by default, max-heap with comparator

    7. Sorting & Utilities 🔗 Notes

    • Arrays.sort(), Collections.sort(), custom comparator / lambda
    • Binary search — Arrays.binarySearch(), manual implementation
    • Collections utility — reverse, shuffle, min, max, frequency
    • Fast I/O with BufferedReader + StringTokenizer (competitive programming)
    • Helper methods — GCD, LCM, power (binary exponentiation)

    8. Bit Manipulation & Characters 🔗 Notes

    • Bitwise operators — &, |, ^, ~, <<, >>
    • Common patterns — check/set/clear/toggle a bit, power-of-2 check, Integer.bitCount()
    • Character class — isDigit, isLetter, toUpperCase, '5' - '0' trick

    Caution

    What's intentionally excluded OOP (classes, inheritance, interfaces), generics internals, file I/O, exceptions, threads, streams API beyond simple usage, Spring, JDBC. These aren't needed for DSA problem-solving.


    Next → 1. Basics