Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prelab Task Please review the following searching algorithms you have learned in COSC 120 & 220. It includes the algorithm, implementation, and worst-case time complexity

image text in transcribed

Prelab Task Please review the following searching algorithms you have learned in COSC 120 & 220. It includes the algorithm, implementation, and worst-case time complexity of each algorithm. Lincar scarch Binary scarch Lab Task: In this lab, wc wll expcriment the worst-casc time complexity of binary scarch by finding the maximum numbcr of comparisons nccded for scarching valucs in an array For a random list of integers, what is the maximum number of comparisons required to find a target value by binary scarch? Pleasc claborate your answer. Declare and define the unction b1nScarch In a file namcd bin earch h. Your function bin Scarch should bc able o record thc total number of compansons the a gorithm exccutes for an unsuccessful scarch * Write a program in a file named lab02.cpp c The program declares an integer array with ARRSIZE (10000) random integers from 0 to RANDOMLIMIT (-99999) o The program performs a total of RANDOMVALUES (-10000) times binary search. During cach scarch, a random target value (from 0 to RANDOMLIMIT will be generated to perform search by calling the function of binSearch. Note: The deSelsort function you create in lab 1 will be use to sort the numbers before you perforn binary search.] o The integer sumFailCo ll be used to record the total numbers of comparison in all unsuccessful search after the total of RANDOMVALUES times to run binary search. c The integer successTotal will be used to record the lotal number of successful searh during the total of RANDOMVALUES limes lo perform binary search. c The program will output the empirical result for the worst-case comparison used for an unsuccessful binary, which can be calculated by sumFailCom/( RANDOMVALUES-successTotal) * Run your program and print out the outputs. *Does your empirical results verify your answer for the maximum number of comparisons required to find a target value by the binary search? What to Turn In * Hand in your printouts. o binSearch.h e lab02.cpp c Sample outputs c Answers to questions

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

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions