"# coursera_algorithms_part_1_percolation" 100/100
See the Assessment Guide for information on how to interpret this report.
ASSESSMENT SUMMARY
Compilation: PASSED API: PASSED
Findbugs: PASSED PMD: PASSED Checkstyle: PASSED
Correctness: 30/30 tests passed Memory: 8/8 tests passed Timing: 20/20 tests passed
Aggregate score: 100.00% [Compilation: 5%, API: 5%, Findbugs: 0%, PMD: 0%, Checkstyle: 0%, Correctness: 60%, Memory: 10%, Timing: 20%]
ASSESSMENT DETAILS
4.0K Feb 27 15:21 Percolation.java 2.4K Feb 27 15:21 PercolationStats.java
- COMPILING
% javac Percolation.java *-----------------------------------------------------------
% javac PercolationStats.java *-----------------------------------------------------------
================================================================
Checking the APIs of your programs. *----------------------------------------------------------- Percolation:
PercolationStats:
================================================================
- CHECKING STYLE AND COMMON BUG PATTERNS
% findbugs *.class *-----------------------------------------------------------
================================================================
% pmd . *----------------------------------------------------------- PercolationStats.java:7: Can you replace the instance (or static) variable 'experimentsCount' with a local variable? [SingularField] PMD ends with 1 warning.
================================================================
% checkstyle *.java *-----------------------------------------------------------
% custom checkstyle checks for Percolation.java *-----------------------------------------------------------
% custom checkstyle checks for PercolationStats.java *-----------------------------------------------------------
================================================================
- TESTING CORRECTNESS
Testing correctness of Percolation *----------------------------------------------------------- Running 15 total tests.
Tests 1 through 8 create a Percolation object using your code, then repeatedly open sites by calling open(). After each call to open(), it checks the return values of isOpen(), percolates(), numberOfOpenSites(), and isFull() in that order. Except as noted, a site is opened at most once.
Tests 13 through 15 test backwash.
Test 1: open predetermined list of sites using file inputs
- filename = input6.txt
- filename = input8.txt
- filename = input8-no.txt
- filename = input10-no.txt
- filename = greeting57.txt
- filename = heart25.txt ==> passed
Test 2: open random sites until just before system percolates
- n = 3
- n = 5
- n = 10
- n = 10
- n = 20
- n = 20
- n = 50
- n = 50 ==> passed
Test 3: open predetermined sites for n = 1 and n = 2 (corner case test)
- filename = input1.txt
- filename = input1-no.txt
- filename = input2.txt
- filename = input2-no.txt ==> passed
Test 4: check predetermined sites with long percolating path
- filename = snake13.txt
- filename = snake101.txt ==> passed
Test 5: open every site
- filename = input5.txt ==> passed
Test 6: open random sites until just before system percolates, allowing open() to be called on a site more than once
- n = 3
- n = 5
- n = 10
- n = 10
- n = 20
- n = 20
- n = 50
- n = 50 ==> passed
Test 7: call methods with invalid arguments
- n = 10, (row, col) = (-1, 5)
- n = 10, (row, col) = (11, 5)
- n = 10, (row, col) = (0, 5)
- n = 10, (row, col) = (5, -1)
- n = 10, (row, col) = (5, 11)
- n = 10, (row, col) = (5, 0)
- n = 10, (row, col) = (-2147483648, -2147483648)
- n = 10, (row, col) = (2147483647, 2147483647) ==> passed
Test 8: call constructor with invalid argument
- n = -10
- n = -1
- n = 0 ==> passed
Test 9: create multiple Percolation objects at the same time (to make sure you didn't store data in static variables) ==> passed
Test 10: open predetermined list of sites using file inputs, but permute the order in which methods are called
- filename = input8.txt; order = isFull(), isOpen(), percolates()
- filename = input8.txt; order = isFull(), percolates(), isOpen()
- filename = input8.txt; order = isOpen(), isFull(), percolates()
- filename = input8.txt; order = isOpen(), percolates(), isFull()
- filename = input8.txt; order = percolates(), isOpen(), isFull()
- filename = input8.txt; order = percolates(), isFull(), isOpen() ==> passed
Test 11: call all methods in random order until just before system percolates
- n = 3
- n = 5
- n = 7
- n = 10
- n = 20
- n = 50 ==> passed
Test 12: call all methods in random order until almost all sites are open, but with inputs not prone to backwash
- n = 3
- n = 5
- n = 7
- n = 10
- n = 20
- n = 50 ==> passed
Test 13: check for backwash with predetermined sites
- filename = input20.txt
- filename = input10.txt
- filename = input50.txt
- filename = jerry47.txt
- filename = sedgewick60.txt
- filename = wayne98.txt ==> passed
Test 14: check for backwash with predetermined sites that have multiple percolating paths
- filename = input3.txt
- filename = input4.txt
- filename = input7.txt ==> passed
Test 15: call all methods in random order until all sites are open, allowing isOpen() to be called on a site more than once (these inputs are prone to backwash)
- n = 3
- n = 5
- n = 7
- n = 10
- n = 20
- n = 50 ==> passed
Total: 15/15 tests passed!
================================================================
- TESTING CORRECTNESS (substituting reference Percolation)
Testing correctness of PercolationStats *----------------------------------------------------------- Running 15 total tests.
Test 1: check that methods in PercolationStats do not print to standard output
- n = 20, trials = 10
- n = 50, trials = 20
- n = 100, trials = 50
- n = 64, trials = 150 ==> passed
Test 2: check that mean() returns value in expected range
- n = 2, trials = 10000
- n = 5, trials = 10000
- n = 10, trials = 10000
- n = 25, trials = 10000 ==> passed
Test 3: check that stddev() returns value in expected range
- n = 2, trials = 10000
- n = 5, trials = 10000
- n = 10, trials = 10000
- n = 25, trials = 10000 ==> passed
Test 4: check that PercolationStats creates trials Percolation objects, each of size n-by-n
- n = 20, trials = 10
- n = 50, trials = 20
- n = 100, trials = 50
- n = 64, trials = 150 ==> passed
Test 5: check that PercolationStats calls open() until system percolates
- n = 20, trials = 10
- n = 50, trials = 20
- n = 100, trials = 50
- n = 64, trials = 150 ==> passed
Test 6: check that PercolationStats does not call open() after system percolates
- n = 20, trials = 10
- n = 50, trials = 20
- n = 100, trials = 50
- n = 64, trials = 150 ==> passed
Test 7: check that mean() is consistent with the number of intercepted calls to open() on blocked sites
- n = 20, trials = 10
- n = 50, trials = 20
- n = 100, trials = 50
- n = 64, trials = 150 ==> passed
Test 8: check that stddev() is consistent with the number of intercepted calls to open() on blocked sites
- n = 20, trials = 10
- n = 50, trials = 20
- n = 100, trials = 50
- n = 64, trials = 150 ==> passed
Test 9: check that confidenceLo() and confidenceHigh() are consistent with mean() and stddev()
- n = 20, trials = 10
- n = 50, trials = 20
- n = 100, trials = 50
- n = 64, trials = 150 ==> passed
Test 10: check that exception is thrown if either n or trials is out of bounds
- n = -23, trials = 42
- n = 23, trials = 0
- n = -42, trials = 0
- n = 42, trials = -1
- n = -2147483648, trials = -2147483648 ==> passed
Test 11: create two PercolationStats objects at the same time and check mean() (to make sure you didn't store data in static variables)
- n1 = 50, trials1 = 10, n2 = 50, trials2 = 5
- n1 = 50, trials1 = 5, n2 = 50, trials2 = 10
- n1 = 50, trials1 = 10, n2 = 25, trials2 = 10
- n1 = 25, trials1 = 10, n2 = 50, trials2 = 10
- n1 = 50, trials1 = 10, n2 = 15, trials2 = 100
- n1 = 15, trials1 = 100, n2 = 50, trials2 = 10 ==> passed
Test 12: check that the methods return the same value, regardless of the order in which they are called
- n = 20, trials = 10
- n = 50, trials = 20
- n = 100, trials = 50
- n = 64, trials = 150 ==> passed
Test 13: check that no calls to StdRandom.setSeed()
- n = 20, trials = 10
- n = 20, trials = 10
- n = 40, trials = 10
- n = 80, trials = 10 ==> passed
Test 14: check distribution of number of sites opened until percolation
- n = 2, trials = 100000
- n = 3, trials = 100000
- n = 4, trials = 100000 ==> passed
Test 15: check that each site is opened the expected number of times
- n = 2, trials = 100000
- n = 3, trials = 100000
- n = 4, trials = 100000 ==> passed
Total: 15/15 tests passed!
================================================================
- MEMORY (substituting reference Percolation)
Analyzing memory of PercolationStats *----------------------------------------------------------- Running 4 total tests.
Test 1a-1d: check memory usage as a function of T trials for n = 100 (max allowed: 8*T + 128 bytes)
T bytes
=> passed 16 48
=> passed 32 48
=> passed 64 48
=> passed 128 48
==> 4/4 tests passed
Estimated student memory = 48.00 (R^2 = 1.000)
Total: 4/4 tests passed!
================================================================
- TIMING (substituting reference Percolation)
Timing PercolationStats *----------------------------------------------------------- Running 4 total tests.
Test 1: count calls to StdStats.mean() and StdStats.stddev()
- n = 20, trials = 10
- n = 50, trials = 20
- n = 100, trials = 50
- n = 64, trials = 150 ==> passed
Test 2: count calls to methods in StdRandom
- n = 20, trials = 10
- n = 20, trials = 10
- n = 40, trials = 10
- n = 80, trials = 10 ==> passed
Test 3: count calls to methods in Percolation
- n = 20, trials = 10
- n = 50, trials = 20
- n = 100, trials = 50
- n = 64, trials = 150 ==> passed
Test 4: Call PercolationStats methods with trials = 3 and values of n that go up by a factor of sqrt(2). The test passes when n reaches 2,896.
The approximate order-of-growth is n ^ (log ratio)
n seconds log ratio
------------------------
512 0.13 2.2
724 0.27 2.1
1024 0.54 2.0
1448 1.73 3.3
2048 3.63 2.1
2896 8.43 2.4
==> passed
Total: 4/4 tests passed!
================================================================
- MEMORY
Analyzing memory of Percolation *----------------------------------------------------------- Running 4 total tests.
Test 1a-1d: check that total memory <= 17 n^2 + 128 n + 1024 bytes
n bytes
=> passed 64 71968
=> passed 256 1122592
=> passed 512 4473120
=> passed 1024 17858848
==> 4/4 tests passed
Estimated student memory = 17.00 n^2 + 32.00 n + 288.00 (R^2 = 1.000)
Test 2 (bonus): check that total memory <= 11 n^2 + 128 n + 1024 bytes
- failed memory test for n = 64 ==> FAILED
Total: 4/4 tests passed!
================================================================
- TIMING
Timing Percolation *----------------------------------------------------------- Running 16 total tests.
Test 1a-1e: Creates an n-by-n percolation system; open sites at random until the system percolates, interleaving calls to percolates() and open(). Count calls to connected(), union() and find().
2 * connected()
n union() + find() constructor
=> passed 16 397 336 2
=> passed 32 1119 1110 2
=> passed 64 5205 4668 2
=> passed 128 25375 20584 2
=> passed 256 93116 78474 2
=> passed 512 370528 312166 2
=> passed 1024 1479459 1246634 2
==> 7/7 tests passed
If one of the values in the table violates the performance limits the factor by which you failed the test appears in parentheses. For example, (9.6x) in the union() column indicates that it uses 9.6x too many calls.
Tests 2a-2f: Check whether the number of calls to union(), connected(), and find() is a constant per call to open(), isOpen(), isFull(), and percolates(). The table shows the maximum number of union(), connected(), and find() calls made during a single call to open(), isOpen(), isFull(), and percolates().
n per open() per isOpen() per isFull() per percolates()
=> passed 16 8 0 1 1
=> passed 32 8 0 1 1
=> passed 64 8 0 1 1
=> passed 128 8 0 1 1
=> passed 256 8 0 1 1
=> passed 512 8 0 1 1
=> passed 1024 8 0 1 1
==> 7/7 tests passed
Running time (in seconds) depends on the machine on which the script runs.
Test 3: Create an n-by-n percolation system; interleave calls to percolates() and open() until the system percolates. The values of n go up by a factor of sqrt(2). The test is passed if n >= 4096 in under 10 seconds.
The approximate order-of-growth is n ^ (log ratio)
log union-find log
n seconds ratio operations ratio
-------------------------------------------
1024 0.19 2.5 4173854 2.0
1448 0.64 3.6 8387856 2.0
2048 1.51 2.5 16643348 2.0
2896 4.08 2.9 33446616 2.0
4096 8.53 2.1 66746558 2.0
==> passed
Test 4: Create an n-by-n percolation system; interleave calls to open(), percolates(), isOpen(), isFull(), and numberOfOpenSites() until. the system percolates. The values of n go up by a factor of sqrt(2). The test is passed if n >= 4096 in under 10 seconds.
log union-find log
n seconds ratio operations ratio
-------------------------------------------
1024 0.22 2.6 4125786 1.9
1448 0.66 3.1 8452912 2.1
2048 1.89 3.0 16819612 2.0
2896 4.85 2.7 33633188 2.0
4096 8.45 1.6 67164946 2.0
==> passed
Total: 16/16 tests passed!
================================================================