Answers for Homework 1
Abbreviations. IH = Induction Hypothesis.
TLR = The Limit Rule.
(i) PG Problem 20.
We take the hint and rst show: 2n > 2n + 1 for all
n 3.
B ASE CASE . 23 = 8 > 7 = 2 3 + 1.
I NDUCTION STEP. IH: 2n > 2n + 1 for some n 3.
We need to
CIS 675 Fall 2015 Homework 1
Instructions: Submit your solutions in a pdf le to Blackboard by midnight
Eastern time on September 24, 2015. Late submissions will not be accepted!
All answers must be proved: it is not sucient to simply state the answer.
You
CIS 675, Spring 2012
Solution of Homework 2
Solution of 1.2:
Take any number N , where (N 1). The number of bits needed to represent N in
binary is log2 (N + 1) and the number of digits needed to represent N is log10 (N + 1) .
But, we know that log2 (N +
Homework 1 - Solutions
Question 0.3
In this problem we will conrm that this sequence grows exponentially fast and obtain some bounds on its
growth.
(a) Use induction to prove that Fn 20.5n for n 6.
Ans:
Proving the result for the base case
Let n = 6
F6
F6
CIS 675, Spring 2012
Solutions of Homework 3
Question 2.4
Suppose you are choosing between the following three algorithms.
Algorithm A solves problems by dividing them into ve sub-problems of half the
size, recursively solving each sub-problem, and then
Homework 3 - Solutions
Question 2.5
Solve the following recurrence relations and give bound for each of them.
(a) T (n) = 2T ( n ) + 1
3
Ans:
Use Master Theorem; a = 2, b = 3 and d = 0.
logb a = log3 2 = 0.63
So, logb a > d and T (n) = (nlog3 2 )
(b) T (n
Greedy Algorithms
CIS 675
Greedy Algorithms
Not easy to define what we mean by "greedy
algorithm"
Generally means we take little steps, looking
only at our local choices
Often among the first reasonable algorithms
we can think of
Frequently doesn't le
Dynamic Programming
CIS 675
Introduction to Dynamic Programming
Dynamic programming is a method of solving a
problem in which the solution to a large problem is
based on the solutions to smaller sub-problems
CIS 675
Introduction to Dynamic Programming
D
Graphs
CIS 675
Map-Coloring
Suppose you are trying to pick colors for a map
If two countries are next to each other, they
should have different colors
How do you pick the colors?
CIS 675
Graphs
A natural representation for this problem is a graph
Gra
Preliminaries
CIS 675
Preliminaries
Homework 1 will be posted on Blackboard this
evening.
It is due next Thursday.
CIS 675
Recurrence Relations
CIS 675
In-Class Exercise
Solve (with proof!) the following recurrences:
1.
2.
3.
4.
5.
6.
T(0) = 1, T(1) = 0
Preliminaries
CIS 675
Preliminaries
Textbook (optional): Algorithms, by Dasgupta,
Papadimitriou, Vazirani
Thomas H. Cormen, Charles E. Leiserson,
Ronald L. Rivest, and Clifford Stein.
Introduction to Algorithms, 3rd edition, 2009.
CIS 675
Asymptotic Ana
About Exam 2
1. Next Tuesday (April 4th, 2017).
2. Its a closed-book exam, you CANNOT use any notes, textbook,
electronic devices.
4. It will cover:
Greedy algorithms
Linear Programming, network flows
Dynamic programming
Amortized analysis
Preparing for E
Homework 1 Solutions
0.4
a) Show that two 22 matrices can be multiplied using 4 additions and 8 multiplications?
Lets take any two 22 matrices denoted by X and Y.
Let X = [
So, XY = [
] and Y = [
][
]
] =[
]
So it is evident that every entry of XY is the
NP-Complete Problems
CIS 675
NP-Completeness
Tricky use of reductions: If Problem A does not
have a polynomial time solution and it reduces to
Problem B, then Problem B also does not have a
polynomial time solution!
A search problem is NP-complete if ev
NP-Complete Problems
CIS 675
Algorithm Running Time
We have seen a lot of algorithms with polynomial
running time.
This means that the running time is O(nk), where k
is some fixed constant that does not depend on n.
Is O(n log n) polynomial?
CIS 675
Al
DESIGN AND IMPLEMENTATION
OF SUN NETWORK FILE SYSTEM
Presented BySAMEER SAI
BOBBY JASUJA
Introduction
Sun NFS is a distributed file system that provides remote access to
files.
Developed by Sun Microsystems in 1984
Build over UNIX kernel
Latest version NF
Preliminaries
CIS 675
Preliminaries
Homework 1 due Thursday!
Note: assume array copying is O(n) time.
CIS 675
Divide-and-Conquer
CIS 675
Overview
A divide-and-conquer algorithm has three main
steps:
1. Break the problem into smaller subproblems
2. Recur
Asymptotic Analysis
CIS 675
Big-O Notation: Definition
f(x) = O(g(x) means that
There exists:
some positive constant M
some minimum x-value x0
Such that for all x > x0:
f(x) M * g(x)
CIS 675
Other Types of Asymptotic Relationships
Little-o notation:
CIS 675, Spring 2012
Homework1
Due on Thursday, February 2
Note: This homework is worth two homeworks; take two weeks to do it.
Problem
Problem 0.4 (page 9) of the text (Dasgupta et al.)
1
CIS 675, Spring 2012
Homework 2
Due on Thursday, February 9
Problems There are ve problems in this homework; solve problems 1.2, 1.5, 1.6, 1.10,
and 1.13 from Chapter 1 of the text.
CIS 675, Spring 2012
Homework 3
Due on Thursday, February 16
Problems There are ve problems in this homework; solve problems 2.5, 2.12, 2.13, 2.17
and 2.19 from Chapter 2 of the text.
CIS 675, Spring 2012
Solution of Homework 2
Question 1.15 Determine necessary and sucient conditions on x and c so that the
following holds: for any a, b, if ax bx mod c, then a b mod c.
Answer: The necessary and sucient condition is that x and c must be
SOLUTION
CS515: Algorithms
Fall 2010
Midterm
Name:
Instructions: Each question is worth 10 points. There are 4 questions. Write the answer to each question
in the space provided, using the back of each sheet as necessary. The nal sheet is blank and may be
CIS 675, Spring 2011
Quiz 1
Thursday, February 23
Name
Problem 1
Is (530,000 6123,456 ) a multiple of 31?.
Solution:
1
2
Problem 2 Find the inverse of 20 modulo 79. That is, nd an integer a, 1 a 78
such that a 20 = 1 modulo 79.
Solution:
3
Problem 3 Suppo
Mid-term Exam Answers and Final Exam
Study Guide
CIS 675
Summer 2010
Midterm Problem 1: Recall that for two functions g : N N+ and
h : N N+ , h = (g ) i for some positive integer N and positive real
numbers c1 and c2 , for every n N , c1 g (n) h(n) c2 g (
Answers for Homework 4
CIS 675 ? Algorithms
(i) DPV Problem 2.5.
September 21, 2009
So the recursive call is search( A, x, m, r). But since m = , this is an
innite recursion.
(a) T (n) = 2T (n/3) + 1. So a = 2, b = 3, and d = 0. Thus 0 = d <
logb a = log3
Answers for Homework 3
CIS 575 ? Algorithms
September 11, 2008
(i) Fermats Corollary.
(iv) DPV Problem 1.39.
c
c
Suppose p is prime, 1 a < p, and n > 0. Show that: am an By Fermats Little Theorem: ab ab mod ( p1) (mod p).
c
(mod p), where n is m mod ( p 1
Answers for Homework 2
CIS 675 ? Algorithms
September 7, 2009
(i) DPV Problem 1.1.
The largest 2-digit base b number is (b 1) b + (b 1) = b2 1. The
largest sum of three 1-digit base b numbers is 3 (b 1) = 3b 3. We
need to show that b2 1 3b 3 for all b 2.