notesonly.in

One notebook for every subject — open it anywhere.

Log in

Recursion and backtracking basics

Data Structures · Engineering

Study notes

Solve a maze by backtracking: at each cell, try moving right; recurse. If the path hits a dead end, undo the move (backtrack) and try down. Mark visited cells to avoid loops. The recursion explores all paths but abandons failures early, which is why backtracking beats brute force.

← Back to topics for Engineering