Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zinovyev/ruborithms
Algorithms and data structures implemented in Ruby
https://github.com/zinovyev/ruborithms
Last synced: 1 day ago
JSON representation
Algorithms and data structures implemented in Ruby
- Host: GitHub
- URL: https://github.com/zinovyev/ruborithms
- Owner: zinovyev
- License: mit
- Created: 2017-04-17T20:45:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-17T20:48:42.000Z (over 7 years ago)
- Last Synced: 2024-04-24T19:49:09.185Z (8 months ago)
- Language: Ruby
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ruborithms
Algorithms and data structures implemented on pure Ruby.
[![Gem Version](https://badge.fury.io/rb/ruborithms.svg)](https://badge.fury.io/rb/ruborithms)
## Install
```bash
gem install ruborithms
```Require library:
```ruby
require 'ruborithms'
```## Algorithms
### Linear Search
Include:
```ruby
class Array; include Ruborithms::Algorithms::LinearSearch; end
```Linear search can now be used as a class singleton method:
```ruby
irb(main):006:0> Array.linear_search([1, 55, 22, 44], 55)
=> 1
```Or in the instance context:
```ruby
irb(main):007:0> [1, 55, 22, 44].linear_search(55)
=> 1
```### Binary Search
Include:
```ruby
class Array; include Ruborithms::Algorithms::BinarySearch; end
```Binary search can now be used as a class singleton method:
```ruby
irb(main):008:0> Array.binary_search([1, 55, 22, 44], 55)
=> 1
```Or in the instance context:
```ruby
irb(main):009:0> [1, 55, 22, 44].binary_search(55)
=> 1
```### Selection Sort
Include:
```ruby
class Array; include Ruborithms::Algorithms::SelectionSort; end
```Binary search can now be used as a class singleton method:
```ruby
irb(main):017:0> Array.selection_sort([1, 55, 22, 44])
=> [1, 22, 44, 55]
```Or in the instance context:
```ruby
irb(main):019:0> [1, 55, 22, 44].selection_sort
=> [1, 22, 44, 55]
```