my First assignment on algorithm percolation1#4
my First assignment on algorithm percolation1#4rasheey97-alt wants to merge 1 commit intosweskills:masterfrom
Conversation
erictoguem
left a comment
There was a problem hiding this comment.
Please could you implement all methods, while respecting the method signature, but most important having the method does what it is supposed to do.
| for (int j = 0; j < n; j++) { | ||
| flow(isOpen, isFull, 0, j); | ||
| } | ||
| return isFull; |
There was a problem hiding this comment.
This is not isOpen is supposed to do, it should just check the site is open.
| flow(isOpen, isFull, i, j+1); // right | ||
| flow(isOpen, isFull, i, j-1); // left | ||
| flow(isOpen, isFull, i-1, j); // up | ||
| } |
There was a problem hiding this comment.
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.
| boolean[][] isFull = flow(isOpen); | ||
| for (int j = 0; j < n; j++) { | ||
| if (isFull[n-1][j]) return true; | ||
| } |
There was a problem hiding this comment.
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.
|
|
||
|
|
||
| // does the system percolate? | ||
| public static boolean percolates(boolean[][] isOpen) { |
There was a problem hiding this comment.
percolates is not supposed to take any parameter.
No description provided.