Suppose you have a set of classes to schedule among a large number of lecture halls, where any class can class place in any lecture hall. Each class cj has a start time sj and finish time fj. We wish to schedule all classes using as few lecture halls as possible. Verbally describe an efficient greedy algorithm to determine which class should use which lecture hall at any given time. What is the running time of your algorithm?
This problem is an example of the
activity-selection problem. We assume that the
activities are mutually compatible. In this, we have to select the
maximum subset of all the mutually compatible activities. The best
greedy approach is to select the activities using the finishing
time. Iterate through all the activities, if the starting time of
the
activity is more than the starting time of
activity, then include that activity in the schedule set.
So, the algorithm would be like
SCHEDULE_HALLS(s , f)
BEGIN
// include the first activity in the schedule set
A = {c1}
i = 1
for j = 2 to s.length()
BEGIN
If s[j] >= f[i]
BEGIN
// add the j th activity in the schedule set
A = A U { cj }
i = j
END
END
Return A
END
The algorithm would run only n times where n is the number of classes to schedule.
SO,
Time Complexity = O(n)
Suppose you have a set of classes to schedule among a large number of lecture halls,...
George Mason University has hired you to write an algorithm to schedule their final exams. Each semester, Mason offers n different classes. There are r different rooms on campus and t different time slots in which exams can be offered. You are given two arrays E[1,... , n] and S[1,...,r], where Eli is the number of students enrolled in the i-th class, and Slj] is the number of seats in the j-th room. At most one final exam can be...
Suppose you’ve taken a part-time job where you drive sales executives of a company to client sites. Each trip starts and ends at the company’s headquarters. A sales executive specifies a trip by its start and finish times. A trip is specified by a start time s and a finish time f. The start time is when you leave the headquarters for a client site; the finish time is when you get back to the headquarters from the client’s site....
Problem 3 Suppose that you have a set of n large, orderable, objects, each of size q, so that it requires time e(a) to time to compute a hash function h(a) for any object and requires time e(g) to compare any two objects. Describe a compound data structure, built out of a heap and a hash table, that supports the following operations with the specified run times.. elt (x) Is x an element of the set? Expected run time O(g)....
You are managing a large scale construction project with hundreds of subprojects, some which have to be completed before others can begin whereas some subprojects can be carried out simultaneously. The project and its subprojects, and the presence of dependencies between subprojects (which subprojects have to be done before which), can be modeled as a connected unweighted directed graph with nodes representing subprojects and directed edges representing dependencies. 42. Which of the following algorithms will allow you to determine if...
12. Suppose you haven video streams that need to be sent, one after another, over a communication link. Streami consists of a total of b, bits that need to be sent, at a constant rate, over a period of t seconds. You cannot send two streams at the same time, so you need to determine a schedule for the streams: an order in which to send them. Whichever order you choose, there cannot be any delays between the end of...
its about in C++
You will implement a simple calendar application The implementation should include a class named Calendar, an abstract class named Event and two concrete classes named Task and Appointment which inherit from the Event class The Event Class This will be an abstract class. It will have four private integer members called year, month, day and hour which designate the time of the event It should also have an integer member called id which should be a...
Before you start doing this code
Read carefully there is a format that you have to follow
HERE IS THE FORMAT
YOU MUST USE FOR HW #2 - NOTE THE IF ELSE IF...not IF IF
IF
HW #2 Format
:
Instructions: This program will generate some information for a user about interplanetary travel (pretend we can travel easily to other planets for this problem). This program will perform calculations concerning weight on various planets as well as travel time between...
Question I This question carries 20% of the marks for this assignment. You are asked to develop a set of bash shell script: Write a script that asks for the user's salary per month. If it is less or equals to 800, print a message saying that you need to get another job to increase your income, what you earn is the Minim living cost. If the user's salary is higher than 800 and below 2000, print a message telling...
Python program This assignment requires you to write a single large program. I have broken it into two parts below as a suggestion for how to approach writing the code. Please turn in one program file. Sentiment Analysis is a Big Data problem which seeks to determine the general attitude of a writer given some text they have written. For instance, we would like to have a program that could look at the text "The film was a breath of...
(Use the case of “Global Treps”) You have been selected as the project manager for the Global Treps project. You helped to run a local shark tank like event at your college last year as part of a class project, so you have a general idea of what is involved. The schedule goal is six months, and the budget is $120,000. Your favorite professor, Dr. K., and a few of her associates have agreed to fund the project. Your strengths...