
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
- 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.

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- Produce the following program. Series 8arrow_forwardIn c++ i have this information Type of Ticket &. Cost Monday. Adult= £25 and Child = £15 Thursday. Adult = £40 and child = £20 I have made a vector to store this information Vectorticket ={“Monday”, “Thursday”}; Vectoradult = {25, 40}; Vectorchildren ={15, 20}; Thr format of the adult and children vectors is in the order such that the first elements in those vectors correspond with the first element in the ticket vector Now what am struggling with, is i want the program to calculate the total cost of the tickets in correspondant with The user’s inputs which will be the quantity of how many tickets the user bought respectively (adult and children) So something like Monday 1 2 So 1 will be quantity of adult ticket and 2 will quantity of children ticket and the total costs of both added togetherarrow_forwardComplete the following function that counts the even numbers in a 2D vector of integers. int count_evens(const std::vector<std::vector<int>>& v) { // Add your code... } Please add output screenshot!arrow_forward
- Integers are read from input and stored into a vector until 0 is read. If the vector's last element is odd, output the odd elements in the vector. Otherwise, output the even elements in the vector. End each number with a newline. Ex: If the input is -9 12 -6 1 0, the vector's last element is 1. Thus, the output is: -9 1 Note: (x % 2 != 0) returns true if x is odd. int value; int i; bool isodd; 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 } cin >> value; while (value != 0) { } for (i = 0; i > value; Check return 0; 1 Next level 2 X 1: Compare output 3 4 For input -9 12 -6 1 0, the vector elements are -9, 12, -6, and 1. The last element, 1, is odd. The odd elements in the vector, -9 and 1, are output, each on a new line. Not all tests passed. 2 V 3arrow_forwardYou may insert an element into an arbitrary position inside a vector using an iterator. Write a function, insert(vector, value) which inserts value into its sorted position inside the vector. The function returns the vector after it is modified. #include <vector>using namespace std; vector<int>& insert(vector<int>& v, int value){ ................ return v; }arrow_forwardIntegers are read from input and stored into a vector until 0 is read. If the vector's last element is odd, output the odd elements in the vector. Otherwise, output the even elements in the vector. End each number with a newline. Ex: If the input is -9 12 -6 1 0, the vector's last element is 1. Thus, the output is: -9 1 Note: (x % 2!= 0) returns true if x is odd. 4 5 int main() { 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20} vector vect1; int value; int i; bool isodd; cin >> value; while (value != 0) { vect1.push_back(value); cin >> value; } V* Your code goes here */ return 0; 2 3arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





