One morning, you wake up to realize that your dog ate some of your CS 170...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
One morning, you wake up to realize that your dog ate some of your CS 170 homework paper, which is an mxn rectangular grid of squares. Some of the squares have holes chewed through them, and you cannot use paper that has a hole in it. You would like to cut the paper into pieces so as to separate all the tattered squares from all the clean, un-bitten squares. You want to do this so that you can save as much as your work as possible. For example, shown below is a 6 x 4 piece of paper where the bitten squares are marked with *. As shown in the picture, one can separate the bitten parts out in exactly four cuts. * * * * * * * * * * CS * CS * * * C S C S 1 70 * 1 7 0 * 0 * 0 * 1 7 1 7 * * * * * * * * * * * * * * * * * * * * ↑↑ * * CS 1 0 7 * * * * * * * (Each cut is either horizontal or vertical, and of one piece of paper at a time.) Design a DP based algorithm to find the smallest number of cuts needed to separate all the bitten parts out. Formally, the problem is as follows: Input: Dimensions of the paper m x n and an array A[i, j] such that A[i, j] = 1 if and only if the ijth square has holes bitten into it. Goal: Find the minimum number of cuts needed so that the A[i, j] values of each piece are either all 0 or all 1. (a) Define your subproblem. Hint: try making any arbitrary cut. What two subproblems do you now have? (b) Write down the recurrence relation for your subproblems. A fully correct recurrence relation will always have the base cases specified. (c) Describe the order in which we should solve the subproblems in your DP algorithm. (d) What is the runtime complexity of your DP algorithm? Provide a justification. (e) What is the space complexity of your algorithm? Provide a justification. One morning, you wake up to realize that your dog ate some of your CS 170 homework paper, which is an mxn rectangular grid of squares. Some of the squares have holes chewed through them, and you cannot use paper that has a hole in it. You would like to cut the paper into pieces so as to separate all the tattered squares from all the clean, un-bitten squares. You want to do this so that you can save as much as your work as possible. For example, shown below is a 6 x 4 piece of paper where the bitten squares are marked with *. As shown in the picture, one can separate the bitten parts out in exactly four cuts. * * * * * * * * * * CS * CS * * * C S C S 1 70 * 1 7 0 * 0 * 0 * 1 7 1 7 * * * * * * * * * * * * * * * * * * * * ↑↑ * * CS 1 0 7 * * * * * * * (Each cut is either horizontal or vertical, and of one piece of paper at a time.) Design a DP based algorithm to find the smallest number of cuts needed to separate all the bitten parts out. Formally, the problem is as follows: Input: Dimensions of the paper m x n and an array A[i, j] such that A[i, j] = 1 if and only if the ijth square has holes bitten into it. Goal: Find the minimum number of cuts needed so that the A[i, j] values of each piece are either all 0 or all 1. (a) Define your subproblem. Hint: try making any arbitrary cut. What two subproblems do you now have? (b) Write down the recurrence relation for your subproblems. A fully correct recurrence relation will always have the base cases specified. (c) Describe the order in which we should solve the subproblems in your DP algorithm. (d) What is the runtime complexity of your DP algorithm? Provide a justification. (e) What is the space complexity of your algorithm? Provide a justification.
Expert Answer:
Answer rating: 100% (QA)
a Subproblem Definition Lets define our subproblem as follows Given a paper grid with dimensions m x n we want to find the minimum number of cuts required to separate the bitten parts Aij1 from the un... View the full answer
Related Book For
Cost Management Accounting and Control
ISBN: 978-0324559675
6th Edition
Authors: Don R. Hansen, Maryanne M. Mowen, Liming Guan
Posted Date:
Students also viewed these programming questions
-
For your initial post, describe the ways a manager in an organization might want to use persuasion as opposed to a direct request when communicating with employees. In that situation, provide...
-
You are hired to work on an "International Market Assessment" project for a Canadian company 1. The business: Toronto-based Claire's is a small business producing a range of products, including...
-
"For 1-year SPX options, we observe that the 25-delta put implied volatility is at 45%, the 50-delta call implied volatility is at 30%, the 25-delta call implied volatility is at 35%. These...
-
Researchers examined forecasters' interest rate predictions for 34 quarters to see whether the predictions corresponded to what actually happened. The 2 x 2 contingency table below shows the...
-
A vaulted roof truss is loaded as shown. Determine the force in members BE, CE, and DF. ATAN
-
Refer to the internal control questionnaire on a payroll system. a. Assume that the answer to each question is no. Prepare a table matching the questions to errors or frauds that could occur because...
-
A project has been selected for implementation. The net cash flow (NCF) profile associated with the project is shown below. MARR is 10 percent/year. a. What is the internal rate of return of this...
-
Lebo Hardware reported cost of goods sold as follows. Lebo made two errors: (1) 2010 ending inventory was overstated $3,000, and (2) 2011 ending inventory was understated $6,000.InstructionsCompute...
-
3. Katelyn's financial manager invested her savings in a portfolio of shares that comprised of investments of $2000, $1800, and $3100 in the infrastructure, high- tech, and garment industries,...
-
Mr G is an accountant. Mr. G is 47 years old and is married to Claire who is 45 years old and blind. She has Net Income For Tax Purposes in 2020 of $9,000, all of which is interest on investments she...
-
The value of n n n lim (n+1)9n-(n+1) (n+2)9n-(n+2) (n+3) 9n-(n+3) is (Correct upto two decimal places)_ 71 (2n-1)9n-(2n-1)
-
What would be the Canadian equivalent of an S-Corp?
-
How does budget control help the restaurants to improve their financial performance? List any three
-
During which phase of the cell cycle does the DNA duplicate into two identical copies?
-
In general, when should a gain from an intercompany sale be recognized? Give reference.
-
1. (35 points) Write a program to declare the following array of elements and using one of the sorting methods (Selection or Exchange) sort the elements in descending order. {47, 67, 85, 92, 24, 35,...
-
Problem 1. (12 points) A standard deck of cards has 52 cards, which can be classified as face cards - King, Queen, Jack-and non-face cards. The distribution of face cards and non-face cards is below....
-
Privitera and Freeman (2012) constructed a scale to measure or estimate the daily fat intake of participants; the scale was called the estimated daily intake scale for fat (EDIS-F). To validate the...
-
Classify the following environmental activities as prevention costs, detection costs, internal failure costs, or external failure costs. For external failure costs, classify the costs as societal or...
-
The following data are for four independent process-costing departments. Inputs are added uniformly. Required: Compute the equivalent units of production for each of the preceding departments using...
-
What is the quantity decision? The pricing decision?
-
A very simple version of the normative model described in the text involves a simple economic growth process converging to a steady-state, where values do not change over time. \({ }^{14}\) A simple...
-
Go to the library or the Internet and, for a particular year, put together a data set of profits in agriculture in different geographical units of your state or country (e.g., counties of a U.S....
-
For each of the following social choice methods, which of Arrow's axioms are violated, and why: a. the Pareto criterion b. plurality-rule voting (of several choices, the one with the most votes wins)...
Study smarter with the SolutionInn App