Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sorting and Searching with Vectors Create your own vector class which will test algorithms from Chapter 16 and those from the STL (Appendix H). Derive

Sorting and Searching with Vectors

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

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 its not sorted already).

Use the template below as a starter for your assignment. All comments in green 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

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 code execution, and a text file of the code. All code should include comments.

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 and clean

20

Uses software tools correctly and efficiently

10

Total

100

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago

Question

10. Discuss the complexities of language policies.

Answered: 1 week ago

Question

1. Understand how verbal and nonverbal communication differ.

Answered: 1 week ago