Skip to content

Resource · Guide or article

Cartesian Product

Set-theory definition of the Cartesian product, the idea behind generating every pairing of two lists.

Reviewed

Open the original: Cartesian Product (opens the original site in a new tab)

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

In set theory a Cartesian product is a mathematical operation that returns a set (or product set or simply product) from multiple sets. That is, for sets A and B, the Cartesian product A × B is the set of all ordered pairs (a, b) where a ∈ A and b ∈ B. Cartesian product AxB of two sets A={x,y,z} and B={1,2,3}

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Reference

What it covers

  • Definition of A x B as all ordered pairs (a, b).
  • Diagram of the product of {x, y, z} and {1, 2, 3}.

How to use it

PrepKit study advice, not a claim made by the source.

Write a function returning the product of two arrays, then extend it to three, and state the output size.

Scope and limitations

Extremely short: one definition, one image, a Wikipedia link. No algorithm, complexity, or exercises.

Access and format

English README on GitHub in trekhleb/javascript-algorithms (MIT), free.

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88

Evidence behind this overview
  • src/algorithms/sets/cartesian-product/README.md

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email