Uploaded by Camilla Ann Llamas

1 Mathematics Review

advertisement
MATHEMATICS REVIEW
Exponents
a0 = 1
a1 = a
a-m = 1 / am
Logarithms
In computer science, all logarithms are to
the base 2 unless specified otherwise
Definition:
Rules on logarithms
Proof:
Let X = logC B, Y = logCA, and Z = logAB. By
definition of logarithms,
CX = B, CY = A, AZ = B.
CX = B =( CY) Z.
X = YZ implies Z = X / Y proving the theorem.
Proof:
Let X = log A, Y = log B, Z = log AB.
Assuming the default base 2,
2X = A, 2Y = B, and 2Z = AB.
Combining the last three equalities,
2X2Y = AB = 2Z.
Therefore X + Y = Z.
Series
Series
n
n
a −1
∑i = ∑i − ∑i
i=a
i =1
where 1 ≤ a ≤ n
i =1
b
∑1 = b − a + 1
i=a
n
n
∑ ci = c∑ i
i =1
i =1
where a ≤ b
for some constant c
Recursion
Rules on Recursion
1.
Base cases.
You must always have some base cases which can be
solved without recursion.
2.
Making Progress
For the cases that are to be solved recursively, the
recursive call must always be to a case that makes
progress toward a base case.
Data Structures
Sets
Dymanic sets. Sets manipulated by algorithms can grow,
shrink, or otherwise change over time.
Algorithms may require several types of operations to
be performed on sets.
(insert, delete, test membership)
Dictionary
A dynamic set that supports insertion, deletion, and test
for membership operations
Elements of a dynamic set
Each element is represented by an object whose
fields can be examined and manipulated if we
have a pointer to the object.
Key field
Operations on dynamic set
Queries
Return information about the set
Modifying operations
Change the set
Operations on dynamic set
SEARCH (S, k)
A query that, given a set S and a key value k, returns a
pointer x to an element in S such that key[x] = k, or NIL
if no such element belongs to S.
INSERT(S, x)
A modifying operation that augments the set S with the
element pointed to by x. We usually assume that any
fields in element x needed by the set implementation
have already been initialized.
Operations on dynamic set
DELETE(S, x)
A modifying operation that, given a pointer x to an
element in the set S, removes x from S. (Note that
this operation uses a pointer to an element x, not a
key value.)
MINIMUM(S)
A query on a totally ordered set S that returns a
pointer to the element of S with the smallest key.
Operations on dynamic set
MAXIMUM(S)
A query on a totally ordered set S that returns a pointer
to the element of S with the largest key.
SUCCESSOR(S, x)
A query that, given an element x whose key is from a
totally ordered set S, returns a pointer to the next
larger element in S, or NIL if x is the maximum element.
The time taken to execute a set operation is usually
measured in terms of the size of the set given as
one of its arguments.
Download