XeLaTeX Compiled Java Edition

The Ultimate
DSA Handbook

A structured, printable, and professional PDF knowledge base for Data Structures & Algorithms. Tailored for a shallow-to-medium depth learning journey. Complete with clean code, Dry Run tables, hand-drawn TikZ visual diagrams, and complexity analysis.

11 Chapters XeLaTeX 153 Compiled Pages Interview-Oriented Verified Code A4 - Ready
Personal Study Handbook

DSA

Handbook
From Fundamentals to 2-D Arrays
int[] arr = {10, 25, 7, 42, 18, 33, 5};
10
25
7
42
18
33
5
Based on: TakeUForward, Love Babbar, Apna College
Biraj
Full-Stack Developer
Version 2.2.0
153 Pages

Release Tracker

Core Architecture

Engineered for High-Fidelity Learning

A look at the structural decisions, formatting design parameters, and compilation criteria that define the handbook's visual clarity.

Strict Topic Flow

Every core concept progresses logically: Conceptual explanation → Verified Java Code → dry run step trace table → vector TikZ memory map → time/space limits → interview pitfalls.

XeLaTeX Compiled

Leverages modern compiler engines for superior OpenType typography scaling (Pagella/Cursor) and textbook-grade mathematical equation formatting. Automatically builds synchronized TOC indexes.

Custom Design Rules

Visual tcolorbox environments (definitionbox, dryrun, warningbox, tipbox, complexity, interviewcorner) are color-coded with exact border parameters, helping your brain segment technical concepts.

Vector Graphics & Code

Features clean GitHub Light syntax highlighted listings (no dark background print eyestrain) and hand-crafted vector diagrams with strictly light tints to guarantee overlays remain highly legible.

Direct Renderer

Handbook Pages Preview

Browse through high-fidelity replicas of compiled pages. Recreated exactly from the XeLaTeX layout guidelines, highlighting color-coded tcolorbox definitions, tables, code listings, and TikZ visualizations.

Desktop View Recommended

To preview the pages, desktop or tablet view is recommended. Alternatively, you can download the full PDF below to view it properly.

PAGE 1 OF 4Book Cover
Personal Study Handbook  •  Java Edition

DSA

Handbook

From Fundamentals to 2-D Arrays

Beginner-Friendly Interview-Oriented Deeply Explained
int[] arr = {10, 25, 7, 42, 18, 33, 5};
10
25
7
42
18
33
5
[0]
[1]
[2]
[3]
[4]
[5]
[6]
Based on TakeUForward (Striver), Love Babbar & APNA CLG DSA Series.
• w3schools.com  • geeksforgeeks.org  • codehelp.in  • apnacollege.in

Biraj

ECE Student · Full-Stack Developer
Version 2.2.0
May 2026153 Pages
DSA Handbook — Java Edition How to Use This Handbook
How to Use This Handbook

This handbook is your structured companion for learning Data Structures & Algorithms in Java — from the very first concept to mastering 2-D Arrays. It is written to be shallow-to-medium depth: clear enough to understand quickly, deep enough to perform in interviews.

Structure of Each Topic
  1. Concept — What it is, explained in plain English.
  2. Java Code — Clean implementation (no step-jumps; every line explained).
  3. Dry Run — Step-by-step table trace on a small example.
  4. Visual Diagram — Color-coded TikZ diagrams mapping out memory layouts, pointer swaps, and math geometries.
  5. Complexity — Time and Space Big-O analysis.
  6. Interview Corner — What interviewers ask, edge cases, and pitfalls.
Visual Code Colors Guide
To maintain high-quality aesthetics, the handbook utilizes specific color-coded layouts:
  • Blue Box (Definition) — Core definition / concept guidelines.
  • Orange Box (Dry Run / Warning) — Step-by-step trace tables and compilation warnings.
  • Indigo Box (Complexity) — Time and Space Big-O limits.
  • Red Box (Interview Corner) — Interview questions and common bugs.
  • Green Box (Tip) — Shortcuts, math tips, and editor hacks.
Chapter 2 • Java Language Basics Variables and Data Types
Chapter 2
Java Language Basics
Java's Eight Primitive Types

A variable is a named slot in memory. In Java, primitives are stored directly in stack memory, whereas objects/classes (like Strings) are references pointing to heap memory.

Type Size Value Range (approx) Default Example
byte 1 byte -128 to 127 0 byte b = 100;
int 4 bytes ≈ -2.1B to +2.1B 0 int n = 42;
long 8 bytes ≈ ±9.2 × 1018 0L long l = 99L;
double 8 bytes ≈ ±1.7 × 10308 0.0 double d = 3.14;
boolean 1 bit true / false false boolean ok = true;
nextInt() + nextLine() Buffer Trap
After calling sc.nextInt(), the newline character '\n' remains in the buffer. An immediate call to sc.nextLine() will consume that leftover newline and return an empty string. Fix: Insert an extra sc.nextLine() to clear the buffer.
1import java.util.Scanner;
2public class InputDemo {
3 public static void main(String[] args) {
4 Scanner sc = new Scanner(System.in);
5 System.out.print("Enter age: ");
6 int age = sc.nextInt(); // leaves newline in buffer
7 sc.nextLine(); // consume buffer newline
8 System.out.print("Enter name: ");
9 String name = sc.nextLine();
10 sc.close();
11 }
12}
Chapter 5 • 1-D Arrays Optimal Array Scanning
Chapter 5
1-D Arrays
Optimal Two-Pointer Zero Movement

Problem: Given an array, move all 0s to the end of it while maintaining the relative order of non-zero elements. Must be done in-place.

Visualizing Swap State
j ↓
i ↓
0
1
0
3
12
[0]
[1]
[2]
[3]
[4]
SWAP(i, j)
j pointer: first zero index  |  i pointer: current scanning non-zero item
Interview Corner: Two-Pointer Optimal Strategy
A naive solution uses an auxiliary array of size n, copying non-zero items first. Space: O(n).
The optimal approach runs in O(n) Time and O(1) Auxiliary Space:
  1. Find the first 0 element at index j.
  2. Scan with pointer i = j + 1. Whenever arr[i] != 0, swap arr[i] with arr[j] and increment j.
1public void moveZeroes(int[] nums) {
2 int j = -1;
3 // find first zero
4 for (int i = 0; i < nums.length; i++) {
5 if (nums[i] == 0) { j = i; break; }
6 }
7 if (j == -1) return; // no zeroes
8 // swap non-zero elements into zero slots
9 for (int i = j + 1; i < nums.length; i++) {
10 if (nums[i] != 0) {
11 int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp;
12 j++;
13 }
14 }
15}
Syllabus Overview

Chapters 1 to 11

A sequential walkthrough mapping essential concepts. Tap any card below to expand full curriculum subsections and see standard listings covered.

Interactive Labs

Developer Playground

Interactive tools designed to demonstrate complexity growth rates, array sorting behaviors, and compiling procedures in real-time.

Sorting Visualizer

Selection Sort
Status: Ready. Press "Run" or "Step" to begin.

Big-O Curve Explorer

O(1) Constant
O(log n) Logarithmic
O(n) Linear
O(n log n)
O(n²) Quadratic
Hover over a curve or legend tag above to analyze its time complexity scaling, search bounds, and sample array operations.

Compiler Terminal Simulator

The DSA Handbook is compiled using XeLaTeX to enable OpenType font structures and premium math notations. Compiling runs the XeLaTeX parser twice to resolve TOC index structures, dynamic math bookmarks, and page counting before cleaning up auxiliary files automatically.

Trigger the build automation script simulator on the right to see the compilation workflow execute line-by-line in real-time.

PowerShell Core
PS C:\Users\biraj\Desktop\DSA_Handbook> _
Dev Dashboard v2.2.0
DOM Nodes: 0
Load Time: 0 ms
XeLaTeX RAM: ~168 MB
Source: API Checked
Press ? to view keyboard shortcuts
Shortcut Commands
Toggle Dashboard HUD D
Close any Modal/Drawer Esc
Next Preview Page
Prev Preview Page
Play/Pause Sort Visualizer Space
Step Sort Visualizer S
Randomize Visualizer Array R
Show/Hide Shortcuts Guide ?