Create a recursive java program that will traverse the array

Assignment Help Computer Engineering
Reference no: EM132076075

Need help with my JAVA programming homework!

Solve for a path through a Two-Dimensional maze by use of exhaustive search and backtracking.

Given a two-dimensional array like the one shown below, create a recursive Java program that will traverse the array looking for a path from the upper left corner to the lower right.

private int[][] grid = { {1,1,1,0,1,1,0,0,0,1,1,1,1},
{1,0,1,1,1,0,1,1,1,1,0,0,1},
{0,0,0,0,1,0,1,0,1,0,1,0,0},
{1,1,1,0,1,1,1,0,1,0,1,1,1},
{1,0,1,0,0,0,0,1,1,1,0,0,1},
{1,0,1,1,1,1,1,1,0,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1}};

Program specifications:

In the maze, values represented are:

- 1 - An available space for a path (an open 'room')

- 0 - A'wall'

- 3 - A visited room

- 7 - A room on a successful path

Your program should:

Start in the upper left corner

Attempt to move in a direction

- Check that the 'room' you want to move into is inside the maze

- Check that the room you want to move to is available (not a wall)

- Check that the room you want to move to has not been visited previously

If the move is not valid try to move in another direction

If the is valid, 'move' into the 'room' and mark it as 'visited' (3)

If no valid move is available, unwind in your recursive call stack to the previous call and try the next direction from there

Repeat until either you've reached the goal or you've determined that there is no path through the maze.

Some suggestions:

Determine what the base cases will be

Your recursive method should return a variable of type boolean.

Your recursive method's signature should accept two parameters only.

Reference no: EM132076075

Questions Cloud

Determine the range for which each alternative is best : Determine the range for which each alternative is best. Are there any alternatives that are never best? Which?
A program that prompts the user for the name of a text file : Write a program called CountLetters.java that prompts the user for the name of a text file, reads in all of the text in that file, and then computes.
Discuss the key arguments and findings from pertinent : Discuss the key arguments and findings from pertinent literature and draft your critical review keeping in mind its purpose Formulate the main research question
Describe in detail a group in which you are currently : Describe in detail a group in which you are currently a member and share how effective your group is based on these three areas. Provide examples
Create a recursive java program that will traverse the array : Create a recursive Java program that will traverse the array looking for a path from the upper left corner to the lower right.
Read the instructions for community assessment : Read the Instructions for Community Assessment, Diagnosis, and Planning Project first.
Describe a challenge you faced as a leader or one : Describe a challenge you faced as a leader or one you faced as a subordinate (follower) or as a leader.
Cross-cultural communication paper : Research the culture of a country of your choice. Describe the key cultural differences between the US and your chosen country.
Create a jframe : When the button is clicked, make the JColorChooser Dialog show up. Use the selected color to set the Background of the JPanel the button is in.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd