Determine whetherfis a function from the set of all bitstrings to the set of integers if

a)f(S)is the position of a 0 bit inS.
b)f(S)is the number of 1 bits inS.
c)f(S)is the smallest integerisuch that theith bit ofSis 1 andf(S)=0 whenSis the empty string, thestring with no bits.

Respuesta :

Answer:

a) Not a function

b) It is a function

c) It is a function

Step-by-step explanation:

a) f(S) is not completly well defined, becuase if the bistring has multiple zeros, you need to pick one and there is not specified method in how you would do so. Another reason for which f is not well defined as a function is that for a bistring with only 1's, f is not defined because there is no zero.

b) This is a function. f(S) returns a concrete and unique integer number for each bistring S. If the bistring has only zeros, the f(S) = 0.

c) This is well defined as a function. It compensates for the failures of the first definition:

- If multiple zeros appears in S, you pick the first one, so there is one possible value for f(S)

-If no zeros appear, f is still well defined because it takes the value 0, as specified in the definition.