Giter Club home page Giter Club logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 22, 2024
Hey Jou-Ting,

Thanks for your inquiry. I checked that algorithm in our book but don't see any 
problem of it. Let me explain how our algorithm works as follows:

I will use 'A', 'B', .., as the notations of tutors. Remember that in our 
problem we have limitation that every tutor must stop tutoring for the day at 
most two hours after starting. For your first example,
A 9- 9:30
A 9:30 - 10
A 10 - 10:30
A 10:30 - 11 (A must stop since he/she has tutored for two hours today.)
B 11 - 11:30
C 11 - 11:30

As a result, for the first example, you need three tutors.

For your second example,
A 9 - 9:30
B 9 - 9:30
A 9:30 - 10
B 9:30 - 10
A 10 - 10:30
B 10 - 10:30
A 10:30 - 11 (A must stop since he/she has tutored for two hours today.)
B 10:30 - 11 (B must stop since he/she has tutored for two hours today.)
C 11 - 11:30
D 11 - 11:30
C 12 - 12:30
C 12:30 - 1

As a result, you need four tutors. The strategy I used here is exactly greedy 
method mentioned in the book (i.e., as soon as there is a request that cannot 
be handled by the previously assigned tutors, we choose a new tutor.)

Feel free to ask questions if you have any problem.

Original comment by [email protected] on 16 Sep 2013 at 7:12

from elements-of-programming-interviews.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 22, 2024

Original comment by [email protected] on 16 Sep 2013 at 11:11

  • Changed state: Invalid

from elements-of-programming-interviews.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.