Fall 2015
CS330 Algorithms
Midterm exam
Midterm exam
Only a single hand-written crib sheet can be used, no books or notes.
You must prove your answer to every question. Please, write legibly and
neatly!
Wild guessing is not recommended. You will get some
CAS CS 112 Spring 2012 Programming
Assignment 4
Due at 10:00 pm on Thursday, March 29
1
Visualizing Binary Trees [79 pts]
In this assignment, we will augment the binary tree classes presented in the textbook with
routines to create large binary trees by r
CAS CS 112 Spring 2012, Assignment 5
Due at 10:00 pm on Thursday, April 12
Anagram Solver
In this assignment you will implement a program which prints out all anagrams of a specied
string. Two strings are anagrams of one another if by rearranging letters
CAS CS 112 Spring 2012, Programming Assignment 6
Due at 10:00 pm on Thursday, May 3
In this assignment you have to investigate the structure of a real world graph using some
of the techniques that we discussed in class. The graph that you will use is a co
CS 330 Spring 2013, Assignment 1
Problems due at the beginning of class on Thursday January 31.
Our rst homework has several questions that require short proofs. In writing up proofs, try to make sure your
reasoning ows logically from one statement to ano
Fall 2015
CS330 Algorithms
Homework 1
Homework 1, due Sept 16
You must prove your answer to every question by a convincing explanation
(in complete sentences). Just writing a formula or yes/no is not sufficient.
I encourage you to type up your problem set
CS 330 Spring 2013, Midterm Study Questions
Exam will be closed book
Question 1. Suppose you have a set of N gold coins of which all but one have identical weight. The exception is
a single fake coin that weighs less than real coins. To detect the fake, y
4.8 Huffman Codes
These lecture slides are supplied by Mathijs de Weerd
Data Compression
Q. Given a text that uses 32 symbols (26 different letters, space, and
some punctuation characters), how can we encode this text in bits?
Q. Some symbols (e, t, a, o,
Interval Scheduling: Greedy Algorithms
and
Dynamic Programming
d
e
f
b
c
g
h
a
0
1
2
3
4
5
6
7
8
9
10
Slides based on Kevin Wayne / Pearson-Addison Wesley
11
Time
Overview of Interval Scheduling
The Basic Interval Scheduling Problem
Schedule as many non-o
CS 330: Notes on Asymptotic Notation
by Leo Reyzin
Computer scientists usually measure resources consumed by algorithms as a function of input size.
(Typically we measure time, but we may be interested in other resources, such as memory, power,
network ba
CS 330 Spring 2017 Lab 5
Question 0. Do before lab
A
4
C
2
1
S
3
1
T
3
3
4
2
B
D
Find the shortest path from S to T by running Dijkstras Algorithm on the above graph.
Find a minimum spanning tree by running Prims Algorithm on the above graph (initialize
CS 330 Spring 2017 Lab 4 Solution
Question 1. Dijkstra Algorithm
Given the Graph G, find the shortest path from s to t.
Boston University
1
Prof. John Byers and Prof. Dora Erdos
Question 2.
Given currency denominations: 1, 5, 10, 25 and 100
(a) Specify a
CS 330 Spring 2017 Lab 6 (Midterm Review)
Question 1.
A
5
3
1
F
5
B
C
1
2
1
4
D
5
E
Consider this graph:
(a) Show the result of running Dijkstras algorithm on the above graph starting at node A.
(b) Show the sequence of edges that are added to the M ST wh
CS 330 Spring 2017 Lab 4
Question 1. Dijkstra Algorithm
Given the Graph G, find the shortest path from s to t.
Question 2.
Given currency denominations: 1, 5, 10, 25 and 100
(a) Specify a greedy algorithm for giving change which minimizes the number of co
CS 330 Spring 2017, Assignment 2 Solutions
Question 1. Chapter 3, Exercise 9, on p. 110.
Claim 1. There must be some node v, not equal to s or t, such that deleting v from G destroys all s to t paths.
Existence of v
Denote the distance between s and t by
Fall 2015
CS330 Algorithms
Homework 1
Homework 1, due Sept 16
You must prove your answer to every question by a convincing explanation
(in complete sentences). Just writing a formula or yes/no is not sucient.
I encourage you to type up your problem sets.
Fall 2015
CS330 Algorithms
Homework 2
Homework 2, due Sept 23
You must prove your answer to every question by a convincing explanation (in
complete sentences). Just writing a formula or yes/no is not sucient.
In the problem below, you will be writing Pyth
Fall 2015
CS330 Algorithms
Homework 1
Homework 1, due Sept 30
You must prove your answer to every question by a convincing explanation
(in complete sentences). Just writing a formula or yes/no is not sufficient.
Problem 1 (20pts) Suppose that you are a tr
Fall 2015
CS330 Algorithms
Homework 2
Homework 2, due Sept 23
You must prove your answer to every question by a convincing explanation (in
complete sentences). Just writing a formula or yes/no is not sufficient.
In the problem below, you will be writing P
Interval Scheduling
B
C
A
E
D
F
G
H
0
1
2
3
4
5
6
7
8
9
10
11
0
1
2
3
4
5
6
7
8
9
10
11
Time
Interval Scheduling
B
C
A
E
D
F
G
H
0
1
2
3
4
5
6
7
8
9
10
11
3
4
5
6
7
8
9
10
11
B
0
1
2
Time
Interval Scheduling
B
C
A
E
D
F
G
H
0
1
2
3
B
0
1
2
4
5
6
7
8
9
10
4.8
Huffman Codes
These lecture slides are supplied by Mathijs de Weerd
Data Compression
Q. Given a text that uses 32 symbols (26 different letters,
space, and some punctuation characters), how can we encode
this text in bits?
Q. Some symbols (e, t, a, o,
CS 330 Spring 2016 Lab 5
Question 1 Let A be an unsorted array of n integers. Assume that all of the n integers are distinct.
(a) Give a (very simple) algorithm to nd the absolute minimum (i.e. the smallest element) in A. Explain
why the absolute minimum
CS 330 Spring 2013, Assignment 6
Problems due in the drop-box by 5PM, Thursday, April 18th (Monday schedule that day)
Late assignments will only be accepted up until 5PM on Friday, April 19th
Question 1 (10 pts). Chapter 6, Exercise 13, on p. 324. [Hint:
Algorithms
Pter Gcs
Freely using the textbooks by
Kleinberg-Tardos and Cormen-Leiserson-Rivest-Stein,
and the slides of Kevin Wayne
Computer Science Department
Boston University
Fall 2015
It is best not to print these slides, but rather to download them
f
Fall 2015
CS330 Algorithms
Homework 9
Homework 9, due Nov 18
You must prove your answer to every question by a convincing explanation
(in complete sentences). Just writing a formula or yes/no is not sucient.
Problem 1 A human-resources manager called Imel
Fall 2015
CS330 Algorithms
12
v1
v2
15
s
3
4
Homework 7
7
t
5
v3
v4
10
10
Figure 1: A ow network
Homework 7, due Nov 4
You must prove your answer to every question by a convincing explanation
(in complete sentences). Just writing a formula or yes/no is no
Fall 2015
CS330 Algorithms
Homework 8
Homework 8, due Nov 11
You must prove your answer to every question by a convincing explanation
(in complete sentences). Just writing a formula or yes/no is not sucient.
Problem 1 (10pts) At a wedding, each of the 120
CS 330 Spring 2017, Assignment 3 Solutions
Question 1.
For each node in the tree, keep track of three values:
left_height[v] = longest path length from v to any leaf in its left subtree
right_height[v] = longest path length from v to any leaf in its right