Question: COMP 2 0 1 3 Data Structures and Algorithms Programming Assignment 2 Deadline: 1 0 : 0 0 am , 2 9 ( {
COMP Data Structures and Algorithms
Programming Assignment
Deadline: :amtext th Nov,
Instructions
Submit the softcopy of your program to Learn@PolyU
You can only submit one program file either C or Java or Python and the filename must follow the format below.
Section : Problem
You are given a set of conference rooms and a set of activities. Each conference room has a specific space size, measured as an integer in square feet. Similarly, each activity has a minimum required space, also an integer, necessary for it to be held. An activity can be accommodated in a conference room if and only if the room's space size is greater than or equal to the activity's minimum required space.
The constraints are as follows:
Each conference room can host at most one activity.
Each activity must be held in exactly one conference room.
Conference rooms cannot be divided to host multiple activities, and activities cannot be split across multiple rooms.
The objective is to determine the maximum number of activities that can be arranged in the available conference rooms. The problem does not assume any specific relationship between n and m ; either can be larger than the other.
Write a greedy algorithm to solve the problem with the following input and output. Input:
An integer n representing the number of activities.
An integer m representing the number of conference rooms.
An array A of n integers where each integer represents the minimum required space for each activity.
An array C of m integers where each integer represents the space size of each conference room.
Output:
An integer representing the maximum number of activities that can be accommodated in the conference rooms.
Note: You cannot use existing libraries to directly call offtheshelf heap, queue, sorting, stack algorithms, but you can implement them when needed. Except these algorithms, you can use existing libraries when necessary, in your program.
Examples for the problem Section : Input and Output Format
You should strictly follow the format requirements, and do not hardcode file names in your program or have unnecessary text output. In Programming Assignment TAs helped you modify your code to meet the format requirements. But in this assignment, we will not do so and strictly follow the requirements to grade.
The format of test files is illustrated by example "filetxt below.
Your program should output on the screen a single value.
Here is a sample of the input file and the output of your program.
The format of the input file is as follows:
the text st line shows the number of activities n
the text nd line shows the number of conference rooms m
the next n lines show the minimum required spaces of the n activities,
then, the next m lines show the space sizes of the m conference rooms.
n is integer in the range
m is integer in the range
Space size and minimum required space size are integers in range
We will run your program by a command line like:
where the argument "inputtxt is an example of the input filename.
Your program should only output the result integer number.
Please follow the output format above and DO NOT print any extra information.
Your program should pass all possible inputs, including those maybe invalid
You need to create test cases to debug and test your program's correctness.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
