algorithms
algorithms copied to clipboard
Ruby algorithms and data structures. C extensions
Thanks for the awesome lib!
The method comment says it is O(1) but the code was O(n). It was doing an unnecessary loop. This reduces the time for the ["Insertion then sort"](https://github.com/kanwei/algorithms/pull/46/files) benchmark from 7.659...
Please refer to this stackoverflow question: http://stackoverflow.com/questions/13978484/kanwei-minheap-slow-ruby
Adds a benchmark for the heap datastructure.
I want to contribute to this repository but, I am not able to understand the folder structure.
The style is improved in accordance with rubocop: trailing whitespaces and unnecessary semicolons are removed, empty lines at the end of some files are added, as in the rest of...
```# Deletes the item and key if it's found, and returns the item. Returns nil # if key is not present. # # !!! Warning !!! There is a currently...
Works when the heap length is < 10 but fails with 10+ ``` ruby min_heap = ::Containers::Heap.new(10.times.map{Object.new}){|x, y| (x y) == -1} while val = min_heap.pop do p val end...
There are several releases on rubygems.org without corresponding git tags. It'd be helpful to have those for reproducibility.
One of the key advantages of heap sort is it can be an in place algorithm (https://en.wikipedia.org/wiki/In-place_algorithm); however, your implementation does not do an in place implementation: https://github.com/kanwei/algorithms/blob/master/lib/algorithms/sort.rb#L85-L90 Instead, you...