Cartesian product
A Cartesian product is the set of all ordered tuples formed by selecting one element from each of multiple sets or sequences.
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 →
Related concepts
- sequenceuses · A sequence is an ordered collection of elements whose positions determine their order of traversal or processing.
- flatmapproduced by · FlatMap is an operation that applies a function producing nested collections or computational contexts to each element and combines the resulting contexts into one flattened result.
- comprehensionused by · A comprehension is a language construct that creates a collection by iterating over one or more sources, optionally filtering elements and transforming them.
- product typeused by · A product type is a composite type whose values combine one value from each of several component types, such as a tuple or record.
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.

