Algorithm Analysis
CSI 3108-02, Fall 2016
Solution Set 3
(1) (50 points)
For 1 i j n and s , let P [i, j, s] be true if si sj has a parenthesization
that evaluates to s, and false otherwise. Let P [i, i, s] be true if and only if s = si .
Lemma 1. For i <

Algorithm Analysis
CSI 3108-02, Fall 2016
Assignment 4
Due at 5:00pm, Thursday, Dec 8
Hand in your solutions electronically using YSCEC. (If you use a grace period,
you must submit your solution to the course sta email on the syllabus.)
This assignment co

Algorithm Analysis
CSI 3108-02, Fall 2016
Solution Set 2
(1) (50 points)
Observation 1. There exists an optimal itinerary where one obtains a new fake ID at
each city i if and only if fi is higher than the clearance level of the current ID.
Proof. From a

Assignment 3: AST Generation
CSI4104 Compiler Design, Fall 2015
Document Version 4.2
Due date: 11:59pm, Nov 30 (Monday) 2015.
Introduction
We will extend our recursive descent parser from Assignment 2 to produce Abstract Syntax
Trees (ASTs) for MiniC. If

Assignment 4: Static Semantic Analysis
CSI4104 Compiler Design, Fall 2015
Document Version 1.3
Due date: 11:59pm, Dec 14 (Monday) 2015.
Introduction
In this assignment we will perform static semantic analysis of the ASTs that we generated
in Assignment 3.

Assignment 5: Code Generation
CSI4104 Compiler Design, Fall 2015
Document Version 1.3
Due date: 11:59pm, Dec 22 (Tuesday) 2015.
Note: no extension can be granted this time, because the university requires us to finish
marking by Dec 28.
Introduction
Congr

Assignment 2: Parser
CSI4104 Compiler Design, Spring 2015
Due date: 11:59pm, Nov 16 (Monday) 2015.
Introduction
We will implement a recursive descent parser (RD parser) for MiniC. With this assignment,
we only check the syntactic correctness of the input

CSI4101 Compiler Design
2nd Semester, 2015
Homework 1
DUE DATE for exercise 7: October 30, 2015 (to be handed in on the provided YSCEC
report section, as a pdf file).
Exercises 16 need not be handed in because youll be given the solutions for your prepara

CSI4101 Compiler Design
2nd Semester, 2015
Solutions to Homework 1
Note: no solution is given for Exercise 7. Exercise 7 is therefore the only exercise that you
should hand in on the due-date.
1. Given the alphabet = cfw_, +, x, y, z, 0, 1 and the below r

Algorithm Analysis
CSI 3108-02, Fall 2016
Solution Set 1
(1) (50 points)
Both the O(n log n)- and O(n)-time algorithm for the maximum subsequence sum problem naturally extend to the given problem. Following is a dynamic programming algorithm, written in J

Algorithm Analysis
CSI 3108-02, Fall 2016
Lecture 6
September 26, 2016
Today we will formally analyze the correctness of the algorithm we have designed for the
closest pair problem. We will stick to the top-down implementation of the algorithm.
Algorithm

CS 4820 PRELIM
There are five questions on this exam, for a total of 60 points. Please make sure you are not missing
any pages. The point breakdown is as follows:
1 = 5 points (1a = 4, 1b = 1)
2 = 10 points (2a = 4, 2b = 3, 2c = 3)
3 = 10 points (3a = 4,

Algorithm Analysis
CSI 3108-02, Fall 2016
Lecture 10
October 12, 2016
Problem 1 (Longest nondecreasing subsequence). Given a sequence of integers a1 , . . . , an ,
find a longest subsequence (which is not necessarily contiguous) that is nondecreasing.
Las

Algorithm Analysis
CSI 3108-02, Fall 2016
Lecture 9
October 10, 2016
Last class we considered the following problem.
Problem 1 (Longest nondecreasing subsequence). Given a sequence of integers a1 , . . . , an ,
find a longest subsequence (which is not nec

Algorithm Analysis
CSI 3108-02, Fall 2016
Assignment 2
Due at 5:00pm, Tuesday, Oct 18
Hand in your solutions electronically using YSCEC.
This assignment consists of one written assignment, and will count as half an
assignment when the final grade is calcu

Algorithm Analysis
CSI 3108-02, Fall 2016
Lecture 8
October 5, 2016
Last class we considered the following problem and gave two recursive algorithms.
Problem 1. Given a sequence of n + 1 cities c0 , . . . , cn and the distance di between each
consecutive

Algorithm Analysis
CSI 3108-02, Fall 2016
Lecture 7
September 28, 2016
Today we analyze the running time of the algorithm from the last class.
Theorem 1. The running time of the algorithm is O(n log n).
Proof. Steps 10 and 16 of the algorithm can be perfo

Algorithm Analysis
CSI 3108-02, Fall 2016
Lecture 4
September 19, 2016
Today we answer several questions raised last week.
Theorem 1. There exists an instance of the stable marriage problem that admits more than
one stable matching.
Proof. Consider the fo

Algorithm Analysis
CSI 3108-02, Fall 2016
Lecture 1
September 5, 2016
Consider the following problem. Using this problem, we will preview the material to be
covered during the first half of this semester.
Problem 1. Given a sequence of integers a1 , . . .

Algorithm Analysis
CSI 3108-02, Fall 2016
Lecture 2
September 7, 2016
Last class, we studied the following problem.
Problem 1. Given a sequence of integers a1 , . . . , an , what is the maximum sum of a contiguous subsequence? We consider the empty set a

Introduction to Analysis of Algorithms
CS 4820, Summer 2012
Solutions to Prelim
(1a)
(m1 , w2 ), (m2 , w3 ), (m3 , w4 ), (m4 , w1 ).
(1b)
No.
(5a)
Let OPTNT [i, v] be the maximum total number of people we can have in the first i days, subject
to an additi

Algorithm Analysis
CSI 3108-02, Fall 2016
Lecture 3
September 12, 2016
We now formally define the stable marriage problem.
Let M = cfw_m1 , . . . , mn be a set of n men and W = cfw_w1 , . . . , wn be women.
Definition 1. We say S M W is a matching if ev

Algorithm Analysis
CSI 3108-02, Fall 2016
Assignment 1
Due at 5:00pm, Thursday, Oct 6
Hand in your solutions electronically using YSCEC.
This assignment consists of one programming assignment and one written assignment.
(1) (50 points) Write a program tha