Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Find the area of the largest house Question The current selected programming language is Java. We emphasize the submission of a fully working code over

Find the area of the largest house

imageimage

Question The current selected programming language is Java. We emphasize the submission of a fully working code over partially correct but efficient code. Once submitted, you cannot review this problem again. You can use System.out.println() to debug your code. The 1 import java.uti 2 import java.lang 34567 3 import java.io.* 5 /* * grid represen */ public class Sol 8 9 { 10 public stati System.out.println() may not work in 11 { case of syntax/runtime error. The version of JDK being used is 1.8. 12 int ans 13 // Write 14 Note: The main class name must be "Solution". 15 16 return ar 17 } 18 The city authorities conduct a study of the houses in a residential area for a city planning scheme. The area is depicted in an aerial view and divided into an N x M grid. If a grid cell contains some part of a house roof, then it is assigned the value 1; otherwise, the cell represents a vacant plot and is assigned the value 0. Clusters of adjacent grid cells with value 1 represent a single house. Diagonally placed grids with value 1 do not represent a single house. The area of a house is the number of 1s that it spans. 19 public static 20 { 21 Scanner i 22 // input 23 int grid_ 24 int grid_ 25 int grid[] 26 for (int i 27 { 28 for(in 29 { 30 gr 31 } 32 } 33 Write an algorithm to find the area of the largest house. 34 int result Input 9 APR 6,949 12

Step by Step Solution

There are 3 Steps involved in it

Step: 1

find the area of the largest house in the grid you can use a depthfirst search DFS algorithm to trav... 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

International Marketing And Export Management

Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr

8th Edition

1292016922, 978-1292016924

More Books

Students also viewed these Programming questions

Question

Graph the following linear equation. 2x + 4y = 16

Answered: 1 week ago