Suppose you have n classes that you want to schedule in rooms. Each class has a fixed time interval at which it is offered, and classes whose times overlap cannot be scheduled in the same room. There are enough rooms to schedule all the classes. Design a O(n log n) time algorithm to find an assignment of classes to rooms that minimizes the total number of rooms used.

Answers

Answer 1

Answer:

Function schedule( list of tuple of start and end times, class available)

   class_list = create list of class from class available

   for items in time_list:

       if items is not same range as time_list[-1]:

           newdict[items] = class_list[0]

           print class time: class venue

       elif items is same range as time_list[-1]:

           used_class = newdict.values

           index = class_list.index(used_class[-1])

           new_dict[items] = class_list[index + 1 ]

           print class time: class venue

Explanation:

The algorithm above describe a program with a time complexity of O(n log n). The function defined accepts two parameters, an array of start and end time tuple and the number of class available for use. The algorithm uses a quick sort to compare the time interval of the items in the list and schedule new classes for classes that overlaps with others.


Related Questions

Database are pranized in
consist of a series of
which consist of a senes of​

Answers

Answer:

fields and records I guess is the answer

Other Questions
Explain the trap. ( percy jackson chapter 15) help please Which text best reflects a personal narrative essay?A. The Labradoodle is one of the gentlest dog breeds. It is a mix of Labrador and poodle.B. Elephants live in groups, which helps them protect one another from predators.C. I cant wait to get home and read a book. Mysteries are my favorite.D. Peanut allergies among children are on the rise. Last year, they increased by as much as 20 percent. I need assistanceAnyone tryna do this for me ? its too hardUsing The Social Dilemma as your primary text, explain how technology can be used to influence your rings of culture (at least 300 words). You must choose at least 3 rings to closely examine. You should reference the documentary as well as examples from your own life. Rings of Culture: age, gender, religious, class, national, orientation, ethnic Joe and Veronica are playing a guessing game about the different properties of matter. One of the students want to give a clue about a gas. Which statement describes a gas? (SC.5.P.8.1) A It will fill its container. B It takes the shape of its container. C It has its own shape and structure. D It can be kept in a persons hand. what is one of the negative consequences of burning wast Find all solutions to the equation $x^2 - 8x = -16$. Determine whether the lines are parallel, perpendicular, or neither. Justify your answer. y = 2x - 8Y = 1/2x + 6if you answer correctly I will give you brainliest Need help pls if you can r = 4 in., = 11 rad; find s Plz help me with this?!?! I will mark you brainliest!!! In which direction will the electrons be pulled in the bond between hydrogen and chlorine?toward the chlorine atomtoward both atoms equallysometimes toward chlorine and sometimes toward hydrogentoward the hydrogen atom Complter avec la prposition correcte:1- Il vient .Londres.2- Vous travaillez .Bangkok Thalande.3- tes vous ..Pakistan ou Inde?4- Il y a de bons monuments Rome ..Italie.5- Elle est .Portugal.6- Nous voyageons Mumbai .avion mais nous allons lcole..vlo. Which of there is a basic characteristic of a civilization?A) Strong military B) Written language C) Capitalist economyD) Democratic government Which of the following correctly shows the next two terms after 40 in the pattern?10, 20, 40 At a dinner, one meal cost $22 and a sales tax of $1.87 was added to the bill. i've hurt my arm.It's very _______. Uniflap....... Which research question would best address the purpose of this essay? When was the American Revolution? Why did the American Revolution occur? Who participated in the American Revolution? What were the effects of the American Revolution How are social traditions and social problems associated Database are pranized inconsist of a series ofwhich consist of a senes of pls solve the question attached