Greedy Algorithms8 sections · 316 units
Open in Course

Problem - Tandem Bicycle

Maximize or minimize speed

nn red riders with speeds r1,..,rnr_1, .., r_n and nn blue riders with speeds b1,..,bnb_1, .., b_n. Each tandem bike has one red and one blue rider. Bike speed = max of the two riders' speeds.

Task 11: Maximize total speed of all bikes. Task 22: Minimize total speed of all bikes.

Before reading on, think: how would you pair riders for each task? The core idea: only one rider's speed per bike counts, so you want to avoid wasting fast riders. How you pair them determines whether you use or waste fast speeds.