Due: September 30, by midnight
Guidelines: (read fully!!)
- Your assignment solution must be submitted as a typed PDF document. Scanned handwritten solutions, solutions in any other format, or unreadable solutions will not be accepted or marked. You are encouraged to learn the LATEX typesetting system and use it to type your solution. See the course website for LATEX resources.
- Your submission should be no more than 8 pages long, in a single - column US Letter or A4 page format, using at least 9 pt font and 1 inch margins.
- To submit this assignment, use the MarkUs system, at URL https://markus.teach.cs.toronto.edu/
- This is a group assignment. This means that you can work on this assignment with at most one other student. You are strongly encouraged to work with a partner. Both partners in the group should work on and arrive at the solution together. Both partners receive the same mark on this assignment.
- Work on all problems together. If one of you writes the solution to a (sub -)problem, then the other student should proof read it. Both members of a group are responsible for understanding all solutions to all problems in their submission.
- You may not consult any other resources except: your partner; your class notes; your textbook and assigned readings. Consulting any other resource, or collaborating with students other than your group partner, is a violation of the academic integrity policy!
- You may use any data structure, algorithm, or theorem previously studied in class, or in one of the prerequisites of this course, by just referring to it, and without describing it. This includes any algorithm, or theorem we covered in lecture, in a tutorial, or in any of the assigned readings. Be sure to give a precise reference for the data structure/algorithm/result you are using.
- Unless stated otherwise, you should justify all your answers using rigorous arguments. Your solution will be marked based both on its completeness and correctness, and also on the clarity and precision of your explanation.
In this question you are given as input n intervals I1 = [a1, b1],..., In = [an, bn] on the real line. Each intervals
We will say that intervals
Part a. (3 marks)
Suppose that there exists some number x so that
Hint: use one of the divide and conquer algorithms from class.
Part b. (8 marks)
Give a divide and conquer algorithm that computes the number of pairs
Part c. (7 marks)
(Bonus question - Optional). Modify your algorithm so that it runs in worst case time complexity
Hint: Try to call any subroutine that takes time
In this question, you are tasked with deciding the locations for k grocery stores, to serve n houses on a street. Suppose we model the street as the interval from 0 to 1, and the locations of the houses are given as real numbers
Part a. (4 marks)
Prove that if
Hint: There are many ways to prove this. One possibility is to show that, for
Part b. (5 marks)
For
Part c. (6 marks)
Give an algorithm that computes the minimum total travel distance achievable with k store locations. I.e., you need to output the minimum of $min {j = 1}^{k}\left|x{1} - y_{j}\right| +... + min {j = 1}^{k}\left|x{n} - y_{j}\right|$ over all choices of
Hint: You can also equivalently write the objective (1) as $min {X{1},..., X_{k}}\left{min {y{1} \in[0,1]}\left(\sum_{i \in X_{1}}\left|x_{i} - y_{1}\right|\right) +... + min {y{k} \in[0,1]}\left(\sum_{i \in X_{k}}\left|x_{i} - y_{k}\right|\right)\right}$, where the first minimum is over all ways to partition
Part d. (4 marks)
Modify your algorithm from the previous problem to also output the choice of store locations
The Galactic Research Society (GRS) has decided to organize an interstellar expedition. The president insists that exactly k members, including herself, join the expedition, and all selected members are required to participate.
There are n GRS members, and they are organized in a strict hierarchical structure (i.e., a tree), with the president at the root. Every society member is represented as a node in the tree. Every member except the president has a supervisor (their parent in the tree), and members supervise at most two other members (their children in the tree).
The society’s HR office has determined a “tension coefficient” between each member and their supervisor. This is a real number, and represents the degree to which there is tension between the member and their supervisor: a large positive number means their relationship is quite tense and there is potential for conflict, and a negative number with large absolute value means they get along very well.
Your task is to use a dynamic programming algorithm to choose exactly k members to join the expedition such that the total tension is minimized. You can assume that k
Part a. (7 marks) Define the subproblem structure you are using, and specify a recurrence satisfied by each subproblem, as well as the base cases of the recurrence. The recurrence should allow you to compute the value of a subproblem quickly (certainly in polynomial time), assuming the values of “smaller” subproblems have already been computed. Justify the recurrence.
Part b. (3 marks) Using your recurrence from the previous question, give a bottom - up dynamic programming algorithm to compute the smallest possible total tension of a set S of k GRS members that includes the president (root of the tree). Your algorithm should run in time polynomial in the total number of GRS members n. Give pseudocode for your algorithm, and analyze its worst case running time.
Part c. (4 marks) Modify your algorithm from the previous subproblem to also output a set S of k GRS members, including the president, that minimizes the total tension. Analyze the modified algorithm’s worst case running time.