What is the space complexity of the following binary search algorithm?
int BinSearch(int a[], int n, int data)
{
int low = 0;
int high = n-1;
while (low <= high)
{
mid = low + (high-low)/2;
if(a[mid] == data)
return mid;
else if(a[mid] < data)
low = mid + 1;
else
high = mid - 1;
}
return -1;
}
Choose true statement :
(I) Binary search is faster than linear search.
(II) Binary search may not be applied on all the input lists on which linear search can be applied.
1 Crore+ students have signed up on EduRev. Have you? Download the App |
For which of the following tasks, stack is not suitable data structure?
(a) Binary search in an array
(b) Breadth first search
(c) Implementing function calls
(d) Process scheduling
The minimum number of comparisons for a particular record among 32 sorted records through binary search method will be:
What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size n?
Consider the following array A, and the searching element is X. How many comparisons are required to search an element X in array A.
A[ ]= {25, 45, 87, 21, 18, 49, 13, 115, 83, 65}
X = 83
Which of the following is/are true about the search in an array data structure with N element?
I. linear search is also called random search
II. At worst case, the number of comparisons needed in linear search is N
Which of the following is/are true about the search in an array data structure with N element?
I. linear search is also called random search
II. At worst case, the number of comparisons needed in linear search is N
Consider the following array A, and the searching element is X. How many comparisons are required to search an element X in array A.
A[ ]= {25, 45, 87, 21, 18, 49, 13, 115, 83, 65}
X = 83
In binary search, the key to be searched is compared with the element in the __________ of a sorted list.