GATE | GATE MOCK 2017 | Question 49

You are given an array A[] having n random bits and a function OR(i,j) which will take two indexes from an array as parameters and will return the result of ( A[i] OR A[j] ) i.e bitwise OR. What is the minimum no of OR calls required so as to determine all the bits inside the array i.e. to determine every index of A[] whether it has 0 or 1 ?

(A) N-1
(B) N*(N-1)/2

(C) N
(D) Not possible to determine the bit array




Answer: (C)

Explanation:

Answer will be N as we can send the same index into that function OR(i,i) and get to know the bit.
If OR(i,i) = 0 that means a[i] = 0 else a[i] = 1.


Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.