Computer Science, asked by MrTSR, 9 days ago

=> Using Iteration - Write C cØde for Binary search.

Answers

Answered by electricacssiddi2
0

Answer:

Here's your answer

Explanation:

Working

The binary search algorithm works by comparing the element to be searched by the middle element of the array and based on this comparison follows the required procedure.

Case 1 − element = middle, the element is found return the index.

Case 2 − element > middle, search for the element in the sub-array starting from middle+1 index to n.

Case 3 − element < middle, search for element in the sub-array starting from 0 index to middle -1.

Answered by Anonymous
4

Answer:

Step 1 : Find the middle element of array. using , middle = initial_value + end_value / 2 ; Step 2 : If middle = element, return 'element found' and index. Step 3 : if middle > element, call the function with end_value = middle - 1 . Step 4 : if middle < element, call the function with start_value = middle + 1 .03-Jan-2020

Similar questions