Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The coach of Stony Brook Universitys Basketball team wants to organize practice sessions for the team. He has three time slots, namely, Morning, Afternoon and

The coach of Stony Brook Universitys Basketball team wants to organize practice sessions for the team. He has three time slots, namely, Morning, Afternoon and Evening. He is given the time table of all the students in the form of a 2D list of integers, i.e., a list of lists of integers. You need to help the coach to find an appropriate time where the maximum students are available for practice.

Write the function find practice time(), which takes a single argument: student time tables: a 2D list of integers representing students time table where 1 means that the student is free in that time slot and 0 meaning the student has a class.

Each individual sub-list inside the overall list always have three values: some combination of 0s and 1s. For example, the sub-list [1, 0, 1] means the student is available for practice in the morning and evening, but not in the afternoon.

The following rules apply:

The coach knows that it is impossible for all students to be free at the same time. He will hold practice when maximum number of students are available.

The coach wants to hold practice as early in the day as possible. So, for example, if there is a tie between afternoon and evening, the practice will take place in the afternoon.

It is guaranteed that at least 1 student is free in 1 time slot, i.e. it is not possible to have a list of all zeroes.

The function returns a string Morning, Afternoon or Evening depending on the above rules.

Clearly we need to iterate over all the time slots of all the students. We also could iterate over each of the sub-lists of 3 elements each if we like. See the pseudocode below:

for each sub-list inside student_time_tables: if a student is free in the morning, then add 1 to the count of students available in the morning if a student is free in the afternoon, then add 1 to the count of students available in the afternoon if a student is free in the evening, then add 1 to the count of students available in the evening

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 23rd International Conference Dexa 2012 Vienna Austria September 2012 Proceedings Part 1 Lncs 7446

Authors: Stephen W. Liddle ,Klaus-Dieter Schewe ,A Min Tjoa ,Xiaofang Zhou

2012th Edition

3642325998, 978-3642325991

More Books

Students also viewed these Databases questions

Question

5. Why does proof of transfer evidence matter?

Answered: 1 week ago

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago