Create your own vector class which will test algorithms  from the STL    Derive class myVector from vector. myVector must implement the following methods:         int seqSearch(T searchItem);   int binarySearch(T searchItem);   void bubbleSort();   void insertionSort(); Create a test program to create some vectors and test your methods above. Recall from your reading that binary search only works on a sorted list. Add a static member to the class to “remember” if the list is sorted ( i.e. binarySearch() should first sort the vector if it’s not sorted already). Use the template below as a starter for your assignment. All comments in bold represent code which you need to implement. #include #include #include using namespace std; template class myVector: public vector {   public:   int seqSearch(T searchItem);   int binarySearch(T searchItem);   void bubbleSort();   void insertionSort(); }; template int myVector::seqSearch(T searchItem) { //implement sequential search } template void myVector::bubbleSort() {   //implement bubble sort } template void myVector::insertionSort() {   //implement insertion sort } template int myVector::binarySearch(T searchItem) {   //implement binary search } int main() {     //define test vector(s)   myVector nameList;     //add values to the vector(s)     //test sort methods     //test search methods     //print sorted vector using range based for loop         //define new test vector(s)                  //define an iterator to each of the above vector containers         //add values to the vector(s)         //test the STL sort method          //test the STL binary_search algorithm         //print the resulting vector(s) using an iterator     return 0; } Useful notes: this->size();   //length of vector from within myVector class this->at(index); //value at specified index of vector from within myVector class

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create your own vector class which will test algorithms  from the STL   

Derive class myVector from vector. myVector must implement the following methods:

        int seqSearch(T searchItem);

  int binarySearch(T searchItem);

  void bubbleSort();

  void insertionSort();

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

Use the template below as a starter for your assignment. All comments in bold 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 new test vector(s)

        

        //define an iterator to each of the above vector containers

        //add values to the vector(s)

        //test the STL sort method

         //test the STL binary_search algorithm

        //print the resulting vector(s) using an iterator

 

  return 0;

}

Useful notes:

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

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

 

 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 8 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education