$5 du
Your Name:
CS 182
MIDTERM
Fall 2011
Left Neighbor: M_ Right Neighbor:
This exam contains 9 numbered pages. Check your copy and exchange it immediately if
it is defective. Print your name and your student id number on the top of this page. Print
th
CS 182 Spring 2015 Homework 6
Due date: Monday, April 6, 2015 (before class)
1. (8pts)
(a) How many ways are there to pick a sequence of two dierent letters of the alphabet that appear in
the word MATHEMATICS?
87
(b) How many ways are there to pick rst a
CS182 Spring 2016: Solution to Homework 1
Due date: Tuesday, September 4th, 2012 (before class).
1. (8pts) Show that each of these implications is a tautology by using truth tables.
(a) [q (p q)] q.
p q
T T
T F
F T
F F
pq
T
F
T
T
q (p q)
T
F
T
F
[q (p q)]
CS182
Homework 8 Sketch of Solution
Spring 2011
Question 1.
1. 2k
2. The net gain is 100 times the following:
2k (2k1 + 2k2 + + 21 + 20 ) = 2k1 (2k2 + + 21 + 20 ) = = 21 20 = 1
where we repeatedly used the fact that 2 2
1
=2
1 .
So the answer is $100.
Que
CS 182 Spring 2015 Homework 7
Due date: Monday, April 20, 2015 (before class)
1. (10pts) Assume that the probability a child is a boy is 0.6 and that the sexes of children
born into a family are independent. What is the probability that a family of 3 chil
Solutions of Homework #4: Proof Techniques
Q1. Show that 3 3 is irrational. Answer Proof by contradiction: Assume that 3 3 = p in its simplest form, i.e., both p q and q do not have a common divisor and therefore the fraction p cannot be q simplied furthe
Solutions of HW#2: Language of Mathematics
Q1. Prove that for any sets A and B, A B = A B. Answer To prove that two sets are equal, we need to prove that each set is a subset of the other: i) To prove that A B A B: x A B x A x B x Ax B / / x AB / x AB
Th
Solutions of HW#1: Basic Logic
Q.1 Make truth tables for the following statement: (p q) (q p) Answer
p T T F F q T F T F pq T F T T qp T T F T (p q) (q p) T T T T
(p q) (p q) Answer
p T T F F q T F T F p q F T T T p q T T T F (p q) (p q) F T T F
Q.2 Usin
CS 182 Spring 2015, Solutions of Midterm exam
1. Sets
To prove that two sets are equal, we need to prove that each set is a subset of the other:
a) To prove that (A B) (A B) A:
x (A B) (A B)
(x A and x B) or (x A or x B)
/
(p q) (p q ) where p : x A, q :
Trees
Margaret M. Fleck
10 November 2011
These notes cover trees and induction on trees.
1
Why trees?
Trees are the central structure for storing and organizing data in computer
science. Examples of trees include
Trees which show the organization of real
Sets of Sets
Margaret M. Fleck
7 November 2011
These notes present topics involving counting subsets and sets which contain other sets.
1
Sets containing sets
So far, most of our sets have contained atomic elements (such as numbers or
strings) or tuples (
State Diagrams
Margaret M. Fleck
14 November 2011
These notes cover state diagrams.
1
Introduction
State diagrams are a type of directed graph, in which the graph nodes represent states and labels on the graph edges represent actions. For example,
here is
CS182
Homework 7
Spring 2011
Question 1. (5+5+10 points) Simplify each of the following expressions.
1. C(n 2, m) + 2C(n 2, m 1) + C(n 2, m 2)
2. C(n 3, m) + 3C(n 3, m 1) + 3C(n 3, m 2) + C(n 3, m 3)
3.
n+r
k=n C(k, k
n)
Question 2. (10+10+10 points) Sup
CS182
Homework 8
Spring 2011
Question 1. (10 points). A gambler (call him Bob) is playing at a casino the following
game: Bob can bet any amount he wishes, then a fair coin is tossed, and if the outcome
of the toss is heads he wins an amount equal to his
CS182
Homework 7 Sketch of Solution
Spring 2011
Question 1.
1. C(n, m) for the following reason. First, recall that in class we interpreted C(n, m) as
the number of paths that, in n horizontal or vertical positive unit steps, go from (0, 0)
to (n m, m). T
CS182 Spring 2016: Homework 2
Due date: Friday, February 5, 2016 (before class).
1. (12 pts) Let the universe of discourse be the set of all real numbers. Let P (x) be the
statement x is an integer, Q(x) be the statement x is a rational number, and R(x)
b
CS182 Spring 2016: Homework 2
Due date: Friday, February 19, 2016 (before class).
1. (8 pts) Prove or disprove the following statements:
(a) For all positive integers n, if n is a perfect square then n + 3 is not a perfect
square. (Recall the definition o
CS182 Spring 2016: Homework 5
Due date: Wednesday, March 23, 2016 (before class).
1. Let f (n) = 3n2 + 5n + 2 be the running time of Steves wonderful sorting algorithm.
Show that f(n) is O(n2 ) by identifying constants C and k such that f (n) Cn2
whenever
CS182 Spring 2016: Homework 4
Due date: Friday, March 4, 2016 (before class).
1. Prove that Z+ Z+ is countably innite.
2. Consider the set R consisting of all real numbers. Give an example of a subset S of R
with S = R such that:
(a) S is countably innite
CS182 Spring 2016: Homework 1
Due date: Friday, January 22, 2016 (before class).
1. Show that each of these implications is a tautology using truth tables:
(a) [q (p q)] q.
(b) [(p q) (p r) (q r)] r.
(c) [p (p q)] q.
(d) [(p q) (q r)] (p r).
2. Determine
CS182Foundation of Computer Science
(http:/www.cs.purdue.edu/homes/spa/cs182.html )
TH 1:302:45 in Forney Hall of Chemical Eng., G140
Professor:
E-mail:
Oce:
Oce Hours:
HEAD TA:
E-mail:
W. Szpankowski (and M. Atallah)
spa@cs.purdue.edu (only in the case o
CS182
Homework 9 Sketch of Solution
Spring 2011
Question 1.
The inorder listing of the nodes is:
mcgldpbjf koehnai
Question 2.
v is ancestor of w if and only if
P reorder(v) < P reorder(w) P reorder(v) + Desc(v) 1
v is to the left of w if and only if it
CS182
Homework 9
Spring 2011
Question 1. (10+5 points) Let T be a tree whose 16 nodes are named a, b, c, d, e, f, g, h, i,
j, k, l, m, n, o, p. A preorder traversal of T lists its nodes in the following order:
dgcmlf bpjkaeohni
A postorder traversal of T
Sets
Margaret M. Fleck
8 September 2011
These notes cover set notation, operations on sets, measuring the size of
sets, and proving claims involving sets. They also discuss vacuous truth.
1
Sets
So far, weve been assuming only a basic understanding of set
Relations
Margaret M. Fleck
5 February 2011
These notes cover the basics of relations.
1
Relations
A relation R on a set A is a subset of A A, i.e. R is a set of ordered pairs
of elements from A. If R contains the pair (x, y), we say that x is related to
CS 182 Spring 2015 Homework 8
Due date: Friday, May 1, 2015 (before class)
Total points: 100
1. (20pts) Solve the congruence
(a) 7x 4 (mod 12).
Notice that gcd(12,7) = 1, so an inverse of 7 modulo 12 exists. gcd(12,7) = 1 =
3 12 5 7. Thus, 5 is an inverse
CS 182 Spring 2015 Homework 8
Due date: Friday, May 1, 2015 (before class)
Total points: 100
1. (20pts) Solve the congruence
(a) 7x 4 (mod 12).
(b) 2x 7 (mod 17).
2. (20pts) Find the solutions to the following system of congruence.
x 1
x 2
x3
x 4
x 5
(mod
CS 182 Spring 2015 Homework 7
Due date: Monday, April 20, 2015 (before class)
1. (10pts) Assume that the probability a child is a boy is 0.6 and that the sexes of children
born into a family are independent. What is the probability that a family of 3 chil