DSA Visualizer - Zero to Hero
A comprehensive Ruby gem for learning Data Structures and Algorithms from scratch by visualizing concepts at the core level, comparing Ruby and C++ implementations with step-by-step execution details, detailed notes, and practice problems.
π― Features
- π Complete DSA Curriculum: 12 sections covering fundamentals to advanced topics
- π¨ Visual Representations: ASCII art visualizations of data structures
- π Ruby vs C++ Comparisons: Side-by-side implementation comparisons
- π§ Core Level Explanations: Deep dive into memory layout and internal workings
- π Memory Tracking: Track allocations and operations
- β±οΈ Complexity Analysis: Time and space complexity for every operation
- π Detailed Notes: Important points, common mistakes, best practices
- π― Real-World Examples: Practical use cases for each concept
- πͺ Practice Problems: Curated problems for each topic
- π Progress Tracking: Track your learning journey
- π₯οΈ Interactive CLI: Command-based navigation through topics
π Complete Curriculum
1. Fundamentals
- Time & Space Complexity (Big O Notation)
- Memory Management (Stack vs Heap)
- Pointers & References
- Recursion Basics
2. Basic Data Structures
- Arrays
- Strings
- Linked Lists (Singly, Doubly, Circular)
3. Stack & Queue
- Stack (Array-based & Linked List-based)
- Queue (Array-based & Linked List-based)
- Circular Queue
- Deque
- Priority Queue
4. Hashing
- Hash Functions
- Hash Tables
- Collision Handling (Chaining, Open Addressing)
- Hash Maps & Sets
5. Trees
- Binary Trees
- Binary Search Trees (BST)
- Tree Traversals (Inorder, Preorder, Postorder, Level-order)
- AVL Trees
- Red-Black Trees
- B-Trees
- Segment Trees
- Fenwick Trees (Binary Indexed Tree)
- Trie (Prefix Tree)
6. Heaps
- Min Heap & Max Heap
- Heap Operations (Insert, Extract, Heapify)
- Heap Sort
7. Graphs
- Graph Representations (Adjacency Matrix, Adjacency List)
- BFS (Breadth-First Search)
- DFS (Depth-First Search)
- Topological Sort
- Shortest Path Algorithms (Dijkstra, Bellman-Ford)
- Minimum Spanning Tree (Kruskal, Prim)
- Floyd-Warshall Algorithm
8. Sorting Algorithms
- Bubble Sort, Selection Sort, Insertion Sort
- Merge Sort, Quick Sort, Heap Sort
- Counting Sort, Radix Sort, Bucket Sort
9. Searching Algorithms
- Linear Search, Binary Search
- Ternary Search, Jump Search
- Interpolation Search
10. Advanced Algorithms
- Dynamic Programming (Fibonacci, Knapsack, LCS, Matrix Chain)
- Greedy Algorithms
- Backtracking
- Divide and Conquer
11. String Algorithms
- Pattern Matching (Naive, KMP, Rabin-Karp)
- Z Algorithm
12. Advanced Data Structures
- Disjoint Set (Union-Find)
- Suffix Array & Suffix Tree
- Skip List
π Installation
Add this line to your application's Gemfile:
gem 'dsa_visualizer'And then execute:
bundle installOr install it yourself as:
gem install dsa_visualizerπ» Usage
Interactive CLI (Recommended)
Start the interactive learning interface:
ruby -Ilib bin/dsa_visualizerOr in your Ruby code:
require 'dsa_visualizer'
DSAVisualizer.start_cliThis launches an interactive menu where you can:
- Navigate through 12 sections of DSA topics
- Select specific topics by number (e.g., "2.1" for Arrays)
- Track your learning progress
- View saved notes
Direct Topic Access
Learn specific topics programmatically:
require 'dsa_visualizer'
# Fundamentals
DSAVisualizer.learn(:complexity_basics)
DSAVisualizer.learn(:memory_basics)
DSAVisualizer.learn(:pointers_basics)
DSAVisualizer.learn(:recursion_basics)
# Data Structures
DSAVisualizer.learn(:array)
DSAVisualizer.learn(:linked_list)
DSAVisualizer.learn(:stack)
DSAVisualizer.learn(:queue)
DSAVisualizer.learn(:hash_table)
DSAVisualizer.learn(:binary_tree)
DSAVisualizer.learn(:bst)
# Algorithms
DSAVisualizer.learn(:bubble_sort)
DSAVisualizer.learn(:binary_search)
DSAVisualizer.learn(:bfs)
DSAVisualizer.learn(:dfs)
DSAVisualizer.learn(:dijkstra)π Example Output
When you run DSAVisualizer.learn(:complexity_basics):
================================================================================
TIME & SPACE COMPLEXITY - Foundation of Algorithm Analysis
================================================================================
π WHAT IS COMPLEXITY ANALYSIS?
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Complexity analysis helps us understand how an algorithm's performance
scales with input size. We measure two things:
1. Time Complexity - How execution time grows
2. Space Complexity - How memory usage grows
1. Big O Notation
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Big O describes the upper bound (worst case) of algorithm growth.
Common Time Complexities (from best to worst):
O(1) Constant β Array access, hash lookup
O(log n) Logarithmic β Binary search, balanced tree ops
O(n) Linear β Array traversal, linear search
O(n log n) Linearithmic β Merge sort, quick sort (avg)
O(nΒ²) Quadratic β Bubble sort, nested loops
...
[Detailed examples with Ruby and C++ code comparisons follow]
π Learning Path
For Beginners (Start Here!)
-
Start with Fundamentals (Section 1)
- Understand complexity analysis first
- Learn memory management basics
- Master pointers/references concept
- Practice recursion
-
Move to Basic Data Structures (Section 2)
- Arrays and Strings
- Linked Lists
-
Learn Stack & Queue (Section 3)
Intermediate Level
- Hashing (Section 4)
- Trees (Section 5)
- Heaps (Section 6)
- Sorting & Searching (Sections 8-9)
Advanced Level
- Graphs (Section 7)
- Advanced Algorithms (Section 10)
- String Algorithms (Section 11)
- Advanced Data Structures (Section 12)
π― What Makes This Gem Special?
- Zero to Hero Approach: Complete curriculum from basics to advanced
- Core Level Understanding: Shows what happens in memory, not just theory
- Language Comparison: Learn by comparing Ruby's abstractions with C++'s control
- Visual Learning: ASCII visualizations make abstract concepts concrete
- Step-by-Step: Track each operation with detailed explanations
- Comprehensive Notes: Important points, common mistakes, best practices
- Practice Problems: Curated problems for each topic
- Progress Tracking: See your learning journey
- Real-World Context: Understand when and why to use each structure
- Interactive CLI: Easy navigation through topics
π Each Topic Includes
- β Concept explanation
- β Ruby implementation with code
- β C++ implementation with code
- β Side-by-side comparison
- β Memory layout visualization
- β Time complexity analysis
- β Space complexity analysis
- β Step-by-step operation walkthrough
- β Important notes and key points
- β When to use / when not to use
- β Real-world applications
- β Common mistakes to avoid
- β Practice problems
π οΈ Requirements
- Ruby >= 2.7.0
- colorize gem (for colored output)
- tty-box gem (for visual boxes)
- tty-table gem (for tables)
π§ Development
After checking out the repo, run:
bundle installTo run the interactive CLI:
ruby -Ilib bin/dsa_visualizerTo run a specific topic:
ruby -Ilib -r dsa_visualizer -e "DSAVisualizer.learn(:array)"π€ Contributing
Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration.
π License
The gem is available as open source under the terms of the MIT License.
πΊοΈ Roadmap
- Core fundamentals (Complexity, Memory, Pointers, Recursion)
- Basic data structures (Array, Linked List, Stack, Queue)
- Interactive CLI with progress tracking
- Complete all tree implementations
- Complete all graph algorithms
- Complete all sorting algorithms
- Add dynamic programming examples
- Add more practice problems
- Add quiz mode
- Export notes to PDF
- Web interface
- Video tutorials integration
π‘ Tips for Learning
- Follow the order: Start with fundamentals, don't skip ahead
- Practice coding: Don't just read, implement the structures yourself
- Understand, don't memorize: Focus on why, not just how
- Compare languages: See how Ruby and C++ approach the same problem
- Solve practice problems: Apply what you learn
- Track progress: Use the built-in progress tracker
- Review notes: Revisit important points regularly
π Credits
Created for developers who want to truly understand data structures and algorithms at a fundamental level, with practical comparisons between high-level (Ruby) and low-level (C++) implementations.
Happy Learning! π Master DSA one topic at a time!