-
Notifications
You must be signed in to change notification settings - Fork 0
/
feedback.html
1385 lines (1104 loc) · 45.6 KB
/
feedback.html
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
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<title>Autograder Feedback</title>
<meta charset="UTF-8">
</head>
<body>
<p>
<em>
See the Assessment Guide for information on how to interpret this report.
</em>
<br><br>
<h2>ASSESSMENT SUMMARY</h2>
<pre>
Compilation: <font color = #009900>PASSED (0 errors, 4 warnings)</font>
API: <font color = #009900>PASSED</font>
SpotBugs: <font color = #009900>PASSED</font>
PMD: <font color = #009900>PASSED</font>
Checkstyle: <font color = #990000>FAILED (0 errors, 12 warnings)</font>
Correctness: <font color = #009900>49/49 tests passed</font>
Memory: <font color = #-019900>124/123 tests passed</font>
Timing: <font color = #009900>193/193 tests passed</font>
Aggregate score: 100.08%
[ Compilation: 5%, API: 5%, Style: 0%, Correctness: 60%, Timing: 10%, Memory: 20% ]
</pre>
<br><br>
<h2>ASSESSMENT DETAILS</h2>
<pre>
The following files were submitted:
----------------------------------
5.2K Aug 6 17:18 Deque.java
477 Aug 6 17:18 Permutation.java
4.5K Aug 6 17:18 RandomizedQueue.java
********************************************************************************
* COMPILING
********************************************************************************
% javac Deque.java
*-----------------------------------------------------------
% javac RandomizedQueue.java
*-----------------------------------------------------------
RandomizedQueue.java:13: warning: [unchecked] unchecked cast
arr = (Item[]) new Object[INITIAL_SIZE];
^
required: Item[]
found: Object[]
where Item is a type-variable:
Item extends Object declared in class RandomizedQueue
RandomizedQueue.java:58: warning: [unchecked] unchecked cast
Item[] biggerArr = (Item[]) new Object[arr.length * 2];
^
required: Item[]
found: Object[]
where Item is a type-variable:
Item extends Object declared in class RandomizedQueue
RandomizedQueue.java:69: warning: [unchecked] unchecked cast
Item[] smallerArr = (Item[]) new Object[arr.length / 2];
^
required: Item[]
found: Object[]
where Item is a type-variable:
Item extends Object declared in class RandomizedQueue
RandomizedQueue.java:84: warning: [unchecked] unchecked cast
private final Item[] shuffled = (Item[]) new Object[N];
^
required: Item[]
found: Object[]
where Item is a type-variable:
Item extends Object declared in class RandomizedQueue
4 warnings
% javac Permutation.java
*-----------------------------------------------------------
================================================================
Checking the APIs of your programs.
*-----------------------------------------------------------
Deque:
RandomizedQueue:
Permutation:
================================================================
********************************************************************************
* CHECKING STYLE AND COMMON BUG PATTERNS
********************************************************************************
% spotbugs *.class
*-----------------------------------------------------------
================================================================
% pmd .
*-----------------------------------------------------------
================================================================
% checkstyle *.java
*-----------------------------------------------------------
[WARN] Deque.java:42:17: The instance variable 'N' must start with a lowercase letter and use camelCase. [MemberName]
[WARN] Deque.java:163:88: Do not put multiple statements on the same line. [OneStatementPerLine]
[WARN] Deque.java:168:88: Do not put multiple statements on the same line. [OneStatementPerLine]
[WARN] RandomizedQueue.java:9:17: The instance variable 'N' must start with a lowercase letter and use camelCase. [MemberName]
[WARN] RandomizedQueue.java:128:87: Do not put multiple statements on the same line. [OneStatementPerLine]
[WARN] RandomizedQueue.java:131:87: Do not put multiple statements on the same line. [OneStatementPerLine]
[WARN] RandomizedQueue.java:134:87: Do not put multiple statements on the same line. [OneStatementPerLine]
[WARN] RandomizedQueue.java:137:87: Do not put multiple statements on the same line. [OneStatementPerLine]
[WARN] RandomizedQueue.java:140:87: Do not put multiple statements on the same line. [OneStatementPerLine]
[WARN] RandomizedQueue.java:143:87: Do not put multiple statements on the same line. [OneStatementPerLine]
[WARN] RandomizedQueue.java:146:87: Do not put multiple statements on the same line. [OneStatementPerLine]
[WARN] RandomizedQueue.java:148:60: ':' is not preceded with whitespace. [WhitespaceAround]
Checkstyle ends with 0 errors and 12 warnings.
% custom checkstyle checks for Deque.java
*-----------------------------------------------------------
% custom checkstyle checks for RandomizedQueue.java
*-----------------------------------------------------------
% custom checkstyle checks for Permutation.java
*-----------------------------------------------------------
================================================================
********************************************************************************
* TESTING CORRECTNESS
********************************************************************************
Testing correctness of Deque
*-----------------------------------------------------------
Running 19 total tests.
Tests 1-8 make random intermixed calls to addFirst(), addLast(),
removeFirst(), removeLast(), isEmpty(), and size(), and iterator().
The probabilities of each operation are (p1, p2, p3, p4, p5, p6, p7),
respectively.
Test 1: check random calls to addFirst(), addLast(), and size()
* 5 random calls (0.4, 0.4, 0.0, 0.0, 0.0, 0.2, 0.0)
* 50 random calls (0.4, 0.4, 0.0, 0.0, 0.0, 0.2, 0.0)
* 500 random calls (0.4, 0.4, 0.0, 0.0, 0.0, 0.2, 0.0)
* 1000 random calls (0.4, 0.4, 0.0, 0.0, 0.0, 0.2, 0.0)
==> passed
Test 2: check random calls to addFirst(), removeFirst(), and isEmpty()
* 5 random calls (0.8, 0.0, 0.1, 0.0, 0.1, 0.0, 0.0)
* 50 random calls (0.8, 0.0, 0.1, 0.0, 0.1, 0.0, 0.0)
* 500 random calls (0.8, 0.0, 0.1, 0.0, 0.1, 0.0, 0.0)
* 1000 random calls (0.8, 0.0, 0.1, 0.0, 0.1, 0.0, 0.0)
* 5 random calls (0.1, 0.0, 0.8, 0.0, 0.1, 0.0, 0.0)
* 50 random calls (0.1, 0.0, 0.8, 0.0, 0.1, 0.0, 0.0)
* 500 random calls (0.1, 0.0, 0.8, 0.0, 0.1, 0.0, 0.0)
* 1000 random calls (0.1, 0.0, 0.8, 0.0, 0.1, 0.0, 0.0)
==> passed
Test 3: check random calls to addFirst(), removeLast(), and isEmpty()
* 5 random calls (0.8, 0.0, 0.0, 0.1, 0.1, 0.0, 0.0)
* 50 random calls (0.8, 0.0, 0.0, 0.1, 0.1, 0.0, 0.0)
* 500 random calls (0.8, 0.0, 0.0, 0.1, 0.1, 0.0, 0.0)
* 1000 random calls (0.8, 0.0, 0.0, 0.1, 0.1, 0.0, 0.0)
* 5 random calls (0.1, 0.0, 0.0, 0.8, 0.1, 0.0, 0.0)
* 50 random calls (0.1, 0.0, 0.0, 0.8, 0.1, 0.0, 0.0)
* 500 random calls (0.1, 0.0, 0.0, 0.8, 0.1, 0.0, 0.0)
* 1000 random calls (0.1, 0.0, 0.0, 0.8, 0.1, 0.0, 0.0)
==> passed
Test 4: check random calls to addLast(), removeLast(), and isEmpty()
* 5 random calls (0.0, 0.8, 0.0, 0.1, 0.1, 0.0, 0.0)
* 50 random calls (0.0, 0.8, 0.0, 0.1, 0.1, 0.0, 0.0)
* 500 random calls (0.0, 0.8, 0.0, 0.1, 0.1, 0.0, 0.0)
* 1000 random calls (0.0, 0.8, 0.0, 0.1, 0.1, 0.0, 0.0)
* 5 random calls (0.0, 0.1, 0.0, 0.8, 0.1, 0.0, 0.0)
* 50 random calls (0.0, 0.1, 0.0, 0.8, 0.1, 0.0, 0.0)
* 500 random calls (0.0, 0.1, 0.0, 0.8, 0.1, 0.0, 0.0)
* 1000 random calls (0.0, 0.1, 0.0, 0.8, 0.1, 0.0, 0.0)
==> passed
Test 5: check random calls to addLast(), removeFirst(), and isEmpty()
* 5 random calls (0.0, 0.8, 0.1, 0.0, 0.1, 0.0, 0.0)
* 50 random calls (0.0, 0.8, 0.1, 0.0, 0.1, 0.0, 0.0)
* 500 random calls (0.0, 0.8, 0.1, 0.0, 0.1, 0.0, 0.0)
* 1000 random calls (0.0, 0.8, 0.1, 0.0, 0.1, 0.0, 0.0)
* 5 random calls (0.0, 0.1, 0.8, 0.0, 0.1, 0.0, 0.0)
* 50 random calls (0.0, 0.1, 0.8, 0.0, 0.1, 0.0, 0.0)
* 500 random calls (0.0, 0.1, 0.8, 0.0, 0.1, 0.0, 0.0)
* 1000 random calls (0.0, 0.1, 0.8, 0.0, 0.1, 0.0, 0.0)
==> passed
Test 6: check random calls to addFirst(), removeFirst(), and iterator()
* 5 random calls (0.8, 0.0, 0.1, 0.0, 0.0, 0.0, 0.1)
* 50 random calls (0.8, 0.0, 0.1, 0.0, 0.0, 0.0, 0.1)
* 500 random calls (0.8, 0.0, 0.1, 0.0, 0.0, 0.0, 0.1)
* 1000 random calls (0.8, 0.0, 0.1, 0.0, 0.0, 0.0, 0.1)
* 5 random calls (0.1, 0.0, 0.8, 0.0, 0.0, 0.0, 0.1)
* 50 random calls (0.1, 0.0, 0.8, 0.0, 0.0, 0.0, 0.1)
* 500 random calls (0.1, 0.0, 0.8, 0.0, 0.0, 0.0, 0.1)
* 1000 random calls (0.1, 0.0, 0.8, 0.0, 0.0, 0.0, 0.1)
==> passed
Test 7: check random calls to all methods except iterator()
* 5 random calls (0.3, 0.3, 0.1, 0.1, 0.1, 0.1, 0.0)
* 50 random calls (0.3, 0.3, 0.1, 0.1, 0.1, 0.1, 0.0)
* 500 random calls (0.3, 0.3, 0.1, 0.1, 0.1, 0.1, 0.0)
* 1000 random calls (0.3, 0.3, 0.1, 0.1, 0.1, 0.1, 0.0)
* 5 random calls (0.1, 0.1, 0.3, 0.3, 0.1, 0.1, 0.0)
* 50 random calls (0.1, 0.1, 0.3, 0.3, 0.1, 0.1, 0.0)
* 500 random calls (0.1, 0.1, 0.3, 0.3, 0.1, 0.1, 0.0)
* 1000 random calls (0.1, 0.1, 0.3, 0.3, 0.1, 0.1, 0.0)
==> passed
Test 8: check random calls to all methods, including iterator()
* 5 random calls (0.2, 0.2, 0.1, 0.1, 0.1, 0.1, 0.2)
* 50 random calls (0.2, 0.2, 0.1, 0.1, 0.1, 0.1, 0.2)
* 500 random calls (0.2, 0.2, 0.1, 0.1, 0.1, 0.1, 0.2)
* 1000 random calls (0.2, 0.2, 0.1, 0.1, 0.1, 0.1, 0.2)
* 5 random calls (0.1, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2)
* 50 random calls (0.1, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2)
* 500 random calls (0.1, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2)
* 1000 random calls (0.1, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2)
==> passed
Test 9: check removeFirst() and removeLast() from an empty deque
* removeFirst()
* removeLast()
==> passed
Test 10: check whether two Deque objects can be created at the same time
* n = 10
* n = 1000
==> passed
Test 11: check iterator() after n calls to addFirst()
* n = 10
* n = 50
==> passed
Test 12: check iterator() after random calls to addFirst(), addLast(),
removeFirst(), and removeLast() with probabilities (p1, p2, p3, p4)
* 20 random operations (0.8, 0.0, 0.2, 0.0)
* 20 random operations (0.8, 0.0, 0.0, 0.2)
* 20 random operations (0.0, 0.8, 0.0, 0.2)
* 20 random operations (0.0, 0.8, 0.2, 0.0)
* 20 random operations (0.4, 0.4, 0.1, 0.1)
* 20 random operations (0.2, 0.0, 0.8, 0.0)
* 20 random operations (0.2, 0.0, 0.0, 0.8)
* 20 random operations (0.0, 0.2, 0.0, 0.8)
* 20 random operations (0.0, 0.2, 0.8, 0.0)
* 20 random operations (0.1, 0.1, 0.4, 0.4)
* 100 random operations (0.4, 0.4, 0.1, 0.1)
* 1000 random operations (0.4, 0.4, 0.1, 0.1)
==> passed
Test 13: create two nested iterators to same deque of size n
* n = 10
* n = 50
==> passed
Test 14: create two parallel iterators to same deque of size n
* n = 10
* n = 50
==> passed
Test 15: create an iterator and check calls to next() and hasNext()
* 10 consecutive calls to hasNext() on a deque of size 10
* 10 consecutive calls to next() on a deque of size 10
* 50 random intermixed calls to next() and hasNext() on a deque of size 10
* 1000 random intermixed calls to next() and hasNext() on a deque of size 100
==> passed
Test 16: create Deque objects of different parameterized types
==> passed
Test 17: call addFirst() and addLast() with null argument
==> passed
Test 18: check that remove() and next() throw the specified exceptions in iterator()
==> passed
Test 19: call iterator() when the deque is empty
==> passed
Total: 19/19 tests passed!
================================================================
Testing correctness of RandomizedQueue
*-----------------------------------------------------------
Running 21 total tests.
Tests 1-6 make random intermixed calls to enqueue(), dequeue(), sample(),
isEmpty(), size(), and iterator(). The probabilities of each operation
are (p1, p2, p3, p4, p5, p6), respectively.
Test 1: check random calls to enqueue() and size()
* 5 random calls (0.8, 0.0, 0.0, 0.0, 0.2, 0.0)
* 50 random calls (0.8, 0.0, 0.0, 0.0, 0.2, 0.0)
* 500 random calls (0.8, 0.0, 0.0, 0.0, 0.2, 0.0)
* 1000 random calls (0.8, 0.0, 0.0, 0.0, 0.2, 0.0)
==> passed
Test 2: check random calls to enqueue() and dequeue()
* 5 random calls (0.7, 0.1, 0.0, 0.1, 0.1, 0.0)
* 50 random calls (0.7, 0.1, 0.0, 0.1, 0.1, 0.0)
* 500 random calls (0.7, 0.1, 0.0, 0.1, 0.1, 0.0)
* 1000 random calls (0.7, 0.1, 0.0, 0.1, 0.1, 0.0)
* 5 random calls (0.1, 0.7, 0.0, 0.1, 0.1, 0.0)
* 50 random calls (0.1, 0.7, 0.0, 0.1, 0.1, 0.0)
* 500 random calls (0.1, 0.7, 0.0, 0.1, 0.1, 0.0)
* 1000 random calls (0.1, 0.7, 0.0, 0.1, 0.1, 0.0)
==> passed
Test 3: check random calls to enqueue() and sample()
* 5 random calls (0.8, 0.0, 0.2, 0.0, 0.0, 0.0)
* 50 random calls (0.8, 0.0, 0.2, 0.0, 0.0, 0.0)
* 500 random calls (0.8, 0.0, 0.2, 0.0, 0.0, 0.0)
* 1000 random calls (0.8, 0.0, 0.2, 0.0, 0.0, 0.0)
* 5 random calls (0.2, 0.0, 0.8, 0.0, 0.0, 0.0)
* 50 random calls (0.2, 0.0, 0.8, 0.0, 0.0, 0.0)
* 500 random calls (0.2, 0.0, 0.8, 0.0, 0.0, 0.0)
* 1000 random calls (0.2, 0.0, 0.8, 0.0, 0.0, 0.0)
==> passed
Test 4: check random calls to enqueue() and iterator()
* 5 random calls (0.8, 0.0, 0.0, 0.0, 0.0, 0.2)
* 50 random calls (0.8, 0.0, 0.0, 0.0, 0.0, 0.2)
* 500 random calls (0.8, 0.0, 0.0, 0.0, 0.0, 0.2)
* 1000 random calls (0.8, 0.0, 0.0, 0.0, 0.0, 0.2)
==> passed
Test 5: check random calls to all methods except iterator()
* 5 random calls (0.6, 0.1, 0.1, 0.1, 0.1, 0.0)
* 50 random calls (0.6, 0.1, 0.1, 0.1, 0.1, 0.0)
* 500 random calls (0.6, 0.1, 0.1, 0.1, 0.1, 0.0)
* 1000 random calls (0.6, 0.1, 0.1, 0.1, 0.1, 0.0)
* 5 random calls (0.1, 0.6, 0.1, 0.1, 0.1, 0.0)
* 50 random calls (0.1, 0.6, 0.1, 0.1, 0.1, 0.0)
* 500 random calls (0.1, 0.6, 0.1, 0.1, 0.1, 0.0)
* 1000 random calls (0.1, 0.6, 0.1, 0.1, 0.1, 0.0)
==> passed
Test 6: check random calls to all methods, including iterator()
* 5 random calls (0.5, 0.1, 0.1, 0.1, 0.1, 0.1)
* 50 random calls (0.5, 0.1, 0.1, 0.1, 0.1, 0.1)
* 500 random calls (0.5, 0.1, 0.1, 0.1, 0.1, 0.1)
* 1000 random calls (0.5, 0.1, 0.1, 0.1, 0.1, 0.1)
* 5 random calls (0.1, 0.5, 0.1, 0.1, 0.1, 0.1)
* 50 random calls (0.1, 0.5, 0.1, 0.1, 0.1, 0.1)
* 500 random calls (0.1, 0.5, 0.1, 0.1, 0.1, 0.1)
* 1000 random calls (0.1, 0.5, 0.1, 0.1, 0.1, 0.1)
==> passed
Test 7: call dequeue() and sample() from an empty randomized queue
* dequeue()
* sample()
==> passed
Test 8: create multiple randomized queue objects at the same time
* n = 10
* n = 100
==> passed
Test 9: check that iterator() returns correct items after a sequence
of n enqueue() operations
* n = 10
* n = 50
==> passed
Test 10: check that iterator() returns correct items after intermixed
sequence of m enqueue() and dequeue() operations
* m = 10
* m = 1000
==> passed
Test 11: create two nested iterators over the same randomized queue of size n
* n = 10
* n = 50
==> passed
Test 12: create two parallel iterators over the same randomized queue of size n
* n = 10
* n = 50
==> passed
Test 13: create two iterators over different randomized queues,
each of length 10
==> passed
Test 14: create an iterator and check calls to next() and hasNext()
* 10 consecutive calls to hasNext() on a deque of size 10
* 10 consecutive calls to next() on a deque of size 10
* 50 random intermixed calls to next() and hasNext() on a deque of size 10
* 1000 random intermixed calls to next() and hasNext() on a deque of size 100
==> passed
Test 15: create RandomizedQueue objects of different parameterized types
==> passed
Test 16: check randomness of sample() by enqueueing n items, repeatedly calling
sample(), and counting the frequency of each item
* n = 3, trials = 12000
* n = 5, trials = 12000
* n = 8, trials = 12000
* n = 10, trials = 12000
==> passed
Test 17: check randomness of dequeue() by enqueueing n items, dequeueing n items,
and seeing whether each of the n! permutations is equally likely
* n = 2, trials = 12000
* n = 3, trials = 12000
* n = 4, trials = 12000
* n = 5, trials = 12000
==> passed
Test 18: check randomness of iterator() by enqueueing n items, iterating over those
n items, and seeing whether each of the n! permutations is equally likely
* n = 2, trials = 12000
* n = 3, trials = 12000
* n = 4, trials = 12000
* n = 5, trials = 12000
==> passed
Test 19: call enqueue() with a null argument
==> passed
Test 20: check that remove() and next() throw the specified exceptions in iterator()
==> passed
Test 21: call iterator() when randomized queue is empty
==> passed
Total: 21/21 tests passed!
================================================================
********************************************************************************
* TESTING CORRECTNESS (substituting reference RandomizedQueue and Deque)
********************************************************************************
Testing correctness of Permutation
*-----------------------------------------------------------
Tests 1-5 call the main() function directly, resetting standard input
before each call.
Running 9 total tests.
Test 1a: check formatting for sample inputs from assignment specification
% java Permutation 3 < distinct.txt
B
I
H
% java Permutation 3 < distinct.txt
I
E
A
% java Permutation 8 < duplicates.txt
CC
BB
CC
BB
BB
BB
AA
BB
==> passed
Test 1b: check formatting for other inputs
% java Permutation 8 < mediumTale.txt
it
foolishness
of
was
times
the
was
the
% java Permutation 0 < distinct.txt
[no output]
==> passed
Test 2: check that main() reads all data from standard input
* filename = distinct.txt, k = 3
* filename = distinct.txt, k = 3
* filename = duplicates.txt, k = 8
* filename = mediumTale.txt, k = 8
==> passed
Test 3a: check that main() prints each item from the sequence at most once
(for inputs with no duplicate strings)
* filename = distinct.txt, k = 3
* filename = distinct.txt, k = 1
* filename = distinct.txt, k = 9
* filename = permutation6.txt, k = 6
* filename = permutation10.txt, k = 10
==> passed
Test 3b: check that main() prints each item from the sequence at most once
(for inputs with duplicate strings)
* filename = duplicates.txt, k = 8
* filename = duplicates.txt, k = 3
* filename = permutation8.txt, k = 6
* filename = permutation8.txt, k = 2
* filename = tinyTale.txt, k = 10
==> passed
Test 3c: check that main() prints each item from the sequence at most once
(for inputs with newlines)
* filename = mediumTale.txt, k = 10
* filename = mediumTale.txt, k = 20
* filename = tale.txt, k = 10
* filename = tale.txt, k = 50
==> passed
Test 4: check main() when k = 0
* filename = distinct.txt, k = 0
* filename = distinct.txt, k = 0
==> passed
Test 5a: check that permutations are uniformly random
(for inputs with no duplicate strings)
* filename = permutation4.txt, k = 1
* filename = permutation4.txt, k = 2
* filename = permutation4.txt, k = 3
* filename = permutation4.txt, k = 4
* filename = permutation6.txt, k = 2
==> passed
Test 5b: check that permutations are uniformly random
(for inputs with duplicate strings)
* filename = permutation5.txt, k = 1
* filename = permutation5.txt, k = 2
* filename = permutation5.txt, k = 3
* filename = duplicates.txt, k = 3
* filename = permutation8.txt, k = 2
==> passed
Total: 9/9 tests passed!
================================================================
********************************************************************************
* TIMING (substituting reference RandomizedQueue and Deque)
********************************************************************************
Timing Permutation
*-----------------------------------------------------------
Running 23 total tests.
Test 1: count calls to methods in StdIn
* java Permutation 5 < distinct.txt
* java Permutation 10 < permutation10.txt
* java Permutation 1 < mediumTale.txt
* java Permutation 20 < tale.txt
* java Permutation 100 < tale.txt
* java Permutation 16412 < tale.txt
==> passed
Test 2: count calls to methods in Deque and RandomizedQueue
* java Permutation 5 < distinct.txt
* java Permutation 10 < permutation10.txt
* java Permutation 1 < mediumTale.txt
* java Permutation 20 < tale.txt
* java Permutation 100 < tale.txt
* java Permutation 16412 < tale.txt
==> passed
Test 3: count calls to methods in StdRandom
* java Permutation 5 < distinct.txt
* java Permutation 10 < permutation10.txt
* java Permutation 1 < mediumTale.txt
* java Permutation 20 < tale.txt
* java Permutation 100 < tale.txt
* java Permutation 16412 < tale.txt
==> passed
Test 4: Time main() with k = 5, for inputs containing n random strings
n seconds
------------------------------
=> passed 1000 0.00
=> passed 2000 0.00
=> passed 4000 0.00
=> passed 8000 0.00
=> passed 16000 0.00
=> passed 32000 0.01
=> passed 64000 0.02
=> passed 128000 0.04
=> passed 256000 0.07
=> passed 512000 0.14
==> 10/10 tests passed
Test 5: Time main() with k = 1000, for inputs containing n random strings
n seconds
------------------------------
=> passed 1000 0.00
=> passed 2000 0.00
=> passed 4000 0.00
=> passed 8000 0.00
=> passed 16000 0.00
=> passed 32000 0.01
=> passed 64000 0.02
=> passed 128000 0.04
=> passed 256000 0.07
=> passed 512000 0.14
==> 10/10 tests passed
Total: 23/23 tests passed!
================================================================
********************************************************************************
* MEMORY
********************************************************************************
Analyzing memory of Permutation
*-----------------------------------------------------------
Running 2 total tests.
Test 1: check that only one Deque or RandomizedQueue object is created
* filename = distinct.txt, n = 9, k = 1
* filename = distinct.txt, n = 9, k = 2
* filename = distinct.txt, n = 9, k = 4
* filename = tinyTale.txt, n = 12, k = 10
* filename = tale.txt, n = 138653, k = 50
==> passed
Test 2: check that the maximum size of any Deque or RandomizedQueue object
created is between k and n
* filename = distinct.txt, n = 9, k = 1
* filename = distinct.txt, n = 9, k = 2
* filename = distinct.txt, n = 9, k = 4
* filename = tinyTale.txt, n = 12, k = 10
* filename = tale.txt, n = 138653, k = 5
* filename = tale.txt, n = 138653, k = 50
* filename = tale.txt, n = 138653, k = 500
* filename = tale.txt, n = 138653, k = 5000
* filename = tale.txt, n = 138653, k = 50000
==> passed
Test 3 (bonus): check that maximum size of any or Deque or RandomizedQueue object
created is equal to k
* filename = tale.txt, n = 138653, k = 5
- max size of RandomizedQueue object = 138653
* filename = tale.txt, n = 138653, k = 50
- max size of RandomizedQueue object = 138653
* filename = tale.txt, n = 138653, k = 500
- max size of RandomizedQueue object = 138653
* filename = tale.txt, n = 138653, k = 5000
- max size of RandomizedQueue object = 138653
* filename = tale.txt, n = 138653, k = 50000
- max size of RandomizedQueue object = 138653
==> <font color = #990000><b>FAILED</b></font>
Total: 2/2 tests passed!
================================================================
********************************************************************************
* MEMORY
********************************************************************************
Analyzing memory of Deque
*-----------------------------------------------------------
For tests 1-4, the maximum amount of memory allowed for a Deque
containing n items is 48n + 192.
Running 49 total tests.
Test 1a-1i: total memory usage after inserting n items,
where n is a power of 2
n bytes
----------------------------------------------------------
=> passed 32 1320
=> passed 64 2600
=> passed 128 5160
=> passed 256 10280
=> passed 512 20520
=> passed 1024 41000
=> passed 2048 81960
=> passed 4096 163880
=> passed 8192 327720
==> 9/9 tests passed
Memory: 40.00 n + 40.00 (R^2 = 1.000)
Test 2a-2i: Total memory usage after inserting n items,
when n is one more than a power of 2.
n bytes
----------------------------------------------------------
=> passed 33 1360
=> passed 65 2640
=> passed 129 5200
=> passed 257 10320
=> passed 513 20560
=> passed 1025 41040
=> passed 2049 82000
=> passed 4097 163920
=> passed 8193 327760
==> 9/9 tests passed
Memory: 40.00 n + 40.00 (R^2 = 1.000)
Test 3a-3i: Total memory usage after inserting 2n-1 items, and then
deleting n-1 items, when n is one more than a power of 2.
n bytes
----------------------------------------------------------
=> passed 33 1360
=> passed 65 2640
=> passed 129 5200
=> passed 257 10320
=> passed 513 20560
=> passed 1025 41040
=> passed 2049 82000
=> passed 4097 163920
=> passed 8193 327760
==> 9/9 tests passed
Memory: 40.00 n + 40.00 (R^2 = 1.000)
Test 4a-4e: Total memory usage after inserting n items,
and then deleting all but one item
(should not grow with n or be too large of a constant).
n bytes
----------------------------------------------------------
=> passed 32 80
=> passed 64 80
=> passed 128 80
=> passed 256 80
=> passed 512 80
=> passed 1024 80
=> passed 2048 80
=> passed 4096 80
=> passed 8192 80
==> 9/9 tests passed
Memory: 80.00 (R^2 = 1.000)
Test 5a-5e: Total memory usage of iterator after inserting n items
(should not grow with n or be too large of a constant).
n bytes
----------------------------------------------------------
=> passed 32 32
=> passed 64 32
=> passed 128 32
=> passed 256 32
=> passed 512 32
=> passed 1024 32
=> passed 2048 32
=> passed 4096 32
=> passed 8192 32
==> 9/9 tests passed
Memory: 32.00 (R^2 = 1.000)
Test 6a: Insert n strings; delete them one at a time, checking for
loitering after each deletion. The probabilities of addFirst()
and addLast() are (p1, p2), respectively. The probabilities of
removeFirst() and removeLast() are (q1, q2), respectively.
* 100 random insertions (1.0, 0.0) and 100 random deletions (1.0, 0.0)
* 100 random insertions (1.0, 0.0) and 100 random deletions (0.0, 1.0)
* 100 random insertions (0.0, 1.0) and 100 random deletions (1.0, 0.0)
* 100 random insertions (0.0, 1.0) and 100 random deletions (0.0, 1.0)
* 100 random insertions (0.5, 0.5) and 100 random deletions (0.5, 0.5)
==> passed
Test 6b: Perform random operations, checking for loitering after
each operation. The probabilities of addFirst(), addLast(),
removeFirst(), and removeLast() are (p1, p2, p3, p4),
respectively.
* 100 random operations (0.8, 0.0, 0.2, 0.0)
* 100 random operations (0.8, 0.0, 0.0, 0.2)
* 100 random operations (0.0, 0.8, 0.2, 0.0)
* 100 random operations (0.0, 0.8, 0.0, 0.2)
* 100 random operations (0.4, 0.4, 0.1, 0.1)
* 100 random operations (0.2, 0.2, 0.3, 0.3)
==> passed
Test 7: Perform m random add/remove operations in the deque and check
that only constant memory is allocated/deallocated per operation
* m = 128
* m = 256
* m = 512
==> passed
Test 8: Insert m items into deque; then iterate over deque and check
that only constant memory is allocated/deallocated per operation
* m = 64
* m = 128
* m = 256
==> passed
Test 9 (bonus): Uses at most 40n + 40 bytes of memory
==> passed
Min observed memory for Deque: 40.00 n + 40.00 (R^2 = 1.000)
Max observed memory for Deque: 40.00 n + 40.00 (R^2 = 1.000)
Total: 50/49 tests passed!
================================================================
Analyzing memory of RandomizedQueue
*-----------------------------------------------------------
For Tests 1-5, the maximum amount of memory allowed for
a RandomizedQueue containing n items is 48n + 192.
For Test 6, the maximum amount of memory allowed for
a RandomizedQueue iterator over n items is 8n + 72.
Test 1a-1i: Total memory usage after inserting n items
when n is a power of 2.
n bytes
----------------------------------------------------------
=> passed 32 376
=> passed 64 696
=> passed 128 1336
=> passed 256 2616
=> passed 512 5176
=> passed 1024 10296
=> passed 2048 20536
=> passed 4096 41016
=> passed 8192 81976
==> 9/9 tests passed
Memory: 10.00 n + 56.00 (R^2 = 1.000)
Test 2a-2i: Total memory usage after inserting n items,
when n is one more than a power of 2.
n bytes
----------------------------------------------------------
=> passed 33 376
=> passed 65 696
=> passed 129 1336
=> passed 257 2616
=> passed 513 5176
=> passed 1025 10296
=> passed 2049 20536
=> passed 4097 41016
=> passed 8193 81976
==> 9/9 tests passed
Memory: 10.00 n + 46.00 (R^2 = 1.000)
Test 3a-3i: Total memory usage after inserting 2n-1 items, and then
deleting n-1 items, when n is one more than a power of 2.
n bytes
----------------------------------------------------------
=> passed 33 696
=> passed 65 1336
=> passed 129 2616
=> passed 257 5176
=> passed 513 10296
=> passed 1025 20536
=> passed 2049 41016
=> passed 4097 81976
=> passed 8193 163896
==> 9/9 tests passed
Memory: 20.00 n + 36.00 (R^2 = 1.000)
Test 4a-4i: Total memory usage after inserting n items, deleting n items,
then inserting n times, when n is a power of 2.
n bytes
----------------------------------------------------------
=> passed 32 376
=> passed 64 696
=> passed 128 1336
=> passed 256 2616
=> passed 512 5176
=> passed 1024 10296
=> passed 2048 20536
=> passed 4096 41016
=> passed 8192 81976
==> 9/9 tests passed
Memory: 10.00 n + 56.00 (R^2 = 1.000)
Test 5a-5i: Total memory usage after inserting n items,
and then deleting all but one item.
n bytes
----------------------------------------------------------
=> passed 32 136
=> passed 64 136
=> passed 128 136
=> passed 256 136
=> passed 512 136
=> passed 1024 136
=> passed 2048 136
=> passed 4096 136
=> passed 8192 136
==> 9/9 tests passed
Memory: 136.00 (R^2 = 1.000)
Test 6a-6i: Total memory usage of iterator after inserting n items.
n bytes
----------------------------------------------------------
=> passed 32 320
=> passed 64 576
=> passed 128 1088
=> passed 256 2112
=> passed 512 4160
=> passed 1024 8256
=> passed 2048 16448
=> passed 4096 32832
=> passed 8192 65600
==> 9/9 tests passed
Memory: 8.00 n + 64.00 (R^2 = 1.000)
Test 7a: Insert 100 strings; delete them one at a time, checking
for loitering after each deletion.
==> passed
Test 7b: Perform random operations, checking for loitering after
each operation. The probabilities of enqueue(), dequeue(),
and sample() are (p1, p2, p3), respectively.
* 200 random operations (0.8, 0.2, 0.0)
* 200 random operations (0.2, 0.8, 0.0)
* 200 random operations (0.6, 0.2, 0.2)
* 200 random operations (0.2, 0.4, 0.4)
==> passed
Test 8: Insert m items into queue; then iterate over deque and check
that only constant memory is allocated/deallocated per operation