<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=211L1Solutions</id>
	<title>211L1Solutions - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=211L1Solutions"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=211L1Solutions&amp;action=history"/>
	<updated>2026-04-29T12:30:37Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=211L1Solutions&amp;diff=266&amp;oldid=prev</id>
		<title>Mark: 1 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=211L1Solutions&amp;diff=266&amp;oldid=prev"/>
		<updated>2008-03-08T22:35:28Z</updated>

		<summary type="html">&lt;p&gt;1 revision(s)&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:35, 8 March 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en-GB&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key mediawiki-mw_:diff:1.41:old-265:rev-266 --&gt;
&lt;/table&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=211L1Solutions&amp;diff=265&amp;oldid=prev</id>
		<title>Mark at 05:18, 31 July 2006</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=211L1Solutions&amp;diff=265&amp;oldid=prev"/>
		<updated>2006-07-31T05:18:32Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Question 1==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Prove the following statements. In each case write down the hypothesis and the conclusion of the statement.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(a) The integers 2, −7, 101 are rational numbers.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Hypothesis:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If 2, -7, and 101 are rational numbers, &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Conclusion:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
then they can be expressed in the form n/m where n and m are integers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
*Case 1: 2 can be written as 2/1 where n=2 and m=1&lt;br /&gt;
*Case 2: -1 can be written as –7/1 where n=-7 and m=1&lt;br /&gt;
*Case 3: 101 can be written as 101/1 where n=101 and m=1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(b) Every integer is a rational number.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Hypothesis:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If every integer is a rational number, &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Conclusion:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
then every integer can be expressed in the form n/m where n and m are integers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
*Since, n/1 = n. Every integer can be expressed in the form where the integer n/m = n where m=1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(c) If p and q are rational numbers then so are p − q and p · q.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Hypothesis:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
p and q are rational numbers&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Conclusion:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
then, p-q and p.q are also rational numbers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
*Since p and q are rational numbers, p can be represented as n/m and q can be represented at s/t where n,m,s,t are integers and m, t != 0.&lt;br /&gt;
&lt;br /&gt;
* For p-q, this can be written as n/m - s/t. n/m - s/t = nt/mt - ms/mt = (nt-ms)/mt where (nt-ms) = i which is an integer, mt = j which is also a non zero integer. As such i/j is a rational number.&lt;br /&gt;
&lt;br /&gt;
* For p.q, this can be written as n/m.x/t. This equals nx/mt where m,t != 0. nx can be written as i and mt can be written as j. These are both integer values. As such n/m.x/t = i/j which is a rational fraction.&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(d) The sum of two even numbers is an even number.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Hypothesis:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If p and q are even numbers.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Conclusion:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
then p+q is also an even number.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
As p and q are even, they both have a factor of two. They can be rewritten as p=2P and 2=2Q. p+q is therefore 2P+2Q = 2(P+Q). It is clear that 2 is a factor of the result, and as such, the result must be even.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(e) The sum of even and an odd number is an odd number.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Hypothesis:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If p is an even number, and q is an odd number.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Conclusion:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
then p+q is an odd number.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
For p to be even, when divided by two, the remainder is zero. For q to be odd, when divided by two, its remainder is 1. Disregard the ambiguity of 0. p can be rewritten as 2P+0, and q as 2Q+1. 2P+2Q+1=2(P+Q)+1. 2 is not a factor of this result and as such, the conclusion holds true.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(f) Let n come from a set of N. If n^2 is an even number then n is also an even number.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Hypothesis:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If n^2 is an even natural number.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Conclusion:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
then n is also an even number.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If n were not an even number, it would be written as 2p+1, as it would have a remainder of 1 when divided by 2. Since (2p+1)^2 = 4p^2 + 1 an odd number squared will always have an odd result. As such it is impossible for the square root of an even number to be an odd number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(g) The sum of a rational number with an irrational number is an irrational number.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Hypothesis:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If p is a rational number, and q is an irrational number.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Conclusion:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
then p+q is an irrational number.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If p is a rational number it can be written in the form n/m where n,m are integers and m != 0. If q is irrational, it can be written as q and not in a fractional of integers. Thus p+q= n/m +q . Since the result cannot be rationalised into a fraction made up of integers, it is irrational. Q.E.D.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(h) The product of a rational number with an irrational number is an irrational number.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Hypothesis:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If p is a rational number, and q is an irrational number.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Conclusion:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
then p.q is an irrational number.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If p is a rational number it can be written in the form n/m where n,m are integers and m != 0. If q is irrational, it can be written as q and not in a fractional of integers. Thus p.q= (n.p)/m . Since the result cannot be rationalised into a fraction made up of integers, it is irrational. Q.E.D.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(i) Prove that for all numbers x and y we have |x + y| &amp;lt;= |x| + |y|.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Hypothesis:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
For all numbers x and y,&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Conclusion:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
|x + y| &amp;lt;= |x| + |y|&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
*Where x is + and y is +&lt;br /&gt;
** |x + y | = x + y, and  |x| + |y| = x + y. Therefore where x and y are positive, |x + y| = |x| + |y|.&lt;br /&gt;
*Where x is - and y is +&lt;br /&gt;
**|-x + y | = |y-x|. This will always be smaller or equal to the absolute value of y. |-x| + |y| = x + y. Therefore where x and y are positive, |-x + y| = |-x| + |y|.&lt;br /&gt;
*Where x is + and y is -&lt;br /&gt;
**|x + -y | = |y-x|. This will always be smaller or equal to the absolute value of x. |x| + |-y| = x + y. Therefore where x and y are positive, |x + -y| = |x| + |-y|.&lt;br /&gt;
*Where x is - and y is -&lt;br /&gt;
** |-x + -y | = x + y, and  |x| + |y| = x + y. Therefore where x and y are positive, |x + y| = |x| + |y|.&lt;br /&gt;
&lt;br /&gt;
==Question 2==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Consider the binary alphabet {a, b}. The string w = a1 . . . an, where each of a1, . . ., an is either a or b, has length n. The symbols a1, . . ., an are called symbols (or digits) of the string w. The symbol a&amp;#039;&amp;#039;i&amp;#039;&amp;#039; is called the &amp;#039;&amp;#039;i&amp;#039;&amp;#039;th symbol of the string. Say that two strings w and v are equal if they both have the same length, and each &amp;#039;&amp;#039;i&amp;#039;&amp;#039;th symbol of w equals the &amp;#039;&amp;#039;i&amp;#039;&amp;#039;th symbol of v. Do the following:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(a) List all strings of lengths 0, 1, 2, 3, and 4.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 String length:&amp;#039;&amp;#039;&amp;#039;      0        1        2        3        4&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
                    &amp;quot;&amp;quot;        a       aa      aaa     aaaa&lt;br /&gt;
                              b       ab      aab     aaab&lt;br /&gt;
                                      ba      aba     aaba&lt;br /&gt;
                                      bb      abb     aabb&lt;br /&gt;
                                              baa     abaa&lt;br /&gt;
                                              bab     abab&lt;br /&gt;
                                              bba     abba&lt;br /&gt;
                                              bbb     abbb&lt;br /&gt;
                                                      baaa&lt;br /&gt;
                                                      baab&lt;br /&gt;
                                                      baba&lt;br /&gt;
                                                      babb&lt;br /&gt;
                                                      bbaa&lt;br /&gt;
                                                      bbab&lt;br /&gt;
                                                      bbba&lt;br /&gt;
                                                      bbbb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(b) How many strings are there of length 3, 4, and 5.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
For every string length n, there are 2^n strings. Thus for a string length of 3 there are 2^3=8 possible string combinations. For 4, 2^4=16 combinations and 5, 2^5=32 string combinations.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(c) Write down a formula that computes the number of strings of length n.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
For any string length n, there are 2^n strings.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;(d) Write down a formula that computes the number of strings of length at most n.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
For all the strings up to a given length, the formula is:&lt;br /&gt;
&lt;br /&gt;
Sum where x=o-n of  2^x&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Prove that there exist irrational numbers a and b such that a^b is rational. (Hint: Use the number sqrt(2)).&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
let x and y be rational integers and a and b are irrational. a^b=x/y. Assume a is sqrt(2), b log(a) = log(x/y). b=log(x/ay). log(x/ay) cannot be expressed as a rational integer and as such b is irrational.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Question 3==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Programming exercises&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
#&amp;#039;&amp;#039;&amp;#039;Write a program that, given n and alphabet &amp;#039;Sigma&amp;#039; as inputs, outputs all strings of length n over the alphabet &amp;#039;Sigma&amp;#039;.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
#*[[211L1SolutionBruteForce|Brute Force information from wiki]]&lt;br /&gt;
#&amp;#039;&amp;#039;&amp;#039;Write a program that given a fraction n/m, where n, m are integers and m 6= 0, outputs its reduced form.&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>