Unformatted text preview:

CS 70 SPRING 2008 — DISCUSSION #5LUQMAN HODGKINSON, AARON KLEINMAN, MIN XU1. More BucketsExercise 1. Upon hearing that our CS70 class has found a way to consistently defuse their bombs, theterrorists in Die Hard decided to make their puzzles harder to crack by adding more buckets. So now, youhave a 6-gallon bucket, a 10-gallon bucket, and a 15-gallon bucket and the villains order you to get precisely13 gallons of water in one bucket. But before we tackle this problem, let’s do some number theory:(1) Show that given (6, 10, 15), the gcd of any pair of numbers is greater than 1. Now, find the greatestcommon divisor of all three numbers, what is it?(2) Describe mathematically all possible values of the expression 6x + 10y where x, y are integers.(3) Now, describe mathematically all possible values of the expression 6x + 10y + 15z.(4) Use the idea of the two buckets algorithm developed in class to devise a new one to get 13 gallonsof water from the 3 buckets (it doens’t have to be efficient!)(5) Describe informally how you might generalize this algorithm to solve problems involving any numberof buckets?Answer:2. PotpourriExercise 2. Modding is in general an O(n2) operation, but in some cases it can be faster. Prove that if a, bare positive integers, then 2a− 1 mod 2b− 1 = 2(a mod b)− 1. Suppose that x = 2a− 1, y = 2b− 1, what isthe running time of x mod y if max(x, y) is an n-bit number.Exercise 3. Now use the previous exercise and Euclid’s algorithm to prove that gcd(2a− 1, 2b− 1) =2gcd(a,b)− 1.Answer:Date: February 26, 2008.The authors gratefully acknowledge the TA’s of CS70 Past for the use of their previous notes: Chris Crutchfield, AlexFabrikant, David Garmire, Assane Gueye, Amir Kamil, Lorenzo Orecchia, Vahab Pournaghshband, Ben Rubinstein. Theirnotes form the basis for this handout.13. Multiplicative InversesExercise 4. Find the multiplicative inverse of 10 modulo 743.Exercise 5. (1) What is 4! mod 5 ?(2) What is 6! mod 7 ?(3) What is 10! mod 11 ?(4) Can you make a conjecture about the value of (p − 1)! mod p when p is prime? Prove it.Answer:4. A ChallengeExercise 6. Prove or find counterexample: if gcd(m, n) = 1, then gcd(m + n, mn) =


View Full Document

Berkeley COMPSCI 70 - Discussion

Documents in this Course
Notes 1

Notes 1

12 pages

Note 2

Note 2

6 pages

Notes

Notes

6 pages

Notes

Notes

7 pages

Note 10

Note 10

8 pages

n20

n20

10 pages

n19

n19

10 pages

n18

n18

10 pages

n17

n17

6 pages

n16

n16

9 pages

n15

n15

10 pages

n14

n14

9 pages

n13

n13

6 pages

n12

n12

7 pages

n11

n11

6 pages

n10

n10

8 pages

n9

n9

5 pages

n8

n8

7 pages

n7

n7

8 pages

n6

n6

5 pages

n5

n5

8 pages

n4

n4

7 pages

n3

n3

10 pages

n2

n2

7 pages

n1

n1

5 pages

Load more
Download Discussion
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Discussion and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Discussion 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?