Please do not give solution in image formate thanku String target and integer numData are read from input. Then, numData alphabetically sorted strings are read from input and each string is appended to a vector. Complete the Search() function: If target is found at index midIndex of the vector, output target, followed by " is found at index " and the value of midIndex. Else if rangeSize is 1, output target, followed by " is not in the list". Otherwise, output target, followed by " is not found at index " and the value of midIndex. End each output with a newline. Ex: If the input is: jaw 9 age all dim egg jaw now pan sat yon then the output is: jaw is found at index 4 Note: string1 == string2 returns true if the two strings are the same, and returns false otherwise.   #include #include #include using namespace std; void Search(vector itemList, string target, int minIndex, int maxIndex) { int midIndex; int rangeSize; rangeSize = (maxIndex - minIndex) + 1; midIndex = (minIndex + maxIndex) / 2; /* Your code goes here */ if (dataVector[middleIndex] == targetName) { cout << targetName << " is found at index " << middleIndex << endl; } else if (rangeSize == 1) { cout << targetName << " is not in the list" << endl; } else if (dataVector[middleIndex] < targetName) { Search(dataVector, targetName, middleIndex + 1, highIndex); } else { Search(dataVector, targetName, lowIndex, middleIndex - 1); } } int main() { string target; vector dataList; int numData; int i; string item; cin >> target; cin >> numData; for (i = 0; i < numData; ++i) { cin >> item; dataList.push_back(item); } Search(dataList, target, 0, dataList.size() - 1); return 0; }   PLEASE MAKE SURE IT OUTPUTS CORRECTLY. THANK YOU.

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

Please do not give solution in image formate thanku

String target and integer numData are read from input. Then, numData alphabetically sorted strings are read from input and each string is appended to a vector. Complete the Search() function:

  • If target is found at index midIndex of the vector, output target, followed by " is found at index " and the value of midIndex.
  • Else if rangeSize is 1, output target, followed by " is not in the list".
  • Otherwise, output target, followed by " is not found at index " and the value of midIndex.

End each output with a newline.

Ex: If the input is:

jaw 9 age all dim egg jaw now pan sat yon

then the output is:

jaw is found at index 4

Note: string1 == string2 returns true if the two strings are the same, and returns false otherwise.

 

#include <iostream>
#include <vector>
#include <string>
using namespace std;

void Search(vector<string> itemList, string target, int minIndex, int maxIndex) {
int midIndex;
int rangeSize;

rangeSize = (maxIndex - minIndex) + 1;
midIndex = (minIndex + maxIndex) / 2;

/* Your code goes here */
if (dataVector[middleIndex] == targetName) {
cout << targetName << " is found at index " << middleIndex << endl;
} else if (rangeSize == 1) {
cout << targetName << " is not in the list" << endl;
} else if (dataVector[middleIndex] < targetName) {
Search(dataVector, targetName, middleIndex + 1, highIndex);
} else {
Search(dataVector, targetName, lowIndex, middleIndex - 1);
}
}

int main() {
string target;
vector<string> dataList;
int numData;
int i;
string item;

cin >> target;
cin >> numData;
for (i = 0; i < numData; ++i) {
cin >> item;
dataList.push_back(item);
}
Search(dataList, target, 0, dataList.size() - 1);

return 0;
}

 

PLEASE MAKE SURE IT OUTPUTS CORRECTLY. THANK YOU.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
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
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