# 4. Task and order of execution / Завдання та порядок виконання > **Source of tasks.** The requirements below are taken **exactly** from the > assignment *"Lab #2: Cartesian Products and Relations"*. Implement the > functions with the specified behaviour; the input/output examples are > authoritative. ## Objective Understand and implement the **Cartesian product** of sets and related operations. ## Order of execution Implement the tasks tier by tier, and test each function against its example before proceeding to the next. Your score corresponds to the **highest tier** that is fully and correctly implemented. ## Tasks ### Tier 1 — Basic Cartesian product (Score: 60–74) | Function | Behaviour | Example input | Example output | |---|---|---|---| | `cartesianProduct(setA, setB)` | Generate the Cartesian product of two sets. | `([1,2], ['a','b'])` | `[(1,'a'), (1,'b'), (2,'a'), (2,'b')]` | ### Tier 2 — Relation testing and advanced operations (Score: 75–89) | Function | Behaviour | Example input | Example output | |---|---|---|---| | `isRelationValid(relation, setA, setB)` | Validate whether a given relation (list of ordered pairs) is valid for the Cartesian product of two sets. | `([(1,'a'), (2,'b')], [1,2], ['a','b'])` | `True` | | `findRelations(setA, relationFunc)` | Find all the relations for a given set based on a relation function. | `([1,2,3,4,6], isDivisible)` | `[(2,1), (3,1), (4,1), (4,2), (6,1), (6,2), (6,3)]` | *Example relation function `isDivisible` — "all numbers divisible by another number in the set".* ### Tier 3 — Advanced Cartesian product with filters (Score: 90–100) | Function | Behaviour | Example input | Example output | |---|---|---|---| | `filteredCartesianProduct(setA, setB, filterFunc)` | Generate the Cartesian product, but include only pairs that satisfy the filter function. | `([1,2,3], [3,4,5], filterFunc)` | `[(1,3), (1,4), (1,5), (2,3), (2,4), (2,5), (3,4), (3,5)]` | *Example filter function — "only pairs where a number from `setA` is less than a number from `setB`".*