Answered step by step
Verified Expert Solution
Link Copied!

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!
image text in transcribed
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

Students also viewed these Databases questions

Question

What do you mean by underwriting of shares ?

Answered: 1 week ago

Question

Define "Rights Issue".

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Explain the procedure for valuation of shares.

Answered: 1 week ago

Question

2 The role of economic theory in economics.

Answered: 1 week ago