ECS 20 Midterm Exam Solutions
1.
3
Ans :
3
2
[(i 1) + (i 2)]
(i j ) =
i=1
i=1 j =1
= [(1 1) + (1 2)] + [(2 1) + (2 2)] + [(3 1) + (3 2)] = 3
2. Ans: By the denition, f : R R and
f (x) = (g h)(x) = g (h(x) = (x4 )1/8 =
| x |.
f is not one-to-one. For examp
ECS 20 Homework 5 Solutions
1. Prove that the product of two odd numbers is odd.
Proof: We use the direct proof. An odd number is of the form 2n + 1, where n is an
integer. Let a and b are two odd numbers, say a = 2n + 1 and b = 2m + 1. Their product
is a
ECS 20
Chapter 12, Languages, Automata, Grammars
1. Introduction
1.1. Computer programming languages must be defined in a manner that allows programmers to write compilers to
translate the languages into machine code.
1.2. People use regular expressions f
ECS 20 Due: January 19th by 4:00pm
Homework #1, Propositional Calculus (44 points)
Winter 2012
From text (13 points) : 4.6 4.9, 4.20 4.28 (1 points each) 1. (6 points) a. Write a truth table for (p q) (p q) using Method 1 (slowly grow parts of the express
ECS 20 Due: January 26th by 4:00pm Each problem is worth 4 points.
Homework #2, Proofs and Set Theory (52 points)
Winter 2012
From text: 1.31a, 1.38a, 1.38b, 1.52, 1.56. 1.59c 1. Given A = cfw_1, 2, ., 9, B = cfw_2, 4, 6, 8, C = cfw_1, 3, 5, 7, 9, D = cfw
ECS 20
Chapter 13, Finite State Machines, and Turing Machines
1. Introduction
1.1. Finite State Machines (FSM) are similar to Finite State Automata (FSA) except an FSM prints out output using an
output alphabet
2. Finite State Machines
2.1. A finite state
ECS 20
Homework #4, Counting Techniques and Recursion (50 points)
Winter 2012
Due: Thursday, February 16th by 4:00pm
1. (5 points) Hexadecimal numbers are numbers using base 16, instead of the usual base 10, and are made using the
sixteen digits 0, 1, 2,
1
Solutions of ECS 20 Final Review Exercises, Spring 2013
1. (a) First show that A B A B : Let x A B . Then x A B , x A or x B . It follows
that x A or x B . Then x A B .
Reversing the steps shows that A B A B .
(b) Solution: draw yourself.
2. (a) R = cfw
ECS 20
Homework #7, Binary Trees (43 points)
Winter 2012
Due: Tuesday, March 13th by 4:00pm
1. (20 points, 1 point each) Answer the questions based on the following tree, T.
45
20
70
5
1
35
7
24
65
40
77
68
a) Is the tree a binary tree? Why or why not?
b)
ECS 20
Homework #3, Functions and Algorithms (34 points)
Winter 2012
Due: Wednesday, February 1st by 4:00pm
1. (5 points) Given B = cfw_2, 4, 6, 8, and C = cfw_1, 3, 5, 7, 9, and a relation f from B to C.
a. If f = cfw_(2, 3), (6, 1), (4, 3), (8, 7), is f
ECS 20
Homework #6, Graph Theory (50 points)
Winter 2012
Due: Tuesday, February 28th by 4:00pm 1. (4 points) Provide the result of the final operation after each series of operations is executed. a) On a stack: push(7), push(12), pop(), push(15), top(), p
ECS 20
Homework #5, Probability (50 points)
Winter 2012
Due: Wednesday, February 22nd by 4:00pm
1. (5 points) In role playing games a wide variety of dice are used because the games do not want to be limited to the 1 in
6 probabilities of a 6-sided die. A
ECS 20 - Sean Davis
Winter 2012
Handy Induction Template
Induction is a proof technique thats applied to objects that are somehow indexed by a natural number one way to
think of this index is as their size. Most induction proofs will follow the same gener
ECS 20
Proof Methods
0. Introduction 0.1. Both discovery and proof are integral parts of problem solving. The "discovery" is thinking of possible solutions, and the proving ensures that the proposed solution actually solves the problem. 0.2. A "proof" is
ECS 20
Chapter 10, Binary Trees
1. Introduction
1.1. Because of their property of dividing data into two, not necessarily equal parts, binary trees can be used to
organize data in a variety ways.
2. Binary Trees
2.1. Tree = a finite set of one or more nod
ECS 20
Chapter 4, Logic using Propositional Calculus
0. Introduction to Discrete Mathematics. 0.1. Discrete = Individually separate and distinct as opposed to continuous and capable of infinitesimal change. Integers vs. real numbers, or digital sound vs.
ECS 20
Chapter 1, Set Theory
1. Intro to Sets.
1.1. Let D = cfw_1, 3, 5, 7, E = cfw_3, 4, 5, F = cfw_2, 4, 6 for this handout.
2. Sets and elements
2.1. Definition of set: An unordered, but well-defined, collection of objects called elements (or members)
ECS 20 Homework 7
1. Problem 6.11
Ans: available in the textbook
2. Problem 6.31
Ans: available in the textbook
3. Problem 6.32
Ans: available in the textbook
4. Problem 6.34
Ans: available in the textbook
5. Consider the nonhomogeneous linear recurrence
ECS 20 Homework 1, Partial Solutions
Problem 1.30
(a) Proof: First, we should show that A\B and A B are disjoint, i.e., (A\B ) (A B ) = . This
is simply due to the facts that all elements of A B are also elements of B , and that no elements
of A\B are el
ECS 20 Homework 2, Partial Solutions
Problem 2.30: Prove that if R is an equivalence relation on a set A, then R1 is also an equivalence
relation on A.
Proof: First recall that if R is a relation on A, then the inverse relation of R is given by
R1 = cfw_
ECS 20 Quiz 1 (50 pts)
Solutions
1. Consider the universal set U = cfw_1, 2, . . . , 9 and sets A = cfw_1, 2, 5, 6, B = cfw_2, 5, 7, C = cfw_1, 3, 5, 7, 9.
Find
(a) A B =
Ans: A B = cfw_2, 5
(b) AC =
Ans: AC = cfw_3, 4, 7, 8, 9
(c) A B =
Ans: A B = (A\B )
ECS 20 Quiz 2 (50 pts)
Solutions
1. Find the number of relations from A = cfw_a, b, c to B = cfw_1, 2
Ans. There are 3 2 = 6 elements in A B , and hence there are m = 26 = 64 subsets of A B .
Thus there are 64 relations from A to B .
2. Consider the relat
ECS 20 Quiz 4 (50 pts)
Solutions
1. Find the truth table for p q
Answer: The truth table
p
T
T
F
F
q
T
F
T
F
p
F
F
T
T
q
F
T
F
T
p q
F
F
F
T
2. Verify that the proposition p (p q ) is a tautology
Answer: The following table shows the truth values for the
ECS 20 1. Introduction 2. Combinations with Repetitions
Chapter 6, Advanced Counting Techniques, Recursion
+ - 1 2.1. For M kinds of objects, the number of combinations of r such objects is C(r + M 1, r) = (+-1)! + - 1 = C(r + M 1, M 1) = = . !(-1)! - 1
ECS 20
Chapter 7, Probability
1. Introduction
1.1. Probability theory is a mathematical modeling of the phenomenon of chance or randomness.
2. Sample Space and Events
2.1. Sample space is the set of all possible outcomes of a given experiment. Notice that
ECS 20
Chapter 5, Techniques of Counting
1. Introduction
1.1. If you flipped two coins 50 times, how many times would you get exactly one head? What is the probability of
having two heads?
1.2. Computer scientists rely on probability to develop algorithms
ECS 20
Chapter 8, Graph Theory
1. Introduction, Data Structures
1.1. The atom of computer memory is a byte. Each byte is capable of holding 256 different values, 0-255. Each
byte has its own address. The post office boxes in a post office are a good analo
ECS 20
Chapter 3, Functions and Algorithms
1. Introduction 1.1. Functions "map" one object to another object. The objects can be anything, e.g. numbers, sets, or cities. We will concentrate on integers. 1.2. Algorithms are finite, step-by-step, lists of w