Discrete Mathematics with Applications 4th Edition

Published by Cengage Learning
ISBN 10: 0-49539-132-8
ISBN 13: 978-0-49539-132-6

Chapter 7 - Functions - Exercise Set 7.1 - Page 395: 27

Answer

a. **\(f(\text{"aba"}) = 0,\quad f(\text{"bbab"}) = 2,\quad f(\text{"b"}) = 0\).** **Range of \(f\)** is \(\{0,1,2,3,\dots\}\). b. **\(g(\text{"aba"}) = \text{"aba"},\quad g(\text{"bbab"}) = \text{"babb"},\quad g(\text{"b"}) = \text{"b"}\).**

Work Step by Step

Below is a step-by-step solution addressing both parts (a) and (b). --- ## (a) Definition of \(f\) and its values **Definition of \(f\):** For any string \(s\) of \(a\)s and \(b\)s, \[ f(s) = \begin{cases} \text{the number of \(b\)s to the left of the left-most \(a\) in \(s\),} & \text{if \(s\) contains at least one \(a\),} \\ 0, & \text{if \(s\) contains no \(a\)s.} \end{cases} \] 1. **Compute \(f(\text{"aba"})\):** - The string is \(\text{"aba"}\). - The left-most \(a\) is in the first position, so there are **0** \(b\)s to the left of it. - Thus, \(f(\text{"aba"}) = 0\). 2. **Compute \(f(\text{"bbab"})\):** - The string is \(\text{"bbab"}\). - The left-most \(a\) appears in the third position (the substring is \(b,b,a,b\)). - There are **2** \(b\)s to the left of that \(a\). - Thus, \(f(\text{"bbab"}) = 2\). 3. **Compute \(f(\text{"b"})\):** - The string is \(\text{"b"}\). - There are **no** \(a\)s at all. - By definition, \(f(s) = 0\) if \(s\) has no \(a\)s. - Thus, \(f(\text{"b"}) = 0\). ### Range of \(f\) - If a string has no \(a\)s, \(f\) outputs 0. - If a string has at least one \(a\), say the first \(a\) occurs after \(n\) \(b\)s, then \(f\) outputs \(n\). - Since \(n\) can be any nonnegative integer (we can prepend as many \(b\)s as we like before the first \(a\)), the **range of \(f\)** is all nonnegative integers: \[ \{0,1,2,3,\dots\}. \] --- ## (b) Definition of \(g\) and its values **Definition of \(g\):** For any string \(s\) of \(a\)s and \(b\)s, let \(g(s)\) be the **reverse** of \(s\). Formally, if \[ s = s_1 s_2 \dots s_k \] where each \(s_i \in \{a,b\}\), then \[ g(s) = s_k \dots s_2 s_1. \] 1. **Compute \(g(\text{"aba"})\):** - The reverse of \(\text{"aba"}\) is \(\text{"aba"}\). - Hence, \(g(\text{"aba"}) = \text{"aba"}\). 2. **Compute \(g(\text{"bbab"})\):** - The string \(\text{"bbab"}\) reversed is \(\text{"babb"}\). - Hence, \(g(\text{"bbab"}) = \text{"babb"}\). 3. **Compute \(g(\text{"b"})\):** - The string \(\text{"b"}\) reversed is still \(\text{"b"}\). - Hence, \(g(\text{"b"}) = \text{"b"}\).
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.