Skip to content

dhairyya/CMUDataStructureAssignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lifeguard Coverage Optimizer

What is this project?

Imagine you are managing a swimming pool. You have a team of lifeguards, and each one works during a specific "shift" (a start time and an end time). Your goal is to make sure the pool is covered by at least one lifeguard for as much of the day as possible.

However, you are told that you must let one lifeguard go. You need to pick the lifeguard whose removal will have the smallest impact on the total time the pool is covered.

This project is a computer program that solves this problem. It looks at all the lifeguard shifts, tests what would happen if each one was removed, and calculates the maximum possible coverage time you can achieve with the remaining lifeguards.

How it Works (First Principles)

  1. The Problem: We have several overlapping time intervals. We want to remove one interval so that the total length of the remaining intervals (where they don't overlap or the union of them) is as large as possible.
  2. The Steps:
    • Step 1: Sort the Shifts. We list all the times when lifeguards start and end their shifts in order from the beginning of the day to the end.
    • Step 2: Map the Time. Since the actual times could be very large (like billions of seconds), we use a special "map" to simplify them into smaller numbers we can easily work with.
    • Step 3: Test Each Removal. The program loops through every lifeguard. For each one, it calculates how much time the pool would be covered if that specific person was fired.
    • Step 4: Find the Best Result. After checking every possibility, the program tells us the highest possible coverage time we can get.

Why this is useful

This is a classic problem in computer science about "interval coverage." It teaches how to efficiently manage data that overlaps in time and how to optimize decisions when you have limited resources.

About

CMU data Structure Assignment July 2019

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages