Uploaded by saad.hansrod3

ITM 207 - Notes

advertisement
ITM207 - Notes
Week 1
Natrual numbers
Zero and any numbers obtained by adding 1 to it
0, 3, 100, 100000
Negative number
A number with a - sign before it
-1, -4, -1000, -10100
Integers
A natural number, a negative number
Ex: 249, 0, -324232, -34
Rational numbers
An integer or the quotient of two integers
Ex: -249, -1, 0, 3/7, - ⅖
Decimal base
Numbers from 0-9
“A number system which uses digits from 0 to 9 to represent a number with
base 10 is the decimal system number. The number is expressed in base-10 where
each value is denoted by 0 or first nine positive integers. Each value in this number
system has the place value of power 10.”
Positional Notation
Ex: 600 + 40 + 2
600 ones + 40 ones + 2 ones
642 is 600 + 40 + 2 in BASE 10
The base of a number determines the number of different digit symbols (numerals)
an the values of digit positions
BECAUSE
6 x 10^2 = 6 x 100 = 600
4 x 10^1 = 4 x 10 = 40
2 x 10^0 = 2 x 1 = 2
(2 is like this because it is a base number 0-9)
The Base Equation would be
dn * Rn - 1 + dn - 1 * Rn - 2 + ... + d2 * R1 + d1 * R0 >>> D is the digit in the ith position, n is
the number of digits in the number
Equation of 642 would be:
642 is 6 x 10^2 + 4 x 10 + 2 x 1
What if 642 has a base of 13?
+ 6 x 13^2 = 1014
+ 4 x 13^1 = 52
+ 2 x 13^0 = 2
= 1068 in base 10
642 in base 13 is 1068 in base 10
Binary
Decimal in base 10 an has 10 digit symbols
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Binary is base 2 an has 2 digit symbols
0, 1
For a number to exist in a given base it can only contain digits in that base from 0 up to but
not including the base
Bases higher than 10
How are digits in bases higher than the 10 represented
With distinct symbols for 10 an above
Base 16 has 16 digits
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F
What bases can these numbers be in? 122, 198, 178, G1A4
Converting hexadecimal to decimal
D x 16^2 = 13 x 256 = 3328
+ E x 16^1 = 14 x 16 = 224
+ F x 16^ º = 15 x 1 = 15 = 3567 in base 10
Check slides for Octal stuff…
All dividing stuff is in Lecture slides
Binary Numbers and computers
Low voltage = 0
High Voltage = 1
All bits have 0 or 1
Or other way around but we dont have to worry about that
Bytes
8 bits The number of bits in a word determines the word length of the computer,
which is usually a multiple of 8.
• 32-bit machines • 64-bit machines • Etc. Binary and Computers
Practice equation
Tips:
Start from left of number always
(11011101) = (?)base10
1x2^0 = 1
0x2^1= 0
1x2^2= 4
1x2^3 8
1x2^4 16
0x2^5 0
1x2^6 64
1x2^7 128
It all Equals 221
Week 2
Analog and Digital Information
Information can be represented in One of Two Ways: Analog or Digital
Analog Data
A continuous representation, analogous to the actual info it represents
Digital Data
A discrete representation breaking the information up into separate elements
Computers cannot work well with Analog data, so we digitize the data
Digitize
Break data into pieces and represent those pieces separately
- Those discrete elements are individually represented using binary digits
Why do we use Binary to represent digitised data?
Electronic Signals
Important facts about electronic signals
- An Analog Signal continually fluctuates in voltage up and down
- A digital signal has only a high or low state corresponding to the two binary digits
- All electronic signals (Both Analog and Digital) Degrade as they move down a line
- The voltage of the signal fluctuates due to environmental effects
Digital signal: Jump sharply b/w two extremes referred as pulse-code modulation (PCM)
Periodically a Digital signal is reclocked to regain its original shape as long as it is reclocked
before to much degradation occurs no info is lost
Binary Representations
- Each bit can be either 0 or 1, so it can represent a choice between two possibilities
(or “two things)
- Two bits can represent four things
(possible gears: Park, Drive, Reverse, Neutral // Park represented by 00, drive by 01,
reverse by 10, neutral by 11)
How many things can 3 bits represent?
Would be 8 because 2^3
How many things can 4 bits represent?
Would be 16 because 2^4
How many things can 8 bits represent?
Would be 256 because 2^8
How many bits are needed to represent 32 things? 6 Bits. One Hundred Things? 7.
How many things can n bits represent?
2^n Different things
What happens every time you increase the number of bits by one?
Representing Natural Numbers
- Convert to Binary
- Computers store data in fixed size chunks so we have leading zeros
-
What do integers include that the natural numbers do not?
Representing Negative Values
Fixed Sized Numbers
Half the natural numbers will represent themselves the other half will represent negative
integers
Using two decimal digits,
Let 1 through 49 represent 1 through 49
Let 50 through 99 represent -50 through -1
To perform addition, add the numbers and discard any carry to the hundreds digit
5 + 94 = 99 , 5 + -6 = -1
-4 + 6 = 2 , 96 + 6 = 2
-2 + -4 = -6 , 98 + 96 = 94
Now I try it
48 - 1 = 47 (Signed Magnitude)
48 - 99 = 47
To perform subtraction, use A - B = A + (-B)
Add the negative off the second to the first
-5 - (-3) = -8
New scheme 95 - 3 = -3= 97, 95 + 97 = 92
4 - 3 , 4 - (-3) , -1 - 2
—-----Called Tens Complement representation because we can use this formula to compute the
representation of a negative number
Negative (I) = 10^k -1, where k is the number of digits
For example -3 is negative(3) so using two digits its representation is
Negative(3) = 100 -3 = 97
Three digits rep = Negative(3) = 10^3 -3 = 997
Twos Complement
(The binary number line is easier to read when written vertically)
Would the tens complement formula work with the 10 replaced by 2?
Do you notice something interesting about the left most bit 1^2
Number Overflow
If each value is stored using 8 bits, then 127 + 3 overflow
01111111
00000011
= 10000010
Apparently 127 + 3 is not -126. If we were not representing negative numbers the
result would be correct
Remember when we said we would always fail in our attempt to map an infinite world
onto a finite machine
Representing Real Numbers
Real Numbers are numbers with a whole part and a fractional part (either of which
may be zero)
104.32
0.9999999
357.0
3.14159
In decimal, positions to the right of the decimal point are the tenth hundreths
thousandths etc, 10^-1 , 10^-4, 10^-5
Week 3
Gate
A device that performs a basic operation on electrical signals
Circuit
Is a electrical circuit
Boolean Expressions
Uses Boolean algebra a mathematical notation for expressing two valued logic
Logic Diagram
A graphical representation of a circuit each gate has its own symbol
Truth tables
A table showing all possible input values and associated output values
NOT GATE
A NOT Gate accepts one input signal (0 or 1) and returns the complementary
(opposite) signal as output
AND GATE
An AND Gate accepts two input signals
If both are 1 the output is 1 otherwise the output is 0
AND operation a single dot . or asterisk ‘
OR Gate
An OR Gate accepts two input signals
If both are 0 the output is 0 otherwise the output is 1
OR operation plus sign +
XOR Gate
An XOR gate accepts two input signals
If both are the same the output is 0 otherwise the output is 1
NAND Gate
The NAND NOT AND AND Gate accepts two input signals
If both are 1 the output is 0 otherwise output is 1
OR gate
Opposite of OR Gate
If both r 0 output is 1 otherwise output is 0
Gates with more Inputs
Some gates can be generalized to accept three or more input values
A three input AND gate for ex produced an output of 1 only if all input values r 1
Circuits
Combinational Citcuirt
All the input values explicitly determine the output
Sequential circuit
The output is a function of the input values and the existing state of the circuit
We describe circuit operations using
Boolean expressions
Logic diagrams
And truth tables
Combination Circuits
Gates are combined into circuits by using the output of one gate as the input for
another
Week 4
—__–__–__–__–__—__—
In Slides
Week 5
Raptor Tips & Rules & Etc..
Context -> Program Source Code -> Executables (Binaries)
-
A matter or situation regarded as unwelcome or harmful and needing to be dealt with
an overcome
A thing that is difficult to achieve
An inquiry starting from given conditions to investigate or demonstrate a fact result or
law
A proposition in which something has to be constructed
General Problem Solving
How to solve it - A new aspect of mathematical method by George Polya
1. Understand the problem
- What do I know
- What info I have to process
- What does the solution look like
- What sort of special cases exist
- How will I recognize that I have found the solution
2. Devise a Plan (Choose A Strategy)
- Divide & conquer
- Look For a pattern
- Mathematical formulation - Solve an Equation
- Daw a diagram/pic
- Guess n check
- Make a list
- Work backwards
- etc
3. Carry out the plan
4. Look Back (Reflect)
Problem Solving Process -> Understand The Problem -> Solution Design (Raptor) +
Implement Test Modify and Maintain + Multiple Iterations + Incremental Refinements
Problem Solving Strategies - How TO?
-
Break down the problem into smaller subproblems divide and conquer - Separation
of Concerns
Identify Potential patterns of similarity with previously encountered and solved
problems - reuse a known solution
Reformulate the problem or sub problem to explore potential solutions that would not
otherwise be apparent
Use abstraction to ignore unnecessary details that would otherwise constitute “Noise”
preventing you from seeing a potential solution
Use an (Iterative) incremental refinement approach - What the problem an the
solution spaces look like after each iteration changes, providing new problem
understanding and solution opportunities.
What is an Algorithim?\
EX —
What is the highest mark?
No Mark . …… 1st Mark —--> Person —> Highest Mark
Highest Mark Algo is
1. Start
2. Read first mark
3. Designate the first mark to be the highest
4. Read the next mark
5. If new mark is higher make it the new highest mark
6. IF all marks read proceed to step 7
7. Write highest mark
8. End
Bold is Processing
1. Finite duration. End occurs within a finite time from start
2. Three core elements
- Input
- Processing
- Output
3. Unambiguous statement of the solution -> Encoding into a computer program is
straight forward
4. Deterministic (Most algorithms) - For the same input the algo generates the same
output
Use random numbers for adding each other and the same random number to division
E1
E1’ = E1
E2
E2’ = E2
+
Divide “/”
Algorithm Refinement
- Add an diitional step to account for the trivial case where only a single mark is given
as input
- Use of variables and relational operators
- Use of shorthand symbols such as the assignment operator
←—-- ex of shorthand symbol
Flowchart Specification of Algorithms
Each shape has a different use - Check Slides
When enter text in Prompt box use Quotations
Download