Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Timing Tests of Sorting functions C++ running timing tests on the algorithms

ID: 3739333 • Letter: C

Question

C++

Timing Tests of Sorting functions C++

running timing tests on the algorithms. You can download my sorts.h file and include it. Call each method with a single vector of (probably) unsorted objects.

Sorts.h file = https://raw.githubusercontent.com/irawoodring/263/master/sorting/code_samples/sorts.h

You will need to do a tiny bit of programming though. I would like you to create a Celebrity class. This class should hold the following information (state): Their name How badly you want to meet them (0-10, 10 being you would sell your parents to meet them [assuming you love your parents...]) What area they are involved in (movies, music, standup, etc.) Whether or not you have met them before You will also need to create the normal accessor and mutator functions (behavior). Most importantly though, you must implement the operator

Explanation / Answer

The code:

#include<iostream>
#include"sort.h"
#include<algorithm>
#include<string>
#include<vector>
#include<ctime>
using namespace std;
class Celebrity
{
private:
string name;
int meetInterest;
string area;
bool metBefore;
public:
Celebrity(string name,int howmuch,string area,bool metbefore)
{
    this->name = name;
    this->meetInterest = howmuch;
    this->area = area;
    this->metBefore = metbefore;
}

string getName() const
{
    return name;
}
int getMeetInterest() const
{
    return meetInterest;
}
string getArea() const
{
    return area;
}
bool getMetBefore() const
{
    return metBefore;
}

void setName(string name)
{
    this->name=name;
}
void setMeetInterest(int meetinterest)
{
    this->meetInterest = meetinterest;
}
void setArea(string area)
{
    this->area = area;
}
void setMetBefore(bool metbefore)
{
    this->metBefore = metbefore;
}
bool operator <(const Celebrity& c)
{
    if(c.getMeetInterest() > meetInterest)
      return true;
    else if(c.getMeetInterest() == meetInterest)
      {
   if(c.getMetBefore() > metBefore)
      return true;
   else if(c.getMetBefore() == metBefore)
      {
        if(lexicographical_compare(c.getName().begin(),c.getName().end(),name.begin(),name.end()))
          return true;
      }
      }
    return false;
}
};
string genRandom(int len)
{
static const string alphanum ="ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz";
string s;
for(int i = 0; i < len; i++)
    s += alphanum[rand()%(alphanum.length())];
return s;
}
      


int main()
{
//cout << "How many celebrities?:" << endl;
int number=1000000 ;
// cin >> number;

vector<Celebrity> vc;
for(int i =0; i < number ;i++)
    {
      string n = genRandom(8);
      int meet = rand()%10+1;
      bool met = rand()%2;
      string a ="";
      Celebrity c(n,meet,a,met);
      vc.push_back(c);
    }
insertion_sort(vc);
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote