solve using binary search write stepwise procedure for given array - 23,12,5,29,10,65,55,70​

To solve this using binary search, we need to follow these steps:

1. Sort the given array in ascending order: 5, 10, 12, 23, 29, 55, 65, 70
(The sorted array will help us perform the binary search operation efficiently.)

2. Initialize two variables, 'start' and 'end', as the indices of the first and last elements in the sorted array, respectively.
- 'start' = 0
- 'end' = length of the array - 1

3. Calculate the middle index as (start + end) / 2.
- 'mid' = (0 + 7) / 2 = 3

4. Check if the element at the middle index is equal to the target value (let's say 'target' is the item we are searching for). In this case, the target value is unknown, so let's assume 'target' as 23.
- If arr[mid] == target, we have found the element. Return the index (mid).
- If arr[mid] > target, the target element must lie in the left half of the array. Update the 'end' value as mid - 1.
- If arr[mid] < target, the target element must lie in the right half of the array. Update the 'start' value as mid + 1.

5. Repeat steps 3-4 until the start index becomes greater than the end index, signifying that the target element is not present in the array.

Let's apply these steps to find the index of 23 in the given array [23, 12, 5, 29, 10, 65, 55, 70]:

Step 1: Sort the array => [5, 10, 12, 23, 29, 55, 65, 70]

Step 2: Initialize 'start' = 0, 'end' = 7

Step 3: Calculate 'mid' = (0+7)/2 = 3

Step 4: Check arr[mid] = arr[3] = 23
Since arr[mid] = 23, we have found the target element. Return the index 3.

Therefore, the target element 23 is found at index 3 in the array.

Sure! Here are the steps for solving this using binary search:

Step 1: Sort the given array in ascending order: 5, 10, 12, 23, 29, 55, 65, 70.

Step 2: Define the target element you want to search for. Let's say the target is 23.

Step 3: Initialize the lower and upper boundaries. Set the lower bound to the first index of the array (0) and the upper bound to the last index of the array (7).

Step 4: Calculate the middle index as (lower bound + upper bound) divided by 2. In this case, (0 + 7) / 2 = 3.

Step 5: Compare the middle element of the array with the target element. If they are equal, the search is successful and the index is returned. If the middle element is greater than the target, update the upper bound to (middle index - 1). If the middle element is smaller, update the lower bound to (middle index + 1).

Step 6: Repeat steps 4 and 5 until the target element is found or the lower bound becomes greater than the upper bound. If the lower bound is greater than the upper bound, the target element is not present in the array.

That's it! By following these steps, you can perform a binary search to find the target element in the given array.