Essence of Computing - Department of Computer and Information

Download Report

Transcript Essence of Computing - Department of Computer and Information

CSCI N201
Programming Concepts and Database
3 – Essence of Computing
Lingma Acheson
[email protected]
Department of Computer and Information Science, IUPUI
Definition of Computer
• Universal
• Information
• Manipulator
Definition of Computer
• Universal
– Works with all kinds of information
• Words, maths, images, videos
– Performs different tasks
• Games, create a document read books, long distance
calls, modify images…
– Very few limitations
• Do anything with any kind of information
Definition of Computer
• Information
– Seems to be able to work with anything
– Actually very limited
• All translated into 1s and 0s
– Tiny pieces of data combined into complex information
Definition of Computer
• Manipulator
– Seem able to do anything with data
– Actually very limited
• Come down to a few basic operations
– Simple commands combined into complex instructions
Computer and Information
• Information limited to on/off impulses, like a
light switch
• Light switch demo
– http://wally.cs.iupui.edu/n100/update/binLights.html
– One light switch
• 1 – on, 0 – off
• Two messages – Have a lecture class today? (on: yes; off: no)
– Two light switches
• Switch one – Have a lecture class today? (on: yes; off: no)
• Switch two – Have a lab class today? (on: yes; off: no)
• How many messages can two switches send?
Computer and Information
– Three light switches
•
•
•
•
Switch one – Have a lecture class today? (on: yes; off: no)
Switch two – Have a lab class today? (on: yes; off: no)
Switch three – Have a quiz today? (on: yes; off: no)
How many messages can two switches send?
– Adding each extra switch will double the number of
messages
– 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, ….
Computer and Information
• Related to how computers store information
–
–
–
–
–
Brick counter demo
http://wally.cs.iupui.edu/n100/update/legoMover.html
Represent 1, 2, 4, 8
How to represent other numbers? (0 – 15)
How to represent more numbers?
Binary Conversion
• Converting from binary to base 10
– Use a spreadsheet
– E.g. 1: 101
• Brick Demo
Binary Conversion
– E.g. 2: 1101
– E.g. 3: 1010
– Try it yourself!
Binary Conversion
• How are binary numbers related to base 10
numbers?
• E.g., 367
Binary Conversion
• Binary numbers, base 2. Able to deal with any number with
the power of 2
• Binary 101 = 1*2^2 + 0*2^1 + 1*2^0 = 5
• Decimal 101 = 1*10^2 + 0*10^1 + 1*10^0 = 101
Binary Conversion
• Base 10, 0 – 9 digits, add more digits as numbers grow
• Base 2, 0 – 1, add more switches as numbers grow
Binary Conversion
• Converting from base 10 to binary
– Use a spreadsheet
– Try it yourself!
Binary Conversion
• Converting from base 10 to binary
– Large numbers
• E.g., 34
What is the result from using spreadsheet?
34/2 = 17 with a remainder of 0
17/2 = 8 with a remainder of 1
8/2 = 4 with a remainder of 0
4/2 = 2 with a remainder of 0
2/2 = 1 with a remainder of 0
1/2 = 0 with a remainder of 1
Result: 100010 (get the remainder backwards)
• E.g. 157
Computer Definition Revisit
• Information
– Only deal with 1s and 0s
Binary conversion readings:
http://www.cs.iupui.edu/~n241/readings/binconv.html
Computer Definition Revisit
• Operation
– Very limited
– Only three logical operations
• AND, OR, NOT
Basic Logic Gates
• True or False conditions
– E.g.I have a football. – True, False?
– Why True or False ? – 1 or 0
• Add logic operations
– E.g. I have a football and a baseball.
I have a football or a baseball.
I do not have a football.
– E.g. A hardware device example
Basic Logic Gates
• Truth tables
– Logical AND
A
B
Result
F
F
F
F
T
F
T
F
F
T
T
T
Basic Logic Gates
• Truth tables
– Logical OR
A
B
Result
F
F
F
F
T
T
T
F
T
T
T
T
Basic Logic Gates
• Truth tables
– Logical NOT
A
NOT A
F
T
T
F
Basic Logic Gates
• These devices are called gates
• Turning them into electronic devices, we can
put them together to build electronic circuit
boards and components, and make computers do
different jobs, such as adding or subtracting
binary numbers
• Everything comes down to the operations of the
three logic gates
Basic Logic Gates
• Practice:
– If you are a student of computer science, or if you are
a freshman, you can access the computers in this lab.
• Can I access the computers in this lab if I am a first year
computer science student?
– If ((midterm>80) and (final>90)) then grade=“A”
• Will Sam get an “A” if his midterm score is 85 and final is 89?
– If (count <3) then let the user try again.
• Mary has tried logging to the account three times, will she be
allowed to try again?
– If you are taller than 4ft, or you are over 16 years old,
then you can ride the roller coaster.
• Peter is 15 years old, can he ride the roller coaster?