Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone help me with this using java? i haven't learned how to use arrays yet I've gotten as far as do while, for, and

can someone help me with this using java? i haven't learned how to use arrays yet I've gotten as far as do while, for, and while Loop

Challenge 1:( max 7 points )

Suppose the robot is dropped into a square grid of rooms and starts in the north-west corner of the grid. Come up with an algorithm that the robot can use to figure out how many rooms are in the grid.

An algorithm is a deterministic set of steps that do not require any outside information.

Remember, your robot doesnt know how many squares there are in advance; if you refer to the size of the grid in your instructions to the robot, it wont work.

Once you have a plan use it to implement the method challenge1 in RobotApp.

Make sure it works for different size grids. ( 2 out of 7 points ) If you change the size of the grid to 1 or 10 the robot should still return the correct number of rooms.

Minimize the number of moves:( 1 out of 7 points ) In a 3-by-3 grid, how many times will the robot have to move through a door to run your algorithm? How about a 4-by-4? An n-by-n? Assume that we want to save on robot fuel. Try to make an algorithm that minimizes the moves it takes for the robot to solve the challenge (to figure out the number of rooms in the grid).

One more thing to do:( 1 out of 7 points ) Once you have an algorithm you think is general (works for all size squares) and efficient (uses few moves), consider through how many doors the robot has to enter in order to figure out the total number of rooms. It should be an expression based on n e.g.for an n-by-n grid the robot moves through 2n+5 doors or something like that.

At the end, the robot should say the number of rooms and the expression describing the number of moves. The number of rooms is dynamicallycalculated with the help of the robot. The expression is something you figured out and part of the hard-coded text. Use the following format: {numberOfRooms} rooms {expression} moves E.g.:3 rooms 2n+5 moves Notice: neither 3 nor 2n+5 are the right answer but just an example of the expected format

Challenge 2:( max 7 points )

This time the robot is dropped into a rectangular (not necessarily square) grid of rooms. Again, the robot starts in the north-west corner of the grid and again the robot is tasked to figure out the total number of rooms. Solve the analogous challenges described above but this time for a rectangular grid.

This time implement the method challenge2 in RobotApp.

Make sure it works for different grid sizes. ( 2 out of 7 points ) Minimize the number of moves to save robot fuel:( 1 out of 7 points )

Expression based on width(w) and height(h):( 1 out of 7 points ) Come up with an expression that describes the number of moves needed for a w-by-h grid. At the end, the robot should say the number of rooms and the expression based on w and h

Challenge 3:( max 7 points )

In this third challenge, the robot is dropped into a rectangular (not necessarily square) grid of rooms. However, this time the robot starts in any arbitrary room in the grid.

Solve the analogous challenges described above by implementing the method challenge3 in RobotApp.

Make sure the robot returned the correct number of rooms regardless of the grid size. ( 2 out of 7 points ) Minimize the number of moves to save robot fuel:( 1 out of 7 points )

Expression based on width(w) and height(h):( 1 out of 7 points ) Come up with an expression that describes the number of moves needed for a w-by-h grid. Since this will probably depend on the starting location of the robot, assume the robot starts in the worst possible room (the room that requires the robot to open the most doors) At the end, the robot should say the number of rooms and the expression based on w and h

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions