-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpercolation-grade.txt
835 lines (639 loc) · 27.5 KB
/
percolation-grade.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
See the Assessment Guide for information on how to interpret this report.
Want to receive personalized feedback on this submission?
You can pay to have a teaching assistant read and provide
personalized feedback on your submission at https://mooc.codepost.io.
ASSESSMENT SUMMARY
Compilation: PASSED
API: PASSED
Spotbugs: PASSED
PMD: PASSED
Checkstyle: PASSED
Correctness: 30/38 tests passed
Memory: 8/8 tests passed
Timing: 20/20 tests passed
Aggregate score: 87.37%
[Compilation: 5%, API: 5%, Spotbugs: 0%, PMD: 0%, Checkstyle: 0%, Correctness: 60%, Memory: 10%, Timing: 20%]
ASSESSMENT DETAILS
The following files were submitted:
----------------------------------
5.2K Jun 22 19:53 Percolation.java
2.1K Jun 22 19:53 PercolationStats.java
********************************************************************************
* COMPILING
********************************************************************************
% javac Percolation.java
*-----------------------------------------------------------
% javac PercolationStats.java
*-----------------------------------------------------------
================================================================
Checking the APIs of your programs.
*-----------------------------------------------------------
Percolation:
PercolationStats:
================================================================
********************************************************************************
* CHECKING STYLE AND COMMON BUG PATTERNS
********************************************************************************
% spotbugs *.class
*-----------------------------------------------------------
================================================================
% pmd .
*-----------------------------------------------------------
================================================================
% checkstyle *.java
*-----------------------------------------------------------
% custom checkstyle checks for Percolation.java
*-----------------------------------------------------------
[INFO] Percolation.java:87: Using a loop in this method might be a performance bug. [Performance]
% custom checkstyle checks for PercolationStats.java
*-----------------------------------------------------------
================================================================
********************************************************************************
* TESTING CORRECTNESS
********************************************************************************
Testing correctness of Percolation
*-----------------------------------------------------------
Running 21 total tests.
Tests 1 through 7 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.
Tests 12 through 15 create a Percolation object using your code, then repeatedly
call the methods open(), isOpen(), isFull(), percolates(), and, numberOfOpenSites()
in random order with probabilities p = (p1, p2, p3, p4, p5). The tests stop
immediately after the system percolates.
Tests 18 through 21 test backwash.
Except as noted, a site is opened at most once.
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 the 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
- percolates() returns wrong value after 0 sites opened
- student percolates() = true
- reference percolates() = false
* filename = input1-no.txt
- percolates() returns wrong value after 0 sites opened
- student percolates() = true
- reference percolates() = false
* filename = input2.txt
* filename = input2-no.txt
==> FAILED
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 the 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: open random sites with large n
* n = 250
* n = 500
* n = 1000
* n = 2000
==> passed
Test 8: 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 9: call constructor with invalid argument
* n = -10
* n = -1
* n = 0
==> passed
Test 10: create multiple Percolation objects at the same time
(to make sure you didn't store data in static variables)
==> passed
Test 11: 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 12: call open(), isOpen(), and numberOfOpenSites()
in random order until just before system percolates
* n = 3, trials = 40, p = (0.4, 0.4, 0.0, 0.0, 0.3)
* n = 5, trials = 20, p = (0.4, 0.4, 0.0, 0.0, 0.3)
* n = 7, trials = 10, p = (0.4, 0.4, 0.0, 0.0, 0.3)
* n = 10, trials = 5, p = (0.4, 0.4, 0.0, 0.0, 0.3)
* n = 20, trials = 2, p = (0.4, 0.4, 0.0, 0.0, 0.3)
* n = 50, trials = 1, p = (0.4, 0.4, 0.0, 0.0, 0.3)
==> passed
Test 13: call open() and percolates() in random order until just before system percolates
* n = 3, trials = 40, p = (0.5, 0.0, 0.0, 0.5, 0.0)
* n = 5, trials = 20, p = (0.5, 0.0, 0.0, 0.5, 0.0)
* n = 7, trials = 10, p = (0.5, 0.0, 0.0, 0.5, 0.0)
* n = 10, trials = 5, p = (0.5, 0.0, 0.0, 0.5, 0.0)
* n = 20, trials = 2, p = (0.5, 0.0, 0.0, 0.5, 0.0)
* n = 50, trials = 1, p = (0.5, 0.0, 0.0, 0.5, 0.0)
==> passed
Test 14: call open() and isFull() in random order until just before system percolates
* n = 3, trials = 40, p = (0.5, 0.0, 0.5, 0.0, 0.0)
* n = 5, trials = 20, p = (0.5, 0.0, 0.5, 0.0, 0.0)
* n = 7, trials = 10, p = (0.5, 0.0, 0.5, 0.0, 0.0)
* n = 10, trials = 5, p = (0.5, 0.0, 0.5, 0.0, 0.0)
* n = 20, trials = 2, p = (0.5, 0.0, 0.5, 0.0, 0.0)
* n = 50, trials = 1, p = (0.5, 0.0, 0.5, 0.0, 0.0)
==> passed
Test 15: call all methods in random order until just before system percolates
* n = 3, trials = 40, p = (0.2, 0.2, 0.2, 0.2, 0.2)
* n = 5, trials = 20, p = (0.2, 0.2, 0.2, 0.2, 0.2)
* n = 7, trials = 10, p = (0.2, 0.2, 0.2, 0.2, 0.2)
* n = 10, trials = 5, p = (0.2, 0.2, 0.2, 0.2, 0.2)
* n = 20, trials = 2, p = (0.2, 0.2, 0.2, 0.2, 0.2)
* n = 50, trials = 1, p = (0.2, 0.2, 0.2, 0.2, 0.2)
==> passed
Test 16: call all methods in random order until almost all sites are open
(with inputs not prone to backwash)
* n = 3
* n = 5
* n = 7
* n = 10
* n = 20
* n = 50
==> passed
Test 17: substitute WeightedQuickUnionUF data type that sets root nondeterministically;
call all methods in random order until almost all sites are open
(with inputs not prone to backwash)
* n = 3
* n = 5
* n = 7
* n = 10
* n = 20
* n = 50
==> passed
Test 18: check for backwash with predetermined sites
* filename = input20.txt
- isFull() returns wrong value after 231 sites opened
- student isFull(18, 1) = true
- reference isFull(18, 1) = false
* filename = input10.txt
- isFull() returns wrong value after 56 sites opened
- student isFull(9, 1) = true
- reference isFull(9, 1) = false
* filename = input50.txt
- isFull() returns wrong value after 1412 sites opened
- student isFull(22, 28) = true
- reference isFull(22, 28) = false
* filename = jerry47.txt
- isFull() returns wrong value after 1076 sites opened
- student isFull(11, 47) = true
- reference isFull(11, 47) = false
* filename = sedgewick60.txt
- isFull() returns wrong value after 1577 sites opened
- student isFull(21, 59) = true
- reference isFull(21, 59) = false
* filename = wayne98.txt
- isFull() returns wrong value after 3851 sites opened
- student isFull(69, 9) = true
- reference isFull(69, 9) = false
==> FAILED
Test 19: check for backwash with predetermined sites that have
multiple percolating paths
* filename = input3.txt
- isFull() returns wrong value after 4 sites opened
- student isFull(3, 1) = true
- reference isFull(3, 1) = false
* filename = input4.txt
- isFull() returns wrong value after 7 sites opened
- student isFull(4, 4) = true
- reference isFull(4, 4) = false
* filename = input7.txt
- isFull() returns wrong value after 12 sites opened
- student isFull(6, 1) = true
- reference isFull(6, 1) = false
==> FAILED
Test 20: call all methods in random order until all sites are open
(these inputs are prone to backwash)
* n = 3
- isFull() returns wrong value after 6 sites opened
- student isFull(2, 1) = true
- reference isFull(2, 1) = false
- failed on trial 3 of 40
* n = 5
- isFull() returns wrong value after 16 sites opened
- student isFull(5, 1) = true
- reference isFull(5, 1) = false
- failed on trial 1 of 20
* n = 7
- isFull() returns wrong value after 31 sites opened
- student isFull(5, 7) = true
- reference isFull(5, 7) = false
- failed on trial 1 of 10
* n = 10
- isFull() returns wrong value after 51 sites opened
- student isFull(8, 10) = true
- reference isFull(8, 10) = false
- failed on trial 1 of 5
* n = 20
- isFull() returns wrong value after 221 sites opened
- student isFull(18, 2) = true
- reference isFull(18, 2) = false
- failed on trial 1 of 2
* n = 50
- isFull() returns wrong value after 1501 sites opened
- student isFull(34, 44) = true
- reference isFull(34, 44) = false
- failed on trial 1 of 1
==> FAILED
Test 21: substitute WeightedQuickUnionUF data type that sets root nondeterministically;
call all methods in random order until all sites are open
(these inputs are prone to backwash)
* n = 3
- isFull() returns wrong value after 5 sites opened
- student isFull(3, 3) = true
- reference isFull(3, 3) = false
- failed on trial 14 of 40
* n = 5
- isFull() returns wrong value after 13 sites opened
- student isFull(5, 4) = true
- reference isFull(5, 4) = false
- failed on trial 8 of 20
* n = 7
- isFull() returns wrong value after 33 sites opened
- student isFull(6, 1) = true
- reference isFull(6, 1) = false
- failed on trial 1 of 10
* n = 10
- isFull() returns wrong value after 63 sites opened
- student isFull(8, 1) = true
- reference isFull(8, 1) = false
- failed on trial 2 of 5
* n = 20
- isFull() returns wrong value after 233 sites opened
- student isFull(17, 19) = true
- reference isFull(17, 19) = false
- failed on trial 1 of 2
* n = 50
- isFull() returns wrong value after 1497 sites opened
- student isFull(45, 23) = true
- reference isFull(45, 23) = false
- failed on trial 1 of 1
==> FAILED
Total: 16/21 tests passed!
================================================================
********************************************************************************
* TESTING CORRECTNESS (substituting reference Percolation)
********************************************************************************
Testing correctness of PercolationStats
*-----------------------------------------------------------
Running 17 total tests.
Test 1: check formatting of output of main()
% java-algs4 PercolationStats 20 10
mean = 0.6075
stddev = 0.0018750000000000001
95% confidence interval= [0.5806615946822469,0.6343384053177532]
% java-algs4 PercolationStats 200 100
mean = 0.5927027500000003
stddev = 7.27860466540403E-5
95% confidence interval= [0.5910305811184989,0.5943749188815016]
==> passed
Test 2: 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 3: 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 4: check that stddev() returns value in expected range
* n = 2, trials = 10000
- student PercolationStats stddev() = 0.013871
- true stddev = 0.117851
- 99.99% confidence interval = [0.114620, 0.121104]
- a correct solution will fail this test by bad luck 1 time in 10,000
* n = 5, trials = 10000
- student PercolationStats stddev() = 0.010627
- true stddev = 0.102653
- 99.99% confidence interval = [0.099839, 0.105487]
- a correct solution will fail this test by bad luck 1 time in 10,000
* n = 10, trials = 10000
- student PercolationStats stddev() = 0.005266
- true stddev = 0.073553
- 99.99% confidence interval = [0.071536, 0.075583]
- a correct solution will fail this test by bad luck 1 time in 10,000
* n = 25, trials = 10000
- student PercolationStats stddev() = 0.001762
- true stddev = 0.041952
- 99.99% confidence interval = [0.040802, 0.043110]
- a correct solution will fail this test by bad luck 1 time in 10,000
==> FAILED
Test 5: check that PercolationStats constructor creates
trials Percolation objects, each of size n-by-n
* n = 15, trials = 15
* n = 20, trials = 10
* n = 50, trials = 20
* n = 100, trials = 50
* n = 64, trials = 150
==> passed
Test 6: check that PercolationStats.main() creates
trials Percolation objects, each of size n-by-n
* n = 15, trials = 15
* n = 20, trials = 10
* n = 50, trials = 20
* n = 100, trials = 50
* n = 64, trials = 150
==> passed
Test 7: 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 8: 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 9: 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 10: check that stddev() is consistent with the number of intercepted calls to open()
on blocked sites
* n = 20, trials = 10
- student PercolationStats stddev() = 0.001632222222222223
- anticipated sample stddev from intercepted calls = 0.04040077006966851
- anticipated sample variance from intercepted calls = 0.001632222222222223
* n = 50, trials = 20
- student PercolationStats stddev() = 9.772143157894741E-4
- anticipated sample stddev from intercepted calls = 0.03126042731296989
- anticipated sample variance from intercepted calls = 9.772143157894741E-4
* n = 100, trials = 50
- student PercolationStats stddev() = 3.553129020408164E-4
- anticipated sample stddev from intercepted calls = 0.018849745410503993
- anticipated sample variance from intercepted calls = 3.553129020408164E-4
* n = 64, trials = 150
- student PercolationStats stddev() = 5.068670956613765E-4
- anticipated sample stddev from intercepted calls = 0.02251370906051192
- anticipated sample variance from intercepted calls = 5.068670956613765E-4
==> FAILED
Test 11: check that confidenceLo() and confidenceHigh() are consistent with mean() and stddev()
* n = 20, trials = 10
- PercolationStats confidence low = 0.584803192870932
- PercolationStats confidence high = 0.6506968071290679
- PercolationStats mean = 0.6177499999999999
- PercolationStats stddev = 0.0028256250000000004
- T = 10
- student T = 10
- mean - 1.96 * stddev / sqrt(T) = 0.6159986594805513
- mean + 1.96 * stddev / sqrt(T) = 0.6195013405194485
* n = 50, trials = 20
- PercolationStats confidence low = 0.5828459978860387
- PercolationStats confidence high = 0.6099540021139611
- PercolationStats mean = 0.5963999999999999
- PercolationStats stddev = 9.564294736842105E-4
- T = 20
- student T = 20
- mean - 1.96 * stddev / sqrt(T) = 0.5959808263015068
- mean + 1.96 * stddev / sqrt(T) = 0.596819173698493
* n = 100, trials = 50
- PercolationStats confidence low = 0.5880274260656811
- PercolationStats confidence high = 0.5971605739343188
- PercolationStats mean = 0.592594
- PercolationStats stddev = 2.7141812653061237E-4
- T = 50
- student T = 50
- mean - 1.96 * stddev / sqrt(T) = 0.5925187667336597
- mean + 1.96 * stddev / sqrt(T) = 0.5926692332663402
* n = 64, trials = 150
- PercolationStats confidence low = 0.5907249867914223
- PercolationStats confidence high = 0.5975432423752444
- PercolationStats mean = 0.5941341145833333
- PercolationStats stddev = 4.538012404303156E-4
- T = 150
- student T = 150
- mean - 1.96 * stddev / sqrt(T) = 0.5940614912597318
- mean + 1.96 * stddev / sqrt(T) = 0.5942067379069348
==> FAILED
Test 12: 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 13: 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 14: 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 15: 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 16: check distribution of number of sites opened until percolation
* n = 2, trials = 100000
* n = 3, trials = 100000
* n = 4, trials = 100000
==> passed
Test 17: 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: 14/17 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 176
=> passed 32 304
=> passed 64 560
=> passed 128 1072
==> 4/4 tests passed
Estimated student memory = 8.00 T + 48.00 (R^2 = 1.000)
Total: 4/4 tests passed!
================================================================
********************************************************************************
* TIMING (substituting reference Percolation)
********************************************************************************
Timing PercolationStats
*-----------------------------------------------------------
Running 4 total tests.
Test 1: Call PercolationStats constructor and instance methods and
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: Call PercolationStats constructor and instance methods and
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: Call PercolationStats constructor and instance methods and
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 constructor and instance methods with trials = 3
and values of n that go up by a multiplicative 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.11 2.4
724 0.31 2.9
1024 0.85 2.9
1448 1.68 2.0
2048 3.82 2.4
2896 9.06 2.5
==> 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 37040
=> passed 256 590000
=> passed 512 2359472
=> passed 1024 9437360
==> 4/4 tests passed
Estimated student memory = 9.00 n^2 + 0.00 n + 176.00 (R^2 = 1.000)
Test 2 (bonus): check that total memory <= 11 n^2 + 128 n + 1024 bytes
- bonus available only if solution passes backwash correctness test
==> 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 197 302 1
=> passed 32 793 1234 1
=> passed 64 2749 4648 1
=> passed 128 11626 19426 1
=> passed 256 45880 77182 1
=> passed 512 184017 310126 1
=> passed 1024 740486 1244590 1
==> 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() and find() calls made
during a single call to open(), isOpen(), isFull(), and percolates().
One call to connected() counts as two calls to find().
n per open() per isOpen() per isFull() per percolates()
---------------------------------------------------------------------------------------------
=> passed 16 4 0 2 2
=> passed 32 4 0 2 2
=> passed 64 4 0 2 2
=> passed 128 4 0 2 2
=> passed 256 4 0 2 2
=> passed 512 4 0 2 2
=> passed 1024 4 0 2 2
==> 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.25 3.9 2710768 2.0
1448 0.62 2.7 5437496 2.0
2048 1.67 2.8 10868248 2.0
2896 2.78 1.5 21847170 2.0
4096 5.65 2.1 43296870 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.21 3.2 2725676 2.0
1448 0.64 3.2 5484866 2.0
2048 1.26 2.0 10945500 2.0
2896 2.85 2.3 21707914 2.0
4096 5.99 2.1 43509684 2.0
==> passed
Total: 16/16 tests passed!
================================================================