CSE 260 Homework 8 Solutions: Integer Division, Modulo Arithmetic, and Base Conversions - , Assignments of Discrete Structures and Graph Theory

Solutions to homework 8 of cse 260, which covers topics such as integer division, modulo arithmetic, and base conversions. Examples and exercises to help students understand these concepts. The solutions involve calculating the sequence of a recursive function, identifying relatively prime numbers, and performing arithmetic operations in modulo arithmetic and base conversions.

Typology: Assignments

Pre 2010

Uploaded on 07/28/2009

koofers-user-12y
koofers-user-12y ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE 260
Homework 8- Integer Division -Answer
1. Section 2.4: 42 (hint: example 20 on page 159), 46, 47
42. For each pair (i, j)๎˜(Z+ร—Z+) one can order the pairs the same way
as in figure 2 of page 159.
46.
Part 1: Set of all computer programs in a particular programming lan-
guage is countable (problem 45). A programs can be thought of binary
strings which is a subset of all possible binary strings.. All binary strings
are countable. Therefore, subset is countable.
Part 2: Associate the real number 0.d1d2...dn... to the function fwith
f(n) = dn. For example, if the real is 0.234 . . . then the function will
be
f(1)= 2
f(2)=3
f(3)=4
and so on.
Thus the set of real numbers (between 0 and 1) maps into a subset of
the functions.
Section 3.4: 27, 28, 31
28: We just calculate using the formula. We are given x0= 3. Then
x1=(4.3+1) mod 7=13 mod 7=6; x2=(4.6+1) mod 7=25 mod 7=4;
x3=(4.4+1) mod 7 = 17 mod 7=3.
At this point the sequence must continue to repeat 3, 6, 4, 3, 6, 4, . . .
forever.
2. Which positive integers less than 30 are relatively prime to 30.
{7,11,13,17,19,23,29}
3. The mod function is defined as:
mod p:Zโ†’Z(p), mod(x,p)=x mod p, and Z(p) = {0,1,2, ...p โˆ’1}
We can define add and multiplication in modulo arithmetic as follows:
a+pb= (a+b) mod p and aโˆ—pb= (a.b) mod p, where a, b๎˜Z(p)
An important modulo arithmetic is in Z(2) as follows:
For example, 1+21=(1+1) mod 2=2 mod 2=0 and 1โˆ—21=(1.1) mod 2=
1 mod 2=1
pf2

Partial preview of the text

Download CSE 260 Homework 8 Solutions: Integer Division, Modulo Arithmetic, and Base Conversions - and more Assignments Discrete Structures and Graph Theory in PDF only on Docsity!

CSE 260

Homework 8- Integer Division -Answer

  1. Section 2.4: 42 (hint: example 20 on page 159), 46, 47
    1. For each pair (i, j)(Z+^ ร— Z+) one can order the pairs the same way as in figure 2 of page 159.
    Part 1: Set of all computer programs in a particular programming lan- guage is countable (problem 45). A programs can be thought of binary strings which is a subset of all possible binary strings.. All binary strings are countable. Therefore, subset is countable. Part 2: Associate the real number 0.d 1 d 2 ...dn... to the function f with f (n) = dn. For example, if the real is 0.234... then the function will be f(1)= 2 f(2)= f(3)= and so on. Thus the set of real numbers (between 0 and 1) maps into a subset of the functions. Section 3.4: 27, 28, 31 28: We just calculate using the formula. We are given x 0 = 3. Then x 1 =(4.3+1) mod 7=13 mod 7=6; x 2 =(4.6+1) mod 7=25 mod 7=4; x 3 =(4.4+1) mod 7 = 17 mod 7=3. At this point the sequence must continue to repeat 3, 6, 4, 3, 6, 4,... forever.
  2. Which positive integers less than 30 are relatively prime to 30.

{ 7 , 11 , 13 , 17 , 19 , 23 , 29 }

  1. The mod function is defined as: mod p : Z โ†’ Z(p), mod(x,p)=x mod p, and Z(p) = { 0 , 1 , 2 , ...p โˆ’ 1 } We can define add and multiplication in modulo arithmetic as follows: a +p b = (a + b) mod p and a โˆ—p b = (a.b) mod p, where a, bZ(p) An important modulo arithmetic is in Z(2) as follows: For example, 1+ 2 1=(1+1) mod 2=2 mod 2=0 and 1โˆ— 2 1=(1.1) mod 2= 1 mod 2=

The addition and the multiplication table for the + 2 , โˆ— 2 , respectively, are as follows:

  • 2 | 0 1 * 2 | 0 1 ----|------- ----|------ 0 | 0 1 0 | 0 0 1 | 1 0 1 | 0 1

(a) Give the tables for + 5 and โˆ— 5

  • 5 | 0 1 2 3 4 * 5 | 0 1 2 3 4 ----|-------------- ----|-------------- 0 | 0 1 2 3 4 0 | 0 0 0 0 0 1 | 1 2 3 4 0 1 | 0 1 2 3 4 2 | 2 3 4 0 1 2 | 0 2 4 1 3 3 | 3 4 0 1 2 3 | 0 3 1 4 2 4 | 4 0 1 2 3 4 | 0 4 3 2 1 (b) Give the following sum and product in base 5: (^4235 ) +240 5 โˆ— (^3345) โ€”โ€”โ€” โ€”โ€”โ€”- 12135 1421
  • 1202x
  • 1202x
  • โ€”โ€”โ€”โ€”โ€”-
  • 134141 (c) Based on the above tables for + 5 and โˆ— 5 , solve the following equa- tions for x in Z(5). 2 + 5 x = 1
  • 53 + 5 3 x = 4 2 โˆ— 5 x = 3 โˆ— 53 โˆ— 5 3 x = 4
  1. Make the following conversions between bases:

(a) 743A 11 = x 14 (^383214) (b) 11001100011010100 2 = x 8 (^3143248)