Skip to Content
Puzzles for Programmers and Pros
book

Puzzles for Programmers and Pros

by Dennis E. Shasha
May 2007
Intermediate to advanced
240 pages
5h 20m
English
Wrox
Content preview from Puzzles for Programmers and Pros

6.3. Finding a Schedule That Works

You have a set of tasks for a robot. There is no precedence constraint requiring any task to be completed before another. Each requires a certain amount of time and has a certain deadline. Your predecessor assures you there is enough time for the robot to do everything, but he doesn't remember how. (His lack of organization explains why he is your predecessor and not your boss.) You have to arrange things so your robot finishes each task by its deadline.

  1. In which order do you schedule the tasks starting from current day 0?

    Task T1 takes 4 days with deadline on day 45

    Task T2 takes 4 days with deadline on day 48

    Task T3 takes 5 days with deadline on day 25

    Task T4 takes 2 days with deadline on day 49

    Task T5 takes 5 days with deadline on day 36

    Task T6 takes 2 days with deadline on day 31

    Task T7 takes 7 days with deadline on day 9

    Task T8 takes 5 days with deadline on day 39

    Task T9 takes 4 days with deadline on day 13

    Task T10 takes 6 days with deadline on day 17

    Task T11 takes 4 days with deadline on day 29

    Task T12 takes 1 day with deadline on day 19

NOTE

The best algorithm for this problem has the very suggestive name: "Earliest Deadline First."

6.3.1. Solution to Finding a Schedule That Works

  1. In which order do you schedule the tasks starting from current day 0?

This is a situation where you don't want the computer to explore all cases, trying all 12! Orderings might take a while and would be completely impractical if there were even 20 tasks. As alluded ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mobile Game Development With Corona SDK

Mobile Game Development With Corona SDK

J.A. White
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 9780470121689Purchase book