Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in JAVA Soil scientists characterize and classify soils into different groups. Each group of soil has differing ability to hold water depending on the particles

in JAVA
Soil scientists characterize and classify soils into different groups. Each group of soil has
differing ability to hold water depending on the particles inside. For the sake of simplicity, you
are given the internal structure of soil as n-by-n grid of cells. Each cell is either 1 or 0.
1 means, the cell allows water to drain.
0 means that cell will hold the water.
You need to create the required classes and methods to enable the following client application
to read data from a specified file and determine if water can drain from it. Please ensure that
your code works correctly with the provided sample code, as it will be tested using a file similar
to the one below.
public class Client {
public static void main(String[] args) throws Exception {
Soil soil = new Soil("sample1.txt");
if (soil.doesDrain()){
System.out.println("Allows water to drain");
} else {
System.out.println("Doesn't allow water to drain");
}
}
}
You are asked to implement and use the Weighted Quick Union with Path Compression union-
find algorithm to solve whether a soil example allows water to drain. You are not allowed to use
union-find implementations provided in alg4.jar.
Sample Input File-1:
10101
11010
01101
10101
10111
Expected Output:
Allows water to drain
Sample Input File-2:
10011
01110
10001
10001
11011
Expected Output:
Dont allow water to drain
Sample Input File-3:
1001111000
0111000110
1001100100
1000111000
1101111000
1011011110
0000110000
1011111000
0101101010
1101011000
Expected Output:
Allows water to drain

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

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

What projects have I completed at home, work, or school?

Answered: 1 week ago