mirror of
https://github.com/ro31337/rubyisforfun
synced 2024-11-16 19:50:09 +01:00
Save
This commit is contained in:
parent
7a56ca4e61
commit
d2d670b991
1 changed files with 5 additions and 0 deletions
|
@ -878,3 +878,8 @@ books = [
|
|||
This data has sequential nature, and looking up an object takes _linear time_ - in other words, the only way to go is to iterate and compare isbn to get the right one.
|
||||
|
||||
However, when books are represented as hash (second block), ids are the hash key. There is no specific order (well, in Ruby language there is an order for convenience, but normally hash data structure has no order), but knowing how hashes work allows us to do quick search in _constant time_. We do not explain how exactly hashes achieve this performance, it's not the purpose of this book. However, we highly encourage to read up on that, the algorithm is simple enough and quite interesting.
|
||||
|
||||
075
|
||||
===
|
||||
|
||||
Skip for now
|
||||
|
|
Loading…
Reference in a new issue