Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 1.05 KB

README.md

File metadata and controls

40 lines (27 loc) · 1.05 KB

Build Status

Algorithms

Collection of different algorithms, in ruby.

Installation

Add this line to your application's Gemfile:

gem 'algorithms', github: 'davidkariuki/algorithms'

And then execute:

$ bundle

Usage

# kth_smallest example
arr = (1..100).shuffle
smallest_22 = Algorithms::KthSmallest.new(arr).kth_smallest(22) #returns the 22nd smallest number in arr

# quick_sort! example
Algorithms::QuickSort.new(arr).sort!

# k-means example
clusterer = Algorithms::KMeans::Clusterer.new(filename: 'path-to-file')
clusterer.run
clusterer.to_chart_data #gives clustered data you can throw in a google
visualization (e.g. geochart)

Contributing

  1. Fork it ( http://github.com/davidkariuki/algorithms/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request