Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This also uses the solutions for fileIO.cpp and checkArray.cpp from my last post. (Exercise) Create - searchArray1.cpp In this part of the lab, you will

image text in transcribed

This also uses the solutions for fileIO.cpp and checkArray.cpp from my last post.

(Exercise) Create - searchArray1.cpp In this part of the lab, you will create a recursive function that searches for a key in an array with a binary search algorithm. Revisit lecture 4 for the concept of the binary search algorithm. All you need to do is to repeat splitting an array by half and compare the key to the value of the middle element. In the main function: Input an array from a file. created from the previous exe code that you wrote so far (exercise 2) *Call function (checkArraySort) to check if the array is sorted. So far, you can use the code you rcises. .Exit program if the array is not sorted, otherwise continue to the next steps. Once again, you can use the Prompt the user to input the search key (k) * Call function (binarySearchR) to search for the key recursively .Output your search result: o "Found key "!" if the key was found, where is the search key string (notice the quotes around the key string that must be printed) and is the index of the first element where the key was found. o "The key "" was not found in the array!" if the key was not found Your binarySearchR function will return an integer value i as the first index in the array A where the key is found (or -1 in key is not found), and it will take the following arguments: a string array A (again, it is a pointer) the number of elements in the array the key to search (a string) * * Before writing r binarySearchR function, think about the algorithm and write its pseudocode in file

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

Explain the sources of recruitment.

Answered: 1 week ago

Question

Differentiate sin(5x+2)

Answered: 1 week ago

Question

Compute the derivative f(x)=1/ax+bx

Answered: 1 week ago

Question

What is job enlargement ?

Answered: 1 week ago