Question
This program uses functions with pass-by-reference parameters. The Problem Statement You are very meticulous with your scheduling. Whenever you have a potential activity, you prefer
This program uses functions with pass-by-reference parameters.
The Problem Statement
You are very meticulous with your scheduling. Whenever you have a potential activity, you prefer to schedule it on the day with the fewest activities. You have already made a list of the number of activities for each day in the rest of the semester.
Program Setup
A scaffold of the solution has been created for you:
schedule-scaffold.c
Do not modify the code that is already present. Instead, fill in the function at the end of the program.
This a function will take in a list of the number of activities for each day. The function should also take in a starting day and an ending day to create a range. The function should then return the day number with the fewest activities in that range.
For example, if the input array looked like this:
index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
# activities | 8 | 3 | 6 | 7 | 9 | 5 | 3 | 8 | 6 | 7 | 4 | 5 |
and the start day of the request was 2 and the end day of the request was 9, the answer would be 6, since on day 6 there are only 3 activities and this is less than any of the other days.
Since you like getting things out of the way as early as possible, if there are multiple days that are the "least busy" in the given interval, return the day that is earliest. For example, if you were given the query day 0 to day 10 with the array above, your function should return 1, since day 1 is the first day with only 3 activities planned.
Function Prototype
You must use this prototype to receive credit for the assignment.
// Pre-condition: low
// Post-condition: Returns the lowest index in [low, high] storing
// the minimum of array[low]array[high].
int findMinIndex(int data[], int low, int high);
SCHEDULE-SCAFFOLD.C INCLUDED BELOW
//Scaffold for COP 3223 //Homework 9 #include#define MAX 100 int findMinIndex(int data[], int low, int high); int main() { int i, loop, n, queries, data[MAX]; // Read in the schedule data. FILE* ifp = fopen("schedule.in", "r"); fscanf(ifp, "%d", &n); for (i=0; i <>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started