Determine number of starting positions on the left side

Assignment Help Computer Engineering
Reference no: EM132206418

Write a method startingPoints to determine number of starting positions on the left side of the grid that have a path connecting to the right side of the grid.

A path consists of a sequence of horizontally and vertically adjacent 'x' characters. The grid contains only '.' and 'x' characters.

You can write startingPoints in any way, but here are some hints:

Start at every grid location on the left and explore paths from it using a helper method.

Exploring a grid location means: if it's off the grid stop, if it doesn't contain an 'x' stop

Exploring a grid location on the right means: if it's an x, you've found a new path.

Exploring a grid location means: if it contains an 'x' it might be part of a path. Mark it as explored, check four neighbors, unmark it as explored.

Constraints

grid has between 1 and 16 rows, inclusive.

There are between 1 and 10 columns in the grid, inclusive.

Each character in each element of String[] grid can only be one of the following: a period (representing blocked space that does not connect) or an X (representing open space that can be on a path).

The enclosure is perfectly rectangular. That is, each element of String[] grid will be of the same length.

skeleton code is provided below

ublic class GridSolve {

public int startingPoints(String[] grid) {

// replace with working code

return 0; } }

Examples:

grid = { "...x....x", "...x.....", "...xxx...", "x..x.x.xx", "xxxx.xxx.", "...x.....", "........." }

return 2

grid = { "x......x", "x..x.xxx", "x..x.x..", "xxxxxx.." }

Returns 4. The paths do not need to be distinct.

grid = { "...x....", "...x....", "...x....", "...x...." } Returns 0

Reference no: EM132206418

Questions Cloud

Provide end result of these steps take number 135 : Write MIPS instructions to execute the following steps. Provide end result of these steps Take number 135 [in any register]. Shift the number left 2 times.
In pizza delivery quickly business : In a Pizza Delivery Quickly business. With this type of business in mind, what PMLC model would you use for each of the six subsystems.
How you leverage knowledge gained in intellipath assignments : What competencies were you able to develop in researching and writing the course Comprehensive Project? How did you leverage knowledge gained.
Calculate the stock standard deviation : A stock's returns have the following distribution: Calculate the stock's expected return. Calculate the stock's standard deviation
Determine number of starting positions on the left side : Write a method startingPoints to determine number of starting positions on the left side of the grid that have a path connecting to the right side of the grid.
Criteria includes partial-full telecommunications ability : Given that an organization's resumption strategy for an exclusive-use site criteria includes partial/full telecommunications ability
Was this enough to constitute an act in criminal law : Cindy Sengchanthong was sleeping in his vehicle when he was found by a police officer. Was this enough to constitute an act in criminal law?
What characteristics of hosting the summer olympics suggest : What characteristics of hosting the Summer Olympics suggest that it might be treated as a project??
Why are training designs difficult to understand : Why are training designs difficult to understand? Explain how learning technologies are used and easy grasp the concept.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Find all n prime numbers that are positive integers greater

How to write a java code that take a given number n , and finds all n prime numbers that are positive integers greater .

  How to fit a image in the main frame

how to fit a image in the main frame of uploaded file?

  Computer hardware purchases over the next five years

what criteria will you use to make the purchases.

  What is the maximum achievable data rate

If a binary signal is sent over a 10Khz channel whose signal-to-noise ratio is 20dB, what is the maximum achievable data rate?

  How would an attacker break a caesar-style cipher

Julius Caesar used one of the earliest known cipher systems to communicate with Cicero in Rome while he was conquering Europe.

  Write a program to measure time taken to access an element

Write a program to measure the time taken to access an element of an object of our array class by means of the member function, element o.

  Write the php script that produces the current results

Write the PHP script that produces the current results of the survey of Exercise 9.11. Write HTML document to create a form that collects favorite popular song.

  Write a program that reads the radius of a sphere

Write a program that reads the radius of a sphere and prints its volume and surface area. Use the following formulas. Print the output to four decimal places.

  Design an application that accepts 10 numbers

Embed the algorithm in the Dev C++ source code file as comments. Please ensure, when you Compile & Run program there is zero errors.

  Write a function definition for a function called one more

Write a function definition for a function called one More, which has a formal parameter for an array of integers and increase value of each array element by 1.

  Design to perform data entry for the organization

You are the lead human "computer interaction (HCI) engineer on a major design project for an organization. Design to perform data entry for the organization.

  What peeked your interest the most

Your discussion subject of this week is what did you find most complex or perplexing about vulnerability assessment? What peeked your interest the most?

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