Let S be the set of all strings of 0’s and 1’s, and define D:S -> Z as follows: For all S in S, D(s)= the number of 1’s in s minus the number of 0’s in s. a. Is D one-to-one? Prove or give a counterexample. b. Is D onto? Prove or give a counterexample.

Anito49

Anito49

Open question

2022-08-19

Let S be the set of all strings of 0’s and 1’s, and define D:SZ as follows: For all SS, D(s)= the number of 1’s in s minus the number of 0’s in s.
a. Is D one-to-one? Prove or give a counterexample.
b. Is D onto? Prove or give a counterexample.

Answer & Explanation

cuevamc

cuevamc

Beginner2022-08-20Added 6 answers

Step 1
DEFINITIONS
A function F from A to B satisfied the following two properties:
- For every element xA, there exists an element yB such that (x,y)F.
- If (x,y)F and (x,z)F, then y=z (thus an element in A cannot have two different images).
A is called the domain, while B is called the codomain.
The function f is one-to-one if and only if f(a)=f(b) implies that a=b for all a and b in the domain.
The function f is onto if and only if for every element BB there exist an element aA such that f(a)=b.
Step 2
SOLUTION
D:Sz
S= Set of all strings
D(s)= Number of 1's in s minus the number of 0's in s
a) Not one-to-one
D is not one-to-one, which we will justify with a counterexample.
COUNTEREXAMPLE
Let us consider the strings 10 and 01.
Both strings contain one 1 and one 0, thus their image is 0 (as 11=0).
D(10)=0=D(01)
However, the strings 10 and 01 are not the same, while their images are the same. By the definition of one-to-one, D is then not one-to-one.
Step 3
b) Onto
D is onto, which we will justify with a proof.
To proof: D is onto
PROOF
Let xZ. We will need to find an element in the domain S that has x as its image. If such an element exists (for any x in the codomain), then D is onto.
First case x=0
The string 01 has one 1 and one 0, thus the image of the string is 11=0
D(01)=11=0
Second case x>0
Let us consider the string 0x which is the string consisting of no ones and -x zeros. Thus the image of the string 0x is then 0(x)=x
D(0x)=0(x)=x
Thus 01 or 1x or 0x (choice dependent on value of x) is some element in the domain which has x as its image and this then implies that D is onto.
razdiral3m

razdiral3m

Beginner2022-08-21Added 1 answers

Step 1
The objective is to determine whether D is one-one or not and D is on-to or not.
Where, S bet the set of all strings of 0's and 1's, and define D:SZ for all s belongs S and D(s)= the number of 1's in s - the number of 0's in S.
Step 2
No, D is not 1-1,
Since, if number of 1's is 5 and number is 0's is 2 then D=52=3.
If number of 1's is 8 and number of 0's is 5 then D=52=3
Hence, D is not one-one.
Yes, D is onto because for every element of D(s) there exist pre-image of the element. That means for every D= the number of 1's in s - the number of 0's in S
There exists element in S.
Hence, D is on-to.

Do you have a similar question?

Recalculate according to your conditions!

New Questions in Discrete math

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?