This preview shows pages 1–3. Sign up to view the full content.
CS 103
J. Michael Fitzpatrick
Test 3 Review
Page 1 of 10
Review 3: All 14 Weeks
Textbook Coverage = Chapters 112 (entire book)
Lecture Coverage
(
Purple things were deemphasized.
)
Week 1
•
Computer science
is the study of algorithms for processing information with
computers.
•
An
algorithm
is a precise stepbystep procedure for performing a task.
•
Syntax vs. Semantics
•
Interpret vs. Compile
•
Variables
o
Rules for naming variables:
o
The = sign assigns a value to a variable
•
Matrix is a two dimensional rectangular arrangement of numbers
o
size(M)
•
K x N ~ matrix
•
N x 1 or 1 x N ~ vector or array
•
1 x 1 ~ scalar
o
Matrix elements are referenced by their row and column numbers
ex:
A(2,1)
~ element in the second row, first column.
o
Matrix Multiplication
o
Transpose
•
Operators and Functions
o
Passing input values via arguments
o
In computer programming, a function doesn’t have to give a unique value.
o
rand
is a “pseudo” random number generator
•
Colon operator
o
Increments can be negative!
C = 10 : .5 : 1
o
Can be combined with arithmetic operations:
pi*(2:0.03:7)8
Week 2
•
A
program
is a sequence of symbols that describes an algorithm.
•
Source code vs. executable code
•
Software = set of files containing source, and/or executable
•
Colon operator (continued)
•
Complex numbers
•
Subarray operations: example,
A(2:4,4:end1)
•
3D arrays: example, color image representation
•
Matrix multiplication
:
Z=X*Y
:
end
1
( , )
( , ) ( , )
k
Z m n
X m k Y k n
=
=
o
“Inner matrix dimensions” must be equal.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentCS 103
J. Michael Fitzpatrick
Test 3 Review
Page 2 of 10
o
“Outer matrix dimensions” determine shape of result.
o
Not commutative:
A*B
usually not =
B*A
o
Is associative:
A*(B*C) = (A*B)*C
•
Problems involving manufacturing materials
•
Addition:
Z=X+Y
X, Y
, and
Z
have same shape, and
( , )
( , )
( , )
Z m n
X m n
Y m n
=
+
•
Subtraction:
Z=XY
X, Y
, and
Z
have same shape, and
( , )
( , )
( , )
Z m n
X m n
Y m n
=

•
Array multiplication:
Z = X.*Y
X, Y
, and
Z
have same shape, and
( , )
( , )
( , )
Z m n
X m n
Y m n
=
•
Array division
:
Z = X./Y
or
X.\Y
X, Y
, and
Z
have same shape, and
( , )
( , )/ ( , )
Z m n
X m n
Y m n
=
or
( , )
( , ) \ ( , )
Z m n
X m n
Y m n
=
•
Dot product
•
Distributivity:
o
Multiplication distributes over addition:
example,
A*(B+C) = A*B + A*C
example,
(B+C). *A = B.*A + C.*A
o
Array division distributes over addition one way
example,
A./(B+C)
not equal to
A./B + A./C
example,
(B+C)./A = B./A + C./A
•
Array exponentiation
:
Z=X.^Y
(also called “array power”)
X, Y
, and
Z
have same shape, and
( , )
( , )
( , )
Y m n
Z m n
X m n
=
•
Matrix exponentiation
:
Z=X^p (
we don’t cover
p^X
)
X
is square and
p
is a scalar (if
X
and
p
are matrices,
error
!)
•
Diagonal matrix
•
Identity
matrix:
eye(N)
•
Inverse
of a matrix:
X^(1)
or inv(X)
o
inverseX*X = X*inverseX =
identity matrix
•
Operators
(e,g,
+, , *, /, .*, ./, ^, ‘
)
o
This is the end of the preview. Sign up
to
access the rest of the document.
 Spring '07
 FITZPATRICK
 Algorithms

Click to edit the document details