I’m working on a java question and need the explanation and answer to help me learn.

Learning Goal: I’m working on a computer science question and need the explanation and answer to help me learn.

COMPLETE IN JAVA

Overview: Cleo is a cat that likes to climb up to high places and watch birds. Every day she

escapes her cage and wanders until she finds a good location. At the end of every day you need

to find Cleo and return her to her cage. For this project you will write a program to determine

the locations where Cleo may decide to perch.

Details: You have mapped the rectangular island where Cleo lives by dividing it into a grid of

cells with r rows and c columns (like a 2-d array). Cleo’s cage is at location row x and column y.

Each square has a height (above sea level). When Cleo escapes her cage she walks according to

the following rules:

  • Cleo will never move from a square to a lower square.
  • Cleo may move to one of the four adjacent squares if the adjacent square is the same or
  • greater height.

  • Cleo may stop if none of the four adjacent squares is higher.
  • The input will be provided in a file named input.txt which will be placed in the same directory

    as your java file. The format of this file will be a sequence of whitespace separated integers. The

    first line will contain r and c. The second line will contain x and y. The next r lines will contain

    the c heights of the cells in that row.

    Your output will consist of a line with n the number of locations where Cleo may stop and each

    of the next n lines will be the locations where Cleo may stop. No other output should appear in

    the final project. See the examples below.

    The easiest way to solve the problem is to read the data file into a 2-d array, treat the cells of the

    array as nodes, have a directed edge from a cell/node to an adjacent cell/node if the height of the

    adjacent cell is the same or larger, run BFS or DFS to determine which cells are reachable, and

    check whether Cleo might stop at the cell/node by seeing if it is at least as high as the adjacent

    cells.

    required project specifications:

    Consist of 1 or more dot-java files (no class files, zip files, input files, or other files should

    be submitted).• have each file begin with your name and project number.

  • not be placed into any package.
  • have one file called Project1.java.
  • compile with the command ‘javac Project1.java’.
  • run using the command ‘java Project1’.
  • accept input from a file called input.txt in the same directory as the java file(s) formatted
  • precisely as described above.

  • accomplishes the goal of the project. In other words, the output should be the correct
  • answer formatted correctly.

    Examples:

    If input.txt contains:

    5 5

    2 2

    9 9 9 9 9

    9 8 1 8 9

    9 1 5 1 9

    9 8 1 8 9

    9 9 9 9 9

    then the output would be

    1

    2 2

    since Cleo cannot leave the square where she starts without going down.

    If input.txt contains:

    5 5

    2 2

    1 9 7 8 1

    1 1 5 1 1

    1 1 3 4 5

    1 1 5 1 1

    1 8 7 7 7

    then the output would be:

    6

    0 1

    0 3

    2 4

    4 1

    4 3

    4 4

    Note all 6 of these locations are at least as high as their neighbors and any square not containing

    a 1 is reachable.

    If input.txt contains:

    8 8

    0 0

    1 2 3 4 5 6 7 7

    1 2 3 4 5 6 7 8

    2 3 4 1 1 1 1 1

    2 3 2 1 2 2 2 2

    3 4 3 1 5 2 5 5

    4 5 2 1 2 2 8 9

    5 6 3 1 6 2 8 4

    1 7 5 1 5 2 1 9

    then the output would be:

    4

    0 6

    1 7

    2 2

    7 1

    because there are 4 locations that Cleo can wander to and might stop. For example, Cleo could

    walk from (0,0) to (0,1) to (0,2) to (0,3) to (0,4) to (0,5) to (0,6) and stop, since the heights don’t

    decrease: 1, 2, 3, …,7 and the cells adjacent to (0,6) are not higher. Similarly, Cleo could walk

    from (0,0) to (1,0) to (2,0) to (3,0) to (4,0) to (5,0) to (6,0) to (6,1) to (7,1) and stop, since the

    heights don’t decrease 1, 1, 2, 2, 3, 4, 5, 6, 7 and the cells adjacent to (7,1) aren’t higher.

    Note that the list does not contain (0,7) because a neighbor (1,7) is higher and does not contain

    (7,7) because it is unreachable.

    COMPLETE IN JAVA

    Requirements: complete

    Are you struggling with your paper? Let us handle it - WE ARE EXPERTS!

    Whatever paper you need - we will help you write it

    Get started

    Starts at $9 /page

    How our paper writing service works

    It's very simple!

    • Fill out the order form

      Complete the order form by providing as much information as possible, and then click the submit button.

    • Choose writer

      Select your preferred writer for the project, or let us assign the best writer for you.

    • Add funds

      Allocate funds to your wallet. You can release these funds to the writer incrementally, after each section is completed and meets your expected quality.

    • Ready

      Download the finished work. Review the paper and request free edits if needed. Optionally, rate the writer and leave a review.