Question: For this lab you will implement two searches and two sorts Searches - The searches will take a data vector and an element to find,

For this lab you will implement two searches and two sorts

Searches - The searches will take a data vector and an element to find, and return the index of the element in the vector, and -1 if the item is not found in the vector. Searches must work for integer, double, char, and string. Whether this is accomplished through templating or overloading is up to you. Must be named linearSearch and binarySearch.

  • Linear Search
  • Binary Search

Sorts - The sorts will take a data vector and return a sorted copy of the vector. Sorts must also work for integer, double, char, and string as with the searches. Must be named mergeSort and quickSort.

  • Quicksort
  • Merge Sort

You may include additional helper functions, if you wish. Submit Searches.h and Sorts.h with the implemented functions.

Here's the starter code for Sorts.h

#pragma once

#include

template std::vector mergeSort(std::vector lst){ }

template std::vector quickSort(std::vector lst){ } Here's the starter code for Searches.h

#pragma once

#include

template int linearSearch(std::vector data, T target){ }

template int binarySearch(std::vector data, T target){ }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!