2. Read and understand the problem stated below. 3. Design an algorithm to solve the stated problem and write its pseudocode. 4. Analyze your algorithm running time, and provide an asymptotic upper bound using BigOh notation. 5. Implement your algorithm using Java. 6. Submit your report (pseudocode, running time and asymptotic upper bound analysis) along with your .java file via Blackboard before the deadline. The Snake and Ladder Problem: Sarah takes out her Snakes and Ladders Game, stares at the board and wonders: "What if I can always roll the dice to whatever number I want, what would be the least number of rolls to reach the destination?" RULES: 1. The game is played with cubic dice of 6 faces numbered from 1 to 6. 2. Starting from 1, the goal is to land on square 100 with the exact roll of the dice. If the number rolled would place the player beyond square 100, no move is made. 3. If a player lands at the base of a ladder, the player must climb the ladder. Ladders go up only. 4. If a player lands at the mouth of a snake, the player must go down the snake and come out through the tail. Snakes go down only. BOARD DESCRIPTION: – The board is always 10 x 10 with squares numbered from 1 to 100. – The board contains N ladders given in a form of 2D matrix A of size N * 2 where (A[i][0], A[i][1]) denotes a ladder that has its base on square A[i][0] and end at square A[i][1]. – The board contains M snakes given in a form of 2D matrix B of size M * 2 where (B[i][0], B[i][1]) denotes a snake that has its mouth on square B[i][0] and tail at square B[i][1]. Problem Constraints 1 B[i][1] Neither square 1 nor square 100 will be the starting point of a ladder or snake. A square will have at most one endpoint from either a snake or a ladder. Input Format First argument is a 2D matrix A of size N * 2 where (A[i][0], A[i][1]) denotes a ladder that has its base on square A[i][0] and end at square A[i][1]. Second argument is a 2D matrix B of size M * 2 where (B[i][0], B[i][1]) denotes a snake that has its mouth on square B[i][0] and tail at square B[i][1]. Output Format Return the least number of rolls to move from start to finish on a separate line. If there is no solution, return -1. Example Input Input 1: A = [ [32, 62] [42, 68] [12, 98] ] B = [ [95, 13] [97, 25] [93, 37] [79, 27] [75, 19] [49, 47] [67, 17] Input 2: A = [ [8, 52] [6, 80] [26, 42] [2, 72]] B = [ [51, 19] [39, 11] [37, 29] [81, 3] [59, 5] [79, 23] [53, 7] [43, 33] [77, 21] Example Output Output 1: 3 Output 2: 5 Example Explanation Explanation 1: The player can roll a 5 and a 6 to land at square 12. There is a ladder to square 98. A roll of 2 ends the traverse in 3 rolls. Explanation 2: The player first rolls 5 and climbs the ladder to square 80. Three rolls of 6 get to square 98. A final roll of 2 la

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
2. Read and understand the problem stated below. 3. Design an algorithm to solve the stated problem and write its pseudocode. 4. Analyze your algorithm running time, and provide an asymptotic upper bound using BigOh notation. 5. Implement your algorithm using Java. 6. Submit your report (pseudocode, running time and asymptotic upper bound analysis) along with your .java file via Blackboard before the deadline. The Snake and Ladder Problem: Sarah takes out her Snakes and Ladders Game, stares at the board and wonders: "What if I can always roll the dice to whatever number I want, what would be the least number of rolls to reach the destination?" RULES: 1. The game is played with cubic dice of 6 faces numbered from 1 to 6. 2. Starting from 1, the goal is to land on square 100 with the exact roll of the dice. If the number rolled would place the player beyond square 100, no move is made. 3. If a player lands at the base of a ladder, the player must climb the ladder. Ladders go up only. 4. If a player lands at the mouth of a snake, the player must go down the snake and come out through the tail. Snakes go down only. BOARD DESCRIPTION: – The board is always 10 x 10 with squares numbered from 1 to 100. – The board contains N ladders given in a form of 2D matrix A of size N * 2 where (A[i][0], A[i][1]) denotes a ladder that has its base on square A[i][0] and end at square A[i][1]. – The board contains M snakes given in a form of 2D matrix B of size M * 2 where (B[i][0], B[i][1]) denotes a snake that has its mouth on square B[i][0] and tail at square B[i][1]. Problem Constraints 1 B[i][1] Neither square 1 nor square 100 will be the starting point of a ladder or snake. A square will have at most one endpoint from either a snake or a ladder. Input Format First argument is a 2D matrix A of size N * 2 where (A[i][0], A[i][1]) denotes a ladder that has its base on square A[i][0] and end at square A[i][1]. Second argument is a 2D matrix B of size M * 2 where (B[i][0], B[i][1]) denotes a snake that has its mouth on square B[i][0] and tail at square B[i][1]. Output Format Return the least number of rolls to move from start to finish on a separate line. If there is no solution, return -1. Example Input Input 1: A = [ [32, 62] [42, 68] [12, 98] ] B = [ [95, 13] [97, 25] [93, 37] [79, 27] [75, 19] [49, 47] [67, 17] Input 2: A = [ [8, 52] [6, 80] [26, 42] [2, 72]] B = [ [51, 19] [39, 11] [37, 29] [81, 3] [59, 5] [79, 23] [53, 7] [43, 33] [77, 21] Example Output Output 1: 3 Output 2: 5 Example Explanation Explanation 1: The player can roll a 5 and a 6 to land at square 12. There is a ladder to square 98. A roll of 2 ends the traverse in 3 rolls. Explanation 2: The player first rolls 5 and climbs the ladder to square 80. Three rolls of 6 get to square 98. A final roll of 2 lands on the target square in 5 total rolls.
36 35
25 26
24
23
13 14
12 11
1
2
34 33 32 31
27 28 29 30
22 21 20
17
3' 4
15 16
10 9 8 7
5
6
19
18
Transcribed Image Text:36 35 25 26 24 23 13 14 12 11 1 2 34 33 32 31 27 28 29 30 22 21 20 17 3' 4 15 16 10 9 8 7 5 6 19 18
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY