-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue-grade.txt
1282 lines (1018 loc) · 39.9 KB
/
queue-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
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
See the Assessment Guide for information on how to interpret this report.
ASSESSMENT SUMMARY
Compilation: PASSED (0 errors, 2 warnings)
API: PASSED
Spotbugs: PASSED
PMD: PASSED
Checkstyle: FAILED (0 errors, 3 warnings)
Correctness: 45/45 tests passed
Memory: 135/134 tests passed
Timing: 193/193 tests passed
Aggregate score: 100.07%
[Compilation: 5%, API: 5%, Spotbugs: 0%, PMD: 0%, Checkstyle: 0%, Correctness: 60%, Memory: 10%, Timing: 20%]
ASSESSMENT DETAILS
The following files were submitted:
----------------------------------
3.8K Jul 26 19:58 Deque.java
878 Jul 26 19:58 Permutation.java
3.8K Jul 26 19:58 RandomizedQueue.java
********************************************************************************
* COMPILING
********************************************************************************
% javac Deque.java
*-----------------------------------------------------------
% javac RandomizedQueue.java
*-----------------------------------------------------------
RandomizedQueue.java:15: warning: [unchecked] unchecked cast
q = (Item[]) new Object[sz];
^
required: Item[]
found: Object[]
where Item is a type-variable:
Item extends Object declared in class RandomizedQueue
RandomizedQueue.java:22: warning: [unchecked] unchecked cast
final Item[] aux = (Item[]) new Object[sz];
^
required: Item[]
found: Object[]
where Item is a type-variable:
Item extends Object declared in class RandomizedQueue
2 warnings
% javac Permutation.java
*-----------------------------------------------------------
================================================================
Checking the APIs of your programs.
*-----------------------------------------------------------
Deque:
RandomizedQueue:
Permutation:
================================================================
********************************************************************************
* CHECKING STYLE AND COMMON BUG PATTERNS
********************************************************************************
% spotbugs *.class
*-----------------------------------------------------------
L D DLS_DEAD_LOCAL_STORE_OF_NULL DLS: Assigns the value null to the local variable 'temp' but never reads the variable. At Deque.java:[line 85]
L D DLS_DEAD_LOCAL_STORE_OF_NULL DLS: Assigns the value null to the local variable 'temp' but never reads the variable. At Deque.java:[line 103]
================================================================
% pmd .
*-----------------------------------------------------------
================================================================
% checkstyle *.java
*-----------------------------------------------------------
[WARN] Deque.java:14:9: Declare instance variables after static variables but before constructors and methods. [DeclarationOrder]
[WARN] Deque.java:15:9: Declare instance variables after static variables but before constructors and methods. [DeclarationOrder]
[WARN] Deque.java:16:9: Declare instance variables after static variables but before constructors and methods. [DeclarationOrder]
Checkstyle ends with 0 errors and 3 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 17 total tests.
Tests 1-6 make random calls to addFirst(), addLast(), removeFirst(),
removeLast(), isEmpty(), and size(). The probabilities of each
operation are (p1, p2, p3, p4, p5, p6), 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)
* 50 random calls (0.4, 0.4, 0.0, 0.0, 0.0, 0.2)
* 500 random calls (0.4, 0.4, 0.0, 0.0, 0.0, 0.2)
* 1000 random calls (0.4, 0.4, 0.0, 0.0, 0.0, 0.2)
==> 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)
* 50 random calls (0.8, 0.0, 0.1, 0.0, 0.1, 0.0)
* 500 random calls (0.8, 0.0, 0.1, 0.0, 0.1, 0.0)
* 1000 random calls (0.8, 0.0, 0.1, 0.0, 0.1, 0.0)
* 5 random calls (0.1, 0.0, 0.8, 0.0, 0.1, 0.0)
* 50 random calls (0.1, 0.0, 0.8, 0.0, 0.1, 0.0)
* 500 random calls (0.1, 0.0, 0.8, 0.0, 0.1, 0.0)
* 1000 random calls (0.1, 0.0, 0.8, 0.0, 0.1, 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)
* 50 random calls (0.8, 0.0, 0.0, 0.1, 0.1, 0.0)
* 500 random calls (0.8, 0.0, 0.0, 0.1, 0.1, 0.0)
* 1000 random calls (0.8, 0.0, 0.0, 0.1, 0.1, 0.0)
* 5 random calls (0.1, 0.0, 0.0, 0.8, 0.1, 0.0)
* 50 random calls (0.1, 0.0, 0.0, 0.8, 0.1, 0.0)
* 500 random calls (0.1, 0.0, 0.0, 0.8, 0.1, 0.0)
* 1000 random calls (0.1, 0.0, 0.0, 0.8, 0.1, 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)
* 50 random calls (0.0, 0.8, 0.0, 0.1, 0.1, 0.0)
* 500 random calls (0.0, 0.8, 0.0, 0.1, 0.1, 0.0)
* 1000 random calls (0.0, 0.8, 0.0, 0.1, 0.1, 0.0)
* 5 random calls (0.0, 0.1, 0.0, 0.8, 0.1, 0.0)
* 50 random calls (0.0, 0.1, 0.0, 0.8, 0.1, 0.0)
* 500 random calls (0.0, 0.1, 0.0, 0.8, 0.1, 0.0)
* 1000 random calls (0.0, 0.1, 0.0, 0.8, 0.1, 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)
* 50 random calls (0.0, 0.8, 0.1, 0.0, 0.1, 0.0)
* 500 random calls (0.0, 0.8, 0.1, 0.0, 0.1, 0.0)
* 1000 random calls (0.0, 0.8, 0.1, 0.0, 0.1, 0.0)
* 5 random calls (0.0, 0.1, 0.8, 0.0, 0.1, 0.0)
* 50 random calls (0.0, 0.1, 0.8, 0.0, 0.1, 0.0)
* 500 random calls (0.0, 0.1, 0.8, 0.0, 0.1, 0.0)
* 1000 random calls (0.0, 0.1, 0.8, 0.0, 0.1, 0.0)
==> passed
Test 6: check random calls to addFirst(), addLast(), removeFirst(),
removeLast(), isEmpty(), and size()
* 5 random calls (0.3, 0.3, 0.1, 0.1, 0.1, 0.1)
* 50 random calls (0.3, 0.3, 0.1, 0.1, 0.1, 0.1)
* 500 random calls (0.3, 0.3, 0.1, 0.1, 0.1, 0.1)
* 1000 random calls (0.3, 0.3, 0.1, 0.1, 0.1, 0.1)
* 5 random calls (0.1, 0.1, 0.3, 0.3, 0.1, 0.1)
* 50 random calls (0.1, 0.1, 0.3, 0.3, 0.1, 0.1)
* 500 random calls (0.1, 0.1, 0.3, 0.3, 0.1, 0.1)
* 1000 random calls (0.1, 0.1, 0.3, 0.3, 0.1, 0.1)
==> passed
Test 7: check removeFirst() and removeLast() from an empty deque
* removeFirst()
* removeLast()
==> passed
Test 8: check whether two Deque objects can be created at the same time
* n = 10
* n = 1000
==> passed
Test 9: check iterator() after n calls to addFirst()
* n = 10
* n = 50
==> passed
Test 10: check iterator() after each of m intermixed calls to
addFirst(), addLast(), removeFirst(), and removeLast()
* m = 20
* m = 50
* m = 100
* m = 1000
==> passed
Test 11: create two nested iterators to same deque
* n = 10
* n = 50
==> passed
Test 12: create two parallel iterators to same deque
==> passed
Test 13: 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 14: create Deque objects of different parameterized types
==> passed
Test 15: call addFirst() and addLast() with null argument
==> passed
Test 16: check that remove() and next() throw the specified exceptions in iterator()
==> passed
Test 17: call iterator() when the deque is empty
==> passed
Total: 17/17 tests passed!
================================================================
Testing correctness of RandomizedQueue
*-----------------------------------------------------------
Running 19 total tests.
Tests 1-4 make random calls to enqueue(), dequeue(), sample(),
isEmpty(), and size(). The probabilities of each operation are
(p1, p2, p3, p4, p5), respectively.
Test 1: check random calls to enqueue() and size()
* 5 random calls (0.8, 0.0, 0.0, 0.0, 0.2)
* 50 random calls (0.8, 0.0, 0.0, 0.0, 0.2)
* 500 random calls (0.8, 0.0, 0.0, 0.0, 0.2)
* 1000 random calls (0.8, 0.0, 0.0, 0.0, 0.2)
==> passed
Test 2: check random calls to enqueue() and dequeue()
* 5 random calls (0.7, 0.1, 0.0, 0.1, 0.1)
* 50 random calls (0.7, 0.1, 0.0, 0.1, 0.1)
* 500 random calls (0.7, 0.1, 0.0, 0.1, 0.1)
* 1000 random calls (0.7, 0.1, 0.0, 0.1, 0.1)
* 5 random calls (0.1, 0.7, 0.0, 0.1, 0.1)
* 50 random calls (0.1, 0.7, 0.0, 0.1, 0.1)
* 500 random calls (0.1, 0.7, 0.0, 0.1, 0.1)
* 1000 random calls (0.1, 0.7, 0.0, 0.1, 0.1)
==> passed
Test 3: check random calls to enqueue(), sample(), and size()
* 5 random calls (0.8, 0.0, 0.1, 0.0, 0.1)
* 50 random calls (0.8, 0.0, 0.1, 0.0, 0.1)
* 500 random calls (0.8, 0.0, 0.1, 0.0, 0.1)
* 1000 random calls (0.8, 0.0, 0.1, 0.0, 0.1)
* 5 random calls (0.1, 0.0, 0.8, 0.0, 0.1)
* 50 random calls (0.1, 0.0, 0.8, 0.0, 0.1)
* 500 random calls (0.1, 0.0, 0.8, 0.0, 0.1)
* 1000 random calls (0.1, 0.0, 0.8, 0.0, 0.1)
==> passed
Test 4: check random calls to enqueue(), dequeue(), sample(), isEmpty(), and size()
* 5 random calls (0.6, 0.1, 0.1, 0.1, 0.1)
* 50 random calls (0.6, 0.1, 0.1, 0.1, 0.1)
* 500 random calls (0.6, 0.1, 0.1, 0.1, 0.1)
* 1000 random calls (0.6, 0.1, 0.1, 0.1, 0.1)
* 5 random calls (0.1, 0.6, 0.1, 0.1, 0.1)
* 50 random calls (0.1, 0.6, 0.1, 0.1, 0.1)
* 500 random calls (0.1, 0.6, 0.1, 0.1, 0.1)
* 1000 random calls (0.1, 0.6, 0.1, 0.1, 0.1)
==> passed
Test 5: call dequeue() and sample() from an empty randomized queue
* dequeue()
* sample()
==> passed
Test 6: create multiple randomized queue objects at the same time
* n = 10
* n = 100
==> passed
Test 7: check that iterator() returns correct items after a sequence
of n enqueue() operations
* n = 10
* n = 50
==> passed
Test 8: check that iterator() returns correct items after sequence
of m enqueue() and dequeue() operations
* m = 10
* m = 1000
==> passed
Test 9: create two nested iterators over the same randomized queue
* n = 10
* n = 50
==> passed
Test 10: create two parallel iterators over the same randomized queue
* n = 10
* n = 50
==> passed
Test 11: create two iterators over different randomized queues
==> passed
Test 12: 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 13: create RandomizedQueue objects of different parameterized types
==> passed
Test 14: 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 15: 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 16: 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 17: call enqueue() with a null argument
==> passed
Test 18: check that remove() and next() throw the specified exceptions in iterator()
==> passed
Test 19: call iterator() when randomized queue is empty
==> passed
Total: 19/19 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
A
I
E
% java Permutation 3 < distinct.txt
C
D
E
% java Permutation 8 < duplicates.txt
CC
BB
BB
BB
AA
BB
BB
CC
==> passed
Test 1b: check formatting for other inputs
% java Permutation 8 < mediumTale.txt
was
it
was
age
of
of
foolishness
it
% 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.01
=> passed 32000 0.01
=> passed 64000 0.02
=> passed 128000 0.04
=> passed 256000 0.08
=> passed 512000 0.17
==> 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.01
=> passed 32000 0.01
=> passed 64000 0.03
=> passed 128000 0.04
=> passed 256000 0.08
=> passed 512000 0.17
==> 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
* 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
Total: 3/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 48 total tests.
Test 1a-1i: total memory usage after inserting n items,
where n is a power of 2
n bytes
----------------------------------------------------------
=> passed 32 1576
=> passed 64 3112
=> passed 128 6184
=> passed 256 12328
=> passed 512 24616
=> passed 1024 49192
=> passed 2048 98344
=> passed 4096 196648
=> passed 8192 393256
==> 9/9 tests passed
Memory: 48.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 1624
=> passed 65 3160
=> passed 129 6232
=> passed 257 12376
=> passed 513 24664
=> passed 1025 49240
=> passed 2049 98392
=> passed 4097 196696
=> passed 8193 393304
==> 9/9 tests passed
Memory: 48.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 1624
=> passed 65 3160
=> passed 129 6232
=> passed 257 12376
=> passed 513 24664
=> passed 1025 49240
=> passed 2049 98392
=> passed 4097 196696
=> passed 8193 393304
==> 9/9 tests passed
Memory: 48.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 88
=> passed 64 88
=> passed 128 88
=> passed 256 88
=> passed 512 88
=> passed 1024 88
=> passed 2048 88
=> passed 4096 88
=> passed 8192 88
==> 9/9 tests passed
Memory: 88.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: worst-case constant memory allocated or de-allocated
per deque operation?
* 128 random operations
* 256 random operations
* 512 random operations
==> passed
Min observed memory for Deque: 48.00 n + 40.00 (R^2 = 1.000)
Max observed memory for Deque: 48.00 n + 40.00 (R^2 = 1.000)
Total: 48/48 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 312
=> passed 64 568
=> passed 128 1080
=> passed 256 2104
=> passed 512 4152
=> passed 1024 8248
=> passed 2048 16440
=> passed 4096 32824
=> passed 8192 65592
==> 9/9 tests passed
Memory: 8.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 568
=> passed 65 1080
=> passed 129 2104
=> passed 257 4152
=> passed 513 8248
=> passed 1025 16440
=> passed 2049 32824
=> passed 4097 65592
=> passed 8193 131128
==> 9/9 tests passed
Memory: 16.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 568
=> passed 65 1080
=> passed 129 2104
=> passed 257 4152
=> passed 513 8248
=> passed 1025 16440
=> passed 2049 32824
=> passed 4097 65592
=> passed 8193 131128
==> 9/9 tests passed
Memory: 16.00 n + 40.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 312
=> passed 64 568
=> passed 128 1080
=> passed 256 2104
=> passed 512 4152
=> passed 1024 8248
=> passed 2048 16440
=> passed 4096 32824
=> passed 8192 65592
==> 9/9 tests passed
Memory: 8.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 88
=> passed 64 88
=> passed 128 88
=> passed 256 88
=> passed 512 88
=> passed 1024 88
=> passed 2048 88
=> passed 4096 88
=> passed 8192 88
==> 9/9 tests passed
Memory: 88.00 (R^2 = 1.000)
Test 6a-6i: Total memory usage of iterator after inserting n items.
n bytes
----------------------------------------------------------
=> passed 32 192
=> passed 64 320
=> passed 128 576
=> passed 256 1088
=> passed 512 2112
=> passed 1024 4160
=> passed 2048 8256
=> passed 4096 16448
=> passed 8192 32832
==> 9/9 tests passed
Memory: 4.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 T items into queue; then iterate over queue and check
that worst-case constant memory is allocated or deallocated
per iterator operation.
* T = 64
* T = 128
* T = 256
==> passed
Test 9: Total memory usage after inserting n items, seeking to identify
values of n where memory usage is minimized as a function of n.
n bytes
----------------------------------------------------------
=> passed 8 120
=> passed 16 184
=> passed 32 312
=> passed 64 568
=> passed 128 1080
=> passed 256 2104
=> passed 512 4152
=> passed 1024 8248
=> passed 2048 16440
=> passed 8 120
=> passed 16 184
=> passed 32 312
=> passed 64 568
=> passed 128 1080
=> passed 256 2104
=> passed 512 4152
=> passed 1024 8248
=> passed 2048 16440
==> 18/18 tests passed
Memory: 8.00 n + 56.00 (R^2 = 1.000)
Test 10: Total memory usage after inserting 4096 items, then successively
deleting items, seeking values of n where memory usage is maximized
as a function of n
n bytes
----------------------------------------------------------
=> passed 4094 65592
=> passed 2046 32824
=> passed 1022 16440
=> passed 510 8248
=> passed 254 4152
=> passed 126 2104
=> passed 62 1080
=> passed 30 568
=> passed 14 312
==> 9/9 tests passed
Memory: 16.00 n + 88.00 (R^2 = 1.000)
Min observed memory for RandomizedQueue: 8.00 n + 56.00 (R^2 = 1.000)
Max observed memory for RandomizedQueue: 16.00 n + 40.00 (R^2 = 1.000)
Running 84 total tests.
Total: 84/84 tests passed!
================================================================
********************************************************************************
* TIMING
********************************************************************************
Timing Deque
*-----------------------------------------------------------
Running 103 total tests.
Test 1a-1k: make n calls to addFirst() followed by n calls to removeFirst()
n seconds
----------------------------------
=> passed 1024 0.00
=> passed 2048 0.00
=> passed 4096 0.00
=> passed 8192 0.00
=> passed 16384 0.00
=> passed 32768 0.00
=> passed 65536 0.00
=> passed 128000 0.00
=> passed 256000 0.00
=> passed 512000 0.01
=> passed 1024000 0.02
==> 11/11 tests passed
Test 2a-2k: make n calls to addLast() followed by n calls to removeLast()
n seconds
----------------------------------
=> passed 1024 0.00
=> passed 2048 0.00
=> passed 4096 0.00
=> passed 8192 0.00
=> passed 16384 0.00
=> passed 32768 0.00
=> passed 65536 0.00
=> passed 128000 0.00
=> passed 256000 0.00
=> passed 512000 0.01
=> passed 1024000 0.02
==> 11/11 tests passed
Test 3a-3k: make n calls to addFirst() followed by n calls to removeLast()
n seconds
----------------------------------
=> passed 1024 0.00