- #1
jonroberts74
- 189
- 0
Homework Statement
Let S bet the set of all string's of 0's and 1's. define D: S --> Z as follows : for all s in S, D(s) = the numbers of 1's in s minus the number of 0's in s.
a) Is D 1-1? Prove or give counterexample
b) Is D onto? Prove or give counter example
Homework Equations
The Attempt at a Solution
a) seems easy enough.
[tex]D(s_{i}) = 5[ones]-5[zeros]=0; s_{i} \in S[/tex]
[tex] D(s_{j}) = 6[ones]-6[zeros] = 0; s_{j} \in S[/tex]
[tex]s_{i} \neq s_{s}[/tex]
thus not 1-1
b) It seems to be true.
only proof I could think up would to be
let [tex] s_{k} \in S[/tex] such that the numbers of ones is and zeros in [tex]s_{k}[/tex] is [tex]k_{1}, k_{0} \in \mathbb{Z}[/tex] respectively.
now, [tex] D(s_{k}) = k_{1} - k_{0}[/tex]
and because integers have closure under subtraction [tex]k_{1} - k_{0} = k_{z}[/tex] such that
[tex]k_{z} \in \mathbb{Z}[/tex]
therefore D(s) is an onto function