0
$\begingroup$

I need some help on these problems. I do not know where to begin. The book that I have does not explain much.

Can somebody walk me through on solving these type of problems? I already know the answers to these problems. I just want to know how to solve them using a tree.

Problem 1) A set T of numbers is defined recursively by

  1. 2 belongs to T.
  2. If x belongs to T, so does x+3 and 2*x.

Which of the following numbers belong to T? a) 6 b) 7 c) 19 d) 12

Problem 2) A set S of strings of characters is defined recursively by

  1. a and b belong to S.
  2. If x belongs to S, so does xb.

Which of the following strings belong to S? a) a b) ab c) aba d) aaab e) bbbbb

Book: Mathematical Structures for Computer Science

EDIT: new problem added.

Now, what about this problem:

Problem 3) A set M of numbers is defined recursively by:

  1. 2 and 3 belong to M.
  2. If x and y belong to M, so does x*y.

Do I create 2 separate nodes? One for 2 and one for 3?

  • 0
    I just added it in.2017-02-23
  • 0
    Re: #1 part 2, "If $x$ belongs to $T$, so does $x+3$ and $2 \cdot x$." Hint: Do you know a specific $x$ that belongs to $T$? Yes, you do. So use that specific $x$ to figure out $x+3$ and $2 \cdot x$. Then you have two new values in $T$, and you can repeat this process with each of those values.2017-02-23
  • 0
    1) start with $2.$ If $2$ is in $T$ then $2+3 = 5$ is in $T,$ so is $2*2 = 4.$ Now do the same thing with $4.$ Then with $5.$ Soon enough will have exhausted all the number less than $20$ that must be in $T.$ 2) Same idea. $a$ is in $S,$ then $ab$ is in $S,$ $b$ is in $S$ then $bb$ is in $S.$ $ab$ is in $S$ then $abb$ is in $S.$ etc.2017-02-23
  • 0
    I suggest drawing the tree for each. For example in problem 1, start at the node $2$, it doesn't matter for now if it is not the root. From many children does this node have? What are they? Draw them and ask the same questions for each of the children. Problem 2 works the same way, except you have to start with 2 nodes in the tree.2017-02-23

1 Answers 1

1

Both problems would benefit from just getting starting on applying the rules a few times.

In problem (1) you've got two rules to apply to each existing member to generate new members (after which you can effectively forget that one).

$2\overset{\times 2}{ \longrightarrow} \color{red}4$
$2\overset{+3}{ \longrightarrow} \color{blue}5$
$\color{red}4\overset{\times 2}{ \longrightarrow} 8$
$\color{red}4\overset{+3}{ \longrightarrow} \color{orange}7$
$\color{blue}5\overset{\times 2}{ \longrightarrow} 10$
$\color{blue}5\overset{+3}{ \longrightarrow} 8$
$\color{orange}7\overset{\times 2}{ \longrightarrow} 14$
etc.

A few more steps of this will convince you of at least the answers to the question asked.

Problem (2) only has one rule, which is even easier and the pattern should become apparently really quickly.

$a\overset{\&\,b}{ \longrightarrow} ab$
$b\overset{\&\,b}{ \longrightarrow} bb$
$ab\overset{\&\,b}{ \longrightarrow} abb$
etc.

  • 0
    Thanks. I am understanding it now. So, for problem 2 do we have two separate nodes? One for a and one for b? For node b, one "b" will always be adding to the previous b right? So, it will only have "b"?2017-02-23
  • 0
    yes, the two original members will generate totally separate descendants, unlike the crossovers in the first problem2017-02-23
  • 0
    I added a new problem. Can you help me with this one? I was thinking of creating a separate node for 2 and 3. However, what value would be x and what value would be y?2017-02-23
  • 0
    I suggest you just accept ($\checkmark$) my answer on this one and ask the new problem separately. You might do well to expand on what you mean by "a separate node" (but I can tell you it doesn't really apply in that case)2017-02-23