Question: i am working on a percolation code and i need help. percolation: percolation stats: import dsa.WeightedQuickUnionUF; import stdlib.In; import stdlib.Stdout // Models an N-by-N percolation
i am working on a percolation code and i need help.
percolation:


![percolation system. public class Percolation { int N; / xn matrix boolean[][]](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f0697fc365e_67966f0697f68ec3.jpg)
percolation stats:


![all sites blocked. public Percolation(int N) { this.N=N; open = new boolean(this.N][this.N];](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f06981c64dd_68166f069814d4dd.jpg)



import dsa.WeightedQuickUnionUF; import stdlib.In; import stdlib.Stdout // Models an N-by-N percolation system. public class Percolation { int N; / xn matrix boolean[][] open; // THE matrix int siteOpen; private WeightedQuickUnionUF uf; // union find data structured int source; int sink; // Creates an N-by-N grid, with all sites blocked. public Percolation(int N) { this.N=N; open = new boolean(this.N][this.N]; uf = new WeightedQuickUnionUF(this.N * this.N +2); sink=this.N * this. N +1; source = 0; D> A if(this.N this.N -1 ) { | throw new IndexOutOfBoundsException(); } if(i this.N -1 ){ A if(i this.N -1 ){ throw new IndexOutOfBoundsException(); } if(!isOpen(i,j)) { open[i][j]= true; siteOpen +=1; } if(i + 1 = 0 && i = 0 && j A if(this.N this.N -1 ) { | throw new IndexOutOfBoundsException(); } if(i this.N -1 ){ A if(i this.N -1 ){ throw new IndexOutOfBoundsException(); } if(!isOpen(i,j)) { open[i][j]= true; siteOpen +=1; } if(i + 1 = 0 && i = 0 && j
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
