Write a function that receives a vector of integers already sorted in ascending order, an integer n representing the number of elements in this vector, and an integer b. Implement the sequential search algorithm to look for the integer b in the vector. The binary search works as follows: you must look for the element in the position exactly in the half of the vector, if it is the one searched for it returns the number of tests done so far, if it is not the searched one, calculate the midpoint of the half of the vector after assess whether the searched value is greater or less than the value at the middle position. Not finding the value searched, the function must return 0. The name of the function will be called "busca_bin".
Write a function that receives a
Program in C.
![int busca_bin(int vetor[], int n, int b)
{
//seu código
}
For example:
Test
Input Result
int vetor[]={1,2,3,4,5}, n=5, b, x; 3
scanf("%d", &b);
x=busca_bin(vetor,n,b);
printf("%d",x);
int vetor[]={1,2,3,4,5}, n=5, b, x;
scanf ("%d", &b);
x=busca_bin(vetor,n,b);
printf("%d",x);
5
3
int vetor[]={1,2,3,4,5}, n=5, b, x; 6
scanf("%d",&b);
x=busca_bin(vetor,n,b);
printf("%d",x);](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7b6aad0f-c0c6-41e8-8561-d5e50da89235%2F1fc5819c-6314-4d2d-8be5-da898771c2b0%2F4iwcnl_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)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)