Assuming you have a class Student
1- Implement the class constructor and print member function.
2- Overload the operator < such that it compares the names of 2
student objects.
3- Save the class declaration and implementation in a single header
file named as
Student.h
4- Include your Student.h in the main file.
5- Now implement as template functions:
• A quadratic sorting algorithm (bubble, selection or
insertion)
• The sub-quadratic algorithm Shell Sort with Hibbard’s
increments (look it up).
• Another sub-quadratic algorithm (quick or merge sort)
class Student
{
string name;
string id;
double gpa;
public:
Student(string, string, double);
void print();
};6- Read into 3 dynamic arrays of student objects (a1, a2 &
a3) from a file named
students.cpp which will have the number of students
followed by their info as follows:
7- Sort the 3 arrays , each using one of the 3 sorting
algorithms you implemented in step 5. For example
a1 will be sorted using selection sort, a2 will be sorted
using shell sort, & a3 will be sorted using quick sort.
8- 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 ex.,
Bubble.txt, Shell.txt, and Merge.txt.
9- You should count comparisons for each of the sorting
algorithms you implemented such that the number of comparisons made
by
each sorting algorithm will be written as the first line in the txt
file that
contains the array sorted by this algorithm. An example text file
follows.
10-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.
11-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.
Assuming you have a class Student 1- Implement the class constructor and print member function. 2- Overload the operator
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am