Language: C Implement the binary search algorithm, to find an integer in a sorted array. a) Declare an array of N integers. Use the preprocessor #define directive for the size of the array. Let the first element be 0. Fill the array, by assigning to each element the value of the previous element plus a pseudorandom, nonnegative number. b) Given a sorted array of N integers, write a function to recursively search for a given element x in and return the index of x in the array, or -1 if the element is not found. To this end, divide the interval into two halves. If the value of the element is less than the item in the middle of the interval, search further in the lower half of the interval, otherwise, search it in the upper half. c) Test your results, searching for randomly picked element from the array.
Language: C
Implement the binary search
![Problem 4:
Implement the binary search algorithm, to find an integer in a sorted array.
a) Declare an array of N integers. Use the preprocessor #define directive for the size of the
array. Let the first element be 0. Fill the array, by assigning to each element the value of the
previous element plus a pseudorandom, nonnegative number.
b) Given a sorted array of N integers, write a function to recursively search for a given element
x in and return the index of x in the array, or -1 if the element is not found. To this end, divide
the interval into two halves. If the value of the element is less than the item in the middle of the
interval, search further in the lower half of the interval, otherwise, search it in the upper half.
c) Test your results, searching for randomly picked element from the array.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa189e731-9824-45eb-b60d-554e8b785106%2F69d353cb-3296-43b6-b5d2-ddee2abdf5f4%2Fgiz5eg_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)