Question
#include using namespace std; class Course{ private: string title; int courseNo; public: }; int main() { string titleArr [] = {Introduction to Computer Science, Data-Driven
#include
class Course{ private: string title; int courseNo;
public: };
int main() { string titleArr [] = {"Introduction to Computer Science", "Data-Driven Problem Solving & Programming", "Programming and Data Types", "Programming and Problem Solving I ", "Programming and Problem Solving II", "Data Structures", "Computer Organization", "Foundations of Computer Science", "Object-Oriented Development", "Fundamentals of Databases", "Languages and Computation", "Computing Systems", "Design and Analysis of Algorithms", "Software as a Service", "Mobile Software Development"}; int keyArr [] = {1000,1220,1230,1420,1430,2430,2500,2600,3200,3300, 3400,3500,4100,4240,4250};
return 0; }
Do NOT use any of the STL in your code. For this lab, you should create a hash table that stores course titles (value) based on the corresponding course number (key). After downloading or copying lab5.cpp to your directory as written on Canvas, follow these steps: 1. Complete the Course class with data members string title and int course No. It should have a default and a parameterized constructor. 2. Create a hash table - a static array of Courses called schedule of size 7 - in the driver. 3. Write a basic hash function int hashFunc (int key) that returns a valid index. 3. Write an addCourse function that inserts a Course (the key-value pair) in the table based on the key. Return false if there is a collision. Otherwise, insert the course and return true. You will be dealing with collisions later in PA #5. 4. In the driver, insert all the key-value pairs from the key array (keyArr) and the value array (titleArr). The first title in titleArr should be paired with the first course number in keyArr, the second title with the second course number, and so forth. There are 15 values in each array. (Ex. CourseNo = 1000, Title = "Introduction to Computer Science" ) If there is a collision, print a warning message. Keep a counter for the number of collisions as you insert all the key-value pairs. 5. Print the number of collisions and all the key-value pairs in the table. Check the execution example for the formatting. I will be testing your code with different courses. 6. Change the hash table size to get a better load factor and number of collisions. What happens when the array size is 10, 12, or 13? Write your answer at the top of your file. Execution example Collision at index 6 Collision at index 2 Collision at index 1 Collision at index 1 Collision at index 3 Collision at index 5 Collision at index 5 Collision at index 5 Collision at index 1 There were 9 collisions. schedule [0] Course: CPSC 3500 Title: Computing Systems schedule [1] - Course: CPSC 2430 Title: Data Structures schedule [2]- Course: CPSC 1220 Title: Data-Driven Problem Solving & Programming schedule [3] - Course: CPSC 2600 Title: Foundations of Computer Science schedule [4]- schedule [5] - Course: CPSC 1230 Title: Programming and Data Types schedule [6] - Course: CPSC 1000 Title: Introduction to Computer Science Do NOT use any of the STL in your code. For this lab, you should create a hash table that stores course titles (value) based on the corresponding course number (key). After downloading or copying lab5.cpp to your directory as written on Canvas, follow these steps: 1. Complete the Course class with data members string title and int course No. It should have a default and a parameterized constructor. 2. Create a hash table - a static array of Courses called schedule of size 7 - in the driver. 3. Write a basic hash function int hashFunc (int key) that returns a valid index. 3. Write an addCourse function that inserts a Course (the key-value pair) in the table based on the key. Return false if there is a collision. Otherwise, insert the course and return true. You will be dealing with collisions later in PA #5. 4. In the driver, insert all the key-value pairs from the key array (keyArr) and the value array (titleArr). The first title in titleArr should be paired with the first course number in keyArr, the second title with the second course number, and so forth. There are 15 values in each array. (Ex. CourseNo = 1000, Title = "Introduction to Computer Science" ) If there is a collision, print a warning message. Keep a counter for the number of collisions as you insert all the key-value pairs. 5. Print the number of collisions and all the key-value pairs in the table. Check the execution example for the formatting. I will be testing your code with different courses. 6. Change the hash table size to get a better load factor and number of collisions. What happens when the array size is 10, 12, or 13? Write your answer at the top of your file. Execution example Collision at index 6 Collision at index 2 Collision at index 1 Collision at index 1 Collision at index 3 Collision at index 5 Collision at index 5 Collision at index 5 Collision at index 1 There were 9 collisions. schedule [0] Course: CPSC 3500 Title: Computing Systems schedule [1] - Course: CPSC 2430 Title: Data Structures schedule [2]- Course: CPSC 1220 Title: Data-Driven Problem Solving & Programming schedule [3] - Course: CPSC 2600 Title: Foundations of Computer Science schedule [4]- schedule [5] - Course: CPSC 1230 Title: Programming and Data Types schedule [6] - Course: CPSC 1000 Title: Introduction to Computer ScienceStep 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