Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C#, please Lab8B: For this part of the lab, you will practice using Linear Search and Binary Search. Please review the lecture slides and try

image text in transcribedC#, please

Lab8B: 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. For this first part of the lab, write a program that prompts the user to enter 15 numbers in sorted order (meaning the user enters them in ascending order). Store the inputted numbers into a 1D 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. Note: 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. Your output should look like the sample output below. User input is in bold. Sample output #1 Enter slot 0 : 0 Enter slot 1: 1 Enter slot 2: 2 Enter slot 3: 3 Enter slot 4: 4 Enter slot 5: 5 Enter slot 6: 6 Enter slot 7: 7 Enter slot 8: 8 Enter slot 9: 9 Enter slot 10: 10 Enter slot 11: 11 Enter slot 12: 12 Enter slot 13: 13 Enter slot 14: 14 Enter a target: 15 01112131415161718 910 | 11 12 | 13 14 | Sample output #2 Enter slot 0 : 3 Enter slot 1: 11 Enter slot 2: 45 Enter slot 3: 57 Enter slot 4: 81 Enter slot 5: 125 Enter slot 6: 129 Enter slot 7: 311 Enter slot 8: 333 Enter slot 9: 361 Enter slot 10: 402 Enter slot 11: 412 Enter slot 12: 475 Enter slot 13: 499 Enter slot 14: 501 Enter a target: 402 3|11|45|57|81|125129311333361 402 412 475 499501|

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago