1. Homepage
  2. Programming
  3. CSE 450 Design and Analysis of Algorithms: Assignment 4 Dynamic Programming

CSE 450 Design and Analysis of Algorithms: Assignment 4 Dynamic Programming

Engage in a Conversation
USASUCSE 450Design and Analysis of AlgorithmsDynamic Programming

CSE 450: Assignment 4 (Dynamic Programming) CourseNana.COM

This assignment should be completed in groups of two. As stated in the course syllabus, “students are encouraged to discuss homework problems with others, but each group is expected to turn in the results of their own effort, not that of another group’s.” Even when not explicitly asked, you should concisely justify your answers. Each individual or group should prepare a single writeup in LATEX using the provided template and submit it as a PDF on Canvas to receive credit. CourseNana.COM

Problem 1 CourseNana.COM

The instance of Weighted-Interval-Scheduling shown below has its intervals sorted by increasing finish time. The weight of interval i is given by wi and its predecessor is given by p(i). Detail the complete execution of the dynamic programming algorithm for Weighted-Interval-Scheduling on this instance using either of the memoized recursive or bottom-up versions. State both the optimal set of intervals and their total weight. CourseNana.COM

w1=2 w2=4 w3=4 w4=7 w5=2 w6=1 CourseNana.COM

Problem 2 CourseNana.COM

p(1)=0 p(2)=0 p(3)=1 p(4)=0 p(5)=3 p(6)=4 CourseNana.COM

An ordered graph is a connected, directed graph G = (V, E) with nodes V = {v1, . . . , vn} such that (1) every edge (vi,vj) E has i < j; i.e., each edge starts at a node with a lower index than the node where it ends, and (2) every node except vn has at least one outgoing edge. We want to find the longest path starting at v1 and ending at vn, where the length of a path is its number of edges. For the example ordered graph below, the longest path is P = [v1, v2, v4, v5] which has length 3. CourseNana.COM

v1 v2 v3 v4 v5 CourseNana.COM

(a) Prove that the following algorithm does not correctly solve this problem by (1) defining an ordered graph G on which this algorithm does not find the longest path, (2) identifying what the true longest path in G is and what its length is, and (3) identifying what path the algorithm outputs. time CourseNana.COM

Algorithm 1 BrokenOrderedLongestPath Input: An ordered graph G = (V, E). CourseNana.COM

1: 2: 3: 4: 5: CourseNana.COM

InitializeP =[v1],l0,andvv1. while there is an edge leaving node v do CourseNana.COM

Let (v,vi) be the edge for which i is as small as possible. CourseNana.COM

Appendvi toP,updatevvi,andupdatell+1. return the longest path P and its length l. CourseNana.COM

 (b) Use dynamic programming to devise an efficient algorithm for finding the longest path in an ordered graph. Your solution should (1) define the OPT function, (2) define and justify the dynamic program- ming recurrence for OPT, (3) state your algorithm in pseudocode, and (4) briefly state and justify your algorithm’s asymptotic runtime. CourseNana.COM

Problem 3 CourseNana.COM

Suppose that as you near the end of the semester, you have n final projects to complete. You only have H > n total hours to allocate to working on these projects, so you want to determine the optimal allocation of hours to projects that will get you the best overall grades. For each project i, there is a function fi that estimates the relationship between hours spent and the final grade; specifically, for a number of hours hi H spent on project i, fi(hi) 1 is your numerical grade for the project. You may assume that the input to any estimation functions fi is always an integer number of hours. You may also assume that the functions fi are “nondecreasing”; i.e., if h > h, then fi(h) fi(h). CourseNana.COM

Use dynamic programming to design an algorithm that takes as input the functions f1 , . . . , fn and returns an allocation of hours h1, . . . , hn to spend on each project that maximizes ?ni=1 fi(hi). Your solution should (1) define the OPT function, (2) define and justify the dynamic programming recurrence for OPT, (3) state your algorithm in pseudocode, and (4) briefly state and justify your algorithm’s asymptotic runtime. Its runtime should be polynomial in n and H. CourseNana.COM

Problem 4 CourseNana.COM

Gerrymandering is the practice of drawing the boundaries of electoral districts such that outcomes will favor a particular political party. Algorithms for performing and fighting against gerrymandering have been a major tension in social computing over the last two decades. To understand how this is an algorithmic issue, consider the following (simplified) scenario. CourseNana.COM

Suppose we have n “precincts” each containing m voters. We are additionally given the political party registrations of each of the m voters in each precinct; for simplicity, we assume all voters are registered with one of two political parties. A set of precincts is susceptible to gerrymandering if it is possible to partition the precincts into two electoral districts, each containing n/2 of the precincts, such that the same political party holds the majority in both districts. For example, the precincts shown in the table below are susceptible to gerrymandering because if the districts were defined as precincts (1, 4) and (2, 3), then party A—despite only having a slim majority in the overall population—would have the majority in both districts. CourseNana.COM

Precinct CourseNana.COM

Party A Voters Party B Voters CourseNana.COM

1 2 CourseNana.COM

55 43 45 57 CourseNana.COM

3 4 CourseNana.COM

60 47 40 53 CourseNana.COM

Give a dynamic programming algorithm determining whether a set of precincts is susceptible to gerryman- dering. Your solution should (1) define the OPT function, (2) define and justify the dynamic programming recurrence for OPT, (3) state your algorithm in pseudocode, and (4) briefly state and justify your algorithm’s asymptotic runtime. Its runtime should be polynomial in n and m. CourseNana.COM

Problem 5 CourseNana.COM

Let c1,...,cn be the different currencies used across the global economy. For every pair of currencies (ci,cj) where i ̸= j, there is an exchange rate rij that determines how much one unit of currency ci is worth in currency cj. For example, if the exchange rate from USD to EUR is 1:0.93, then rUSD,EUR = 0.93 and rEUR,USD = 1/0.93 1.075. Informally, an arbitrage opportunity is a series of exchanges starting and ending in the same currency such that the amount of currency you end with is greater than the amount you started with. Formally, an arbitrage opportunity is a cycle C such that the product of exchange rates over the cycle is strictly greater than 1; i.e., CourseNana.COM

rij > 1. (ci ,cj )C CourseNana.COM

Give a polynomial-time algorithm that finds an arbitrage opportunity, if one exists, and otherwise declares that there is none. Briefly state and justify its runtime. [Hint: log(a · b) = log a + log b.] CourseNana.COM

Problem 6 CourseNana.COM

Consider the Sequence-Alignment problem on the DNA sequences CGAAGTCA and CTCAAGA using a gap penalty of δ = 1 and the substitution matrix: CourseNana.COM

AGCT CourseNana.COM

A 1 1 1 1 G 1 1 1 1 C 1 1 1 1 T 1 1 1 1 CourseNana.COM

For each of the Needleman–Wunsch (global alignment) and Smith–Waterman (local alignment) algorithms, show the completed tables of alignment scores and their tracebacks and state the final sequence alignment and score. Note that you do not have to show the step-by-step executions; you can simply give the completed tables of optimal values and the resulting tracebacks. If you are not comfortable creating these tables in LATEX, you can draw them by hand, take pictures, and include them as figures in your LATEX writeup. CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
US代写,ASU代写,CSE 450代写,Design and Analysis of Algorithms代写,Dynamic Programming代写,US代编,ASU代编,CSE 450代编,Design and Analysis of Algorithms代编,Dynamic Programming代编,US代考,ASU代考,CSE 450代考,Design and Analysis of Algorithms代考,Dynamic Programming代考,UShelp,ASUhelp,CSE 450help,Design and Analysis of Algorithmshelp,Dynamic Programminghelp,US作业代写,ASU作业代写,CSE 450作业代写,Design and Analysis of Algorithms作业代写,Dynamic Programming作业代写,US编程代写,ASU编程代写,CSE 450编程代写,Design and Analysis of Algorithms编程代写,Dynamic Programming编程代写,USprogramming help,ASUprogramming help,CSE 450programming help,Design and Analysis of Algorithmsprogramming help,Dynamic Programmingprogramming help,USassignment help,ASUassignment help,CSE 450assignment help,Design and Analysis of Algorithmsassignment help,Dynamic Programmingassignment help,USsolution,ASUsolution,CSE 450solution,Design and Analysis of Algorithmssolution,Dynamic Programmingsolution,