Menu

Sorting Searching Vectors Create Vector Class Test Algorithms Chapter 16 Stl Appendix H D Q43894449

Sorting and Searching with Vectors

Create your own vector class which will test algorithms fromChapter 16 and those from the STL (Appendix H).

Derive class myVector from vector. myVector must implement thefollowing methods:

        int seqSearch(TsearchItem);

  int binarySearch(T searchItem);

  void bubbleSort();

  void insertionSort();

Create a test program to create some vectors and test yourmethods above. Recall from your reading that binary search onlyworks on a sorted list. Add a static member to the class to“remember” if the list is sorted ( i.e. binarySearch() should firstsort the vector if it’s not sorted already).

Use the template below as a starter for your assignment. Allcomments in green represent code which you need to implement.

#include <iostream>

#include <string>

#include <vector>

using namespace std;

template <class T>

class myVector: public vector<T> {

public:

  int seqSearch(T searchItem);

  int binarySearch(T searchItem);

  void bubbleSort();

  void insertionSort();

};

template <class T>

int myVector<T>::seqSearch(T searchItem)

{

//implement sequential search

}

template <class T>

void myVector<T>::bubbleSort()

{

  //implement bubble sort

}

template <class T>

void myVector<T>::insertionSort()

{

  //implement insertion sort

}

template <class T>

int myVector<T>::binarySearch(T searchItem)

{

  //implement binary search

}

int main()

{

  //define test vector(s)

  myVector<string> nameList;

  //add values to the vector(s)

  //test sort methods

  //test search methods

  //print sorted vector using range based for loop

        //define newtest vector(s)

        

        //define aniterator to each of the above vector containers

        //add values tothe vector(s)

        //test the STLsort method

         //test theSTL binary_search algorithm

        //print theresulting vector(s) using an iterator

  return 0;

}

Useful notes:

this->size();   //length of vector from withinmyVector class

this->at(index); //value at specified index of vector fromwithin myVector class

The STL concepts are taken from Appendix H

Submission requirements:

Submit all files required to make this program run as required.Your solution can be a single file.

Submit source code, a screenshot with a time stamp of codeexecution, and a text file of the code. All code should includecomments.

Grading Criteria Assignments

Maximum Points

Program accomplishes requested operations per instructions

40

The code works and meets all assignment specifications

30

The code is organized and easy to follow and output is clear andclean

20

Uses software tools correctly and efficiently

10

Total

100

Expert Answer


Answer to Sorting and Searching with Vectors Create your own vector class which will test algorithms from Chapter 16 and those fro…

OR