liveBook · Manning

Cartesian product

The Cartesian product of sets is the set of ordered tuples formed by choosing one element from each set.

How 3 Manning books explain it

Fabulous Adventures in Data Structures and Algorithms

A Cartesian product algorithm enumerates tuples by choosing one element from each of multiple input sequences.

How it is used
Generates every pairing or longer tuple of independent choices, including combinations useful for test cases.
How deep it goes
Builds two-input and arbitrary-input implementations, including projection, result types, and zero-input behavior; does not provide performance measurements.
Examples
Uses character-class and weapon pairings, three strings of letters, and products of decimal digits.
What you can do after
Build it from scratch as C# extension methods for fixed or runtime-known input counts, optionally projecting each result.

Read how Fabulous Adventures in Data Structures and Algorithms explains Cartesian product →

Java Persistence with Spring Data and Hibernate epub

A relational operation that forms every possible pairing of rows from two relations, potentially producing redundant combinations when multiple collections are joined.

How it is used
Diagnoses oversized SQL results caused by eager JOIN fetching of multiple collections.
How deep it goes
Explains row multiplication, redundant data, and operational costs, but does not detail database execution optimization.
Examples
Uses an Item with bids and images, showing nine rows for 3 × 3 collections and 250 rows for 50 × 5 collections.
What you can do after
Diagnose redundant joined results and select a procedure-specific fetching strategy instead of eagerly joining multiple collections.

Read how Java Persistence with Spring Data and Hibernate epub explains Cartesian product →

Data-Oriented Programming in Java

A Cartesian product is the set of all ordered tuples formed by choosing one element from each of several sets.

How it is used
Frames records as state spaces and guides domain modeling and exhaustive invariant reasoning.
How deep it goes
Defines products, enumerates record states, and applies exhaustive assertions, stopping short of broader formal algebra.
Examples
Uses Beverage combinations and generated RawData states to illustrate enumeration and invariant checking.
What you can do after
Evaluate/understand record state spaces, enumerate possible values, and test invariants across combinations.

Read how Data-Oriented Programming in Java explains Cartesian product →

Also covered in

What to know first

Related concepts

Questions about Cartesian product

What is Cartesian product?

The Cartesian product of sets is the set of ordered tuples formed by choosing one element from each set.

Which Manning books explain Cartesian product?

Fabulous Adventures in Data Structures and Algorithms, Java Persistence with Spring Data and Hibernate epub and Data-Oriented Programming in Java.

What should I know before learning Cartesian product?

Manning books that teach Cartesian product usually introduce set and tuple first.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.