Page 1 of 1

Binary search algorithm works on the principle of divide and conquer. This search method looks for a particular item by

Posted: Tue Jul 12, 2022 8:20 am
by answerhappygod
Binary Search Algorithm Works On The Principle Of Divide And Conquer This Search Method Looks For A Particular Item By 1
Binary Search Algorithm Works On The Principle Of Divide And Conquer This Search Method Looks For A Particular Item By 1 (72.53 KiB) Viewed 29 times
Binary search algorithm works on the principle of divide and conquer. This search method looks for a particular item by comparing the middle most item of the collection. If a match occurs, then the index of item is returned. You are given a set of arrays and variables to demonstrate binary search as follows. int arr[]={5,7,11,26,30}; int l=0; int r=n−1; int x=11; int n= sizeof (arr)/sizeof(arr[0]); Based on the given values and variables, write the function definition of binary search of the following design. i. Binary search using recursion. (8 marks) ii. Binary search using iteration. ( 8 marks)