Week 15: Sorting Algorithms and Recursion
CONTENTS:
- Readings
- Background
- PreQuiz (due Monday April 21 at 9am)
- Recitation
- Recitation Submission Guidelines
- Homework 9
Readings
Please note the advised readings of “Brief C++ Late Objects” - Cay Horstmann:
- Monday: 6.1, 6.2
- Wednesday: 5.10
- Friday: Review content as needed.
Background
Sorting Algorithms
There are several different strategies to sort unordered lists of data. They generally fall into two categories based on how long it takes for them to run proportionate to the number of items they are designed to sort.
When discussing how long an algorithm takes to run, we use something called “Big O Notation”. To use Big O, you need to determine the size of the input, which is designated as n
. The number of singular operations to execute your algorithm as a function of the input size defines how long it takes – for example if you have to look at every element in your list only once, you would need n
operations. If you had to compare every element to every other element in your list, you would need n^2
(n-squared) operations. Big O then removes any constants or smaller terms, as we are only concerned with the limit of the behavior – i.e., what happens as your input gets exceedingly large.
When using Big-O, the two categories of sorting algorithms become clear: algorithms that generally either require that you compare every element against every other element, meaning they take O(n^2)
time, or algorithms that continuously break your data set in halves and compare these smaller pieces, which would take O(n*log(n))
time, as seen in Quick Sort.
Below are four algorithms chosen to represent the different styles of sorting algorithms available to you.
Bubble Sort
Bubble Sort is generally considered the simplest sorting algorithm. It works by repeatedly swapping the adjacent elements if they are in the wrong order, only comparing two at a time.
Image Source: https://www.computersciencebytes.com/sorting-algorithms/bubble-sort/
Bubble sort requires comparing n
elements against n
elements, and so its computational complexity described using Big-O is O(n^2)
.
Selection Sort
Selection Sort involves picking the smallest (or largest) number out of the unsorted elements and then putting it in its own list, one after the other, so that you find the smallest, then the second smallest, and so on and so forth.
Image Source: https://www.hackerearth.com/practice/algorithms/sorting/selection-sort/tutorial/
For the first level of selection sort, you must search all n
elements to find the smallest one. For the second level, you must search n-1
elements, then n-2
, and so on and so forth. This will ultimately require n^2/2
operations. We do not worry about constants such as 1/2
in Big-O, and so this is still a computational complexity of O(n^2)
.
Insertion Sort
Insertion sort works by splitting the list of elements into two pieces: one piece that has already been sorted, and one piece that has not been sorted yet. The algorithm goes through the unsorted list one element at a time and inserts it into the correct position in the sorted list until all elements have been sorted.
Image Source: https://www.geeksforgeeks.org/insertion-sort-algorithm/
The first element is already considered sorted. For the second element, you must compare against 1 element to decide where to put it; the third requires 2 comparisons; this pattern continues until the last comparison, which would be against n-1
elements. The formula 1+2+...+n-1
, when removing constants, also reduces to a Big-O of O(n^2)
.
Quick Sort
Quick Sort is a little more complex, but it is faster than the previous algorithms, hence the name. Quick sort works by splitting our list around a randomly chosen “pivot” into two smaller lists for us to sort, where one list is smaller than the pivot and the other list is larger than the pivot. We then split those smaller lists around their own pivots again, resulting in four lists. This continues until we run out of elements in our lists.
As you can see, this sorting creates a tree-like structure. Each layer contains n
elements and requires n
operations comparing those elements against their respective pivots. However, the trick that makes this faster than the previous algorithms lies in the number of repetitions for this search: instead of requiring n
separate comparisons for each element, as you have seen in the previous three sorting algorithms, you only need as many repetitions as there are layers in this tree. Since each iteration of the tree is splitting the number of elements in half, there are log(n)
layers, resulting in a total time complexity of O(n*log(n))
.
Recursion
A recursive function is one which calls itself. Recursion can be used to accomplish a repetitive task, like loops. Indeed, it turns out that anything you can do with a loop, you could also do with recursion, and vice versa. However, some algorithms are easier to express with loops, and others are easier to express with recursion. You’ll want both in your toolkit to write elegant, simplistic, short code.
Every recursive function includes two parts:
- base case: A simple non-recursive occurrence that can be solved directly. Sometimes, there are multiple base cases.
- recursive case: A more complex occurrence that can be described using smaller chunks of the problem, closer to the base case.. It is possible to have multiple recursive cases as well.
To write a recursive function, we often use the following format:
returnType functionName(arguments)
{
if (/* baseCase? */)
{
return /* baseCase result */;
}
else
{
// some calculations, including a call to functionName
// with “smaller” arguments.
return /* general result */
}
}
Consider the following simple recursive function, which calculates the sum of the numbers 1, 2, 3, …, n:
int sumNumsRecursive(int num)
{
// base case: if the number is 0, we will return 0
if(num == 0)
{
return 0;
}
else
{
// recursive case: where we try to find the result of the previous step
return num + sumNumsRecursive(num - 1);
}
}
The following examples show the final returned value and intermediate recursive function calls.
For example, if num = 3
.
- recursive call 1:
sumNumsRecursive(3)
will return3 + sumNumsRecursive(2)
(we are running the else statement since num is 3). - recursive call 2: When
sumNumsRecursive(2)
is called, it will return2 + sumNumsRecursive(1)
. - recursive call 3: Similarly,
sumNumsRecursive(1)
willreturn 1 + sumNumsRecursive(0)
. - recursive call 4: Finally,
sumNumsRecursive(0)
will return 0, by definition of the base case. - Next if we go back the chain and replace
sumNumsRecursive(0)
with 0, we will havesumNumsRecursive(1) = 1 + 0
. Therefore,sumNumsRecursive(1) = 1
. - Similarly,
sumNumsRecursive(2) = 2 + sumNumsRecursive(1)
, wheresumNumsRecursive(1) = 1
. Therefore,sumNumsRecursive(2) = 2 + 1
; thus,sumNumsRecursive(2) = 3
. - Lastly,
sumNumsRecursive(3) = 3 + 3
; the second 3 is the result ofsumNumsRecursive(2)
. Therefore,sumNumsRecursive(3) = 6
.
Below is the same explanation in a different format.
sumNumsRecursive(3) = 3 + sumNumsRecursive(2) // running the else statement
= 3 + 2 + sumNumsRecursive(1)
// sumNumsRecursive(2) = 2 + sumNumsRecursive(1)
= 3 + 2 + 1 + sumNumsRecursive(0)
// sumNumsRecursive(1) = 1 + sumNumsRecursive(0)
= 3 + 2 + 1 + 0
// sumNumsRecursive(0) = 0 (base case)
= 6
PreQuiz (due Monday April 21 at 9am)
Recitation
Recitation Spot The Error- Problem 1
The following program attempts to erase the first number (0th index) from a vector. Identify the error(s) in the code and provide the corrected line(s).
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<int> v = {5, 6, 7, 8, 9};
v.erase(0);
cout << v[0] << endl;
return 0;
}
Recitation Spot The Error- Problem 2
The following program attempts to add an element to an empty vector. Identify the error(s) in the code and provide the corrected line(s).
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<int> v;
v.at(0) = 42;
cout << v.at(0) << endl;
return 0;
}
Recitation Spot The Error- Problem 3
The following program attempts to delete the even numbers from a vector. Identify the error(s) in the code and provide the corrected line(s).
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<int> v = {2, 4, 6, 8, 9};
for (int i = 0; i < v.size(); i++) {
if (v[i] % 2 == 0) {
v.erase(v.begin() + i);
}
}
// Print remaining elements
for (int i = 0; i < v.size(); i++) {
cout<< v[i] <<" ";
}
cout << endl;
return 0;
}
Recitation Spot The Error- Problem 4
The following program attempts to double every element in the vector and add it at the end of the cector. Identify the error(s) in the code and provide the corrected line(s).
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<int> v = {5, 6, 7, 8, 9};
for(int i = 0; i < v.size(); i++){
v.push_back(v[i] * 2);
}
for(int i=0; i<v.size(); i++){
cout<< v[i]<< endl;
}
}
Recitation Fibonacci Sequence - Problem 5
The Fibonacci Sequence is on of the popular sequences that can be found in nature.
Write a function to calculate the nth number in the Fibonacci Series. You can read all about Fibonacci numbers here.
In summary, nth number in the series is the sum of (n-1)th and (n-2)th number i.e
fib(n) = fib(n-1) + fib(n-2)
Given:
fib(0) = 0
fib(1) = 1
fib(2) = 1
Write a function that takes in an integer n and returns the ‘n’th fibonacci number. Take an input from the user and print the nth fibonacci number using the function.
Hint: Recursion
Recitation Fibonacci Sequence- Problem 5.a. : Algorithm
Write out the steps you would use to solve this problem by hand as pseudocode.
Recitation Fibonacci Sequence - Problem 5.b.: Examples
Pick four possible inputs for each of your function. Follow the steps you wrote for these values to find your result, and verify it.
Recitation Fibonacci Sequence- Problem 5.b. : Implementation
Translate your pseudocode into a C++ program to solve the above code, verify that your program works as expected.
Recitation Submission Guidelines
Important: Follow these instructions carefully when preparing your recitation assignments. Your final submission should be in a single document, and the only action required on Canvas is uploading that document.
- Documentation:
- Create a pdf that includes your submission for all recitation questions. This is the pdf you will upload to your canvas assignment. Feel free to use Word/Google doc to create the pdf.
- Clearly label each question with its corresponding number and include content as applicable (see #2).
- Content to Include:
- Screenshots of Your Code:
- For each question, include a screenshot of your code.(corrected code in case of spot the errors)
- Screenshots of Code Output (if applicable):
- For some longer questions, it might be required to take a screenshot of the code’s output. Include these screenshots as part of your submission.
- Longer Recitation Questions (Multiple Parts):
- Option A:
- Comment your answers directly within your code file.(Spot the errors)
- Take screenshots of the commented code and paste them into your document.
- Option B:
- Take screenshots of the unmodified code.
- Write your answers (Free Response/Pseudocode/Edge case identifictation) to the subquestions in the pdf document next to the corresponding screenshots.
- Option A:
- Screenshots of Your Code:
- Submission:
- Upload the final pdf document to Canvas. This is the only action required on Canvas for your submission.
By following these steps, your submission will be clear, organized, and standardized across all recitation assignments.
Homework 9
Warning: You are not allowed to use global variables for this assignment.
This homework is extra credit, you will receive credit for the questions you have completed. Regardless of your completion of this extra credit homework assignment, sorting and recursion is fair game for the final exam.
This assignment is due Friday May 2. Prior to that, you have deadlines for Project 2. Please plan accordingly.
All function names, return types, and parameters must precisely match those shown. You may not use pass by reference or otherwise modify the function prototypes. You are welcome to create additional functions that may help streamline your code.
Carbon Emission Reduction
This question may require the use of recursion, logical and relational operators, if-else statements, declaring and calling a function, and processing user input. Note: you are not allowed to use loops for this question.
You are tasked with estimating the future reduction in your organization’s carbon emissions. Based on historical data, the reduction of carbon emissions for the next year can be predicted from the current year using the following equation:
next_year_reduction = current_reduction + 0.5 * current_reduction + 10
Develop a recursive function that takes the current year’s carbon emission reduction and the number of years forward for which the reduction needs to be predicted and returns the estimated reduction.
Function: | emissionReduction(double, int)double emissionReduction(double current_reduction, int years) |
Purpose: | To estimate future reductions in carbon emissions based on current reduction efforts and projected yearly improvements. |
Parameters: | double current_reduction - The current year’s reduction in carbon emissions. int year - number of years forward |
Return Value: | Returns the estimated reduction in carbon emissions after the specified number of years. |
Error Handling: | - If current_reduction and/or year is negative, -1 is returned. - If year is equal to 0, return original current_reduction - It should not print anything. |
Example:
Note: This is only an example of the function; you need to develop your own main function to fulfill the requirement for this problem.
// Assume the proper libraries are included.
// Assume the proper implementation of emissionReduction() is included.
int main()
{
cout << "Predicted reduction in carbon emissions: "
<< emissionReduction(100, 3)
<< endl;
return 0;
}
// // OUTPUT:
// Predicted reduction in carbon emissions: 385
For Question 1, develop and validate your solution in VS Code. Once you are happy with your solution, go to coderunner on Canvas and paste emissionReduction() and any helper function(s) to the answer box!
Vector Shuffle
This question may require the use of functions, vectors, and loops.
Your task is to write a C++ function that takes the elements of two vectors and returns a vector of integer values that combines the two input vectors by alternating between values from each of the two vectors. If the vectors are of different sizes, the remaining elements from the longer vector should be appended to the result vector.
Function: | vectorShuffle(vector<int>, vector<int>)vector<int> vectorShuffle(vector<int> vec1, vector<int> vec2) |
Purpose: | To shuffle the elements of two vectors and return a new vector containing elements from both vectors in an interleaved fashion. |
Parameters: | vector<int> vec1 - The first vector of integers vector<int> vec2 - The second vector of integers |
Return Value: | - vector<int> Returns a new vector containing elements from both vec1 and vec2 - The function should not print anything. |
Error Handling: | - If one vector is shorter than the other (including size 0), alternate as long as you can and append the remaining elements from the longer vector. - If both vectors are empty (size 0), the return value should be an empty vector. - The first element of the returned vector should come from the first input argument. |
Example:
Note: This is only an example of the function; you need to develop your own main function to fulfill the requirement for this problem.
// Assume the proper libraries are included.
// Assume the proper implementation of vectorShuffle() is included.
int main()
{
vector<int> vec1 = {1, 3, 5};
vector<int> vec2 = {2, 4, 6, 8, 10};
vector<int> result = vectorShuffle(vec1, vec2);
if (result.size() == 0)
{
cout << "No elements found" << endl;
}
else
{
cout << "Shuffled vector:" << endl;
for (int i = 0; i < int(result.size()); i++)
{
cout << result.at(i) << " ";
}
cout << endl;
}
return 0;
}
// // OUTPUT:
// Shuffled vector:
// 1 2 3 4 5 6 8 10
For Question 2, develop and validate your solution in VS Code. Once you are happy with your solution, go to coderunner on Canvas and paste the vectorShuffle() and any helper function(s) into the answer box!!
The Magical List
This question may require the use of functions, vectors, and loops.
Alex is a curious programmer who loves solving puzzles. One day, while tinkering with numbers, Alex decides to create a magical list that follows a set of peculiar rules. Here’s how the game works:
Alex starts with an empty list. They ask a friend to keep entering positive integers, one at a time. The program will continuously prompt the user with “Please enter a number:” until -1 is entered and each number influences the list in some way:
- If the list is empty, Alex adds the number to the list immediately and does not consider the remaining rules of the game
- If the number is divisible by 5, Alex removes the first number from the list (if there is one).
- If the number is divisible by 3, Alex removes the last number from the list (if there is one).
- NOTE: If the number is divisible by both 3 and 5, Alex does both: remove the first and last numbers from the list (if there is a number).
- If none of the above applies, Alex simply adds the number to the end of the list.
However, there’s a catch! If someone enters a negative number that isn’t -1
, or zero, Alex scolds them with:
“The number should be a positive integer or -1.”
When someone finally enters -1
, Alex stops the game. Then, Alex proudly displays the final list of numbers, separated by spaces. Note: the printing will happen in main( )
.
Function: | processMagicalList( )vector<int> processMagicalList() |
Purpose: | To process a series of user inputs according to the rules and return the final list of integers. |
Parameters: | None. All inputs are provided by the user interactively during execution. |
Return Value: | vector<int> Returns a vector containing the final list of numbers after applying the rules. |
Error Handling: | - The program should prompt the user with “Please enter a number:” for each input. - If the user enters a non-positive number (excluding -1 ), display “The number should be a positive integer or -1.”.- The function should not print the vector. Printing should be handled by the main function. |
Example:&
Note: This is only an example of the function; you need to develop your own main function to fulfill the requirement for this problem.
Sample Code:
// Assume the proper libraries are included.
// Assume the proper implementation of processMagicalList() is included.
int main()
{
vector<int> result = processMagicalList();
if (result.size() == 0)
{
cout << "The vector is empty." << endl;
}
else
{
cout << "The elements in the vector are: ";
for (int i = 0; i < int(result.size()); i++)
{
cout << result[i] << " ";
}
cout << endl;
}
return 0;
}
// // OUTPUT
// The elements in the vector are: 8
For Question 3, develop and validate your solution in VS Code. Once you are happy with your solution, go to coderunner on Canvas and paste the processMagicalList() function into the answer box!
T Ball Players
This question may require the use of arrays, logical and relational operators, if-else statements, declaring and calling a function.
Coach Prime is getting ready for the new T-ball season and needed to finalize his roster. The team is open to kids between the ages of 4 and 6, and parents had already sent in names and ages of their children.
Write a function, printEligiblePlayers, to help Coach Prime filter out the eligible players from the list of names and ages. Your function should identify players between 4 and 6 years old (inclusive) and print their names along with their ages, so Prime Kelly can focus on training her future stars.
Function Specification :
Function: | printEligiblePlayers(string, double, int)void printEligiblePlayers(string names[], double ages[], int num) |
Purpose: | To identify players between 4 and 6 years old (inclusive) and print their names along with their ages |
Parameters: | string names[] - an array of strings to hold names of players double ages[] - an array of floating point numbers (as doubles) to hold ages of players int num - an integer that gives the number of elements in the players and ages arrays |
Return Value: | The function does not return anything |
Error Handling: | The size of names and ages will be the same represented by num. |
Example:
Note: This is only an example of the function; you need to develop your own main function to fulfill the requirement for this problem.
// Assume the proper libraries are included.
// Assume the proper implementation of printEligiblePlayers() is included.
int main()
{
string names[4] = {"Joe", "Jack", "Amy", "Bob"};
double ages[4] = {4.0, 5.6, 6.0, 4.2};
printEligiblePlayers(names, ages, 4);
}
// // OUTPUT
// Joe 4
// Jack 5.6
// Amy 6
// Bob 4.2
For Question 4, develop and validate your solution in VS Code. Once you are happy with your solution, go to coderunner on Canvas and paste printEligiblePlayers() and any helper function(s) to the answer box!
Music App
For this question, you’ll develop a basic Music App System by creating a Library class to manage a collection of songs. For this question, you will create a Song class.
The Song class comprises the following attributes:
Data members (private)
Member Type | Member Name | Description |
---|---|---|
string |
_title |
The name of the song |
string |
_artist |
The name of the song who sang the song |
int |
_downloads |
A count of the number of times the song was download |
Member Functions (public)
Function | Description |
---|---|
Default constructor | Creates a new instance of Song by setting _title to an empty string, _artist to an empty string and _downloads to 0. |
Song(string) |
Creates a new instance of Song by setting _title as the string parameter, _artist to an empty string and _downloads to 0. |
Song(string, string, int) |
Creates a new instance of Song by setting _title as the first string parameter, _artist as the second string parameter and _downloads to the integer parament. See Function Specification table below for more details. |
string getTitle() |
Returns the _title of the Song . |
string getArtist(); |
Returns the _artist of the Song . |
int getDownloads(); |
Returns the number of _downloads of the Song . |
void setTitle(string) |
Sets the _title to the value of the provided string parameter. |
void setArtist(string) |
Sets the _artist to the value of the provided string parameter. |
void setDownloads(int) |
Sets the _downloads to the value of the provided int parameter. |
double grossRevenue(double) |
Calculates the revenue generated by the Song by taking in a price per download and returning the total revenue. Formula: revenue = price * _downloads . See the Function Specification table below for more details. |
Function Specifications:
Function: | Song(string, string, int)Song(string title, string artist, int downloads) |
Purpose: | This parameterized constructor creates a new instance of the Song class. - Sets _title to title . - Sets _artist to artist Sets _downloads to downloads |
Parameters: | string title - The title of the Song. string artist - The artist who sang the Song. int downloads - Number of times the songs has been downloaded. |
Return Value: | N/A |
Error Handling: | If the downloads count is non-positive, set _download to 0. |
Example:
// Assume the proper libraries are included
// Assume the proper implementation of the class is included
int main() {
string title = "Aint Got It Like That";
string artist = "Earl St. Clair";
int downloads = 5;
Song new_song = Song( title, artist, downloads );
}
// // Expected Contents of `new_song` Object:
// _title = "Aint Got It Like That"
// _artist = "Earl St. Clair"
// _downloads = 5
Function: | double grossRevenue(double)double grossRevenue(double price) |
Purpose: | Calculates the revenue generated by the Song using the formula:revenue = price * _downloads . |
Parameters: | int price - The price per download of a song. |
Return Value: | double : Returns a double representing the revenue generated from the Song downloads. |
Error Handling: | If the price amount is non-positive, do not add or modify any contents, and return -1 . |
Example:
// Assume the proper libraries are included
// Assume the proper implementation of the Library class is included
int main() {
string _title = "Get Schwifty";
string _artist = "Rick Sanchez";
int _downloads = 1000;
double price = 1.1;
Song new_song = Song(_title, _artist, _downloads);
cout << fixed << setprecision(2) << new_song.grossRevenue(price) << endl;
}
// // OUTPUT:
// 1100.00
For Question 4, develop and validate your solution in VS Code. Once you are happy with your solution, go to coderunner and paste the Song Class header (.h
file) and all the implementations (.cpp
file). Do NOT include your driver file (main( )
)
College Admission
This question may require the use of file streams, logical and relational operators, if-else statements, declaring and calling a function, and processing user input.
You are part of a college admission board and have been requested to write a program to recommend prospective students for admission based on specific criteria using data from a text file. Each line in the file contains student data in the comma-separated format:
Student Name, SAT, GPA, Interest, High School Quality, Sem1, Sem2, Sem3, Sem4
- Overall Score Calculation Use the following formula to calculate each student’s score:
Score = (0.4 * GPA) + (0.3 * SAT/1600) + (0.2 * High School Quality) + (0.1 * Interest)
- Students with a score of 2.5 or higher are selected under the “score” criteria.
- Outlier Detection Flag students as “outlier” if the interest is 0 and they have a score of 1.5 or higher.
- Grade Improvement Detection Students are flagged for “grade improvement” if their semester grades show a consistent increase (i.e.,
Sem1 < Sem2 < Sem3 < Sem4
) and they have a score of 1.5 or higher. - Output For each student, print their name, score (to 6 decimal places), and the criteria (“score”, “outlier”, or “grade improvement”) if applicable. If no criteria are met, print just the name and score.
Required Functions :
- Use your
split( )
function from earlier in the semester, or use streams to achieve this effect. - Implement the
processAdmission()
function to handle calculations and criteria checking. - Hint: you may use the
to_string
function to convert numbers (int, double) into strings. For example,string example = to_string(1.0);
.
Function Specification :
Function: | string processAdmission(string)string processAdmission(string line) |
Purpose: | To analyze a student’s data, calculate their admission score, and determine whether they meet the criteria for admission based on score, outlier, or grade improvement. |
Parameters: | string line - A single line of comma-separated student data containing the student’s name, SAT, GPA, interest, high school quality, and semester grades. Note: we have skipped the header in main( ) ; therefore, you may assume that all line that are passed can be parsed (is formatted as expected). |
Return Value: | Returns a string formatted as: Name,Score,Criteria. |
Error Handling: | - Flag students as “outlier” if Interest = 0 and the score is 1.5 or higher (and “score” does not apply). - Flag students for “grade improvement” if the grade of each semester is higher than the previous semester and the student has a score of 1.5 or higher (and “outlier” and “score” does not apply). - Assumes valid input format for the line. The function does not handle cases where the line is improperly formatted or contains invalid data types. - The function should not print anything. - if no criteria are met, then the function returns a string formatted as: Name,Score |
Example:
Note: This is only an example of the function; you need to develop your own main function to fulfill the requirement for this problem.
// Assume the proper libraries are included.
// Assume the proper implementation of processAdmission()
// and split() is included (if used)
int main(){
string fileName;
string line;
cout<<"Enter the file name:"<<endl;
cin>>fileName;
ifstream file(fileName);
if(file.is_open()){
cout << endl << "Results:" <<endl;
getline(file, line); // Skip header
while (getline(file, line)){
cout << processAdmission(line) << endl;
}
} else {
cout<<"Could not open file."<<endl;
}
return 0;
}
// // Input:
// text8.txt
// // File Content:
// Student,SAT,GPA,Interest,High School Quality,Sem1,Sem2,Sem3,Sem4
// Anne Mutant,1550,3.89,0,9,97,87,97,87
// Ayla Ranefer,1370,4,3,7,85,86,91,95
// // Output:
// Results:
// Anne Mutant,3.646625,score
// Ayla Ranefer,3.556875,score
For Question 6, develop and validate your solution in VS Code. Once you are happy with your solution, go to coderunner on Canvas and paste processAdmission(), split() and any helper function(s) to the answer box!