What is the Virtual DOM and how does React use it?
The Virtual DOM is an in-memory representation of the real DOM — a tree of plain JavaScript objects describing what the UI should look like. React uses it to make UI updates fast: instead of touching the slow real DOM on every change, React builds a new virtual tree, diffs it against the previous one, and applies the smallest set of real DOM changes.
Reconciliation — the process of comparing two virtual trees and computing the minimum diff.
Diffing algorithm — O(n) heuristic that compares same-type elements and uses keys to match list items efficiently.
Batched updates — multiple state changes within an event are coalesced into a single render and DOM commit.
Why it's fast — in-memory object compares are cheap; the actual DOM mutations are kept small.
Fiber architecture (16+) — lets React pause, abort, and prioritize rendering work for smoother UIs.
Not magic — you can still force unnecessary renders;
React.memo,useMemo, and stable keys help when needed.
Avoid saying 'the Virtual DOM is faster than the real DOM' — that is an oversimplification. Explain that it enables efficient batched updates and a declarative API.
Mention the O(n) diffing heuristics and the role of keys.