GATE Papers >> CSE >> 2017 >> Question No 48

Question No. 48 CSE | GATE 2017

Let A be an array of 31 numbers consisting of a sequence of 0's followed by a sequence of 1's. The Problem is to find the smallest index i such that A[i] is 1 by probing the minimum number of locations in A. The worst case number of probes performed by an optimal algorithm is _________


Answer : 5.0 to 5.0


Solution of Question No 48 of GATE 2017 CSE Paper

Since 0 are followed by 1, so we have a sorted array of 0 and 1 and we can apply binary search algorithm with some modification, which will take maximum probes $ \left[\log_2\;31\right]=5. $

Comments
XOqxrT http://pills2sale.com/ levitra nizagara

Posted on  18/10/2020 15:03:34  by  dobsonz
Leave a comment
Go