Skip to content

my First assignment on algorithm percolation1#4

Open
rasheey97-alt wants to merge 1 commit intosweskills:masterfrom
rasheey97-alt:master
Open

my First assignment on algorithm percolation1#4
rasheey97-alt wants to merge 1 commit intosweskills:masterfrom
rasheey97-alt:master

Conversation

@rasheey97-alt
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@erictoguem erictoguem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you implement all methods, while respecting the method signature, but most important having the method does what it is supposed to do.

Comment thread Percolation.java
for (int j = 0; j < n; j++) {
flow(isOpen, isFull, 0, j);
}
return isFull;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not isOpen is supposed to do, it should just check the site is open.

Comment thread Percolation.java
flow(isOpen, isFull, i, j+1); // right
flow(isOpen, isFull, i, j-1); // left
flow(isOpen, isFull, i-1, j); // up
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method doesn't determine full site, but just mark as full any site that is open, and this is not the definition of a full site, which is: A full site is an open site that can be connected to an open site in the top row via a chain of neighboring (left, right, up, down) open sites.

Comment thread Percolation.java
boolean[][] isFull = flow(isOpen);
for (int j = 0; j < n; j++) {
if (isFull[n-1][j]) return true;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the isFull was actually returning full sites, then your method would be working. However, it would have not respected performance requirements, as this check is O(n) not constant and flow is not constant also.

Comment thread Percolation.java


// does the system percolate?
public static boolean percolates(boolean[][] isOpen) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

percolates is not supposed to take any parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants