CMSC 451:Fall 2013
Dave Mount
Homework 2: Greedy Algorithms
Handed out Thu, Oct 3. Due at the start of class Thu, Oct 17. Late homeworks are not accepted, but you
may drop your lowest homework score.
Problem 1. Let cfw_f1 , . . . , fn be a collection of
CMSC 451:Fall 2013
Dave Mount
Solutions to Homework 2: Greedy Algorithms
Solution 1:
(a) Let (s1 , p1 ) = (1, 0.1) and (s2 , p2 ) = (2, 0.9). If we put f1 before f2 (size order), the expected access
cost is 1 0.1 + (2 + 1) 0.9 = 2.8, but if we reverse the
COMP 271 Design and Analysis of Algorithms 2004 Fall Semester Question Bank 3
Solving these questions will give you good practice for the midterm exam. Some of these questions (or similar ones) will denitely appear on your exam! Note that you do not have
Max Flow, Min Cut, and Matchings (Solution)
1. The gure below shows a ow network on which an s-t ow is shown.
The capacity of each edge appears as a label next to the edge, and the
numbers in boxes give the amount of ow sent on each edge. (Edges
without b
The Hong Kong University of Science & Technology COMP 271: Design and Analysis of Algorithms Fall 2007 Tutorial 6: Knapsack & MCM
Below is the suggest solution to the tutorial questions. Question 1 : What is the optimal way to compute A1 A2 A3 A4 A5 , whe
Part III: Dynamic Programming
Lecture 10: The 0-1 Knapsack Problem
Lecture 10: The 0-1 Knapsack Problem
Part III: Dynamic Programming
Introduction to Part III
What is dynamic programming? A technique for solving optimization problems. What are optimizatio
The Hong Kong University of Science & Technology COMP 271: Design and Analysis of Algorithms Fall 2007 Solution to Assignment 1
Idea of the algorithm: If we divide A into two roughly equal size sub-arrays, each with approximately n/2 elements, we observe
CMSC 451:Fall 2013
Dave Mount
Homework 1: Algorithm Design Basics
Handed out Thu, Sep 12. Due at the start of class Tue, Sep 24. Late homeworks are not accepted, but you
may drop your lowest homework score.
Notation: Throughout the semester, we will use l
CMSC 451:Fall 2013
Dave Mount
Solutions to Homework 1: Algorithm Design Basics
Solution 1: Throughout, let X = cfw_x1 , . . . , xn denote the set of men, and let Y = cfw_y1 , . . . , yn denote the
set of women.
(a) The answer is yes. Without loss of gen
Chapter 9: Maximum Flow and the Minimum Cut
A common question about networks is what is the maximum flow rate between a given node
and some other node in the network? For example, traffic engineers may want to know the
maximum flow rate of vehicles from t
CS 97SI: INTRODUCTION TO
PROGRAMMING CONTESTS
Jaehyun Park
Last Lecture on Graph Algorithms
Network Flow Problems
Maximum
Flow
Minimum Cut
Ford-Fulkerson Algorithm
Application: Bipartite Matching
Min-cost Max-flow Algorithm
Network Flow Problems
A type
COMP 272, FALL 2004UNIT 12: THE
FUNDAMENTAL CFL THEOREM
Derick Wood
CS, HKUST
October 7, 2004
COMP 272, Fall 2004Unit 12: THE FUNDAMENTAL CFL THEOREM
OVERVIEW OF UNIT
CFLs are PDM languages
PDM languages are CFLs
WARNING! We prove PDM languages are
CFL
Part III: Dynamic Programming
Lecture 12: All-Pairs Shortest Paths
Lecture 12: All-Pairs Shortest Paths
Part III: Dynamic Programming
Objective and Outline
Objective: A third example of dynamic programming Dierent DP formulations possible for some problem
The Hong Kong University of Science & Technology COMP 271: Design and Analysis of Algorithms Fall 2007 Solution to Assignment 2
In the DSelection algorithm described in Lecture 5, input elements are divided into groups of 5. The running time is then O(n)
Part IV: Greedy Algorithms
Lecture 13: The Fractional Knapsack Problem
Lecture 13: The Fractional Knapsack Problem
Part IV: Greedy Algorithms
Objective and Outline
Objective: Illustrate greedy algorithms using the knapsack problem. Reference: Section 16.2
Part IV: Greedy Algorithms
Lecture 14: Human Coding
Lecture 14: Human Coding
Part IV: Greedy Algorithms
Objective and Outline
Objective: Another example of greedy algorithms Reference: Section 16.3 of CLRS
Outline Coding and Decoding The optimal source co
Part VI: Dealing with Hard Problems
Lecture 16: Problem Classes P & NP
Lecture 16: Problem Classes P & NP
Part VI: Dealing with Hard Problems
Introduction to Part VI
So far: techniques for designing ecient algorithms: divide-and-conquer, dynamic-programmi
Part VI: Dealing with Hard Problems
Lecture 17: NP-Completeness
Lecture 17: NP-Completeness
Part VI: Dealing with Hard Problems
Objective and Outline
Objective: Introduce NP-completeness and show how to prove that a problem is NP-complete. Reference: Chap
Part VI: Dealing with Hard Problems
Lecture 18: Approximation algorithms
Lecture 18: Approximation algorithms
Part VI: Dealing with Hard Problems
Objective and Outline
Objective: Introduction to approximate algorithms. Reference: Sections 35.1 & 35.2 of C
The Hong Kong University of Science & Technology COMP 271: Design and Analysis of Algorithms Fall 2007 Assignment 1
Assigned: 6/9/07 Due Date: 4pm, 18/9/07 Question 1 : Let A[] be an array of positive integers. Design a divide-andconquer algorithm for com
Part III: Dynamic Programming
Lecture 11: Chain Matrix Multiplication
Lecture 11: Chain Matrix Multiplication
Part III: Dynamic Programming
Objective and Outline
Objective: Another example of dynamic programm Reference: Section 15.2 of CLRS
Outline Review
COMP 272, FALL 2004UNIT 9:
PROVING NONREGULARITY
Derick Wood
CS, HKUST
October 7, 2004
COMP 272, Fall 2004Unit 9: PROVING NONREGULARITY
OVERVIEW OF UNIT
Proving regularity
Proving nonregularity I
Proving nonregularity II
The Pigeonhole Principle
Derick Wo
COMP 272, FALL 2004UNIT 13:
CLOSURE PROPERTIES OF CFLS
Derick Wood
CS, HKUST
November 18, 2004
COMP 272, Fall 2004Unit 13: CLOSURE PROPERTIES OF CFLs
OVERVIEW OF UNIT
The basic operations
Regular intersection
Proving context-freeness
Derick Wood
1
COMP
Logic Examples I
Problem 1. Is the following reasoning for finding the solutions of the equation
x correct?
(1) 2x2 1 = x: Given
2x2 1 =
(2) 2x2 1 = x2 : Square both sides
(3) X 2 = 1
(4) So, x = 1 or x = 1.
Solution: The reasoning is incorrect. We have
(
Recurrence for a Probability Problem
Problem: A line of 100 people are waiting to enter an airplane. They each hold a
ticket for one of the 100 seats on the flight. (For convenience, assume that
the nth passenger in line has a ticket for seat number n, e.
Probability Examples
Number of times until first success
Throw a fair die
How many times, on average, do you need to
throw the die until you see a 1?
P(getting 1 at each throw) = 1/6
Answer: 1/(1/6) = 6
Page 2
Number of times until first success
Thro
COMP 2711 Discrete Mathematical Tools for CS
Spring Semester, 2016
Written Assignment # 9
Distributed: 29 April 2016 Due: 4pm, 6 May 2016
Solution Keys
Your solutions should contain (i) your name, (ii) your student ID #, (ii) your
email address, and (iv)
COMP 2711 Discrete Mathematical Tools for CS
Spring Semester, 2016
Written Assignment # 7
Distributed: 13 April 2016 Due: 4pm, 20 April 2016
Your solutions should contain (i) your name, (ii) your student ID #, (ii) your
email address, and (iv) your tutori