Homework 3
Fall 2013 EECE 320 UBC
1. (Sorting with few item types.)
You are given a list L of n numbers chosen, with repetitions allowed, from the set cfw_1, 2, . . . , n10 . You
are given the additio
Whats left?
Algorithms: Unambiguous instructions to accomplish some task.
To nd my name in the phone book, scan trough the names in
order until you nd mine.
Recursion: Induction for algorithms.
To n
Even number of odd vertices
Theorem:
v V
deg(v ) = 2|E | for every graph G = (V, E ).
Proof:
Theorem: Every graph has an even number of vertices with odd degree.
Proof:
1
Even number of odd vertices
T
How long does it take?
S ELECTION S ORT(A[1 . n]):
for i
1 to n
for j
i + 1 to n
if A[j ] < A[i]
swap A[i] $ A[j ]
What computer? What language? What compiler? What OS?
How long does it take to comp
A set is an unordered collection of objects, called its elements.
cfw_Groucho, Chico, Harpo, Zeppo, Gummo
=
cfw_Chico, Groucho, Harpo, Gummo, Zeppo
=
cfw_Groucho, Gummo, Harpo, Chico, Harpo, Groucho,
Examples involving mathematical induction
1. You are teaching a computer engineering course and would like to divide the students into
groups for projects such that each group has 4 or 5 students. Usi
A binary relation between A and B is a subset of A B .
A is called the domain; B is called the codomain.
A = Students; B = Classes; R = cfw_(a, b) | a is taking b this semester.
A = People; B = Peop
437
A Guide to Proof-Writing
A Guide to Proof-Writing
by Ron Morash, University of MichiganDearborn
Toward the end of Section 1.5, the text states that there is no algorithm for proving theorems . . .
e Pigeonhole Principle
Basic Geometric Problems
1.
2.
3.
4.
5.
Five darts are thrown at a square target measuring 14 inches on a side. Prove that two of
them must be at a distance no more than 10 inch
The 16 binary boolean functions
T
T
T
T
T
p_q p
q
T
T
T
T
T
F
F
T
p
T
T
F
F
q
T
F
T
F
p
T
T
F
F
q p"q p q
T
F
F
F
T
T
T
T
T
F
T
F
q
F
T
F
T
p
T
T
F
F
p!q
T
F
T
T
p9q
F
T
F
F
p
F
F
T
T
q
T
F
T
F
p$q p^
EECE 320
Graphs and Trees
Examples
EECE 320: Discrete Structures & Algorithms
Graphs and Trees
Some examples with complete solutions
1. Eulers Theorem states that for any planar graph G = (V, E ) with
Some notes on counting with polynomials and
combinatorial arguments
1
Counting with polynomials
Polynomials and their products provide very general and powerful methods to
count a variety of sets. In
Homework 2
Fall 2013 EECE 320 UBC
1. (Running times.)
(a) Suppose that you have algorithms with the running times as shown below. You may assume that these
running times are exact for an input of size
482
Common Mistakes in Discrete Mathematics
Common Mistakes in Discrete Mathematics
In this section of the Guide we list many common mistakes that people studying discrete mathematics sometimes
make.