-
Notifications
You must be signed in to change notification settings - Fork 11
/
Assignment3-CollinearPoints-Sorting.txt
611 lines (473 loc) · 20.9 KB
/
Assignment3-CollinearPoints-Sorting.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
See the Assessment Guide for information on how to interpret this report.
ASSESSMENT SUMMARY
Compilation: PASSED
API: PASSED
Findbugs: FAILED (2 warnings)
PMD: PASSED
Checkstyle: FAILED (0 errors, 1 warning)
Correctness: 41/41 tests passed
Memory: 1/1 tests passed
Timing: 41/41 tests passed
Aggregate score: 100.00%
[Compilation: 5%, API: 5%, Findbugs: 0%, PMD: 0%, Checkstyle: 0%, Correctness: 60%, Memory: 10%, Timing: 20%]
ASSESSMENT DETAILS
The following files were submitted:
----------------------------------
2.9K Jun 28 12:09 BruteCollinearPoints.java
3.9K Jun 28 12:09 FastCollinearPoints.java
4.6K Jun 28 12:09 Point.java
********************************************************************************
* COMPILING
********************************************************************************
% javac Point.java
*-----------------------------------------------------------
% javac BruteCollinearPoints.java
*-----------------------------------------------------------
% javac FastCollinearPoints.java
*-----------------------------------------------------------
================================================================
Checking the APIs of your programs.
*-----------------------------------------------------------
Point:
BruteCollinearPoints:
FastCollinearPoints:
================================================================
********************************************************************************
* CHECKING STYLE AND COMMON BUG PATTERNS
********************************************************************************
% findbugs *.class
*-----------------------------------------------------------
L D FE_FLOATING_POINT_EQUALITY FE: Tests for exact floating-point equality. Because floating-point calculations may involve rounding, the calculated values may be imprecise. At BruteCollinearPoints.java:[line 23]
L D FE_FLOATING_POINT_EQUALITY FE: Tests for exact floating-point equality. Because floating-point calculations may involve rounding, the calculated values may be imprecise. At FastCollinearPoints.java:[line 36]
Warnings generated: 2
================================================================
% pmd .
*-----------------------------------------------------------
================================================================
% checkstyle *.java
*-----------------------------------------------------------
[WARN] BruteCollinearPoints.java:21:30: Do not use the letter 'l' as a local variable name. It is hard to distinguish from the number '1'. [LocalVariableName]
Checkstyle ends with 0 errors and 1 warning.
% custom checkstyle checks for Point.java
*-----------------------------------------------------------
% custom checkstyle checks for BruteCollinearPoints.java
*-----------------------------------------------------------
% custom checkstyle checks for FastCollinearPoints.java
*-----------------------------------------------------------
================================================================
********************************************************************************
* TESTING CORRECTNESS
********************************************************************************
Testing correctness of Point
*-----------------------------------------------------------
Running 3 total tests.
Test 1: p.slopeTo(q)
* positive infinite slope, where p and q have coordinates in [0, 500)
* positive infinite slope, where p and q have coordinates in [0, 32768)
* negative infinite slope, where p and q have coordinates in [0, 500)
* negative infinite slope, where p and q have coordinates in [0, 32768)
* positive zero slope, where p and q have coordinates in [0, 500)
* positive zero slope, where p and q have coordinates in [0, 32768)
* symmetric for random points p and q with coordinates in [0, 500)
* symmetric for random points p and q with coordinates in [0, 32768)
* transitive for random points p, q, and r with coordinates in [0, 500)
* transitive for random points p, q, and r with coordinates in [0, 32768)
* slopeTo(), where p and q have coordinates in [0, 500)
* slopeTo(), where p and q have coordinates in [0, 32768)
* slopeTo(), where p and q have coordinates in [0, 10)
* throw a java.lang.NullPointerException if argument is null
==> passed
Test 2: p.compareTo(q)
* reflexive, where p and q have coordinates in [0, 500)
* reflexive, where p and q have coordinates in [0, 32768)
* antisymmetric, where p and q have coordinates in [0, 500)
* antisymmetric, where p and q have coordinates in [0, 32768)
* transitive, where p, q, and r have coordinates in [0, 500)
* transitive, where p, q, and r have coordinates in [0, 32768)
* sign of compareTo(), where p and q have coordinates in [0, 500)
* sign of compareTo(), where p and q have coordinates in [0, 32768)
* sign of compareTo(), where p and q have coordinates in [0, 10)
* throw java.lang.NullPointerException exception if argument is null
==> passed
Test 3: p.slopeOrder().compare(q, r)
* reflexive, where p and q have coordinates in [0, 500)
* reflexive, where p and q have coordinates in [0, 32768)
* antisymmetric, where p, q, and r have coordinates in [0, 500)
* antisymmetric, where p, q, and r have coordinates in [0, 32768)
* transitive, where p, q, r, and s have coordinates in [0, 500)
* transitive, where p, q, r, and s have coordinates in [0, 32768)
* sign of compare(), where p, q, and r have coordinates in [0, 500)
* sign of compare(), where p, q, and r have coordinates in [0, 32768)
* sign of compare(), where p, q, and r have coordinates in [0, 10)
* throw java.lang.NullPointerException if either argument is null
==> passed
Total: 3/3 tests passed!
================================================================
********************************************************************************
* TESTING CORRECTNESS (substituting reference Point and LineSegment)
********************************************************************************
Testing correctness of BruteCollinearPoints
*-----------------------------------------------------------
Running 17 total tests.
The inputs satisfy the following conditions:
- no duplicate points
- no 5 (or more) points are collinear
- all x- and y-coordinates between 0 and 32,767
Test 1: points from a file
* filename = input8.txt
* filename = equidistant.txt
* filename = input40.txt
* filename = input48.txt
==> passed
Test 2a: points from a file with horizontal line segments
* filename = horizontal5.txt
* filename = horizontal25.txt
==> passed
Test 2b: random horizontal line segments
* 1 random horizontal line segment
* 5 random horizontal line segments
* 10 random horizontal line segments
* 15 random horizontal line segments
==> passed
Test 3a: points from a file with vertical line segments
* filename = vertical5.txt
* filename = vertical25.txt
==> passed
Test 3b: random vertical line segments
* 1 random vertical line segment
* 5 random vertical line segments
* 10 random vertical line segments
* 15 random vertical line segments
==> passed
Test 4a: points from a file with no line segments
* filename = random23.txt
* filename = random38.txt
==> passed
Test 4b: random points with no line segments
* 5 random points
* 10 random points
* 20 random points
* 50 random points
==> passed
Test 5: points from a file with fewer than 4 points
* filename = input1.txt
* filename = input2.txt
* filename = input3.txt
==> passed
Test 6: check for dependence on either compareTo() or compare()
returning { -1, +1, 0 } instead of { negative integer,
positive integer, zero }
* filename = equidistant.txt
* filename = input40.txt
* filename = input48.txt
==> passed
Test 7: check for fragile dependence on return value of toString()
* filename = equidistant.txt
* filename = input40.txt
* filename = input48.txt
==> passed
Test 8: random line segments, none vertical or horizontal
* 1 random line segment
* 5 random line segments
* 10 random line segments
* 15 random line segments
==> passed
Test 9: random line segments
* 1 random line segment
* 5 random line segments
* 10 random line segments
* 15 random line segments
==> passed
Test 10: check that data type is immutable by testing whether each method
returns the same value, regardless of any intervening operations
* input8.txt
* equidistant.txt
==> passed
Test 11: check that data type does not mutate the constructor argument
* input8.txt
* equidistant.txt
==> passed
Test 12: numberOfSegments() is consistent with segments()
* filename = input8.txt
* filename = equidistant.txt
* filename = input40.txt
* filename = input48.txt
* filename = horizontal5.txt
* filename = vertical5.txt
* filename = random23.txt
==> passed
Test 13: throws an exception if either the constructor argument is null
or any entry in array is null
* argument is null
* Point[] of length 10, number of null entries = 1
* Point[] of length 10, number of null entries = 10
* Point[] of length 4, number of null entries = 1
* Point[] of length 3, number of null entries = 1
* Point[] of length 2, number of null entries = 1
* Point[] of length 1, number of null entries = 1
==> passed
Test 14: check that the constructor throws an exception if duplicate points
* 50 points
* 25 points
* 5 points
* 4 points
* 3 points
* 2 points
==> passed
Total: 17/17 tests passed!
================================================================
Testing correctness of FastCollinearPoints
*-----------------------------------------------------------
Running 21 total tests.
The inputs satisfy the following conditions:
- no duplicate points
- all x- and y-coordinates between 0 and 32,767
Test 1: points from a file
* filename = input8.txt
* filename = equidistant.txt
* filename = input40.txt
* filename = input48.txt
* filename = input299.txt
==> passed
Test 2a: points from a file with horizontal line segments
* filename = horizontal5.txt
* filename = horizontal25.txt
* filename = horizontal50.txt
* filename = horizontal75.txt
* filename = horizontal100.txt
==> passed
Test 2b: random horizontal line segments
* 1 random horizontal line segment
* 5 random horizontal line segments
* 10 random horizontal line segments
* 15 random horizontal line segments
==> passed
Test 3a: points from a file with vertical line segments
* filename = vertical5.txt
* filename = vertical25.txt
* filename = vertical50.txt
* filename = vertical75.txt
* filename = vertical100.txt
==> passed
Test 3b: random vertical line segments
* 1 random vertical line segment
* 5 random vertical line segments
* 10 random vertical line segments
* 15 random vertical line segments
==> passed
Test 4a: points from a file with no line segments
* filename = random23.txt
* filename = random38.txt
* filename = random91.txt
* filename = random152.txt
==> passed
Test 4b: random points with no line segments
* 5 random points
* 10 random points
* 20 random points
* 50 random points
==> passed
Test 5a: points from a file with 5 or more on some line segments
* filename = input9.txt
* filename = input10.txt
* filename = input20.txt
* filename = input50.txt
* filename = input80.txt
* filename = input300.txt
* filename = inarow.txt
==> passed
Test 5b: points from a file with 5 or more on some line segments
* filename = kw1260.txt
* filename = rs1423.txt
==> passed
Test 6: points from a file with fewer than 4 points
* filename = input1.txt
* filename = input2.txt
* filename = input3.txt
==> passed
Test 7: check for dependence on either compareTo() or compare()
returning { -1, +1, 0 } instead of { negative integer,
positive integer, zero }
* filename = equidistant.txt
* filename = input40.txt
* filename = input48.txt
* filename = input299.txt
==> passed
Test 8: check for fragile dependence on return value of toString()
* filename = equidistant.txt
* filename = input40.txt
* filename = input48.txt
==> passed
Test 9: random line segments, none vertical or horizontal
* 1 random line segment
* 5 random line segments
* 25 random line segments
* 50 random line segments
* 100 random line segments
==> passed
Test 10: random line segments
* 1 random line segment
* 5 random line segments
* 25 random line segments
* 50 random line segments
* 100 random line segments
==> passed
Test 11: random distinct points in a given range
* 5 random points in a 10-by-10 grid
* 10 random points in a 10-by-10 grid
* 50 random points in a 10-by-10 grid
* 90 random points in a 10-by-10 grid
* 200 random points in a 50-by-50 grid
==> passed
Test 12: m*n points on an m-by-n grid
* 3-by-3 grid
* 4-by-4 grid
* 5-by-5 grid
* 10-by-10 grid
* 20-by-20 grid
* 5-by-4 grid
* 6-by-4 grid
* 10-by-4 grid
* 15-by-4 grid
* 25-by-4 grid
==> passed
Test 13: check that data type is immutable by testing whether each method
returns the same value, regardless of any intervening operations
* input8.txt
* equidistant.txt
==> passed
Test 14: check that data type does not mutate the constructor argument
* input8.txt
* equidistant.txt
==> passed
Test 15: numberOfSegments() is consistent with segments()
* filename = input8.txt
* filename = equidistant.txt
* filename = input40.txt
* filename = input48.txt
* filename = horizontal5.txt
* filename = vertical5.txt
* filename = random23.txt
==> passed
Test 16: throws an exception if either constructor argument is null
or any entry in array is null
* argument is null
* Point[] of length 10, number of null entries = 1
* Point[] of length 10, number of null entries = 10
* Point[] of length 4, number of null entries = 1
* Point[] of length 3, number of null entries = 1
* Point[] of length 2, number of null entries = 1
* Point[] of length 1, number of null entries = 1
==> passed
Test 17: check that the constructor throws an exception if duplicate points
* 50 points
* 25 points
* 5 points
* 4 points
* 3 points
* 2 points
==> passed
Total: 21/21 tests passed!
================================================================
********************************************************************************
* MEMORY
********************************************************************************
Analyzing memory of Point
*-----------------------------------------------------------
Running 1 total tests.
The maximum amount of memory per Point object is 32 bytes.
Student memory = 24 bytes (passed)
Total: 1/1 tests passed!
================================================================
********************************************************************************
* TIMING
********************************************************************************
Timing BruteCollinearPoints
*-----------------------------------------------------------
Running 10 total tests.
Test 1a-1e: Find collinear points among n random distinct points
slopeTo()
n time slopeTo() compare() + 2*compare() compareTo()
-----------------------------------------------------------------------------------------------
=> passed 16 0.00 3640 0 3640 0
=> passed 32 0.00 71920 0 71920 0
=> passed 64 0.01 1270752 0 1270752 0
=> passed 128 0.04 21336000 0 21336000 0
=> passed 256 0.31 349585280 0 349585280 0
==> 5/5 tests passed
Test 2a-2e: Find collinear points among n/4 arbitrary line segments
slopeTo()
n time slopeTo() compare() + 2*compare() compareTo()
-----------------------------------------------------------------------------------------------
=> passed 16 0.00 3786 0 3786 23
=> passed 32 0.00 72488 0 72488 45
=> passed 64 0.01 1272836 0 1272836 88
=> passed 128 0.12 21343948 0 21343948 166
=> passed 256 1.73 349617038 0 349617038 333
==> 5/5 tests passed
Total: 10/10 tests passed!
================================================================
Timing FastCollinearPoints
*-----------------------------------------------------------
Running 31 total tests.
Test 1a-1g: Find collinear points among n random distinct points
slopeTo()
n time slopeTo() compare() + 2*compare() compareTo()
-----------------------------------------------------------------------------------------------
=> passed 64 0.01 3968 18865 41698 303
=> passed 128 0.01 16128 89591 195310 739
=> passed 256 0.02 65024 415477 895978 1750
=> passed 512 0.22 261120 1898670 4058460 3971
=> passed 1024 0.35 1046528 8563366 18173260 8980
=> passed 2048 0.96 4190208 38157893 80505994 19973
==> 6/6 tests passed
lg ratio(slopeTo() + 2*compare()) = lg (80505994 / 18173260) = 2.15
=> passed
==> 7/7 tests passed
Test 2a-2g: Find collinear points among the n points on an n-by-1 grid
slopeTo()
n time slopeTo() compare() + 2*compare() compareTo()
-----------------------------------------------------------------------------------------------
=> passed 64 0.00 4032 4764 13560 7056
=> passed 128 0.00 16256 17796 51848 22970
=> passed 256 0.01 65280 68717 202714 79797
=> passed 512 0.02 261632 269399 800430 292576
=> passed 1024 0.06 1047552 1065026 3177604 1112892
=> passed 2048 0.18 4192256 4231214 12654684 4329493
=> passed 4096 0.47 16773120 16859163 50491446 17060394
==> 7/7 tests passed
lg ratio(slopeTo() + 2*compare()) = lg (50491446 / 12654684) = 2.00
=> passed
==> 8/8 tests passed
Test 3a-3g: Find collinear points among the n points on an n/4-by-4 grid
slopeTo()
n time slopeTo() compare() + 2*compare() compareTo()
-----------------------------------------------------------------------------------------------
=> passed 64 0.00 4032 14906 33844 4620
=> passed 128 0.00 16256 43854 103964 16249
=> passed 256 0.01 65280 149618 364516 56034
=> passed 512 0.02 261632 548156 1357944 202146
=> passed 1024 0.08 1047552 2087496 5222544 758187
=> passed 2048 0.20 4192256 8122445 20437146 2921990
=> passed 4096 0.65 16773120 31990953 80755026 11450349
==> 7/7 tests passed
lg ratio(slopeTo() + 2*compare()) = lg (80755026 / 20437146) = 1.98
=> passed
==> 8/8 tests passed
Test 4a-4g: Find collinear points among the n points on an n/8-by-8 grid
slopeTo()
n time slopeTo() compare() + 2*compare() compareTo()
-----------------------------------------------------------------------------------------------
=> passed 64 0.00 4032 18045 40122 3953
=> passed 128 0.00 16256 75863 167982 16570
=> passed 256 0.01 65280 232229 529738 61392
=> passed 512 0.02 261632 854545 1970722 226893
=> passed 1024 0.08 1047552 3260991 7569534 862608
=> passed 2048 0.23 4192256 12699218 29590692 3347244
=> passed 4096 0.92 16773120 50043244 116859608 13163276
==> 7/7 tests passed
lg ratio(slopeTo() + 2*compare()) = lg (116859608 / 29590692) = 1.98
=> passed
==> 8/8 tests passed
Total: 31/31 tests passed!
================================================================