+ All Categories
Home > Documents > Binary Exploration Session -...

Binary Exploration Session -...

Date post: 07-Sep-2019
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
51
Binary! 0010100100110010010101
Transcript
Page 1: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Binary!  0010100100110010010101  

Page 2: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Why  do  computers  use  binary?  

•  Easy  to  detect  the  state  of  a  switch  –  they’re  either  on  or  off!  

• Using  another  base  makes  computers  more  prone  to  error.  

Page 3: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

CounCng  

In  decimal  (base  10),  we  have  digits  0-­‐9.  In  binary,  we  only  have  digits  0  and  1.  

         0  

Page 4: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

CounCng  

In  decimal  (base  10),  we  have  digits  0-­‐9.  In  binary,  we  only  have  digits  0  and  1.  

         1  

Page 5: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

CounCng  

In  decimal  (base  10),  we  have  digits  0-­‐9.  In  binary,  we  only  have  digits  0  and  1.  

       10  

Page 6: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

CounCng  

In  decimal  (base  10),  we  have  digits  0-­‐9.  In  binary,  we  only  have  digits  0  and  1.  

       11  

Page 7: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

CounCng  

In  decimal  (base  10),  we  have  digits  0-­‐9.  In  binary,  we  only  have  digits  0  and  1.  

     100  

Page 8: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

CounCng  

In  decimal  (base  10),  we  have  digits  0-­‐9.  In  binary,  we  only  have  digits  0  and  1.  

     101  

Page 9: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

CounCng  

In  decimal  (base  10),  we  have  digits  0-­‐9.  In  binary,  we  only  have  digits  0  and  1.  

     110  

Page 10: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

CounCng  

In  decimal  (base  10),  we  have  digits  0-­‐9.  In  binary,  we  only  have  digits  0  and  1.  

     111  

Page 11: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

CounCng  

In  decimal  (base  10),  we  have  digits  0-­‐9.  In  binary,  we  only  have  digits  0  and  1.  

   1000  

Page 12: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Places  

1011  1’s  

Page 13: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Places  

1011  2’s  

Page 14: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Places  

1011  4’s  

Page 15: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Places  

1011  8’s  

Page 16: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Places  

1011  20  

4853  100  

Page 17: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Places  

1011  21  

4853  101  

Page 18: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Places  

1011  22  

4853  102  

Page 19: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Places  

1011  23  

4853  103  

Page 20: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

TranslaCng  Binary  to  Decimal  

1011    1  

Page 21: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

TranslaCng  Binary  to  Decimal  

1011    1  2  +  

Page 22: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

TranslaCng  Binary  to  Decimal  

1011    1  2  +  0  +  

Page 23: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

TranslaCng  Binary  to  Decimal  

1011    1  2  +  0  +  8  +  

Page 24: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

TranslaCng  Binary  to  Decimal  

101100  

Answer:  44  

Page 25: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

TranslaCng  Binary  to  Decimal  

10001110  

Answer:  142  

Page 26: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Adding  is  the  easiest.  EVER.  

                100101  

                110110  

            1  

Page 27: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Adding  is  the  easiest.  EVER.  

                100101  

                110110  

          11  

Page 28: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Adding  is  the  easiest.  EVER.  

                100101  

                110110  

     011  

Page 29: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Adding  is  the  easiest.  EVER.  

                100101  

                110110  

     1011  

Page 30: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Adding  is  the  easiest.  EVER.  

                100101  

                110110  

   11011  

Page 31: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Adding  is  the  easiest.  EVER.  

                100101  

                110110  

 011011  

Page 32: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Adding  is  the  easiest.  EVER.  

                100101     37  

                110110     54  

1011011       91  

Page 33: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Dividing  by  2  is  neat-­‐o.    

                101100  

44  

Page 34: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Dividing  by  2  is  neat-­‐o  

                010110  

22  

Page 35: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Dividing  by  2  is  neat-­‐o  

                001011  

11  

Page 36: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Dividing  by  2  is  neat-­‐o  

000101 .1  

5 .5  

Page 37: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

Dividing  by  2  is  neat-­‐o  

00010 .11  

2 .75  

Page 38: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Zorah’s  favorite  things  about  Binary  

You  can  count  to,  like,  a  bajillion  on  your  fingers  in  binary.  

Try  it.  I  know  you  want  to.  

Page 39: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

ASCII  –  Mapping  of  numbers  to  characters  

01100001  -­‐-­‐  a  01000001  -­‐-­‐  A  

011  –  lowercase,  010  –  uppercase,  00001  –  first  le`er  of  the  alphabet  

Page 40: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

What  does  the  secret  message  (in  light  green)  say?  

Page 41: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

RepresenCng  a  sound  wave  

Page 42: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

1-­‐bit   2-­‐bit  

4-­‐bit   8-­‐bit   24-­‐bit  

RepresenCng  Color  

Page 43: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Can  you  see  the  secret  message  hidden  in  this  picture?  

Page 44: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Example  on  encrypCng  the  le`er  ‘a’    

8-­‐bits  (one  byte)  per  character        8  pixels  for  each  le`er  in  the  message  

Page 45: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

Turing  Machine  

Value  is  printed  on  infinitely  long  tape  

Pointer  to  the  specific  bit  to  look  at  

Page 46: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

InstrucCon  Set  for  Turing  Machine  •  PRINT  0  

•  PRINT  1  

•  GO  LEFT  

•  GO  RIGHT  

•  GO  TO  STEP  i  if  0  SCANNED  

•  GO  TO  STEP  i  if  1  SCANNED  

•  STOP  

Page 47: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

InstrucCon  Set  for  Turing  Machine  

Page 48: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

What  does  this  code  do?  

•  1.  GO  LEFT  •  2.  GO  TO  STEP  6  IF  0  SCANNED  •  3.  PRINT  0  •  4.  GO  LEFT  •  5.  GO  TO  STEP  3  IF  1  SCANNED  •  6.  PRINT  1  •  7.  STOP  

Page 49: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

What  does  this  code  do?  

1.  GO  LEFT  2.  GO  TO  STEP  6  IF  0  SCANNED  3.  PRINT  0  

4.  GO  LEFT  5.  GO  TO  STEP  3  IF  1  SCANNED  6.  PRINT  1  7.  STOP  

Try  execuCng  this  code  when  the  Turing  machine  looks  like  this  

Page 50: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

A  mad  scienCst  has  1000  bo`les  of  wine,  but  one  of  them  is  poisoned.  He  also  has  10  rats,  for  which  the  poison  bo`le  will  kill  in  any  amount,  within  10  days.  

The  scienCst  wants  to  have  a  party  on  the  11th  day,  and  remove  the  poisoned  bo`le  unCl  there.  How  can  he  find  the  right  bo`le?  

Binary  Riddle  

Page 51: Binary Exploration Session - courses.cs.washington.educourses.cs.washington.edu/courses/cse142/16wi/Binary Exploration Session.pdf · Counng(In(decimal((base(10),(we(have(digits(0J9.(In(binary,(we(only(have(digits(0(and(1.(((((0

“There  are  10  types  of  people  in  the  world:  those  who  understand  binary  and  those  who  don’t.”  


Recommended