For this program you will first read in 10 integers and store them in an array. Then you will search the array using the recursive version of linear search. Be sure to test the program both for the case where the integer for which you are looking is in the array and the integer for which you are looking is not in the array. If the integer is in the array, be sure to give the index of the first occurrence of the integer for which you are looking.
Notice that there are a couple of minor changes from the algorithm discussed in class. Why is this better?
Search the array a[0,..,N-1] for the element s value.
Procedure LSearch ( array Array, int i, int M, value Search )
begin LSearch
if ( i > M )
return not found
if ( Array[i] = Search )
return found at i
LSearch ( Array, i + 1, Search )
end LSearch
Linear Search:
LSearch ( a, 0, N - 1, s value )

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

    using namespace std;

    int reclinsearch(int a[], int left, int right, int target)
    if (left > right)
       return -1; //not found, since we iterated through the entire array recursively and incremented left
    if (a[left] == target) //if found retain position
       return left;...

By purchasing this solution you'll be able to access the following files:
Solution.docx and

50% discount

$13.00 $6.50
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Data Structures and Algorithms Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats