Introduction to Analysis of Algorithms - Graph and DP algorithms. please provide step-by-step instructions I believe graph
No answer yet for this question.
Ask a Tutor
Question:
Introduction to Analysis of Algorithms - Graph and DP algorithms.
please provide step-by-step instructions I believe graph algo would help with the question.
Transcribed Image Text:
Problem 1 (Snakes and Ladders, ). Snakes and Ladders is a classic board game, originating in India no later than the 16th century. The board consists of an n x n grid of squares, numbered consecutively from 1 to n, starting in the bottom left corner and proceeding row by row from bottom to top, with rows alternating to the left and right. Certain pairs of squares, always in different rows, are connected by either "snakes" (leading down) or "ladders" (leading up). Each square can be an endpoint of at most one snake or ladder. An example board is shown in figure 1. 100 99 97 96 94 93 92 91 81 82 8 80 84 85 86 87 89 90 78 77 76 75 74 73 71 61 62 63 64 65 66 68 6 70 58 555 545 52 51 60 41 443 5 46 4 48 49 40 39 38 37 36 35 34 33 32 31 21 22 23 25 6 28 29 30 20 19 8 1 16 514 3 2 11 4 5 5 7 9 10 Figure 1: A typical Snakes and Ladders board. Upward straight arrows are ladders; downward wavy arrows are snakes. You start with a token in cell 1, in the bottom left corner. In each move, you advance your token up to k positions (i.e. from your current square s to any square from s +1 to s+ k), for some fixed constant k (typically 6). If the token ends the move at the top end of a snake, you must slide the token down to the bottom of that snake. If the token ends the move at the bottom end of a ladder, you may move the token up to the top of that ladder. (a) Describe an algorithm to compute the smallest number of moves required for the token to reach the last square of the grid. Don't forget to take into consideration when the last square (b) (c) can not be reached. Analyze the runtime of your algorithm if the board is given explicitly as an n x n grid of squares, each with fields indicating whether they are the start of a snake or ladder and giving the destination if so. Analyze the runtime of your algorithm (in terms of the input size) if instead the input is just the number n (written in binary), together with lists of snakes and ladders represented as pairs (i, j) giving the numbers of their start and end squares. If it helps, you can let m be the number of ladders plus the number of snakes. Problem 1 (Snakes and Ladders, ). Snakes and Ladders is a classic board game, originating in India no later than the 16th century. The board consists of an n x n grid of squares, numbered consecutively from 1 to n, starting in the bottom left corner and proceeding row by row from bottom to top, with rows alternating to the left and right. Certain pairs of squares, always in different rows, are connected by either "snakes" (leading down) or "ladders" (leading up). Each square can be an endpoint of at most one snake or ladder. An example board is shown in figure 1. 100 99 97 96 94 93 92 91 81 82 8 80 84 85 86 87 89 90 78 77 76 75 74 73 71 61 62 63 64 65 66 68 6 70 58 555 545 52 51 60 41 443 5 46 4 48 49 40 39 38 37 36 35 34 33 32 31 21 22 23 25 6 28 29 30 20 19 8 1 16 514 3 2 11 4 5 5 7 9 10 Figure 1: A typical Snakes and Ladders board. Upward straight arrows are ladders; downward wavy arrows are snakes. You start with a token in cell 1, in the bottom left corner. In each move, you advance your token up to k positions (i.e. from your current square s to any square from s +1 to s+ k), for some fixed constant k (typically 6). If the token ends the move at the top end of a snake, you must slide the token down to the bottom of that snake. If the token ends the move at the bottom end of a ladder, you may move the token up to the top of that ladder. (a) Describe an algorithm to compute the smallest number of moves required for the token to reach the last square of the grid. Don't forget to take into consideration when the last square (b) (c) can not be reached. Analyze the runtime of your algorithm if the board is given explicitly as an n x n grid of squares, each with fields indicating whether they are the start of a snake or ladder and giving the destination if so. Analyze the runtime of your algorithm (in terms of the input size) if instead the input is just the number n (written in binary), together with lists of snakes and ladders represented as pairs (i, j) giving the numbers of their start and end squares. If it helps, you can let m be the number of ladders plus the number of snakes.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these algorithms questions
-
A survey of information systems managers was used to predict the yearly salary of beginning programmer/analysts in a metropolitan area. Managers specified their standard salary for a beginning...
-
You have been hired by the Regional Real Estate Company to help them analyze real estate data. One of the companys Pacific region salespeople just returned to the office with a newly designed...
-
Use c program to solve this. Problem B [10 marks] Write a program to calculate age (birth date and current date will be entered by user). Make a structure named Date to store the elements day, month...
-
A random variable X has a distribution given by the probability density function f(X) = (1 - x)/2 with a state space - 1 < x < 1. (a) What is the expected value of X? (b) What is the standard...
-
What surface integrals can be converted to volume integrals? How?
-
CGI Federal, Inc., is a corporation that provides a number of services to the United States Passport Agency, included the processing of passport application. Passport applicants must submit sensitive...
-
Southwood Furniture Company is a U.S.-based furniture manufacturer that offshored all of its actual manufacturing operations to China about a decade ago. It set up a distribution center in Hong Kong...
-
Amazon Sales $177,866 Accounts receivable: Beginning of year 20,816 End of year 16,677 Determine the accounts receivable turnover. For interim computations, carry amounts out to one decimal place....
-
1. Describe how the correction of the overstated inventory, Retained Earning, and earnings would be recorded in financial statements following current US GAAP. 2. What factors do you believe...
-
Total demand ( D ) is 3 5 0 units, the holding cost per unit ( Ch ) is equal to ( 0 . 6 ) and the ordering cost per order ( Co ) is ( 1 1 . 5 ) . Calculate the total costs for each plan and state...
-
If a company wants to maximize their profit when they sell their inventory, which of the following managerial accounting decisions would help them achie desired goal? O The management team should...
-
How do power dynamics and hegemonic ideologies perpetuate systemic inequalities, and what strategies can be employed to challenge and dismantle oppressive structures in pursuit of social justice and...
-
Consider a multi-factor key rate model with key rates being YTM on 2, 5, 10, and 30-year par ponds. In lectures, we have shown that the price p(x) of a T-year par dp. 100 bond, where y is the bond's...
-
How does society conceptualize and delineate the notion of deviance, and what multifaceted factors could potentially precipitate individuals to engage in behavior classified as "deviant"?
-
A futures contract covers 5000 pounds with a minimum price change of $0.01 is sold for $31.60 per pound. If the initial margin is $2,525 and the maintenance margin is $1,000, at what price would...
-
A genetically engineered strain of Escherichia coli (E. coli) is used to synthesize human insulin for people suffering from type I diabetes mellitus. In the following simplified reaction scheme,...
-
The descending order in which current assets should be shown in the statement of financial position is (A) Inventory, Accounts receivable. Bank, Cash (B) Cash, Bank, Accounts receivable, Inventory...
-
Carriage inwards is charged to the trading account because (A) It is an expense connected with buying goods (B) It should not go in the statement of financial position (C) It is not part of motor...
-
The costs of putting goods into a saleable condition should be charged to (A) The trading account (B) The profit and loss account (C) The statement of financial position (D) None of these
Study smarter with the SolutionInn App