# Designing an Algorithm to Match Skiers to Skis

## How can we design an algorithm to match skiers to skis efficiently?

What is a brute-force algorithm and how long would it take to execute it on a computer with specific parameters?

What is a sub-optimal greedy algorithm and can it sometimes produce a worse solution than optimal?

What factors should be considered in designing a fast algorithm for this matching problem?

## Algorithm Explanation:

To design an algorithm that matches skiers to skis, we can consider two approaches: a brute-force algorithm and a sub-optimal greedy algorithm.

The brute-force algorithm involves trying all possible combinations of skiers and skis to find the optimal solution.

The sub-optimal greedy algorithm assigns skiers the pair of skis that most closely matches their height, but may not always be optimal.

To design a fast algorithm, we consider the concept of inversions and aim to create a solution without any inversions.

## Algorithm Details:

A brute-force algorithm for matching skiers to skis would take approximately 0.0000004 seconds to execute on a computer that performs 1 billion operations per second, given 20 skiers and 20 pairs of skis.

A sub-optimal greedy algorithm can produce a worse solution than optimal, as shown in the example provided.

To design a fast algorithm, we can consider the concept of inversions and perform a detailed case analysis to ensure the solution does not have any inversions.

The running time of the fast algorithm is O(n log n), where n is the number of skiers and pairs of skis.