Monday, January 26, 2009. - Lynbrook Computer Science

advertisement

Lynbrook Computer Science

MONDAY, JANUARY 26 TH , 2009

Upcoming Dates

 February USACO – This week - Feb 6-9!

 ACSL #2 – next week!

Free Response = Friday, February 6; Brunch

Written Test = Monday, February 9; Lunch

 CML Computer Contest – April 20-May 1

Team based upon high scoring ACSL-ers ($5)

If you've paid your $15 fee, you're automatically selected

Upcoming ACSL Topics

 Boolean Algebra

A + B * C ⊕ D => A || ( B && (C^D) )

 Bit String Flicking

LSHIFT-1 01010 = 10100

 Computer Number Systems

Already covered in previous meetings

10

2

= 2

Boolean Algebra

 Ā = not in the set of A = !A

 A + B = A OR B

 A * B = A AND B

A ⊕ B = A XOR B

XOR = If and only if one of the arguments is true

Boolean Algebra Sample Problem

 (A Ḃ + C)(A + Ḉ ) + ĀB + C( Ā + B)

Simplify as much as possible. Final answer must have fewest number of parenthesis and may not use any negation (!X)

 Ḃ = B w/ line over (!B)

 Ḉ = C w/ line over (!C)

 Hint 1: Try distributing and simplifying

 Hint 2: A set containing all elements = 1, and can be canceled out

Boolean Algebra Solution

 (A Ḃ + C)(A + Ḉ ) + ĀB + C( Ā + B)

 (A Ḃ A + A ḂḈ + A C + C Ḉ ) + ĀB + (ĀC + BC)

 A Ḃ + A ḂḈ + AC + ĀB + ĀC + BC

A Ḃ (1+ Ḉ ) + ĀB + C(A+Ā+B)

A Ḃ + ĀB + C

(A && !B) || (!A && B) || C

 A ⊕ B + C

Bit String Flicking

 LSHIFT-X

Shift binary value left by X places; insert 0's on the right, drop off values on the left

LSHIFT-2 10110 = 11000

 RSHIFT-X

Shift binary value right by X places; insert 0's on the left, drop off values on the right.

RSHIFT-2 10110 = 00101

Bit String Flicking Continued

 LCIRC-X

Shift binary value left by X places; move values dropped off to the end of the binary string

LCIRC-2 10110 = 11010

 RCIRC-X

Shift binary value right by X places; move values dropped off to the beginning of the binary string

RCIRC-2 10110 = 10101

Bit String Flicking Sample Problem

 x OR LSHIFT-2 11011 = RCIRC-2 11011

 Hint:

 x is a five-digit binary number

Evaluate the

LSHIFT-2 and the

RCIRC-2 first

Bit String Flicking Solution

 x OR LSHIFT-2 11011 = RCIRC-2 11011

 abcde OR 01100 = 11110

 Consider each letter a e as a single bit and compare each one with 0 , 1 , 1 , 0 , and 0 .

 a OR 0 = 1 => a = 1

 b OR 1 = 1 => b = 0, 1

 c OR 1 = 1 => c = 0, 1

 d OR 0 = 1 => d = 1

 e OR 0 = 0 => e = 0

 Answers: 10010 , 11010 , 10110 , 11110

Download