DSA using Java

From Big-O to DP — see each structure and algorithm come alive.

Introduction to DSA and Java Setup

Watch one algorithm scan an array for an answer, then follow your first .java file through javac into the JVM.

Algorithm Analysis and Complexity

Watch step counts explode across a grid as n grows — and see why halving beats counting every single time.

Arrays and ArrayList

Fill an ArrayList until it bursts and watch it grow and copy — then compare fixed arrays against resizable lists.

Strings and StringBuilder

Append a StringBuilder to watch its buffer grow, then see why Strings refuse to change and copies pile up.

Searching Algorithms

Chase 49 through a sorted array as low, mid and high halve the window — then watch linear search crawl the long way.

Sorting Algorithms – Basics

Watch 9 bubble to the end, the minimum snap into place and keys slide home — three O(n²) sorts, bar by bar.

Efficient Sorting Algorithms

Split [9,4,7,1,8,5] down to atoms, merge it back sorted — and watch a pivot re-partition the array around itself.

Recursion and Backtracking Basics

Watch the call stack pile up and unwind digitSum frames — then follow fib(4) through every branch of its recursion tree.

Singly Linked Lists

Follow head and curr along a node chain — insert at the front in two moves and watch a middle node get bypassed.

Doubly and Circular Linked Lists

Walk a doubly-linked list forwards and backwards, then ride a circular list whose last node loops back to the first.

Stacks

Push, pop and peek through an ArrayDeque — then watch brackets balance and the next-greater scan unfold.

Queues and Deques

Watch a circular queue wrap its buffer, a queue pump out binary numbers, and a deque work from both ends.

Hashing and HashMap

Follow a key through hashCode into its bucket, watch chains grow on collisions, and see a rehash in action.

Trees and Binary Trees

Walk a binary tree level by level with a queue, then recurse through it inorder — with Java code that prints it.

Binary Search Trees and Heaps

Watch 47 and 12 walk the compare path into a BST, then see 9 sift to the root of a min-heap — PriorityQueue included.

Graph Fundamentals and Traversals

Six stops, six walkways: BFS sweeps the graph in waves from A while DFS dives corridor-deep — adjacency lists included.

Graph Algorithms

Poll the cheapest offer, relax, repeat: Dijkstra locks exact prices from A — then Prim rewires the very same map for a total of 18.

Greedy Algorithms

Watch a meeting room fill by earliest finish, then count out 63 in coins — one irrevocable greedy choice at a time.

Dynamic Programming

Fill a 4×6 knapsack table row by row and tabulate Fibonacci — every subproblem solved once, then reused forever.

Advanced Problem Solving and Revision

Two pointers converge on a hidden pair sum, then a sliding window sweeps the best stretch in a single O(n) pass.