-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
my First assignment on algorithm percolation1 #4
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
flow(isOpen, isFull, 0, j); | ||
} | ||
return isFull; |
There was a problem hiding this comment.
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.
flow(isOpen, isFull, i, j-1); // left | ||
flow(isOpen, isFull, i-1, j); // up | ||
} |
There was a problem hiding this comment.
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.
for (int j = 0; j < n; j++) { | ||
if (isFull[n-1][j]) return true; | ||
} |
There was a problem hiding this comment.
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.
|
||
// does the system percolate? | ||
public static boolean percolates(boolean[][] isOpen) { |
There was a problem hiding this comment.
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.
No description provided.