Please solve the following using Java. Please also provide some explanations because I am new to Graph Traversal.  Canadian Computing Competition: 2010 Stage 1, Junior #5 Below is an 8×88×8 chessboard on which we will designate square locations using the ordered pairs as indicated. For example, notice that piece AA is at position (2,2)(2,2) and piece BB is at position (4,3)(4,3). 8                 7                 6                 5                 4                 3       B         2   A             1                   1 2 3 4 5 6 7 8 A knight is a special game piece that can leap over other pieces, moving in the "L" pattern. Specifically, in the diagram below, KK represents the knight's starting position and the numbers 1 through 8 represent possible places the knight may move to. 8                 7                 6     8   1       5   7       2     4       Knight         3   6       3     2     5   4       1                   1 2 3 4 5 6 7 8 Your program will read the starting location of the knight and output the smallest number of jumps or moves needed to arrive at a location specified in the second input. Input Specification Your program will read four integers, where each integer is in the range 1…81…8. The first two integers represent the starting position of the knight. The second two integers represent the final position of the knight. Output Specification Your program should output the minimum (non-negative integer) number of moves required to move the knight from the starting position to the final position. Note that the knight is not allowed to move off the board during the sequence of moves. Sample Input 1 2 1 3 3 Output for Sample Input 1 1 Sample Input 2 4 2 7 5 Output for Sample Input 2 2

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please solve the following using Java. Please also provide some explanations because I am new to Graph Traversal. 

Canadian Computing Competition: 2010 Stage 1, Junior #5

Below is an 8×88×8 chessboard on which we will designate square locations using the ordered pairs as indicated. For example, notice that piece AA is at position (2,2)(2,2) and piece BB is at position (4,3)(4,3).

8                
7                
6                
5                
4                
3       B        
2   A            
1                
  1 2 3 4 5 6 7 8

A knight is a special game piece that can leap over other pieces, moving in the "L" pattern. Specifically, in the diagram below, KK represents the knight's starting position and the numbers 1 through 8 represent possible places the knight may move to.

8                
7                
6     8   1      
5   7       2    
4       Knight        
3   6       3    
2     5   4      
1                
  1 2 3 4 5 6 7 8

Your program will read the starting location of the knight and output the smallest number of jumps or moves needed to arrive at a location specified in the second input.

Input Specification

Your program will read four integers, where each integer is in the range 1…81…8. The first two integers represent the starting position of the knight. The second two integers represent the final position of the knight.

Output Specification

Your program should output the minimum (non-negative integer) number of moves required to move the knight from the starting position to the final position. Note that the knight is not allowed to move off the board during the sequence of moves.

Sample Input 1

2 1 3 3

Output for Sample Input 1

1

Sample Input 2

4 2 7 5

Output for Sample Input 2

2

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Polynomial time
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education