CSCI 170 Homework #2 Solutions
1. Suppose you have two sets A and B, each with n elements consisting of real numbers in no
particular order. Let C be the Cartesian Product of sets A and B.
(a) Devise an algorithm which takes as input A, B, and C, and outp
CSCI 170 Homework #1 Solutions
1. Write your name, student ID number, lecture time, and discussion time. Multi-page submissions must be stapled. Failure to complete any of these items will result in delays in the
grading and return of your homework assign
CSCI 170 Homework #1
Due Date: Monday, September 8th
You may submit in class on the due date, or you may submit in the dropbox (Box 7, in the lobby
of PHE. Upon entering PHE, the boxes are tucked just out of sight by the window on the left).
1. Write your
CSCI 170 Homework #2 Solutions
1. Write your name, student ID number, lecture time, and discussion time. Multi-page submissions must be stapled. Failure to complete any of these items will result in delays in the
grading and return of your homework assign
CSCI 170 Homework #5 Solutions
1. Write your name, student ID Number, which lecture you attend (MW morning, MW afternoon, or TTh afternoon), and which discussion section you attend (Mon
4pm, Mon 6pm, Tues, or Wed). Multi-page submissions must be stapled.
CSCI 170 Homework #7 Solutions
1. Write your name, student ID Number, which lecture you attend (MW morning, MW afternoon, or TTh afternoon), and which discussion section you attend (Mon
4pm, Mon 6pm, Tues, or Wed). Multi-page submissions must be stapled.
CSCI 170 Homework #8 Solutions
1. Write your name, student ID Number, which lecture you attend (MW morning, MW afternoon, or TTh afternoon), and which discussion section you attend (Mon
4pm, Mon 6pm, Tues, or Wed). Multi-page submissions must be stapled.
CSCI 170 Homework #1
Due Date: Tuesday, January 28th, 2:30pm
Submit in class or the dropbox (Box 11, rst oor of SAL, opposite the Mens bathrooms).
1. Write your name, student ID Number, which lecture you attend (MW morning, MW afternoon, or TTh afternoon)
CSCI 170 Homework #6 Solutions
1. Write your name, student ID Number, which lecture you attend (MW morning, MW afternoon, or TTh afternoon), and which discussion section you attend (Mon
4pm, Mon 6pm, Tues, or Wed). Multi-page submissions must be stapled.
CSCI 170 Homework #5 Solutions
1. Write your name, student ID number, lecture time, and discussion time. Multi-page submissions must be stapled.
2. A military has set up 4 ground stations G1 , G2 , G3 and G4 along the equator, with the
purpose of communic
CSCI 170 Homework #1 Solutions
1. Consider a sequence indicating the cost to produce a constellation of satellites. Let Cn
denote the cost to produce the nth satellite. Assumedly each successive unit will cost less
as we improve eciency, so this will be r
Graph Theory Lecture 1
An undirected graph is specied by G = (V, E). V denotes the set of vertices (sometimes
called nodes). E denotes the edges between pairs of nodes. By convention, n = |V |, m = |E|.
A self-loop is an edge to and from the same node.
Mu
CSCI 170 Homework #6
Due Date: Wednesday, June 29th, 1pm
You may submit in class on the due date, or at any time in the homework dropbox (Box 9, lobby
of PHE. Upon entering PHE, the boxes are tucked just out of sight by the window on the left).
1. Write y
Graph Theory, Lecture 2
Graph Isomorphism
Two simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are isomorphic i there exists a bijective
function f : V1 V2 , such that (a, b) E1 i (f (a), f (b) E2 .
Directed graphs
EE
352
104L
201
103
350
170
270
The abo
Advanced Induction
Associated Reading: 5.4, 5.5
Structural Induction
Consider the following recursive denition for set S. What is S composed of?
3 S.
If x S and y S, then x + y S.
In Structural Induction, we show that a result holds for all elements in
CSCI 170: Program Correctness
Associated Reading: Textbook 5.5
Warm-Up : Recall the recursive factorial function from last lecture:
factorial(n)
if n = 0 then
return 1
return n factorial(n 1)
Re-write this as an iterative function.
Loop Invariants
If you
The Well-Ordering Property
The Well-Ordering Property states that every nonempty set of nonnegative integers has
a smallest element.
Well. duh? This simple property can be used to prove some surprising things.
For example, we used the Well-Ordering Proper
CSCI 170 Homework #7
Due Date: Wednesday, July 6th, 1pm
You may submit in class on the due date, or at any time in the homework dropbox (Box 9, lobby
of PHE. Upon entering PHE, the boxes are tucked just out of sight by the window on the left).
1. Write yo
Library Research in Archaeology
Anthropological archaeology is a social science that draws on a number of other disciplines in
both the sciences and humanities in order to achieve its goals. As such, sources regarding
archaeological cultures can be found
Graph Theory
Nim: You have a certain number of stones, divided into some number of piles. On each
players turn, they may remove as many stones ( 1) as they like from a single pile. The
person who takes the last stone loses.
Give the game tree for the boar
Elementary Graph Algorithms
Depth-First Search
Given a graph G and two nodes s and t, how could we nd a path from s to t?
For example, how do we nd a path from v1 to v6 in the following graph?
V1
V3
V2
V4
V7
V5
V8
V6
Depth-rst search creates a tree, roote
Trees
An undirected graph is a tree if it is connected and has no cycles.
Any two statements imply the third:
G is connected
G has no cycles
G has n 1 edges.
Weve already talked about graphs. Why should we care if a graph happens to be a tree?
A rooted
Bayes Theorem and Expectations
There are two boxes. The rst contains 2 green balls and 7 red balls. The second contains 4
green balls and 3 red balls. You choose a box at random, then you choose a ball at random.
You draw out a red ball. What is the proba
Probability Theory
Average-Case Complexity of Insertion Sort
Let Xi be the random variable that returns the number of comparisons needed to insert ai
into the presorted list containing a1 , a2 , ., ai1 .
E(X) = E(X1 + X2 + . + Xn ) = E(X1 ) + E(X2 ) + . +
Conditional Probability and Independence
A Bernoulli trial is an experiment with two outcomes that do not necessarily have equal
probability (for example, a biased coin). We consider one outcome the success and the
other outcome the failure.
The probabili
Counting
How many ways are there to arrange 10 people in a line, where two lineups are considered identical if they are mirror images of each other?
In a version of BASIC, variables can be one or two alphanumeric characters (lower
case or capitalized le
Advanced Counting: Generalized Permutations and
Combinations
A message on a Twitter-like service consists of exactly r characters. Because it is the
internet, people only communicate using capital letters, spaces, and the exclamation
mark. How many diere
The Pigeonhole Principle
Chess is played on an 8 8 board. The Queen piece can attack any square horizontal,
vertical, or diagonal from it. Prove that if there are 9 queens on the board, two of them can
attack each other.
The Pigeonhole Principle: If k is
CSCI 170 Lecture 1: What is Discrete Mathematics?
XKCD # 263: Certainty. a(b + c) = (ab) + (ac). Politicize that.
The primary goal of this course is to build problem solving skills which will serve you well throughout the
CSCI curriculum and your career.
CSCI 170 Lecture 7: First-Order Logic
Warm-Up: Consider the predicate has(x, y), where xs universe is the set of all dogs, and ys universe is
the set of all tails. Translate the following statements.
xy has(x, y).
yx has(x, y).
yx has(x, y).
xy has(x,
CSCI 170 Lecture 5: Propositional Logic
The building block of logic is the proposition: a statement which declares a fact that is either true or false.
Exercise 1. Which of these are propositions?
Yes
No
36 is a prime number.
Spaghetti grows on trees.
Go
CSCI 170 Lecture 10: Inductive Proofs
Let P (n) be the predicate that the following summation is true:
that P (n) is true for all integers n > 0.
Pn
i=1
i=
n(n+1)
.
2
Suppose we want to prove
Proof Technique: Inductive Proof. Suppose you want to prove a t
CSCI 170 Lecture 14: Introduction to Graphs
An undirected graph is specified by G = (V, E). V denotes the set of vertices (sometimes called nodes). E
denotes the edges between pairs of nodes. By convention, n = |V |, m = |E|.
A self-loop is an edge to and