C++ Recursion vs Iterative functions. For this assignment you will make a Recurs
ID: 3787936 • Letter: C
Question
C++
Recursion vs Iterative functions.
For this assignment you will make a Recursion class with two recursive member functions.
a) Implement the recursive binSearchRec algorithm presented in this chapter, starting on page 68 for a vector of vehicles.
Sort by year then call a recursive function to do a binary search which lists out all vehicle information for a user input year.
then
Sort by make then call a recursive function to do a binary search which lists out all vehicle information for a user input make.
then
Sort by model then call a recursive function to do a binary search which lists out all vehicle information for a user input model.
Then do these same 3 Searches for an input (year, make, model), but use loops instead of a recursive function.
b)Implement a member function with the same functional requirements, except instead of a recursive member function, use an iterative (non-recursive) binarySearchIter. Your iterative function should produce the same results as your recursive function.
This is the file for vehiclein.txt
2010
Ford
Escape
|
2014
BMW
328xi
|
2014
BMW
428xi
|
2012
Ford
Fusion SE
|
2014
Lamborghini
Gallardo
|
Explanation / Answer
#include // std::cout #include // std::binary_search, std::sort #include // std::vector bool myfunction (int i,int j) { return (iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.