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 I: Divide and Conquer
Lecture 5: Deterministic Linear-Time Selection
Lecture 5: Deterministic Linear-Time Selection
Part I: Divide and Conquer
Objective and Outline
Objective: We discussed a randomized selection algorithm that runs in O (n) on averag
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)
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 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
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 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 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 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 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
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
Part II: Graph Algorithms
Lecture 8: Kruskals MST Algorithm
Lecture 8: Kruskals MST Algorithm
Part II: Graph Algorithms
Objective and Outline
Objective: Discuss another algorithm for the MST problem, i.e. Kruskals algorithm. Reference: Chapters 21 & 23 of
Part II: Graph Algorithms
Lecture 7: Minimum Spanning Trees and Prims Algorithm
Lecture 7: Minimum Spanning Trees and Prims Algorithm
Part II: Graph Algorithms
Objective and Outline
Objective: Introduce a second problem on graphs, i.e. MST, and discuss on
Part II: Graph Algorithms
Lecture 6: Depth-First Search and Its Applications
Lecture 6: Depth-First Search and Its Applications
Part II: Graph Algorithms
Intro to Part II: What are graphs?
A graph is a pair G = (V , E ), where V is the collection of verti
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 1
Idea of the algorithm: If we divide A into two roughly equal size sub-arrays, each with approximately n/2 elements, we observe
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
1. Write an algorithm that determines whether a binary tree is a complete binary tree
(Hint: store tree nodes in an array according to their level order) (20%).
bool Tree:IsComplete()
cfw_
Queue Q;
TreeNode *currentNo
SOLUTIONS: Homework 2, CS320, Spring 2013, McConnell
Recall from the readings that f (n) = O(g (n) means that f (n) does not beat g (n) in the
contest we set up. Its no faster growing in the sense we have dened. Conceptually, allows
f (n) and g (n) to be
SOLUTIONS: Homework 1, CS320, Spring 2013
1. Briey describe how your program turns each instance of Solved Exercise 2 into an
instance of Stable Marriage. Then tell what it does with the solution to turn it into
a solution to the instance of Solved Exerci
Analysis of Algorithms
Algorithm. An algorithm is a description of the
steps needed to solve a problem. Each step is a
computation that should be supported by some basic primitive oered by a computer or some wellunderstood high-level computations. One suc
COMP 3711H Design and Analysis of Algorithms
2012 Fall Semester
Written Assignment 1
Distributed: Sep 24, 2012
Due: 17:00, Oct 8, 2012 in the assignment collection box
1. (10 marks) Let X [1.n] and Y [1.n] be two arrays, each containing n numbers already
COMP 252
Operating Systems
Lab 01
Welcome
About Me
Yiyang Zhao ( )
Website: http:/www.cse.ust.hk/~zhaoyy
Office: 4205
Hobbies: basketball, swimming
About Lab Tutorials
3 parts
Review
Nachos
Practice
Outline
Review Questions
UNIX basics and Vi edit
COMP 252
Operating Systems
Lab 01
Welcome
About Me
Yiyang Zhao ( )
Website: http:/www.cse.ust.hk/~zhaoyy
Office: 4205
Hobbies: basketball, swimming
About Lab Tutorials
3 parts
Review
Nachos
Practice
Outline
Review Questions
UNIX basics and Vi edit
COMP 272, FALL 2004UNIT 14:
PROVING NON-CONTEXT-FREENESS
Derick Wood
CS, HKUST
November 18, 2004
COMP 272, Fall 2004Unit 14: PROVING NON-CONTEXT-FREENESS
OVERVIEW OF UNIT
Sentential syntax trees (SSTs) and languages
(SSTLs)
SSTL Pumping Lemma
WARNING!The