Mastering data structures in Ruby — Recap
Writing this series has been a lot of fun, and based on feedback, I decided to write this post to provide an index (so posts can be bookmarked), and to tell you what this series was all about and what you can learn from it. So, with no further ado, let’s dive in.
The series starts with essential data structures like linked lists and stacks, then moves to advanced data structures like binary search trees and graphs, and finally, it introduces the concept of persistent data structures like the ones you find in functional programming languages like Clojure or Haskell.
To make this series easy to follow, I tried to avoid CS jargon and heavy math. Except for hash tables and sets, there are almost no theoretical aspects discussed in this series.
On each post I’ll show you how to build a particular data structure from scratch using roughly the same format:
- A brief description of the data structure.
- Data structure’s interface.
- Implementation details. (In-depth analysis of code and time complexity.)
- Closing thoughts. (When to use the data structure, mostly.)
The code in this series is mostly educational, you won’t see fancy optimizations or exhaustive error checkings. The code is optimized for “readability” not for production use. It will help you to understand how data structures work internally, but it won’t provide drop-in replacements for Ruby’s own data structures like Array or Hash. If you want to use this code in production, you will have to test it thoroughly and benchmarking it accordingly, otherwise, you will be better off by using Ruby’s built-in data structures.
List of entries in chronological order
- Singly linked lists
- Doubly linked lists
- Circular linked lists
- Hash Tables
- Binary Trees
- AVL Trees (Binary Search Trees)
- Persistent lists
Now that this series is done, I would probably make some time to do a short series on Mastering algorithms in Ruby as a follow up to this series. If you like Mastering data structures, stay tuned!
I hope this series helps you with whiteboard interviews and algorithms design.
Thanks for reading! See you next time.
Also, don’t forget to clap if you like this post :)