Programming & Patterns
Algorithms, data structures, and JavaScript patterns.
Browse by Topic
All Articles (11 articles)
-
Heaps and Priority Queues: Internals, Trade-offs, and When Theory Breaks Down
Programming & Patterns / Data Structures 19 min readHeaps provide the fundamental abstraction for “give me the most important thing next” in O(log n) time. Priority queues—the abstract interface—power task schedulers, shortest-path algorithms, and event-driven simulations. Binary heaps dominate in practice not because they’re theoretically optimal, but because array storage exploits cache locality. Understanding the gap between textbook complexity and real-world performance reveals when to use standard libraries, when to roll your own, and when the “better” algorithm is actually worse.
-
Trees and Graphs: Traversals and Applications
Programming & Patterns / Data Structures 17 min readHierarchical and networked data structures that underpin file systems, databases, build tools, and routing. This guide covers tree variants (BST, AVL, Red-Black, B-trees, tries), graph representations (adjacency matrix vs list), traversal algorithms (DFS, BFS), and key algorithms (cycle detection, topological sort, shortest paths). Focus on design trade-offs and when to choose each structure.
-
Arrays and Hash Maps: Engine Internals and Performance Reality
Programming & Patterns / Data Structures 11 min readTheoretical complexity hides the real story. Arrays promise O(1) access but degrade to O(n) with sparse indices. Hash maps guarantee O(1) lookups until collisions chain into linear probes. Understanding V8’s internal representations—elements kinds, hidden classes, and deterministic hash tables—reveals when these data structures actually deliver their promised performance and when they fail.
-
K-Crystal Balls Problem: Jump Search Pattern
Programming & Patterns / Algorithms Foundations 10 min readThe K-crystal balls (or K-egg drop) problem demonstrates how constrained resources fundamentally change optimal search strategy. With unlimited test resources, binary search achieves O(log n). With exactly k resources that are consumed on failure, the optimal worst-case complexity becomes O(n^(1/k))—a jump search pattern where each resource enables one level of hierarchical partitioning.
-
Sorting Algorithms: Complexity, Stability, and Use Cases
Programming & Patterns / Algorithms Foundations 25 min readA comprehensive guide to sorting algorithms covering fundamental concepts, implementation details, performance characteristics, and real-world applications. Learn when to use each algorithm and understand the engineering trade-offs behind production sorting implementations.
-
Search Algorithms: Linear, Binary, and Graph Traversal
Programming & Patterns / Algorithms Foundations 34 min readA comprehensive guide to search algorithms covering fundamental concepts, implementation details, performance characteristics, and real-world applications. Learn when to use each algorithm and understand the engineering trade-offs behind production search implementations.
-
Publish-Subscribe Pattern in JavaScript
Programming & Patterns / JavaScript Patterns 12 min readArchitectural principles, implementation trade-offs, and production patterns for event-driven systems. Covers the three decoupling dimensions, subscriber ordering guarantees, error isolation strategies, and when Pub/Sub is the wrong choice.
-
Exponential Backoff and Retry Strategy
Programming & Patterns / JavaScript Patterns 17 min readLearn how to build resilient distributed systems using exponential backoff, jitter, and modern retry strategies to handle transient failures and prevent cascading outages.
-
Async Queue Pattern in JavaScript
Programming & Patterns / JavaScript Patterns 13 min readBuild resilient, scalable asynchronous task processing systems—from basic in-memory queues to advanced distributed patterns—using Node.js. This article covers the design reasoning behind queue architectures, concurrency control mechanisms, and resilience patterns for production systems.
-
JavaScript Error Handling Patterns
Programming & Patterns / JavaScript Patterns 21 min readMaster exception-based and value-based error handling approaches, from traditional try-catch patterns to modern functional programming techniques with monadic structures.
-
JavaScript String Length: Graphemes, UTF-16, and Unicode
Programming & Patterns / JavaScript Patterns 13 min readJavaScript’s string.length returns UTF-16 code units—a 1995 design decision that predates Unicode’s expansion beyond 65,536 characters. This causes '👨👩👧👦'.length to return 11 instead of 1, breaking character counting, truncation, and cursor positioning for any text containing emoji, combining marks, or supplementary plane characters. Understanding the three abstraction layers—grapheme clusters, code points, and code units—is essential for correct Unicode handling.