algorithm_selector 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.yardoc/checksums +2 -2
- data/.yardoc/objects/root.dat +0 -0
- data/README.md +145 -34
- data/algorithm_selector.gemspec +2 -2
- data/doc/AlgorithmSelector.html +71 -60
- data/doc/BSTNode.html +19 -19
- data/doc/BinaryTree.html +46 -46
- data/doc/LinkNode.html +19 -19
- data/doc/LinkedList.html +72 -72
- data/doc/Queue.html +55 -68
- data/doc/Searches.html +141 -78
- data/doc/Sorts.html +124 -123
- data/doc/Stack.html +64 -77
- data/doc/_index.html +1 -1
- data/doc/file.README.html +147 -22
- data/doc/index.html +147 -22
- data/doc/top-level-namespace.html +1 -1
- data/lib/algorithm_selector.rb +118 -108
- data/lib/algorithm_selector/version.rb +1 -1
- metadata +4 -4
data/doc/Stack.html
CHANGED
@@ -174,7 +174,7 @@
|
|
174
174
|
<li class="public ">
|
175
175
|
<span class="summary_signature">
|
176
176
|
|
177
|
-
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(size,
|
177
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(size, data_set = []) ⇒ Stack </a>
|
178
178
|
|
179
179
|
|
180
180
|
|
@@ -236,9 +236,7 @@
|
|
236
236
|
|
237
237
|
|
238
238
|
|
239
|
-
<span class="summary_desc"><div class='inline'>
|
240
|
-
<p>Deletion, Worst-Case Time Complexity: O(1).</p>
|
241
|
-
</div></span>
|
239
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
242
240
|
|
243
241
|
</li>
|
244
242
|
|
@@ -323,7 +321,7 @@ Complexity: O(n).</p>
|
|
323
321
|
<div class="method_details first">
|
324
322
|
<h3 class="signature first" id="initialize-instance_method">
|
325
323
|
|
326
|
-
#<strong>initialize</strong>(size,
|
324
|
+
#<strong>initialize</strong>(size, data_set = []) ⇒ <tt><span class='object_link'><a href="" title="Stack (class)">Stack</a></span></tt>
|
327
325
|
|
328
326
|
|
329
327
|
|
@@ -346,21 +344,21 @@ Complexity: O(n).</p>
|
|
346
344
|
<pre class="lines">
|
347
345
|
|
348
346
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
347
|
+
277
|
348
|
+
278
|
349
|
+
279
|
350
|
+
280
|
351
|
+
281
|
352
|
+
282</pre>
|
355
353
|
</td>
|
356
354
|
<td>
|
357
|
-
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line
|
355
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 277</span>
|
358
356
|
|
359
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_size'>size</span><span class='comma'>,</span> <span class='id identifier
|
357
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_size'>size</span><span class='comma'>,</span> <span class='id identifier rubyid_data_set'>data_set</span><span class='op'>=</span><span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
360
358
|
<span class='ivar'>@size</span> <span class='op'>=</span> <span class='id identifier rubyid_size'>size</span>
|
361
359
|
<span class='ivar'>@store</span> <span class='op'>=</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@size</span><span class='rparen'>)</span>
|
362
360
|
<span class='ivar'>@top</span> <span class='op'>=</span> <span class='op'>-</span><span class='int'>1</span>
|
363
|
-
<span class='id identifier
|
361
|
+
<span class='id identifier rubyid_data_set'>data_set</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_el'>el</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
364
362
|
<span class='kw'>end</span></pre>
|
365
363
|
</td>
|
366
364
|
</tr>
|
@@ -411,12 +409,12 @@ Complexity: O(n).</p>
|
|
411
409
|
<pre class="lines">
|
412
410
|
|
413
411
|
|
414
|
-
|
415
|
-
|
416
|
-
|
412
|
+
334
|
413
|
+
335
|
414
|
+
336</pre>
|
417
415
|
</td>
|
418
416
|
<td>
|
419
|
-
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line
|
417
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 334</span>
|
420
418
|
|
421
419
|
<span class='kw'>def</span> <span class='id identifier rubyid_empty?'>empty?</span>
|
422
420
|
<span class='ivar'>@top</span> <span class='op'>==</span> <span class='op'>-</span><span class='int'>1</span>
|
@@ -463,12 +461,12 @@ Complexity: O(n).</p>
|
|
463
461
|
<pre class="lines">
|
464
462
|
|
465
463
|
|
466
|
-
|
467
|
-
|
468
|
-
|
464
|
+
330
|
465
|
+
331
|
466
|
+
332</pre>
|
469
467
|
</td>
|
470
468
|
<td>
|
471
|
-
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line
|
469
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 330</span>
|
472
470
|
|
473
471
|
<span class='kw'>def</span> <span class='id identifier rubyid_full?'>full?</span>
|
474
472
|
<span class='ivar'>@top</span> <span class='op'>==</span> <span class='lparen'>(</span><span class='ivar'>@size</span> <span class='op'>-</span> <span class='int'>1</span><span class='rparen'>)</span>
|
@@ -493,12 +491,12 @@ Complexity: O(n).</p>
|
|
493
491
|
<pre class="lines">
|
494
492
|
|
495
493
|
|
496
|
-
|
497
|
-
|
498
|
-
|
494
|
+
326
|
495
|
+
327
|
496
|
+
328</pre>
|
499
497
|
</td>
|
500
498
|
<td>
|
501
|
-
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line
|
499
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 326</span>
|
502
500
|
|
503
501
|
<span class='kw'>def</span> <span class='id identifier rubyid_look'>look</span>
|
504
502
|
<span class='ivar'>@store</span><span class='lbracket'>[</span><span class='ivar'>@top</span><span class='rbracket'>]</span>
|
@@ -517,36 +515,25 @@ Complexity: O(n).</p>
|
|
517
515
|
|
518
516
|
|
519
517
|
|
520
|
-
</h3><
|
521
|
-
<div class="discussion">
|
522
|
-
|
523
|
-
<p>Deletion, Worst-Case Time Complexity: O(1)</p>
|
524
|
-
|
525
|
-
|
526
|
-
</div>
|
527
|
-
</div>
|
528
|
-
<div class="tags">
|
529
|
-
|
530
|
-
|
531
|
-
</div><table class="source_code">
|
518
|
+
</h3><table class="source_code">
|
532
519
|
<tr>
|
533
520
|
<td>
|
534
521
|
<pre class="lines">
|
535
522
|
|
536
523
|
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
524
|
+
300
|
525
|
+
301
|
526
|
+
302
|
527
|
+
303
|
528
|
+
304
|
529
|
+
305
|
530
|
+
306
|
531
|
+
307
|
532
|
+
308
|
533
|
+
309</pre>
|
547
534
|
</td>
|
548
535
|
<td>
|
549
|
-
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line
|
536
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 300</span>
|
550
537
|
|
551
538
|
<span class='kw'>def</span> <span class='id identifier rubyid_pop'>pop</span>
|
552
539
|
<span class='kw'>if</span> <span class='id identifier rubyid_empty?'>empty?</span>
|
@@ -589,18 +576,18 @@ Complexity: O(n).</p>
|
|
589
576
|
<pre class="lines">
|
590
577
|
|
591
578
|
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
579
|
+
312
|
580
|
+
313
|
581
|
+
314
|
582
|
+
315
|
583
|
+
316
|
584
|
+
317
|
585
|
+
318
|
586
|
+
319
|
587
|
+
320</pre>
|
601
588
|
</td>
|
602
589
|
<td>
|
603
|
-
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line
|
590
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 312</span>
|
604
591
|
|
605
592
|
<span class='kw'>def</span> <span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_el'>el</span><span class='rparen'>)</span>
|
606
593
|
<span class='kw'>if</span> <span class='id identifier rubyid_full?'>full?</span> <span class='kw'>or</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
@@ -643,22 +630,22 @@ Complexity: O(n)</p>
|
|
643
630
|
<pre class="lines">
|
644
631
|
|
645
632
|
|
646
|
-
275
|
647
|
-
276
|
648
|
-
277
|
649
|
-
278
|
650
|
-
279
|
651
|
-
280
|
652
|
-
281
|
653
|
-
282
|
654
|
-
283
|
655
|
-
284
|
656
|
-
285
|
657
633
|
286
|
658
|
-
287
|
634
|
+
287
|
635
|
+
288
|
636
|
+
289
|
637
|
+
290
|
638
|
+
291
|
639
|
+
292
|
640
|
+
293
|
641
|
+
294
|
642
|
+
295
|
643
|
+
296
|
644
|
+
297
|
645
|
+
298</pre>
|
659
646
|
</td>
|
660
647
|
<td>
|
661
|
-
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line
|
648
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 286</span>
|
662
649
|
|
663
650
|
<span class='kw'>def</span> <span class='id identifier rubyid_search'>search</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='rparen'>)</span>
|
664
651
|
<span class='id identifier rubyid_found'>found</span> <span class='op'>=</span> <span class='kw'>false</span>
|
@@ -693,12 +680,12 @@ Complexity: O(n)</p>
|
|
693
680
|
<pre class="lines">
|
694
681
|
|
695
682
|
|
696
|
-
|
697
|
-
|
698
|
-
|
683
|
+
322
|
684
|
+
323
|
685
|
+
324</pre>
|
699
686
|
</td>
|
700
687
|
<td>
|
701
|
-
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line
|
688
|
+
<pre class="code"><span class="info file"># File 'lib/algorithm_selector.rb', line 322</span>
|
702
689
|
|
703
690
|
<span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
|
704
691
|
<span class='ivar'>@size</span>
|
@@ -713,7 +700,7 @@ Complexity: O(n)</p>
|
|
713
700
|
</div>
|
714
701
|
|
715
702
|
<div id="footer">
|
716
|
-
Generated on
|
703
|
+
Generated on Sat Jul 23 23:26:27 2016 by
|
717
704
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
718
705
|
0.9.4 (ruby-2.1.2).
|
719
706
|
</div>
|
data/doc/_index.html
CHANGED
@@ -173,7 +173,7 @@
|
|
173
173
|
</div>
|
174
174
|
|
175
175
|
<div id="footer">
|
176
|
-
Generated on
|
176
|
+
Generated on Sat Jul 23 23:26:27 2016 by
|
177
177
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
178
178
|
0.9.4 (ruby-2.1.2).
|
179
179
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -60,7 +60,152 @@
|
|
60
60
|
<iframe id="search_frame" src="file_list.html"></iframe>
|
61
61
|
|
62
62
|
<div id="content"><div id='filecontents'>
|
63
|
-
<h1 id="label-
|
63
|
+
<h1 id="label-algorithm_selector+rdoc-image-3Ahttps-3A-2F-2Fbadge.fury.io-2Frb-2Falgorithm_selector.svg">algorithm_selector <a href="https://badge.fury.io/rb/algorithm_selector"><img src="https://badge.fury.io/rb/algorithm_selector.svg"></a></h1>
|
64
|
+
<ul><li>
|
65
|
+
<p><a href="https://rubygems.org/gems/algorithm_selector">Live</a></p>
|
66
|
+
</li><li>
|
67
|
+
<p><a href="http://www.rubydoc.info/gems/algorithm_selector">Documentation</a></p>
|
68
|
+
</li></ul>
|
69
|
+
|
70
|
+
<h2 id="label-Description">Description</h2>
|
71
|
+
|
72
|
+
<p>Calculates algorithms and data structures for sorting and searching.
|
73
|
+
Selects best one to use for particular data set.</p>
|
74
|
+
|
75
|
+
<p>Additionally, data structures can be used for own purposes. All data
|
76
|
+
structures have the ability to insert and search. Will add deletion in the
|
77
|
+
future.</p>
|
78
|
+
|
79
|
+
<p>Written by Joseph Bui.</p>
|
80
|
+
|
81
|
+
<h3 id="label-Currently+supports+the+following+algorithms+and+data+structures-3A">Currently supports the following algorithms and data structures:</h3>
|
82
|
+
<ul><li>
|
83
|
+
<p>Sorting (<code>"sort"</code>)</p>
|
84
|
+
</li><li>
|
85
|
+
<p>Bubble Sort (<code>"bubble_sort"</code>)</p>
|
86
|
+
</li><li>
|
87
|
+
<p>Insertion Sort (<code>"insertion_sort"</code>)</p>
|
88
|
+
</li><li>
|
89
|
+
<p>Selection Sort (<code>"selection_sort"</code>)</p>
|
90
|
+
</li><li>
|
91
|
+
<p>Merge Sort (<code>"merge_sort"</code>)</p>
|
92
|
+
</li><li>
|
93
|
+
<p>Quick Sort(<code>"quick_sort"</code>)</p>
|
94
|
+
</li><li>
|
95
|
+
<p>Searching (<code>"search"</code>)</p>
|
96
|
+
</li><li>
|
97
|
+
<p>Stack (<code>"stack"</code>)</p>
|
98
|
+
</li><li>
|
99
|
+
<p>Queue (<code>"queue"</code>)</p>
|
100
|
+
</li><li>
|
101
|
+
<p>Singly-Linked List (<code>"linked_list"</code>)</p>
|
102
|
+
</li><li>
|
103
|
+
<p>Binary Search Tree (<code>"binary_tree"</code>)</p>
|
104
|
+
</li></ul>
|
105
|
+
|
106
|
+
<h3 id="label-Parameters">Parameters</h3>
|
107
|
+
<ul><li>
|
108
|
+
<p><code>action</code> is the string of the action, can be
|
109
|
+
<code>"sort"</code> or <code>"search"</code></p>
|
110
|
+
</li><li>
|
111
|
+
<p><code>data_set</code> has to be in array format</p>
|
112
|
+
</li><li>
|
113
|
+
<p><code>trials</code> is number of test trials (optional, default = 1)</p>
|
114
|
+
</li><li>
|
115
|
+
<p><code>target</code> is element user wants to search (unnecessary for
|
116
|
+
<code>sort</code>, default = null)</p>
|
117
|
+
</li><li>
|
118
|
+
<p><code>algorithm</code> is the string of the algorithm or data structure</p>
|
119
|
+
</li></ul>
|
120
|
+
|
121
|
+
<h3 id="label-Methods">Methods</h3>
|
122
|
+
<ul><li>
|
123
|
+
<p><code>all(action, data_set, trials, target)</code></p>
|
124
|
+
</li><li>
|
125
|
+
<p>Returns the times for each algorithm</p>
|
126
|
+
</li><li>
|
127
|
+
<p>Example: <code>ruby AlgorithmSelector.all("sort", [2,1,4,3],
|
128
|
+
1000) AlgorithmSelector.all("search", [2,1,4,3], 1000, 4) </code></p>
|
129
|
+
</li><li>
|
130
|
+
<p><code>best(action, data_set, trials, target)</code></p>
|
131
|
+
</li><li>
|
132
|
+
<p>Returns the algorithm with the best time</p>
|
133
|
+
</li><li>
|
134
|
+
<p>Example: <code>ruby AlgorithmSelector.best("sort", [2,1,4,3],
|
135
|
+
1000) AlgorithmSelector.best("search", [2,1,4,3], 1000, 4)
|
136
|
+
</code></p>
|
137
|
+
</li><li>
|
138
|
+
<p><code>analyze(action, data_set, algorithm, trials, target)</code></p>
|
139
|
+
</li><li>
|
140
|
+
<p>Returns time for specified algorithm or data structure</p>
|
141
|
+
</li><li>
|
142
|
+
<p>Example: <code>ruby AlgorithmSelector.analyze("sort", [2,1,4,3],
|
143
|
+
"merge_sort", 1000) AlgorithmSelector.analyze("search",
|
144
|
+
[2,1,4,3], "linked_list", 1000, 4) </code></p>
|
145
|
+
</li><li>
|
146
|
+
<p><code>compare(action, data_set, first_algorithm, second_algorithm, trials,
|
147
|
+
target)</code></p>
|
148
|
+
</li><li>
|
149
|
+
<p>Returns the times of two specified algorithms for comparison</p>
|
150
|
+
</li><li>
|
151
|
+
<p>Example: <code>ruby AlgorithmSelector.compare("sort", [2,1,4,3],
|
152
|
+
"merge_sort", "quick_sort", 1000)
|
153
|
+
AlgorithmSelector.compare("search", [2,1,4,3], "stack",
|
154
|
+
"linked_list", 1000, 4) </code></p>
|
155
|
+
</li><li>
|
156
|
+
<p><code>sort(data_set, algorithm)</code></p>
|
157
|
+
</li><li>
|
158
|
+
<p>Returns sorted array of specified sorting algorithm</p>
|
159
|
+
</li><li>
|
160
|
+
<p>Example: <code>ruby AlgorithmSelector.compare([2,1,4,3],
|
161
|
+
"bubble_sort") </code></p>
|
162
|
+
</li></ul>
|
163
|
+
|
164
|
+
<h3 id="label-Data+Structures">Data Structures</h3>
|
165
|
+
|
166
|
+
<h4 id="label-Stack">Stack</h4>
|
167
|
+
<ul><li>
|
168
|
+
<p>Initialize <code>ruby size = 10 stack = Stack.new(size) </code></p>
|
169
|
+
</li><li>
|
170
|
+
<p>Insertion <code>ruby # returns nil value = 6 stack.push(value)
|
171
|
+
</code></p>
|
172
|
+
</li><li>
|
173
|
+
<p>Search <code>ruby # returns true if found, else returns false target =
|
174
|
+
4 stack.search(target) </code></p>
|
175
|
+
</li></ul>
|
176
|
+
|
177
|
+
<h4 id="label-Queue">Queue</h4>
|
178
|
+
<ul><li>
|
179
|
+
<p>Initialize <code>ruby size = 10 queue = Queue.new(size) </code></p>
|
180
|
+
</li><li>
|
181
|
+
<p>Insertion <code>ruby # returns nil value = 6 queue.enqueue(value)
|
182
|
+
</code></p>
|
183
|
+
</li><li>
|
184
|
+
<p>Search <code>ruby # returns true if found, else returns false target =
|
185
|
+
4 queue.search(target) </code></p>
|
186
|
+
</li></ul>
|
187
|
+
|
188
|
+
<h4 id="label-Linked+List">Linked List</h4>
|
189
|
+
<ul><li>
|
190
|
+
<p>Initialize <code>ruby linked_list = LinkedList.new </code></p>
|
191
|
+
</li><li>
|
192
|
+
<p>Insertion <code>ruby # returns nil value = 6
|
193
|
+
linked_list.insert(value) </code></p>
|
194
|
+
</li><li>
|
195
|
+
<p>Search <code>ruby # returns true if found, else returns false target =
|
196
|
+
4 linked_list.search(target) </code></p>
|
197
|
+
</li></ul>
|
198
|
+
|
199
|
+
<h4 id="label-Binary+Search+Tree">Binary Search Tree</h4>
|
200
|
+
<ul><li>
|
201
|
+
<p>Initialize <code>ruby binary_tree = BinaryTree.new </code></p>
|
202
|
+
</li><li>
|
203
|
+
<p>Insertion <code>ruby # returns nil value = 6
|
204
|
+
binary_tree.insert(value) </code></p>
|
205
|
+
</li><li>
|
206
|
+
<p>Search <code>ruby # returns true if found, else returns false target =
|
207
|
+
4 binary_tree.search(target) </code></p>
|
208
|
+
</li></ul>
|
64
209
|
|
65
210
|
<h2 id="label-Installation">Installation</h2>
|
66
211
|
|
@@ -83,26 +228,6 @@
|
|
83
228
|
|
84
229
|
<pre class="code ruby"><code class="ruby">$ require 'algorithm_selector'</code></pre>
|
85
230
|
|
86
|
-
<h3 id="label-Saying+hello">Saying hello</h3>
|
87
|
-
|
88
|
-
<p>You can create a string “hello” by using the test method. For example:</p>
|
89
|
-
|
90
|
-
<p><a href="1">AlgorithmSelector.test(</a>) #=> “hello”</p>
|
91
|
-
|
92
|
-
<h2 id="label-Development">Development</h2>
|
93
|
-
|
94
|
-
<p>After checking out the repo, run <code>bin/setup</code> to install
|
95
|
-
dependencies. Then, run <code>rake spec</code> to run the tests. You can
|
96
|
-
also run <code>bin/console</code> for an interactive prompt that will allow
|
97
|
-
you to experiment.</p>
|
98
|
-
|
99
|
-
<p>To install this gem onto your local machine, run <code>bundle exec rake
|
100
|
-
install</code>. To release a new version, update the version number in
|
101
|
-
<code>version.rb</code>, and then run <code>bundle exec rake
|
102
|
-
release</code>, which will create a git tag for the version, push git
|
103
|
-
commits and tags, and push the <code>.gem</code> file to <a
|
104
|
-
href="https://rubygems.org">rubygems.org</a>.</p>
|
105
|
-
|
106
231
|
<h2 id="label-Contributing">Contributing</h2>
|
107
232
|
|
108
233
|
<p>Bug reports and pull requests are welcome on GitHub at <a
|
@@ -119,7 +244,7 @@ href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
|
|
119
244
|
</div></div>
|
120
245
|
|
121
246
|
<div id="footer">
|
122
|
-
Generated on
|
247
|
+
Generated on Sat Jul 23 23:26:27 2016 by
|
123
248
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
124
249
|
0.9.4 (ruby-2.1.2).
|
125
250
|
</div>
|
data/doc/index.html
CHANGED
@@ -60,7 +60,152 @@
|
|
60
60
|
<iframe id="search_frame" src="class_list.html"></iframe>
|
61
61
|
|
62
62
|
<div id="content"><div id='filecontents'>
|
63
|
-
<h1 id="label-
|
63
|
+
<h1 id="label-algorithm_selector+rdoc-image-3Ahttps-3A-2F-2Fbadge.fury.io-2Frb-2Falgorithm_selector.svg">algorithm_selector <a href="https://badge.fury.io/rb/algorithm_selector"><img src="https://badge.fury.io/rb/algorithm_selector.svg"></a></h1>
|
64
|
+
<ul><li>
|
65
|
+
<p><a href="https://rubygems.org/gems/algorithm_selector">Live</a></p>
|
66
|
+
</li><li>
|
67
|
+
<p><a href="http://www.rubydoc.info/gems/algorithm_selector">Documentation</a></p>
|
68
|
+
</li></ul>
|
69
|
+
|
70
|
+
<h2 id="label-Description">Description</h2>
|
71
|
+
|
72
|
+
<p>Calculates algorithms and data structures for sorting and searching.
|
73
|
+
Selects best one to use for particular data set.</p>
|
74
|
+
|
75
|
+
<p>Additionally, data structures can be used for own purposes. All data
|
76
|
+
structures have the ability to insert and search. Will add deletion in the
|
77
|
+
future.</p>
|
78
|
+
|
79
|
+
<p>Written by Joseph Bui.</p>
|
80
|
+
|
81
|
+
<h3 id="label-Currently+supports+the+following+algorithms+and+data+structures-3A">Currently supports the following algorithms and data structures:</h3>
|
82
|
+
<ul><li>
|
83
|
+
<p>Sorting (<code>"sort"</code>)</p>
|
84
|
+
</li><li>
|
85
|
+
<p>Bubble Sort (<code>"bubble_sort"</code>)</p>
|
86
|
+
</li><li>
|
87
|
+
<p>Insertion Sort (<code>"insertion_sort"</code>)</p>
|
88
|
+
</li><li>
|
89
|
+
<p>Selection Sort (<code>"selection_sort"</code>)</p>
|
90
|
+
</li><li>
|
91
|
+
<p>Merge Sort (<code>"merge_sort"</code>)</p>
|
92
|
+
</li><li>
|
93
|
+
<p>Quick Sort(<code>"quick_sort"</code>)</p>
|
94
|
+
</li><li>
|
95
|
+
<p>Searching (<code>"search"</code>)</p>
|
96
|
+
</li><li>
|
97
|
+
<p>Stack (<code>"stack"</code>)</p>
|
98
|
+
</li><li>
|
99
|
+
<p>Queue (<code>"queue"</code>)</p>
|
100
|
+
</li><li>
|
101
|
+
<p>Singly-Linked List (<code>"linked_list"</code>)</p>
|
102
|
+
</li><li>
|
103
|
+
<p>Binary Search Tree (<code>"binary_tree"</code>)</p>
|
104
|
+
</li></ul>
|
105
|
+
|
106
|
+
<h3 id="label-Parameters">Parameters</h3>
|
107
|
+
<ul><li>
|
108
|
+
<p><code>action</code> is the string of the action, can be
|
109
|
+
<code>"sort"</code> or <code>"search"</code></p>
|
110
|
+
</li><li>
|
111
|
+
<p><code>data_set</code> has to be in array format</p>
|
112
|
+
</li><li>
|
113
|
+
<p><code>trials</code> is number of test trials (optional, default = 1)</p>
|
114
|
+
</li><li>
|
115
|
+
<p><code>target</code> is element user wants to search (unnecessary for
|
116
|
+
<code>sort</code>, default = null)</p>
|
117
|
+
</li><li>
|
118
|
+
<p><code>algorithm</code> is the string of the algorithm or data structure</p>
|
119
|
+
</li></ul>
|
120
|
+
|
121
|
+
<h3 id="label-Methods">Methods</h3>
|
122
|
+
<ul><li>
|
123
|
+
<p><code>all(action, data_set, trials, target)</code></p>
|
124
|
+
</li><li>
|
125
|
+
<p>Returns the times for each algorithm</p>
|
126
|
+
</li><li>
|
127
|
+
<p>Example: <code>ruby AlgorithmSelector.all("sort", [2,1,4,3],
|
128
|
+
1000) AlgorithmSelector.all("search", [2,1,4,3], 1000, 4) </code></p>
|
129
|
+
</li><li>
|
130
|
+
<p><code>best(action, data_set, trials, target)</code></p>
|
131
|
+
</li><li>
|
132
|
+
<p>Returns the algorithm with the best time</p>
|
133
|
+
</li><li>
|
134
|
+
<p>Example: <code>ruby AlgorithmSelector.best("sort", [2,1,4,3],
|
135
|
+
1000) AlgorithmSelector.best("search", [2,1,4,3], 1000, 4)
|
136
|
+
</code></p>
|
137
|
+
</li><li>
|
138
|
+
<p><code>analyze(action, data_set, algorithm, trials, target)</code></p>
|
139
|
+
</li><li>
|
140
|
+
<p>Returns time for specified algorithm or data structure</p>
|
141
|
+
</li><li>
|
142
|
+
<p>Example: <code>ruby AlgorithmSelector.analyze("sort", [2,1,4,3],
|
143
|
+
"merge_sort", 1000) AlgorithmSelector.analyze("search",
|
144
|
+
[2,1,4,3], "linked_list", 1000, 4) </code></p>
|
145
|
+
</li><li>
|
146
|
+
<p><code>compare(action, data_set, first_algorithm, second_algorithm, trials,
|
147
|
+
target)</code></p>
|
148
|
+
</li><li>
|
149
|
+
<p>Returns the times of two specified algorithms for comparison</p>
|
150
|
+
</li><li>
|
151
|
+
<p>Example: <code>ruby AlgorithmSelector.compare("sort", [2,1,4,3],
|
152
|
+
"merge_sort", "quick_sort", 1000)
|
153
|
+
AlgorithmSelector.compare("search", [2,1,4,3], "stack",
|
154
|
+
"linked_list", 1000, 4) </code></p>
|
155
|
+
</li><li>
|
156
|
+
<p><code>sort(data_set, algorithm)</code></p>
|
157
|
+
</li><li>
|
158
|
+
<p>Returns sorted array of specified sorting algorithm</p>
|
159
|
+
</li><li>
|
160
|
+
<p>Example: <code>ruby AlgorithmSelector.compare([2,1,4,3],
|
161
|
+
"bubble_sort") </code></p>
|
162
|
+
</li></ul>
|
163
|
+
|
164
|
+
<h3 id="label-Data+Structures">Data Structures</h3>
|
165
|
+
|
166
|
+
<h4 id="label-Stack">Stack</h4>
|
167
|
+
<ul><li>
|
168
|
+
<p>Initialize <code>ruby size = 10 stack = Stack.new(size) </code></p>
|
169
|
+
</li><li>
|
170
|
+
<p>Insertion <code>ruby # returns nil value = 6 stack.push(value)
|
171
|
+
</code></p>
|
172
|
+
</li><li>
|
173
|
+
<p>Search <code>ruby # returns true if found, else returns false target =
|
174
|
+
4 stack.search(target) </code></p>
|
175
|
+
</li></ul>
|
176
|
+
|
177
|
+
<h4 id="label-Queue">Queue</h4>
|
178
|
+
<ul><li>
|
179
|
+
<p>Initialize <code>ruby size = 10 queue = Queue.new(size) </code></p>
|
180
|
+
</li><li>
|
181
|
+
<p>Insertion <code>ruby # returns nil value = 6 queue.enqueue(value)
|
182
|
+
</code></p>
|
183
|
+
</li><li>
|
184
|
+
<p>Search <code>ruby # returns true if found, else returns false target =
|
185
|
+
4 queue.search(target) </code></p>
|
186
|
+
</li></ul>
|
187
|
+
|
188
|
+
<h4 id="label-Linked+List">Linked List</h4>
|
189
|
+
<ul><li>
|
190
|
+
<p>Initialize <code>ruby linked_list = LinkedList.new </code></p>
|
191
|
+
</li><li>
|
192
|
+
<p>Insertion <code>ruby # returns nil value = 6
|
193
|
+
linked_list.insert(value) </code></p>
|
194
|
+
</li><li>
|
195
|
+
<p>Search <code>ruby # returns true if found, else returns false target =
|
196
|
+
4 linked_list.search(target) </code></p>
|
197
|
+
</li></ul>
|
198
|
+
|
199
|
+
<h4 id="label-Binary+Search+Tree">Binary Search Tree</h4>
|
200
|
+
<ul><li>
|
201
|
+
<p>Initialize <code>ruby binary_tree = BinaryTree.new </code></p>
|
202
|
+
</li><li>
|
203
|
+
<p>Insertion <code>ruby # returns nil value = 6
|
204
|
+
binary_tree.insert(value) </code></p>
|
205
|
+
</li><li>
|
206
|
+
<p>Search <code>ruby # returns true if found, else returns false target =
|
207
|
+
4 binary_tree.search(target) </code></p>
|
208
|
+
</li></ul>
|
64
209
|
|
65
210
|
<h2 id="label-Installation">Installation</h2>
|
66
211
|
|
@@ -83,26 +228,6 @@
|
|
83
228
|
|
84
229
|
<pre class="code ruby"><code class="ruby">$ require 'algorithm_selector'</code></pre>
|
85
230
|
|
86
|
-
<h3 id="label-Saying+hello">Saying hello</h3>
|
87
|
-
|
88
|
-
<p>You can create a string “hello” by using the test method. For example:</p>
|
89
|
-
|
90
|
-
<p><a href="1">AlgorithmSelector.test(</a>) #=> “hello”</p>
|
91
|
-
|
92
|
-
<h2 id="label-Development">Development</h2>
|
93
|
-
|
94
|
-
<p>After checking out the repo, run <code>bin/setup</code> to install
|
95
|
-
dependencies. Then, run <code>rake spec</code> to run the tests. You can
|
96
|
-
also run <code>bin/console</code> for an interactive prompt that will allow
|
97
|
-
you to experiment.</p>
|
98
|
-
|
99
|
-
<p>To install this gem onto your local machine, run <code>bundle exec rake
|
100
|
-
install</code>. To release a new version, update the version number in
|
101
|
-
<code>version.rb</code>, and then run <code>bundle exec rake
|
102
|
-
release</code>, which will create a git tag for the version, push git
|
103
|
-
commits and tags, and push the <code>.gem</code> file to <a
|
104
|
-
href="https://rubygems.org">rubygems.org</a>.</p>
|
105
|
-
|
106
231
|
<h2 id="label-Contributing">Contributing</h2>
|
107
232
|
|
108
233
|
<p>Bug reports and pull requests are welcome on GitHub at <a
|
@@ -119,7 +244,7 @@ href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
|
|
119
244
|
</div></div>
|
120
245
|
|
121
246
|
<div id="footer">
|
122
|
-
Generated on
|
247
|
+
Generated on Sat Jul 23 23:26:27 2016 by
|
123
248
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
124
249
|
0.9.4 (ruby-2.1.2).
|
125
250
|
</div>
|