Docsity

Advanced Algorithms - Homework 4 with Answer Key | CS 5050, Assignments of Algorithms and Programming

Toggle sidebar
bg1
CS5050 Homework 4, Chapter 8,9
(due at class time) 10 points
Working with others is STRONGLY ENCOURAGED. Prepare your answers
individually and then compare/contrast your answers with others. The homework
questions are meant to help you prepare for exams. When you work with others, you are
motivated to consider every aspect of a problem and do your best thinking. Just doing a
google search for the answers is NOT recommended. The learning comes as you struggle
to create the answer from what you already know or from material in the chapters.
Note, these exercises may be done in groups of one, two, or three. If more than one
person is involved, list all the names on ONE set of answers. Groups may change
throughout the semester. Answers should not be compared with others not in your group.
These are typed (or hand-written neatly) exercises, but you are certainly encouraged to
actually code the programming segments if you have time.
In giving your answers, use algorithmic language, building on algorithms and
terminology used in class. In previous assignments, the term “efficient” was used as code
for “polynomial”. In this and future assignments, efficient will mean the best of the
polynomial time algorithms.
Be careful about your algorithms. The algorithm should be specific enough that you
could turn it over to an undergrad and recognize the solution he/she implements as the
same algorithm you specified.
Use good variable names. When specifying an algorithm, explain what
comes in and what comes out.
In some cases you are just to recognize, “This is merely an instance of a well known
problem.” In other cases, the problem is similar to a well know problem, but the
differences are critical. You must comment how the differences from the well-known
problem change the solution. In still other cases, you are asked to improve on the
solution discussed in class.
Chapter 8
1. Let N be a flow network with m edges and n vertices. Show how to compute an
augmenting path with the largest capacity in O((n+m)log n) time. Hint:
Remember, we can look for augmenting paths of a variety of types: any old path,
the one with the largest flow, the shortest one in terms of distance,etc. This asks
for a method for finding the largest flow efficiently, where they define efficient to
be O((n+m)log n) .
2. Given a flow network N and a maximum flow f for N, suppose that the capacity
of an edge e of N is decreased by one, and let N' be the resulting network. Give
pf3

Partial preview of the text

Download Advanced Algorithms - Homework 4 with Answer Key | CS 5050 and more Assignments Algorithms and Programming in PDF only on Docsity!

CS5050 Homework 4, Chapter 8,

(due at class time) 10 points

Working with others is STRONGLY ENCOURAGED. Prepare your answers individually and then compare/contrast your answers with others. The homework questions are meant to help you prepare for exams. When you work with others, you are motivated to consider every aspect of a problem and do your best thinking. Just doing a google search for the answers is NOT recommended. The learning comes as you struggle to create the answer from what you already know or from material in the chapters.

Note, these exercises may be done in groups of one, two, or three. If more than one person is involved, list all the names on ONE set of answers. Groups may change throughout the semester. Answers should not be compared with others not in your group.

These are typed (or hand-written neatly) exercises, but you are certainly encouraged to actually code the programming segments if you have time.

In giving your answers, use algorithmic language, building on algorithms and terminology used in class. In previous assignments, the term “efficient” was used as code for “polynomial”. In this and future assignments, efficient will mean the best of the polynomial time algorithms.

Be careful about your algorithms. The algorithm should be specific enough that you could turn it over to an undergrad and recognize the solution he/she implements as the same algorithm you specified.

Use good variable names. When specifying an algorithm, explain what

comes in and what comes out.

In some cases you are just to recognize, “This is merely an instance of a well known problem.” In other cases, the problem is similar to a well know problem, but the differences are critical. You must comment how the differences from the well-known problem change the solution. In still other cases, you are asked to improve on the solution discussed in class.

Chapter 8

  1. Let N be a flow network with m edges and n vertices. Show how to compute an augmenting path with the largest capacity in O((n+m)log n) time. Hint: Remember, we can look for augmenting paths of a variety of types: any old path, the one with the largest flow, the shortest one in terms of distance,etc. This asks for a method for finding the largest flow efficiently, where they define efficient to be O((n+m)log n).
  2. Given a flow network N and a maximum flow f for N, suppose that the capacity of an edge e of N is decreased by one, and let N' be the resulting network. Give

an algorithm for computing a maximum flow in network N' by modifying f. Hint: You have already computed the flow. You change an edge and want to know how the flow has changed WITHOUT starting over.

  1. A taxi company receives pickup requests from n locations. There are m taxis available where m >= n and the distance of taxi i to location j is dij. Give an algorithm for computing a dispatching of m taxis to the n pickup locations that minimizes the total distance. Note: the taxi’s are all over the city, initially. Distances between the current location of the taxi and each pickup location are already known. Below is a diagram. You want to know which taxi goes to which location. m=7 and n=5 in the diagram.

Chapter 9

  1. (This one is not required) Using minimal edit distance (using insertion, deletion, replacement, and matching), what is the cheapest way of converting the letters of the string something'' to the letters of the stringnothing'' assuming that insertion, deletion, and replacement are of cost 1 and matching is zero. Show your work.
  2. What is the longest common subsequence of bumblebee'' andbeelumber''? Show your work.
  3. Given a pattern P and a text T, determine if P is contained within T or if P can be split into two pieces so that the first piece matches the end of T and the second piece matches the first of T. In other words, P is found by wrapping around T. Hint, think elegant (and simple).