gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
Assuming you have a class Student: 1. Implement the class setter and print member…
- User
Assuming you have a class Student:
- Implement the class setter and print member function.
- Overload the operator < such that it compares the names of 2 student objects.
- Now implement as template functions:
- A quadratic sorting algorithm (bubble, selection or insertion)
- The sub-quadratic algorithm Shell Sort
- Another sub-quadratic algorithm (quick or merge sort) 4.Read into 3 dynamic arrays of student objects (a1, a2 & a3) from a file named students.txt which will have the number of students followed by their info as follows:
- Sort the 3 arrays, each using one of the 3 sorting algorithms you implemented in step 5. For example a1 will be sorted using insertion sort, a2 will be sorted using shell sort, & a3 will be sorted using quick sort.
- Each of the 3 sorted arrays should be saved in a separate txt file with the name of the sorting algorithm. So you will have 3 txt files named, for example: Insertion.txt, Shell.txt, and Merge.txt.
- You should count comparisons for each of the sorting algorithms you implemented such that the number of comparisons made by each
- Implement a binary search algorithm to work on any of your sorted students arrays, such that given a student’s name the search returns its index or -1 if it’s not found. A binary search has better complexity (O(log N)) than a linear search (O(N)). You can look up the code of binary search online.
- In main you should :
- Read from students.txt to fill the 3 arrays.
- Call each of the sorting algorithms on each of the arrays.
- Save the results to 3 text files, one for each sort.
- Then display the following menu, which will change depending on the algorithms you chose to implement.
- For the search option, the user will enter a student’s name and if it’s found the whole student record will be shown, otherwise display an appropriate message.
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.