Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

README

  • Loading branch information...
commit 0b770b104ba119fa6631fdd6d2936b8e8bc05f5b 1 parent 93a721c
@nashby authored
Showing with 32 additions and 0 deletions.
  1. +32 −0 README.md
View
32 README.md
@@ -0,0 +1,32 @@
+### Rabin–Karp algorithm
+
+Rabin–Karp algorithm is a string searching algorithm created by Michael O. Rabin and Richard M. Karp in 1987 that uses hashing to find any one of a set of pattern strings in a text (c) Wiki
+
+### Algorithm description
+
+[Wiki](http://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm)
+
+### Benchmarks
+
+```ruby
+n = 50000
+string = 'hello world'
+substring = 'world'
+
+Benchmark.bm do |x|
+ x.report { n.times { string.rk_search('world') } }
+ x.report { n.times { string.scan('world') } }
+end
+```
+
+results:
+
+```
+ user system total real
+0.360000 0.000000 0.360000 ( 0.358861)
+0.120000 0.000000 0.120000 ( 0.114930)
+```
+
+### TODO:
+
+Write better benchmarks
Please sign in to comment.
Something went wrong with that request. Please try again.