In this problem you will design an algorithm that takes as input a directed acyclic graph...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In this problem you will design an algorithm that takes as input a directed acyclic graph G = (V, E) and two vertices s and t, and returns the number of simple paths from s to t in G. For example, the directed acyclic graph below contains exactly four simple paths from vertex p to vertex v: pov, poryv, posryv, and psryv. Notice: your algorithm needs only to count the simple paths, not list them. m (a) (15 pts) Design a recursive backtracking (brute-force) algorithm that determines the number of paths from s to t. Write down the pseudocode of your algorithm and prove its correctness, i.e., convince us that it works beyond any doubt. (Hint: using induction.) A solution with no proof will receive 0 points! Make your pseudocode as simple as possible. You will be graded on the elegance of your solution, not just the correctness. (b) (15 pts) Modify your pseudocode in part (a) to use memoization. Write down the modified pseu- docode and explain your choice of the memoization table and the indices used for memoization. (Hint: What is a natural way to memoize solutions to subproblems that had already been computed?) (c) (15 pts) Design a bottom-up dynamic programming algorithm that counts the number of simple paths from s to t. Write the pseudocode and analyze its running time. Argue why your choice of the order in which you fill in the values is the correct one. (Hint: Think about the order on which the computation of the paths from each vertex depends.) In this problem you will design an algorithm that takes as input a directed acyclic graph G = (V, E) and two vertices s and t, and returns the number of simple paths from s to t in G. For example, the directed acyclic graph below contains exactly four simple paths from vertex p to vertex v: pov, poryv, posryv, and psryv. Notice: your algorithm needs only to count the simple paths, not list them. m (a) (15 pts) Design a recursive backtracking (brute-force) algorithm that determines the number of paths from s to t. Write down the pseudocode of your algorithm and prove its correctness, i.e., convince us that it works beyond any doubt. (Hint: using induction.) A solution with no proof will receive 0 points! Make your pseudocode as simple as possible. You will be graded on the elegance of your solution, not just the correctness. (b) (15 pts) Modify your pseudocode in part (a) to use memoization. Write down the modified pseu- docode and explain your choice of the memoization table and the indices used for memoization. (Hint: What is a natural way to memoize solutions to subproblems that had already been computed?) (c) (15 pts) Design a bottom-up dynamic programming algorithm that counts the number of simple paths from s to t. Write the pseudocode and analyze its running time. Argue why your choice of the order in which you fill in the values is the correct one. (Hint: Think about the order on which the computation of the paths from each vertex depends.)
Expert Answer:
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
PLEASE GIVE CORRECT ANSWERS Prove that the number of comparators in any sorting network is (n log n). [4 marks] (ii) What does Part (d)(i) imply in terms of the depth of any sorting network? [1 mark]...
-
Give a linear-time algorithm that takes as input a directed acyclic graph G = (V, E) and two vertices s and t, and returns the number of simple paths from s to t in G. For example, the directed...
-
Hi,Please answer no.5 and 6 only. This is my 3rd time to uploadthis question. Thank you so much! Bay Lake Mining Ltd. purchases earth-moving equipment on 1 August \( 20 \times 6 \) and signs a...
-
You want to create a portfolio equally as risky as the market, and you have $1,000,000 to invest. Given this information, fill in the rest of the following table: Asset Investment Beta Stock...
-
In Problem write the expression in the form x n . (x 4 ) 3
-
Graph the heat loss per unit length from the solar collector of Problem 9.76 over the range \(0.1 \leq D_{o} \leq 0.25\mathrm{~m}\) assuming (i) conduction heat transfer across the annular space and...
-
Multiple Choice Question 1. What is a subsidiarys functional currency? a. The parents reporting currency. b. The currency in which transactions are denominated. c. The currency in which the entity...
-
Method, layout and accurate referencing to Australian Standards will be assessed in addition to answers obtained. QUESTION 1 (12 Marks) A floor system of an office building consists of a grid of...
-
How would you summarize the events of 9/11? Is it a natural or man-made disaster, Why (Explain)? How do you think the development of ICS and Homeland Security can help minimize further terrorist...
-
Repeat Exercise E11.15 , but throw exceptions of three exception types that you provide. Data from Exercise E11.15 Modify the BankAccount class to throw an IllegalArgumentException when the account...
-
Outline, but do not implement, a recursive solution for sorting an array of numbers. First sort the subarray without the initial element.
-
Reimplement Exercise E10.13 where the grid is unbounded. The constructor has no arguments, and the row and column parameter variables of the add and getDescription methods can be arbitrary integers....
-
Using the isPalindrome method from Section 13.2 and a recursive reverse method from Exercise E13.6, write a program to address the following mathematical hypothesis. It is believed (but not proven)...
-
Write a class DataSet that stores a number of values of type double. Provide a constructor public DataSet(int maximumNumberOfValues) and a method public void add(double value) that adds a value,...
-
Dan Germain, Head of Creativity at Innocent Drinks argues that creativity must be maintained in the fast-growing company. Innocent Drinks started in 1999. Dan Germain commented Try as we might have...
-
a. Show that the expansion of q(x) in ascending powers of x can be approximated to 10 2x + Bx 2 + Cx 3 where B and C are constants to be found. b. Find the percentage error made in using the series...
-
Show that the pseudoinverse A + satisfies the following four equations: AA* A , A+ AA+ A+ , (AA*)" (A* A) AA+ A A. || || ||
-
Prove that for any collection of events A 1,? A 2, . . . ,A n , Pr {A1 N A2 N.. N An} = Pr {A1} Pr {A2 | A1} Pr{A3 | A1 N A2}... Pr{A, | A1 N A, n..N An-1}
-
Which is asymptotically larger: lg(lg n) or lg (lg n)?
-
In Example 2 with equal taxes, did the outcome of the vote make anyone worse off? If so, whom and by how much?
-
Why is rent-seeking activity socially wasteful?
-
Ocean views (from a house) are not free. Do you agree or disagree? Explain your answer.
Study smarter with the SolutionInn App