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

  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