Discrete Mathematics and Its Applications, Seventh Edition

Published by McGraw-Hill Education
ISBN 10: 0073383090
ISBN 13: 978-0-07338-309-5

Chapter 3 - Section 3.1 - Algorithms - Exercises - Page 203: 23

Answer

procedure onto $(x_1, x_2, x_3, ... x_n, y_1, y_2, y_3, ... y_m:$ the domain and co-domain of some function $f(x),$ respectively$)$ Define a new set representing a $m$ boolean values such that $b_i$ is true if and only if for some $x_{\alpha}, f(x_{\alpha}) = y_i$. {Initially, all $b_i :=$ false} count $:= 0$ for $i:= 1$ to $n$ $\space\space\space$ curvalue $:= f(x_i)$ $\space\space\space$ if $b_{curvalue}$ is false $\space\space\space$$\space\space\space$$\space\space\space$ count $:=$ count $+1$ $\space\space\space$$\space\space\space$$\space\space\space b_{curvalue}:=$ true if count is equal to $m$ then return true else return false {true and false here refer to the status of function as onto}

Work Step by Step

This algorithm attempts to evaluate if a function is onto or not. To be onto, for every value $y$ in the co-domain, there must be an $x$ value such that $f(x) = y$. We check for this by first defining a set of boolean values as described above. These boolean values will allow us to know if we have encountered this value of the co-domain before or not. We know a function is onto if we have m such incidents since the size of the co-domain is $m$.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.