Prove that the set of positive rational numbers is countable by showing that the function K is a one-toone correspondence between the set of positive rational numbers and the set of positive integers if
K(m/n) = p 2a1 1 p 2a2 2 p 2as s q 2b11 1 q 2b21 2 q
Prove that the set of positive rational numbers is countable by setting up a function that assigns to a
rational number p/q with gcd(p, q) = 1 the base 11 number formed by the decimal representation of p
followed by the base 11 digit A, which corresponds
Show that if a b (mod m) and c d (mod m), where a, b, c, d, and m are integers with m 2, then a c
b d (mod m).
Show that if n | m, where n and m are integers greater than 1, and if a b (mod m), where a and b are
integers, then a b (mod n).
Express in pseudocode the trial division algorithm for determining whether an integer is prime.
Prove that for every positive integer n, there are n consecutive composite integers. [Hint: Consider the n
consecutive integers starting with (n + 1)! + 2.]
Suppose that a and b are integers, a 11 (mod 19), and b 3 (mod 19). Find the integer c with 0 c 18
a) c 13a (mod 19).
b) c 8b (mod 19).
c) c a b (mod 19).
d) c 7a + 3b (mod 19).
e) c 2a2 + 3b2 (mod 19).
f ) c a3 + 4b3 (mod 19).
Show that Zm with addition modulo m, where m 2 is an integer, satisfies the closure, associative, and
commutative properties, 0 is an additive identity, and for every nonzero a Zm, m a is an inverse of a
Show that the distributive property of mul
Show that if a and b are positive integers, then ab = gcd(a, b) lcm(a, b). [Hint: Use the prime
factorizations of a and b and the formulae for gcd(a, b) and lcm(a, b) in terms of these factorizations.]
How many divisions are required to find gcd(21, 34) u
. Adapt the proof in the text that there are infinitely many primes to prove that there are infinitely many
primes of the form 3k + 2, where k is a nonnegative integer. [Hint: Suppose that there are only finitely
many such primes q1, q2,.,qn, and consider
powered by FreeFind
Modified: 09/22/2004 02:49:02
Backtracking search for CSPs
Problem structure and problem decomposition
Local search for CSPs
5.1 CONSTRAINT SATISFACTION PROBLEMS
7.1 KNOWLEDGE-BASED AGENTS
Example: Vaccum world
Initially rules and facts (e.g. if Status=Dirty then
TELL KB of percepts (e.g. Status=Dirty,
Location=A) and inference (e.g. Suck
ASK KB what to do based on rules and fac
Solving Problems by
powered by FreeFind
Modified: 09/02/2004 23:12:20
Basic search algorithms
3.1 PROBLEM-SOLVING AGENTS
Agent has map of Romania to guide journey
powered by FreeFind
Modified: 09/23/2004 23:35:24
Adversarial programs must by nature communicate some shared state such as a chess board or
moves to a new state. Obviously, the problem is more interesting and realistic
1. Constructs an array satisfying the max-heap property.
2. Sorts the array in ascending order.
Note: A.length is the length of array A, which does not change.
A.heap-size is the size of the heap, which does change.
1 A.heap-size A.length
Binary tree - recursively defined on a finite set of nodes that either
contains no nodes
is composed of three disjoint sets of nodes:
binary tree called the left subtree
binary tree called the right subtree
"Max" refers to the fact that this algorithm calls Max-Heapify, which guarantees that the
object the with the largest value is at the top of the heap.
- alters A
- post: the tree rooted at location 1 in A satisfies the he
Use recursion tree to determine a good asymptotic bound on the recurrence T(n) =
Sum the costs within each level of the tree to obtain a set of per-level costs.
Sum all the per-level costs to determine the total cost of all levels of recursion.
a line that continually approaches a given curve but does not meet it at any finite
x is asymptotic with x + 1
f(x) = k
Roughly translated might read as:
x approaches , f(x) approaches k
for x close to , f(x
Max heaps maintain the maximum heap value at array location 1.
A priority queue requires that the priority value be accessible at the head of the queue, location 1.
Example - The highest priority (max value) is array location 1.
Suggest an al
The max-heap property:
for every node i other than the root
A[ Parent( i ) ] A[ i ]
Note that the root is excluded as it has no parents.
The max-heap property means that the parent value child value
Max-Heapify function, give
4.3 OVERVIEW - Don't confuse with forward or backward substitution
Substitution as used here, refers to substituting a guess for a closed-end recurrence solution into
an induction proof.
To prove asymptotic bounds, or O, of the recurrence T(n) must show h
Sorting_Machine can be implemented by the sorting algorithms listed in the table below.
The actual work done to get the items sorted will be performed in one of the three
different sorting machine operations:
How fast can we sort?
We will prove a lower bound.
Why ( n ) as a lower bound?
The only operation that may be used to gain order information about a
sequence is comparison of pairs of elements.
if A[ i ] < A[ i + 1 ]
A[ i ] A[ i + 1]
A heap can be defined as a binary tree with one key (value) assigned to each node provided the
following two requirements are met:
Tree shape - the binary tree is essentially complete; all levels are full
except possibly the last level where on
Note that tree here means binary tree.
A complete tree is a full tree.
1. There are at most 2h leaves in a binary tree of height h.
That is the nodes at the bottom level.
h=1, no more than 21 = 2 leaves since a binary tree
2h-1 leaves at most in b
Computing the limit of the ratio of two functions is another way to classify the growth of a
What f(n) is in terms of O, , , o, and
Definition of O, , , o, and by
1. Write down for each statement the number of times the statement is executed in the worst
2. Compute T(n), i.e., the running time of Find_Largest, and simplify (if possible) by
3. What data produces the worst case? The