Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C++ please! Lab88: For this part of the lab, you will practice using Linear Search and Binary Search. Please review the lecture slides and
In C++ please!
Lab88: For this part of the lab, you will practice using Linear Search and Binary Search. Please review the lecture slides and try to re-code them. The goal of this lab is for you to perform these two searches and visualize the behavior. Write a program that reads 15 numbers in sorted order from an input file (called input.but-with each number separated by a space). Store the numbers into a 10 array of size 15. Then, ask the user for a number to search for in the array (i.e. the "target"). Now, print the array. Next, use Linear Search to search the array, Print out each of the indices (or "indexes") that are being examined until the algorithm finds the target. Finally, use Binary Search to search the array. Print out each of the indices (or "indexes") that are being examined until the algorithm finds the target. Your output should look like the sample output below. User input is in bold. Note: Before the target is entered the program has already read in the values form the file and stored them in the array. After the target" is entered by the user, the program needs to print 1) the array, 2) the indices of a linear search and 3) the indices of a binary search. You'll need to create a file called "input.txt" that contains 15 numbers in order separated by a space (e.g. 0-14) and put it in the same directory as your source code. For the submission, you do not need to include your input.txt file (since we will be testing with a different one). Sample output f1 Enter a target: 15 01112131415161718191101111121131141 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 7 11 13 14 Sample output 12 Enter a target: 402 3111145157101112511291311133313614021412147514995011 0 1 2 3 4 5 6 7 8 9 10 7.11 9 10 Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started