0% found this document useful (0 votes)
23 views4 pages

CS200: Intro To Programming Fall 2021-22: Let's Begin!

The document provides guidelines for a mid-term exam including that it must be completed during lab times, code copying is prohibited, and work must be submitted on the LMS. It also describes two exam tasks - the first involves inserting an interval into a sorted array of intervals and returning the updated array, and the second creates a class to represent angle measurements with methods for conversion between radians and degrees and overloaded comparison operators.

Uploaded by

alirazza.10001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

CS200: Intro To Programming Fall 2021-22: Let's Begin!

The document provides guidelines for a mid-term exam including that it must be completed during lab times, code copying is prohibited, and work must be submitted on the LMS. It also describes two exam tasks - the first involves inserting an interval into a sorted array of intervals and returning the updated array, and the second creates a class to represent angle measurements with methods for conversion between radians and degrees and overloaded comparison operators.

Uploaded by

alirazza.10001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CS200: Intro to Programming

Fall 2021-22
Section 2 Thursday, 27 Oct 2021

Mid-Term Manual

Lab Guidelines

1. You are allowed to perform/submit the mid-term during the lab timings only
2. Do not leave the lab without submitting your work on LMS
3. Copying/sharing code is prohibited. Using any unfair means will lead to immediate disqualification
4. Put your work in a folder YourRollNo_Mid_TAname and submit it on LMS (Assignments → Mid)
5. In case of any unforeseen circumstances, please inform your assigned TA immediately

Task 1 Task 2 Total

40 20 60

Let’s Begin!
Task 1: [40 marks]
Estimated time: 80 minutes

From your main function, provide an array of non-overlapping intervals intervals to a


function insertInterval() where

intervals[i] = [start_i, end_i] represent the start and the end of the ith interval and
intervals is sorted in ascending order by start_i. Also provide an interval newInterval =
[start, end] to insertInterval() that represents the start and end of another interval.

Insert newInterval into intervals such that intervals is still sorted in ascending order by
start_i and intervals still does not have any overlapping intervals (merge overlapping
intervals if necessary).

You may provide any other arguments to insertInterval() if required. Please don’t start
coding right away, first spend some time to form your logic, then proceed further to
implement it in code.

Return intervals after the insertion, and print the output.

Marks Distribution:

Creating the memory allocation, element insertion, print, and element deletion functions
correctly (must be fully functional) [10 Marks]

Test Cases [Marks given in [ ] for every test case passing]:

1. Input: intervals = [[1,3],[6,9]], newInterval = [2,5]

Output: [[1,5],[6,9]] [5 Marks]

2. Input: intervals = [[1,5]], newInterval = [2,3]

Output: [[1,5]] [5 Marks]

3. Input: intervals = [[1,5]], newInterval = [2,7]

Output: [[1,7]] [5 Marks]

4. Input: intervals = [[1,2],[3,5],[6,7],[8,10]], newInterval = [4,8]

Output: [[1,2],[3,10]] [15 Marks]

Explanation: Because the new interval [4,8] overlaps with


[3,5],[6,7],[8,10].

_____________________________________________________________________
Task 2: [20 marks]
Estimated time: 40 minutes

In this task, you are going to be implementing a sorted array of angle measurements
modelled as objects of the class named distanceMetrics.
Create a class named distanceMetrics which has the following member variables and
functions:
● Member Variables (all private):

○ double variable called radians


○ double variable called degrees

● Member Functions (all public):

○ Default Constructor: Initializes radians and degrees to 0


○ calculateRadians: void function that’s going to be used to compute radians
from the degrees input by the user
○ calculateDegrees: void function that’s going to be used to compute degrees
from the radians input by the user

○ Setter functions for each of the member variables


○ Getter functions for each of the member variables
○ Overloaded > Operator: This operator must be overloaded such that it
returns as true or false, whether the degrees of one operand are greater
than the degrees of the other operand
○ Overloaded < Operator: This operator must be overloaded such that it
returns as true or false, whether the degrees of one operand are less than
the degrees of the other operand
○ printMeasurement: This function will be used to print out the angle
measurements exactly how they’re shown in the sample output
In main( ), ask the user how many elements they’d like to input. Create an array of the
size input by the user (hint: use a dynamic array), with each element representing an
object of distanceMetrics. Fill the array with user inputs, and then print out the entire
array. Then, use your overloaded operators to sort the array in ascending order of the
degrees. Finally, print out the sorted array.
Make sure that you follow the sample output exactly as it’s shown below.
Sample Output

_____________________________________________________________________

You might also like