CSC 110 – Intro to Computing Lecture 14: Midterm Review.
-
date post
15-Jan-2016 -
Category
Documents
-
view
220 -
download
3
Transcript of CSC 110 – Intro to Computing Lecture 14: Midterm Review.
![Page 1: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/1.jpg)
CSC 110 –Intro to Computing
Lecture 14:
Midterm Review
![Page 2: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/2.jpg)
Announcements
Reminder: Midterm is this ThursdayCovers all material discussed so farYou will be given 75 minutes, arithmetic tables,
logical propertiesEssay must be completed in class, but topic
given at end of class Service learning logs due March 23
Note slight change of date
![Page 3: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/3.jpg)
Important Bases’ Digits
Binary (base-2) uses 2 digits: 0, 1
Octal (base-8) uses 8 digits: 0, 1, 2, 3, 4, 5, 6, 7
Decimal (base-10) uses 10 digits:0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Hexadecimal (base-16) uses 16 digits:0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
![Page 4: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/4.jpg)
Decimal Positional Notation
Formal equation for a number dn...d3d2d1d0
d0 is digit in ones place, d1 is in tens place, …
d0 * 100
d1 * 101
d2 * 102
d3 * 103
…
+ dn * 10n
![Page 5: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/5.jpg)
Converting To Decimal
Use positional notation to any number dn...d3d2d1d0 from base-b to decimal:
+ dn * bn
…
d2 * b2
d3 * b3
d1 * b1
d0 * b0
![Page 6: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/6.jpg)
Converting Binary to Decimal
1000112 = 1 *
1 *
0 *
0 *
0 *
+ 1 *
![Page 7: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/7.jpg)
Converting Octal to Decimal
1078 =
![Page 8: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/8.jpg)
Convert Hexadecimal To Decimal
AF16=
3716=
![Page 9: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/9.jpg)
Converting From Decimal
Converting from decimal to any base-b
While the decimal number is not 0Divide the decimal number by bMove remainder to left end of
answerReplace decimal number with
quotient
33510 =
![Page 10: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/10.jpg)
Converting Binary to Octal
Special relationship between these basesOctal uses 8 digits: 0, 1, 2, 3, 4, 5, 6, 73 binary digits (bits) represent 1 octal digit:
0002 = 08 1002 = 48
0012 = 18 1012 = 58
0102 = 28 1102 = 68
0112 = 38 1112 = 78
Every 3 bits is equal to one octal digitMakes conversion easy
![Page 11: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/11.jpg)
Converting Binary to Octal
Starting from the right, split number into groupings of 3 bits
For each group from right to leftConvert each group from binary to decimalAdd digit to left end of result
![Page 12: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/12.jpg)
Converting Binary to Octal
Convert from binary to octal:11110011002
![Page 13: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/13.jpg)
Converting Binary to Octal
Convert each group to decimal:
1 111 001 100 41002 = 0 * 20 = 0 * 1 = 0
0 * 21 = 0 * 2 = 0
1 * 22 = 1 * 4 = + 4
4
![Page 14: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/14.jpg)
Converting Binary to Octal
Convert each group to decimal:
1 111 001 100 1 40012 = 1 * 20 = 1 * 1 = 1
0 * 21 = 0 * 2 = 0
0 * 22 = 0 * 4 = + 0
1
![Page 15: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/15.jpg)
Converting Binary to Octal
Convert each group to decimal:
1 111 001 100 7 1 41112 = 1 * 20 = 1 * 1 = 1
1 * 21 = 1 * 2 = 2
1 * 22 = 1 * 4 = + 4
7
![Page 16: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/16.jpg)
Converting Binary to Octal
Convert each group to decimal:
1 111 001 100 1 7 1 4 12 = 1 * 20 = 1 * 1 = 1
![Page 17: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/17.jpg)
Converting Binary to Octal
That’s all there us to it!
11110011002 = 17148
![Page 18: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/18.jpg)
Converting Octal To Binary
For each digit (working from right to left)Convert the digit from decimal to binaryAdd 0s to left of the binary to fill 3 bitsAdd binary number to left-end of solution
Finally, remove any 0s padding leftmost digit
![Page 19: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/19.jpg)
Converting Octal to Binary
Convert from octal to binary:3168
![Page 20: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/20.jpg)
Binary to powers-of-two bases
Special relationship between binary and any power-of-two (2, 4, 8, 16, 32…) baseOctal is base-8
23 = 8 Use groupings of 3 bits converting to/from octal
Hexadecimal is base-16 24 = 16 Use groupings of 4 bits converting to/from octal
![Page 21: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/21.jpg)
Conversion Quick Guide
When converting to decimal… …use positional notation
When converting from decimal… …divide by base being converted into
When converting between binary and power-of-two base……use groupings of bits of appropriate size
![Page 22: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/22.jpg)
Addition Algorithm
To add 2 numbers in base-b:
For each position from right to leftCompute sum of the digitsIf sum > b then
sum = sum- bCarry the 1
EndRecord sum at position
![Page 23: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/23.jpg)
Adding Octal Numbers
For each position from right to left
1 2 68
+ 7 2 28
![Page 24: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/24.jpg)
Adding Octal Numbers
Record sum at position
1
1 2 68
+ 7 2 28
08
![Page 25: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/25.jpg)
Adding Octal Numbers
For each position from right to left
1
1 2 68
+ 7 2 28
5 08
![Page 26: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/26.jpg)
Adding Octal Numbers
For each position from right to left
1 1
1 2 68
+ 7 2 28
0 5 08
![Page 27: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/27.jpg)
Adding Hex Numbers
For each position from right to left
B A 616
+ E 0 216
![Page 28: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/28.jpg)
Boolean Negation: NOT
NOT is simplest operationReturns the negation of the input
1 when a is 0; 0 when a is 1
Written as a
0 1
1 0
aaa
![Page 29: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/29.jpg)
Boolean Operation: OR
OR takes two values as inputsWritten as Returns 1 when either value is 1
1 when either a OR b are 1; 0 otherwise
0 00 11 01 1
a b a b
a b
a
b
![Page 30: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/30.jpg)
Boolean Operation: AND
AND also takes two inputsWritten asReturns 1 when both values are 1
1 when a AND b are 1; 0 otherwise
0 00 11 01 1
a b a b
a b
a
b
![Page 31: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/31.jpg)
Boolean Operation: XOR
First slightly unfamiliar idea: XORXOR computes “exclusive or” Written as 1 when a or b, but not both, are 1
0 00 11 01 1
a b a b
a b
a
b
![Page 32: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/32.jpg)
Boolean Operation: NAND
NAND computes NEGATIVE ANDWritten as
Combines notation for AND & NOT
1 when either value is 0 Equivalent to negation of AND
0 0 10 1 11 0 11 1 0
a b a b
a b
a
b
![Page 33: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/33.jpg)
Boolean Operation: NOR
Last operation is NEGATIVE ORWritten as 1 when both values are 0
Also equal to negation of OR
0 0 10 1 01 0 01 1 0
a b a b
a b
a
b
![Page 34: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/34.jpg)
Creating Truth Tables
There is a secret to making the inputs1st input – Alternate one 0 and one 12nd input – Repeat two 0s then two 1s3rd input – Repeat four 0s then four 1s4th input – Repeat eight 0s then eight 1s
Start with row of all 0s Stop when you reach a row with all 1s
![Page 35: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/35.jpg)
Create the Truth Table
( ) ( ) c a a b
![Page 36: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/36.jpg)
Drawing Logic Diagrams
Often use results from one gate as input into another gate
Show by connecting wire from first gate’s output to second gate’s inputE.g., result from used in ( ) a b cb c
b
c
a
![Page 37: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/37.jpg)
Computing Propagation Delay
Set initial delay for circuit inputs to 0For each gate whose input’s delays are known
Find the input with the longest delay Add 1 to this delay time
Set gate’s delay to this new time
Keep going until delay for entire circuit is known
![Page 38: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/38.jpg)
Draw the Circuit
( ) ( ) c a a b
![Page 39: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/39.jpg)
More About Boolean Properties
Properties identify equivalent circuitsE.g., circuits with identical truth table results
Many ways we use these propertiesReduce delays by doing more work in parallelSimplify circuits by removing useless gates
0 1 0
1 0 1
aa a
![Page 40: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/40.jpg)
Using Boolean Properties
Circuit Property Used(c·d)+(d+c) Identity(c·d)+(d·c) DeMorgan’s(c·d)+(d·c) Double Negation(c·d)+(c·d) Commutative
c·(d+d) Distributivec·1 Complementc Identity
Reduce to c:
![Page 41: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/41.jpg)
Adder Circuits
How to know a circuit is equivalent to half-adder or full-adderCircuits are equivalent to if both truth tables
have identical outputEquivalence can be found in two ways:
Memorize circuit and its truth Memorize circuit and its truth tabletable
Check that the carry out and result match the carry, result of adding inputs together
![Page 42: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/42.jpg)
Full-Adders
Full-adder adds two input bits and the carry bit from adding previous bitOutputs result bit and another carry bit
Include new full-adder to add each bit except least significant bit
![Page 43: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/43.jpg)
Adders
Half-adder Full adder
Result
Carry Out
Result
![Page 44: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/44.jpg)
Combining Adders
Circuit adding two 2-bit numbers together
C0
Carry Out
C1
C2
A1
B1
A0
B0
![Page 45: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/45.jpg)
Computer Components
Input Unit Device through which data are entered into the computer
Output Unit Device through which data stored within computer made available to outside world
Secondary Storage Device Device which reads and writes information into computer memory
![Page 46: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/46.jpg)
von Neumann Computer Connections
![Page 47: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/47.jpg)
Harvard Computer Connections
Program
Data
![Page 48: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/48.jpg)
Palgo Loop Selection
Each of Palgo’s loops serves different purpose repeat
Executing the commands a specific number of times for
Remembering the number of times that we are executing the instructions in a loop
Very useful for lists! while
Executing a loop for as long as needed to meet a specific condition
![Page 49: CSC 110 – Intro to Computing Lecture 14: Midterm Review.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649d555503460f94a3344c/html5/thumbnails/49.jpg)
Midterm Essay
Electronic computers have gotten easier to use since they were first developed. Discuss improvements to input, output, and secondary storage devices, and software that have made these machines easier to use.For full credit, you must discuss improvements
including at least 1 input device, at least 1 output device, and at least 1 secondary storage device or program.