06.03.2017 Views

Mathematics for Computer Science

e9ck2Ar

e9ck2Ar

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

“mcs” — 2017/3/3 — 11:21 — page 219 — #227<br />

7.5. Induction in <strong>Computer</strong> <strong>Science</strong> 219<br />

Problems <strong>for</strong> Section 7.1<br />

Practice Problems<br />

Problem 7.1.<br />

The set OBT of Ordered Binary Trees is defined recursively as follows:<br />

Base case: hleafi is an OBT, and<br />

Constructor case: if R and S are OBT’s, then hnode; R; Si is an OBT.<br />

If T is an OBT, let n T be the number of node labels in T and l T be the number<br />

of leaf labels in T .<br />

Prove by structural induction that <strong>for</strong> all T 2 OBT,<br />

Class Problems<br />

l T D n T C 1: (7.24)<br />

Problem 7.2.<br />

Prove by structural induction on the recursive definition(7.1.1) of A that concatenation<br />

is associative:<br />

.r s/ t D r .s t/ (7.25)<br />

<strong>for</strong> all strings r; s; t 2 A .<br />

Problem 7.3.<br />

The reversal of a string is the string written backwards, <strong>for</strong> example, rev.abcde/ D<br />

edcba.<br />

(a) Give a simple recursive definition of rev.s/ based on the recursive definitions<br />

7.1.1 of s 2 A and of the concatenation operation 7.1.3.<br />

(b) Prove that<br />

rev.s t/ D rev.t/ rev.s/; (7.26)<br />

<strong>for</strong> all strings s; t 2 A . You may assume that concatenation is associative:<br />

<strong>for</strong> all strings r; s; t 2 A (Problem 7.2).<br />

.r s/ t D r .s t/

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!