Dicrete Math - Fall 2009 CS131 Combinatorial Structures...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Fall 2009 CS131 – Combinatorial Structures Homework 2 Homework 2, due Sept 22 You must prove your answer to every question. Do not rely only on the homework for exercise: there are several self-check ex- ercises of the easier kind in the book, try to solve them, too! Problem 1. In this exercise, we consider ternary representation in place of binary. (a) (10pt) Write down in a general algorithm, how to compute the base 3 (not base 2) representation of a number. Solution. The algorithm is just as in the binary case. Starting from the least significant digit: 1 If x = 0 return (0) 3 . Else let x 0 = x . 2 While x i 6= 0 do: a i : = the remainder of x i after division by 3 ( a i = x i mod 3). x i + 1 : = ( x i - a i )/3 = b x i /3 c . i : = i + 1. (b) (5pt) Illustrate it on the example of the number 38. Solution. On the example of 38: a 0 = 38 mod 3 = 2, b 38/3 c = 12, a 1 = 12 mod 3 = 0, b 12/3 c = 4, a 3 = 4 mod 3 = 1 b 4/3 c = 1, a 4 = 1 mod 3 = 1, b 1/3 c = 0. Hence 38
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/15/2011 for the course MATHS 100 taught by Professor Fredphelps during the Fall '11 term at Jordan University of Science & Tech.

Page1 / 3

Dicrete Math - Fall 2009 CS131 Combinatorial Structures...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online