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...
-
When a construction project is opened for bidding, two proposals are received with probability 0.11, three proposals are received with probability 0.19, four proposals are received with probability...
-
Emile Kokott, a former disc golf star, operates Emile's Discorama, SA. At the beginning of the current season on April 1, the ledger of Emile's Discorama showed Cash 1,850, Inventory 2,150, and Share...
-
Use the summary statistics in Exercise 12 to test the null hypothesis H0: 1 = 0 versus H1: 1 > 0. Use the = 0.05 level of significance.
-
Draw a decision tree depicting the reimbursement policy in Problem 1.
-
The BB Company plans to sell 300,000 units annually of a certain new product at a projected sales price of $10 per unit. The new product's variable cost is $6 per unit, and annual fixed costs are...
-
The COVID-19 pandemic affected companies in the food industry in unique ways, particularly during 2020. Ruth's Hospitality Group (Ticker: RUTH) develops and operates fine dining restaurants under the...
-
A vendor has 3 kinds of shakes i.e. chocolate, strawberry and banana. He has 204 litres of chocolate shake, 170 litres of strawberry shake and 374 litres of banana shake. He wants to bottle them in...
-
During the audit of Irreg. Company, Betty Bestow was examining the endorsements on payroll checks and comparing the endorsements to the names of the payees on the face of the checks. In prior audits,...
-
Explain how you could build close personal relationships in China to enable the development of long-term business partnerships.
-
The number of electoral college votes for each state in the U.S. and the District of Columbia. In Exercises 1120, determine whether the data set is a population or a sample. Explain your reasoning.
-
John Petite was performing his first audit as a senior. His client was a small toy store with a reputation as a solid and expanding merchandiser. John's CPA firm had performed the audit for several...
-
The studies conducted by the Treadway Commission revealed that fraudulent financial reporting usually occurs as the result of certain environmental, institutional, or individual influences and...
-
. 2) UIP: The current US/Mexican exchange rates are 0.0832 -0.0835 $/peso. Assume 2- year interest rates in the US allow you to invest at annual rates of 1% or borrow at 1.5%. Assume 2-year interest...
-
Find the market equilibrium point for the following demand and supply functions. Demand: 2p = - q + 56 Supply: 3p - q = 34
-
Clifford Johnson has a limited partnership investment and a rental condominium. Clifford actively manages the rental condominium. During 2012, his share of the loss from the limited partnership was...
-
Mallory Corporation has a calendar year-end. The corporation has paid estimated payments of $10,000 during 2012 but still owes an additional $5,000 for its 2012 tax year. a. When is the 2012 tax...
-
Joan is a self-employed attorney in New York City. Joan took a trip to San Diego, CA, primarily for business, to consult with a client and take a short vacation. On the trip, Joan incurred the...
-
Find each probability using the standard normal distribution. (a) \(P(z>-1.68)\) (b) \(P(z <2.23)\) (c) \(P(-0.47
-
What is the highest score that would still place a person in the bottom \(10 \%\) of the scores? In a standardized IQ test, scores are normally distributed, with a mean score of 100 and a...
-
Find the probability that a randomly selected person has an IQ score between 95 and 105. Is this an unusual event? Explain. In a standardized IQ test, scores are normally distributed, with a mean...
Study smarter with the SolutionInn App