-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples
793 lines (655 loc) · 34.1 KB
/
examples
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
Run options: --seed 11844
# Running:
...........................................................................................................SS...
Finished in 0.367446s, 304.8070 runs/s, 33689.3366 assertions/s.
112 runs, 12379 assertions, 0 failures, 0 errors, 2 skips
You have skipped tests. Run with --verbose for details.
ruby -Ilib examples/tree.rb
/proc/loadavg 0.01 0.12 0.07 1/95 5930
#
# Fill up and display some trees
#
vals: [76, 83, 63, 0, 4, 68, 57, 86, 45, 79, 32, 89, 7, 6, 42, 70, 98, 2, 72, 57, 11, 63, 70, 84, 76, 74, 62, 43, 71, 57]
#
# Children: 2
#
#<CompSci::Node:0x2aac4dfbcf74i @value=76 @children=[83, 63]>
76
83 63
0 4 68 57
86 45 79 32 89 7 6 42
70 98 2 72 57 11 63 70 84 76 74 62 43 71 57
#
# Children: 3
#
#<CompSci::Node:0x2aac4dfba5bci @value=76 @children=[83, 63, 0]>
76
83 63 0
4 68 57 86 45 79 32 89 7
6 42 70 98 2 72 57 11 63 70 84 76 74 62 43 71 57
#
# Children: 4
#
#<CompSci::Node:0x2aac4dfb73f8i @value=76 @children=[83, 63, 0, 4]>
76
83 63 0 4
68 57 86 45 79 32 89 7 6 42 70 98 2 72 57 11
63 70 84 76 74 62 43 71 57
ruby -Ilib examples/ternary_search_tree.rb
#
# Insert 50 nodes into a ternary search tree (random keys)
#
18:36
0:48
16:25
8:34
4:11
8:45
31:16
12:18
14:20
41:43
36:5
23:45
6:40
25:48
24:6
46:18
13:13
15:22
18:9
32:23
9:6
12:24
26:32
47:39
12:37
49:27
11:24
37:37
5:30
5:10
42:44
26:32
16:11
46:28
27:4
8:12
36:3
14:18
38:30
42:33
37:33
1:14
22:30
9:4
31:34
22:45
39:26
22:19
19:28
46:37
7:36
0:48 _ 18:36
_ _ 4:11 _ _ _ 16:25 18:9 31:16
_ _ _ _ _ _ 1:14 _ 6:40 _ _ _ _ _ _ _ _ _ 8:34 16:11 _ _ _ _ 23:45 31:34 41:43
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 5:30 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 8:45 12:18 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 22:30 _ 25:48 _ _ _ 36:5 _ 46:18
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 5:10 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _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
search 2:
search 3:
search 4: 11
search 5: 30 10
search 6: 40
search 7: 36
search 8: 34 45 12
search 9: 6 4
search 10:
search 11: 24
search 12: 18 24 37
search 13: 13
search 14: 20 18
search 15: 22
search 16: 25 11
search 17:
search 18: 36 9
search 19: 28
search 20:
search 21:
search 22: 30 45 19
search 23: 45
search 24: 6
search 25: 48
search 26: 32 32
search 27: 4
search 28:
search 29:
search 30:
search 31: 16 34
search 32: 23
search 33:
search 34:
search 35:
search 36: 5 3
search 37: 37 33
search 38: 30
search 39: 26
search 40:
search 41: 43
search 42: 44 33
search 43:
search 44:
search 45:
search 46: 18 28 37
search 47: 39
search 48:
search 49: 27
ruby -Ilib examples/complete_tree.rb
#
# Print CompSci::CompleteBinaryTree filled with static vals
#
initial vals: [39, 5, 76, 4, 64, 30, 48, 41, 15, 41, 89, 12, 55, 58, 71, 88, 28, 50, 33, 61, 68, 16, 48, 1, 77, 70, 29, 54, 57, 87]
#<CompSci::CompleteBinaryTree:0x00561a4eef3940 @array=[39, 5, 76, 4, 64, 30, 48, 41, 15, 41, 89, 12, 55, 58, 71, 88, 28, 50, 33, 61, 68, 16, 48, 1, 77, 70, 29, 54, 57, 87], @child_slots=2>
39
5 76
4 64 30 48
41 15 41 89 12 55 58 71
88 28 50 33 61 68 16 48 1 77 70 29 54 57 87
#
# Push random vals and print again
#
new vals: [1, 19, 74, 8, 56, 42, 78, 40, 58, 57, 17, 89, 15, 50, 86, 3, 30, 42, 31, 5, 9, 52, 54, 5, 67, 76, 27, 25, 27, 45]
39
5 76
4 64 30 48
41 15 41 89 12 55 58 71
88 28 50 33 61 68 16 48 1 77 70 29 54 57 87 1
19 74 8 56 42 78 40 58 57 17 89 15 50 86 3 30 42 31 5 9 52 54 5 67 76 27 25 27 45
#
# Print CompSci::CompleteTernaryTree filled with static vals
#
initial vals: [39, 5, 76, 4, 64, 30, 48, 41, 15, 41, 89, 12, 55, 58, 71, 88, 28, 50, 33, 61, 68, 16, 48, 1, 77, 70, 29, 54, 57, 87]
#<CompSci::CompleteTernaryTree:0x00561a4eeead68 @array=[39, 5, 76, 4, 64, 30, 48, 41, 15, 41, 89, 12, 55, 58, 71, 88, 28, 50, 33, 61, 68, 16, 48, 1, 77, 70, 29, 54, 57, 87], @child_slots=3>
39
5 76 4
64 30 48 41 15 41 89 12 55
58 71 88 28 50 33 61 68 16 48 1 77 70 29 54 57 87
#
# Push random vals and print again
#
new vals: [8, 54, 3, 98, 5, 98, 88, 73, 23, 91, 81, 13, 25, 72, 49, 66, 22, 53, 49, 28, 23, 80, 31, 13, 52, 65, 43, 2, 39, 92]
39
5 76 4
64 30 48 41 15 41 89 12 55
58 71 88 28 50 33 61 68 16 48 1 77 70 29 54 57 87 8 54 3 98 5 98 88 73 23 91
81 13 25 72 49 66 22 53 49 28 23 80 31 13 52 65 43 2 39 92
#
# Print CompSci::CompleteQuaternaryTree filled with static vals
#
initial vals: [39, 5, 76, 4, 64, 30, 48, 41, 15, 41, 89, 12, 55, 58, 71, 88, 28, 50, 33, 61, 68, 16, 48, 1, 77, 70, 29, 54, 57, 87]
#<CompSci::CompleteQuaternaryTree:0x00561a4eee1bc8 @array=[39, 5, 76, 4, 64, 30, 48, 41, 15, 41, 89, 12, 55, 58, 71, 88, 28, 50, 33, 61, 68, 16, 48, 1, 77, 70, 29, 54, 57, 87], @child_slots=4>
39
5 76 4 64
30 48 41 15 41 89 12 55 58 71 88 28 50 33 61 68
16 48 1 77 70 29 54 57 87
#
# Push random vals and print again
#
new vals: [79, 57, 20, 29, 44, 20, 66, 6, 80, 25, 60, 90, 21, 20, 46, 61, 60, 3, 1, 40, 4, 60, 28, 44, 34, 64, 66, 10, 62, 89]
39
5 76 4 64
30 48 41 15 41 89 12 55 58 71 88 28 50 33 61 68
16 48 1 77 70 29 54 57 87 79 57 20 29 44 20 66 6 80 25 60 90 21 20 46 61 60 3 1 40 4 60 28 44 34 64 66 10 62 89
ruby -Ilib examples/binary_search_tree.rb
#
# Insert nodes into a BST (random keys, duplicates: true)
#
[:willie, :edward, :monkey, :charlie, :george, :zebra, :uncle, :ink, :london, :vinegar, :orange, :queenie, :butter, :nuts, :king, :johnnie, :robert, :harry, :sugar, :yellow, :apples, :xerxes, :freddy, :pudding, :duff, :tommy]
[85, 77, 22, 14, 46, 39, 59, 57, 58, 33, 49, 20, 54, 26, 71, 10, 28, 41, 61, 61, 62, 34, 11, 71, 51, 6]
85:willie
77:edward _
22:monkey _ _ _
14:charlie 46:george _ _ _ _ _ _
10:johnnie 20:queenie 39:zebra 59:uncle _ _ _ _ _ _ _ _ _ _ _ _
6:tommy 11:freddy _ _ 33:vinegar 41:harry 57:ink 71:king _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ 26:nuts 34:xerxes _ _ 49:orange 58:london 61:sugar 71:pudding _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 28:robert _ _ _ _ _ _ _ 54:butter _ _ _ 61:yellow _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 51:duff _ _ _ _ _ _ _ _ 62:apples _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _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 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 18:0 20:65 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#
# Search for 30 different keys
#
found 1:27
found 2:4
found 3:36
found 4:55
found 5:83
found 6:44
found 7:8
found 8:87
found 9:66
found 10:60
found 11:88
found 12:18
found 13:24
found 14:9
found 15:8
found 16:82
found 17:31
found 18:0
found 19:22
found 20:65
found 21:19
found 22:7
found 23:37
found 24:60
found 25:4
found 26:4
found 27:33
found 28:24
found 29:79
found 30:18
ruby -Ilib examples/flex_node.rb
#
# Try out Binary, Ternary, and Quaternary FlexNodes
# Push the same vals to each
#
[27, 67, 17, 85, 47, 71, 32, 4, 50, 84, 35, 43, 66, 82, 44, 19, 74, 87, 63, 73, 48, 24, 35, 79, 39, 71, 16, 62, 38, 37]
#<CompSci::ChildFlexNode:0x2ae56ec5898ci @value=27 @children=[67, 17]>
27
67 17
85 47 71 32
4 50 84 35 43 66 82 44
19 74 87 63 73 48 24 35 79 39 71 16 62 38 37 _
df_search visited: 27 67 85 4 19 74 50 87 63 47 84 73 48 35 24 35 17 71 43 79 39 66 71 16 32 82 62 38 44 37
push: [86, 63, 25, 38, 70, 79, 14, 98, 54, 39, 83, 73, 51, 88, 91, 21, 20, 4, 72, 1, 41, 88, 26, 65, 54, 32, 94, 97, 57, 58]
27
67 17
85 47 71 32
4 50 84 35 43 66 82 44
19 74 87 63 73 48 24 35 79 39 71 16 62 38 37 86
63 25 38 70 79 14 98 54 39 83 73 51 88 91 21 20 4 72 1 41 88 26 65 54 32 94 97 57 58 _ _ _
[27, 67, 17, 85, 47, 71, 32, 4, 50, 84, 35, 43, 66, 82, 44, 19, 74, 87, 63, 73, 48, 24, 35, 79, 39, 71, 16, 62, 38, 37]
#<CompSci::ChildFlexNode:0x2ae56ec800f4i @value=27 @children=[67, 17, 85]>
27
67 17 85
47 71 32 4 50 84 35 43 66
82 44 19 74 87 63 73 48 24 35 79 39 71 16 62 38 37 _ _ _ _ _ _ _ _ _ _
df_search visited: 27 67 47 82 44 19 71 74 87 63 32 73 48 24 17 4 35 79 39 50 71 16 62 84 38 37 85 35 43 66
push: [75, 96, 35, 4, 60, 18, 52, 22, 39, 88, 84, 59, 93, 50, 63, 98, 90, 78, 49, 80, 18, 57, 36, 47, 46, 81, 87, 84, 11, 34]
27
67 17 85
47 71 32 4 50 84 35 43 66
82 44 19 74 87 63 73 48 24 35 79 39 71 16 62 38 37 75 96 35 4 60 18 52 22 39 88
84 59 93 50 63 98 90 78 49 80 18 57 36 47 46 81 87 84 11 34 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[27, 67, 17, 85, 47, 71, 32, 4, 50, 84, 35, 43, 66, 82, 44, 19, 74, 87, 63, 73, 48, 24, 35, 79, 39, 71, 16, 62, 38, 37]
#<CompSci::ChildFlexNode:0x2ae56ebe8f10i @value=27 @children=[67, 17, 85, 47]>
27
67 17 85 47
71 32 4 50 84 35 43 66 82 44 19 74 87 63 73 48
24 35 79 39 71 16 62 38 37 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
df_search visited: 27 67 71 24 35 79 39 32 71 16 62 38 4 37 50 17 84 35 43 66 85 82 44 19 74 47 87 63 73 48
push: [1, 17, 74, 75, 45, 95, 63, 81, 26, 39, 43, 18, 4, 97, 17, 28, 18, 51, 41, 57, 89, 90, 23, 59, 25, 12, 22, 77, 75, 98]
27
67 17 85 47
71 32 4 50 84 35 43 66 82 44 19 74 87 63 73 48
24 35 79 39 71 16 62 38 37 1 17 74 75 45 95 63 81 26 39 43 18 4 97 17 28 18 51 41 57 89 90 23 59 25 12 22 77 75 98 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#
# 30 ChildFlexNode pushes and df_search
#
[89, 46, 49, 25, 28, 21, 79, 12, 16, 10, 82, 88, 42, 5, 35, 73, 15, 40, 14, 81, 46, 16, 58, 3, 69, 40, 44, 12, 85, 26]
#<CompSci::ChildFlexNode:0x2ae56ecf70c8i @value=89 @children=[46, 49]>
89
46 49
25 28 21 79
12 16 10 82 88 42 5 35
73 15 40 14 81 46 16 58 3 69 40 44 12 85 26 _
visited 89
visited 46
visited 25
visited 12
visited 73
visited 15
visited 16
visited 40
visited 14
visited 28
visited 10
visited 81
visited 46
visited 82
visited 16
visited 58
visited 49
visited 21
visited 88
visited 3
visited 69
visited 42
visited 40
visited 44
visited 79
visited 5
visited 12
visited 85
visited 35
visited 26
push: [71, 67, 21, 41, 51, 80, 80, 52, 9, 71, 98, 91, 89, 76, 84, 26, 44, 13, 80, 43, 81, 79, 19, 60, 85, 47, 26, 34, 0, 29]
89
46 49
25 28 21 79
12 16 10 82 88 42 5 35
73 15 40 14 81 46 16 58 3 69 40 44 12 85 26 71
67 21 41 51 80 80 52 9 71 98 91 89 76 84 26 44 13 80 43 81 79 19 60 85 47 26 34 0 29 _ _ _
#
# 3 seconds worth of Binary ChildFlexNode pushes
#
100th push: 0.00002117 s
200th push: 0.00006039 s
300th push: 0.00013202 s
400th push: 0.00015090 s
500th push: 0.00016219 s
600th push: 0.00019839 s
700th push: 0.00021225 s
800th push: 0.00034038 s
900th push: 0.00031666 s
1000th push: 0.00040513 s
-----------
1k push: 0.1861 s (5372 push / s)
1100th push: 0.00052165 s
1200th push: 0.00056271 s
1300th push: 0.00070744 s
1400th push: 0.00072167 s
1500th push: 0.00098720 s
1600th push: 0.00083957 s
1700th push: 0.00094691 s
1800th push: 0.00108474 s
1900th push: 0.00125575 s
2000th push: 0.00129720 s
-----------
1k push: 0.8781 s (1138 push / s)
2100th push: 0.00146325 s
2200th push: 0.00158528 s
2300th push: 0.00159953 s
2400th push: 0.00169629 s
2500th push: 0.00183107 s
2600th push: 0.00195065 s
2700th push: 0.00240946 s
2800th push: 0.00223743 s
2900th push: 0.00251893 s
pushed 2961 items in 3.0 s
ruby -Ilib examples/heap_push.rb
#
# 3 seconds worth of Heap pushes
#
10000th push: 0.00000361 s
20000th push: 0.00000240 s
30000th push: 0.00001064 s
40000th push: 0.00000388 s
50000th push: 0.00000485 s
60000th push: 0.00000424 s
70000th push: 0.00000242 s
80000th push: 0.00000382 s
90000th push: 0.00000288 s
100000th push: 0.00000372 s
-------------
100k push: 0.19715859 s (507k push / s)
110000th push: 0.00000472 s
120000th push: 0.00000452 s
130000th push: 0.00000403 s
140000th push: 0.00000236 s
150000th push: 0.00000384 s
160000th push: 0.00000233 s
170000th push: 0.00000561 s
180000th push: 0.00000309 s
190000th push: 0.00000296 s
200000th push: 0.00000377 s
-------------
100k push: 0.19671464 s (508k push / s)
210000th push: 0.00000246 s
220000th push: 0.00000299 s
230000th push: 0.00000314 s
240000th push: 0.00000300 s
250000th push: 0.00000258 s
260000th push: 0.00000258 s
270000th push: 0.00000349 s
280000th push: 0.00000392 s
290000th push: 0.00000346 s
300000th push: 0.00000392 s
-------------
100k push: 0.19690509 s (507k push / s)
310000th push: 0.00000260 s
320000th push: 0.00000469 s
330000th push: 0.00000363 s
340000th push: 0.00000299 s
350000th push: 0.00000245 s
360000th push: 0.00000267 s
370000th push: 0.00000338 s
380000th push: 0.00000350 s
390000th push: 0.00000327 s
400000th push: 0.00000236 s
-------------
100k push: 0.19716994 s (507k push / s)
410000th push: 0.00000238 s
420000th push: 0.00000352 s
430000th push: 0.00000275 s
440000th push: 0.00000255 s
450000th push: 0.00000298 s
460000th push: 0.00000423 s
470000th push: 0.00000306 s
480000th push: 0.00000316 s
490000th push: 0.00000253 s
500000th push: 0.00000381 s
-------------
100k push: 0.19656801 s (508k push / s)
510000th push: 0.00000240 s
520000th push: 0.00000372 s
530000th push: 0.00000291 s
540000th push: 0.00000393 s
550000th push: 0.00000291 s
560000th push: 0.00000505 s
570000th push: 0.00000237 s
580000th push: 0.00000518 s
590000th push: 0.00000359 s
600000th push: 0.00000282 s
-------------
100k push: 0.19746542 s (506k push / s)
610000th push: 0.00000286 s
620000th push: 0.00000330 s
630000th push: 0.00000317 s
640000th push: 0.00000324 s
650000th push: 0.00000332 s
660000th push: 0.00000239 s
670000th push: 0.00000382 s
680000th push: 0.00000354 s
690000th push: 0.00000475 s
700000th push: 0.00000242 s
-------------
100k push: 0.19740061 s (506k push / s)
710000th push: 0.00000337 s
720000th push: 0.00000237 s
730000th push: 0.00000247 s
740000th push: 0.00000234 s
750000th push: 0.00000245 s
760000th push: 0.00000330 s
770000th push: 0.00000234 s
780000th push: 0.00000500 s
790000th push: 0.00000208 s
800000th push: 0.00000422 s
-------------
100k push: 0.19428321 s (514k push / s)
810000th push: 0.00000396 s
820000th push: 0.00000285 s
830000th push: 0.00000235 s
840000th push: 0.00000293 s
850000th push: 0.00000551 s
860000th push: 0.00000258 s
870000th push: 0.00000306 s
880000th push: 0.00000286 s
890000th push: 0.00000284 s
900000th push: 0.00000354 s
-------------
100k push: 0.19715683 s (507k push / s)
910000th push: 0.00000396 s
920000th push: 0.00000299 s
930000th push: 0.00000236 s
940000th push: 0.00000289 s
950000th push: 0.00000250 s
960000th push: 0.00000297 s
970000th push: 0.00000300 s
980000th push: 0.00000484 s
990000th push: 0.00000319 s
1000000th push: 0.00000379 s
-------------
100k push: 0.19428377 s (514k push / s)
1010000th push: 0.00000244 s
1020000th push: 0.00000357 s
1030000th push: 0.00000228 s
1040000th push: 0.00000375 s
1050000th push: 0.00000618 s
1060000th push: 0.00000299 s
1070000th push: 0.00000355 s
1080000th push: 0.00000285 s
1090000th push: 0.00000321 s
1100000th push: 0.00000328 s
-------------
100k push: 0.19454410 s (514k push / s)
1110000th push: 0.00000306 s
1120000th push: 0.00000241 s
1130000th push: 0.00000344 s
1140000th push: 0.00000389 s
1150000th push: 0.00000453 s
1160000th push: 0.00000355 s
1170000th push: 0.00000245 s
1180000th push: 0.00000261 s
1190000th push: 0.00000289 s
1200000th push: 0.00000328 s
-------------
100k push: 0.19763499 s (505k push / s)
1210000th push: 0.00000235 s
1220000th push: 0.00000296 s
1230000th push: 0.00000234 s
1240000th push: 0.00000328 s
1250000th push: 0.00000334 s
1260000th push: 0.00000277 s
1270000th push: 0.00000368 s
1280000th push: 0.00000342 s
1290000th push: 0.00000241 s
1300000th push: 0.00000255 s
-------------
100k push: 0.19445584 s (514k push / s)
1310000th push: 0.00000240 s
1320000th push: 0.00000346 s
1330000th push: 0.00000334 s
1340000th push: 0.00000238 s
1350000th push: 0.00000343 s
1360000th push: 0.00000247 s
1370000th push: 0.00000327 s
1380000th push: 0.00000247 s
1390000th push: 0.00000573 s
1400000th push: 0.00000334 s
-------------
100k push: 0.19393048 s (515k push / s)
1410000th push: 0.00000448 s
1420000th push: 0.00000241 s
1430000th push: 0.00000207 s
1440000th push: 0.00000353 s
1450000th push: 0.00000246 s
1460000th push: 0.00001887 s
1470000th push: 0.00000299 s
1480000th push: 0.00000291 s
1490000th push: 0.00000439 s
1500000th push: 0.00000306 s
-------------
100k push: 0.19736392 s (506k push / s)
1510000th push: 0.00000262 s
1520000th push: 0.00000243 s
pushed 1528908 items in 3.0 s
still a heap with 1528923 items? YES - 1.522 sec
ruby -Ilib examples/heap.rb
#
# display the results of ternary Heap push and pop
#
push: 44 4 25 48 75 10 88 17 19 45 42 50 64 50 95 71 91 25 61 69 4 94 73 95 16 65 91 96 65 91
array: [96, 94, 95, 64, 75, 88, 91, 73, 95, 91, 42, 44, 50, 4, 50, 71, 10, 25, 61, 48, 4, 69, 17, 45, 16, 19, 65, 91, 25, 65]
heap: true
96
94 95 64
75 88 91 73 95 91 42 44 50
4 50 71 10 25 61 48 4 69 17 45 16 19 65 91 25 65
pop: 96
array: [95, 94, 95, 64, 75, 88, 91, 73, 91, 91, 42, 44, 50, 4, 50, 71, 10, 25, 61, 48, 4, 69, 17, 45, 16, 19, 65, 65, 25]
heap: true
95
94 95 64
75 88 91 73 91 91 42 44 50
4 50 71 10 25 61 48 4 69 17 45 16 19 65 65 25
pop: 95 95 94 91 91 91 88 75 73
array: [71, 69, 65, 64, 50, 61, 48, 45, 65, 25, 42, 44, 50, 4, 17, 19, 10, 25, 16, 4]
heap: true
71
69 65 64
50 61 48 45 65 25 42 44 50
4 17 19 10 25 16 4
push: 70 47 10 69 64 9 60 90 74 96 33 76 96 5 19 10 69 39 27 50 57 76 15 37 35 45 68 35 65 2
array: [96, 76, 90, 96, 70, 61, 69, 65, 69, 74, 76, 69, 50, 57, 45, 68, 10, 25, 16, 4, 48, 47, 10, 45, 64, 9, 60, 65, 25, 71, 33, 42, 64, 5, 19, 10, 44, 39, 27, 50, 4, 50, 15, 17, 35, 37, 19, 35, 65, 2]
heap: true
96
76 90 96
70 61 69 65 69 74 76 69 50
57 45 68 10 25 16 4 48 47 10 45 64 9 60 65 25 71 33 42 64 5 19 10 44 39 27 50
4 50 15 17 35 37 19 35 65 2
#
# display the results of binary Heap push and pop
#
push: 73 94 87 38 28 54 24 14 21 24 4 66 42 33 76 1 34 7 72 88 96 14 45 73 50 13 44 9 24 94
array: [96, 94, 94, 72, 88, 73, 87, 34, 38, 73, 45, 66, 44, 24, 76, 1, 14, 7, 21, 24, 28, 4, 14, 54, 50, 13, 42, 9, 24, 33]
heap: true
96
94 94
72 88 73 87
34 38 73 45 66 44 24 76
1 14 7 21 24 28 4 14 54 50 13 42 9 24 33
pop: 96
array: [94, 94, 87, 72, 88, 73, 76, 34, 38, 73, 45, 66, 44, 24, 33, 1, 14, 7, 21, 24, 28, 4, 14, 54, 50, 13, 42, 9, 24]
heap: true
94
94 87
72 88 73 76
34 38 73 45 66 44 24 33
1 14 7 21 24 28 4 14 54 50 13 42 9 24
pop: 94 94 88 87 76 73 73 72 66
array: [54, 45, 50, 38, 28, 44, 42, 34, 21, 24, 14, 4, 9, 24, 33, 1, 14, 7, 13, 24]
heap: true
54
45 50
38 28 44 42
34 21 24 14 4 9 24 33
1 14 7 13 24
push: 21 41 8 45 22 80 18 5 92 61 89 64 45 18 81 49 80 37 57 83 4 43 41 54 18 5 94 36 35 80
array: [94, 92, 89, 80, 83, 80, 80, 45, 64, 43, 81, 50, 45, 42, 61, 38, 45, 49, 57, 24, 41, 28, 54, 36, 44, 9, 18, 5, 24, 33, 54, 1, 34, 14, 18, 7, 21, 13, 37, 24, 4, 21, 41, 14, 18, 5, 8, 4, 35, 22]
heap: true
94
92 89
80 83 80 80
45 64 43 81 50 45 42 61
38 45 49 57 24 41 28 54 36 44 9 18 5 24 33 54
1 34 14 18 7 21 13 37 24 4 21 41 14 18 5 8 4 35 22