Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.cimage text in transcribedimage text in transcribed

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

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

Step: 3

blur-text-image

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago