You are on page 1of 7

What are Set (Array) Algorithms About?

A Set is a collection of values (objects, numbers) which forms an entity itself

Colors Sizes

Example: Shirt manufacturing ‘blue’ ‘red’ ‘M’ ‘L’

Set Set
Cartesian Product

Colors Sizes

Example: Shirt manufacturing ‘blue’ ‘red’ ‘M’ ‘L’

New Set: All variants that should be manufactured

‘blue’ ‘M’ ‘blue’ ‘L’ ‘red’ ‘M’ ‘red’ ‘L’


Cartesian Product – More Than 2 Sets

Colors Styles Sizes


‘v-
‘blue’ ‘red’ ‘round’ ‘M’ ‘L’
neck’
Permutations (With & Without Repetition)

An ordered combination of values.

Without Repetition With Repetition

Example: Todo list items Example: Safe combination you want to set

[‘Walk dog’, ‘Clean toilet’, ’Order food’] [1, 5, 9]

[‘Walk dog’, ‘Clean toilet’, ’Order food’] [1, 1, 9]


[‘Clean toilet’, ‘Walk dog’, ’Order food’] [1, 1, 1]
[‘Walk dog’, ‘Order food’, ’Clean toilet’] [9, 5, 9]
… …
Recursive Permutations

Main function call A B C D

1. Recursive Step B C D

2. Recursive Step C D

3. Recursive Step D
Recursive Permutations

Main function call A B C D

1. Recursive Step B C D

2. Recursive Step C D

C D

3. Recursive Step Combine with D

D C
Recursive Permutations

Main function call A B C D

Combine with
1. Recursive Step B C D

2. Recursive Step C D

C D

3. Recursive Step Combine with D

D C

You might also like