Rules:  Corner cases.  By convention, the row and column indices are integers between 0 and n − 1, where (0, 0) is the upper-left site. Throw an IllegalArgumentException if any argument to open(), isOpen(), or isFull() is outside its prescribed range. Throw

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Rules: 

Corner cases.  By convention, the row and column indices are integers between 0 and n − 1, where (0, 0) is the upper-left site.

  • Throw an IllegalArgumentException if any argument to open(), isOpen(), or isFull() is outside its prescribed range.
  • Throw an IllegalArgumentException in the constructor if n ≤ 0.

Unit testing.  Your main() method must call each public constructor and method directly and help verify that they work as prescribed (e.g., by printing results to standard output).

Performance requirements.  The constructor must take Θ(n^2) time; all instance methods must take Θ(1)Θ(1) time plus Θ(1)Θ(1) calls to union() and find().

 

Percolation data type. To model a percolation system, create a data type Percolation with the following API:
public class Percolation {
// creates n-by-n grid, with all sites initially blocked
public Percolation (int n)
// opens the site (row, col) if it is not open already
public void open (int row, int col)
// is the site (row, col) open?
public boolean isOpen (int row, int col)
// is the site (row, col) full?
public boolean isFull(int row, int col)
// returns the number of open sites
public int numberof0penSites ()
// does the system percolate?
public boolean percolates ()
// unit testing (required)
public static void main (String[] args)
}
Corner cases. By convention, the row and column indices are integers between 0 and n – 1, where (0, 0) is the upper-left site.
• Throw an 1llegalArgumentException if any argument to open ( ), isopen ( ) , or isFull() is outside its prescribed range.
• Throw an 1llegalArgumentException in the constructor if n <0.
Unit testing. Your main () method must call each public constructor and method directly and help verify that they work as prescribed (e.g., by printing results to standard output).
Performance requirements. The constructor must take O(n²) time; all instance methods must take O(1) time plus O(1) calls to union() and find ().
Transcribed Image Text:Percolation data type. To model a percolation system, create a data type Percolation with the following API: public class Percolation { // creates n-by-n grid, with all sites initially blocked public Percolation (int n) // opens the site (row, col) if it is not open already public void open (int row, int col) // is the site (row, col) open? public boolean isOpen (int row, int col) // is the site (row, col) full? public boolean isFull(int row, int col) // returns the number of open sites public int numberof0penSites () // does the system percolate? public boolean percolates () // unit testing (required) public static void main (String[] args) } Corner cases. By convention, the row and column indices are integers between 0 and n – 1, where (0, 0) is the upper-left site. • Throw an 1llegalArgumentException if any argument to open ( ), isopen ( ) , or isFull() is outside its prescribed range. • Throw an 1llegalArgumentException in the constructor if n <0. Unit testing. Your main () method must call each public constructor and method directly and help verify that they work as prescribed (e.g., by printing results to standard output). Performance requirements. The constructor must take O(n²) time; all instance methods must take O(1) time plus O(1) calls to union() and find ().
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education