logo Algo-Science
Recursion quiz
Initializing search
    Algo-Science.
    • Home
    • Getting Started
    • Courses
    • Free Resources
    • Algorithms
    • Monotonic Stack
    • Greedy Algorithms
    • Tree Algorithms
    • Mathematics for Problem Solving
    • Number Theory
    • Data Structures
    • Dynamic Programming
    • Graph Algorithms
    • Interview Prep
    • System Design
    • Quizzes
    • Cohort Curriculum
    • Low-Level Design
    • Misc
    Algo-Science.
    • Home
    • Getting Started
      • C++ for CP ↗
      • Monotonic Stack ↗
      • Greedy Algorithms ↗
      • Google Interview ↗
        • Shapes and Curves
        • Parameter Fixing
        • Sets and States
        • Chaining and Dependency
        • Generating Functions - Theory
        • Generating Functions - Practice
        • Golden Rules of Function Addition
      • Overview
          • Seeing Numbers as Curves
          • Difference Arrays - The Geometric Toolkit
          • When Shapes Survive - Function Addition
          • The Fixing Mindset
          • Fix the Equation
          • Fix the Structure
          • Fix the Group
          • Containers, Sets, and Operations
          • Defining States - The Art of DP
          • Thinking in Chains
          • Structural Chains
          • Chains in DP and Greedy
          • Matrix Exponentiation
        • Recursion vs Iteration
        • Recursion and Memory
        • Logical Recursion
        • Structural Recursion
        • Structural Recursion for NP Tasks
        • Fix and Count (Running Pointer)
        • Merge Sort & Running Pointers
        • Contribution Technique on Trees
        • Unified Theory of Traversal
        • Binary Search - Brainstorming Tasks
        • Binary Search - Implementation Variations
        • Binary Search - Practice Tasks
        • ICPC 2025 Online Round
        • Quick Sort
        • Stack Parenthesis
        • Dijkstra
        • From Chains to Stacks
        • The Four Variants
        • Beyond Inequality — Bitmask Chaining
        • Sliding Window Min/Max
        • Lifespan & Expiration
        • 1D DP Optimization
        • Dual Queues with Two Pointers
        • Heights & Boundaries
        • Largest Rectangle in Histogram
        • The Contribution Technique
        • Matrix Elevations — 2D Histograms
        • Weighted Histograms
        • Remove K Digits
        • The Pop Budget
        • Lexicographic Subsequences
        • What Is a Cartesian Tree
        • Properties & RMQ Equivalence
        • Cartesian Tree DP
        • Lines as Candidates
        • The Geometric Eclipse
        • Beyond Lines — Li Chao Tree
        • Streaming Data
        • Real-Time Heatmaps
        • Offline Range Queries
        • 2D Monotonic Queue
      • Cheat Sheet
        • What Is Greedy?
        • The Guess-and-Prove Workflow
        • When Greedy Fails
        • Huffman Coding
        • Dijkstra’s Shortest Path
        • Minimum Spanning Trees
        • Interval Scheduling
        • Coverage Problems
        • Left-Right Decisions
        • Sorting by Formula
        • Custom Comparators
        • Two-Phase Sorting
        • Assignment Problems
        • Sweep and Invariants
        • Greedy Construction
        • Priority Queue Greedy
        • The Undo Trick
        • Stock Trading
        • Decoupled Sweeps
        • CSES Stick Differences
        • Prefix-Suffix Sweeps
        • Block Compression
        • The Alien’s Trick
        • Connecting WQS, Undo, and Slope Trick
        • Slope Trick Intro
        • LP and Flow Connections
        • Conflict Graphs & Bipartite DSU
        • Implicit State Space Search
        • Greedy Tree Traversals
        • Greedoids, Matroids, and When Greedy Works
        • Antimatroids and Scheduling
        • Trees Are Recursive Structures
        • The Call Stack IS the Tree
        • Top-Down vs Bottom-Up
        • Subtrees vs Paths
        • The DFS Template
        • Tree Input Formats
        • Recursive Traversals
        • Iterative DFS
        • BFS Level Order
        • All Three in One
        • Morris Traversal
        • Postorder Template
        • Pair Return Pattern
        • Subtree Aggregation
        • LCA via Postorder
        • Preorder Template
        • Boundary and Views
        • Nodes at Distance K
        • Burning Tree
        • Prefix Sums on Trees
        • Step-by-Step Directions via LCA
        • Construct from Traversals
        • Serialize and Deserialize
        • Flatten to Linked List
        • BST from Preorder
        • Sorted Array to Balanced BST
        • Search, Insert, Delete
        • Validate BST with Range
        • Kth Smallest Inorder
        • Merge, Two Sum, Largest BST
        • Maximum Sum BST
        • Recursion Tree Visualization
        • Master Theorem as Tree
        • Search as Tree Traversal
        • Divide and Conquer Trees
        • Game Trees and Minimax
        • Trees in the Wild
        • Max Independent Set
        • Min Vertex Cover
        • Max Matching on Trees
        • Tree Coloring
        • Binary Tree Cameras
        • Subtree DP
        • Path DP
        • Stack as Ancestor Tracker
        • Monotonic Stack on Trees
        • Iterative DFS with State
        • Interview Graduation
        • Euler Tour and DFS Ordering
        • Subtree Queries via Flattening
        • Path Queries and RMQ
        • When to Linearize
        • LCA Postorder Review
        • Binary Lifting
        • LCA via Euler Tour and RMQ
        • Distance and Path Queries
        • Difference Arrays on Trees
        • Max Distance to Marked Vertices
        • Heavy-Light Decomposition
        • Centroid Decomposition
        • DSU on Tree
        • Virtual Tree
        • Classification Flowchart
        • Combining Techniques
        • Catalan Numbers and Trees
        • Prüfer Sequences and Cayley’s Formula
        • Tree Isomorphism via Hashing
        • Kirchhoff’s Matrix Tree Theorem
          • Expressions and Linear Equations
          • Quadratics — Factoring, Formula, and Completing the Square
          • Polynomials — Arithmetic, Roots, and Theorems
          • Systems of Equations and Inequalities
          • Algebraic Manipulations and Factoring Tricks
          • Functions — Domain, Range, and Composition
          • Exponents, Logarithms, and Radicals
          • Arithmetic and Geometric Sequences and Series
          • Telescoping, Recursion, and Advanced Series
          • Linear and Quadratic Inequalities
          • AM-GM, Cauchy-Schwarz, and Power Mean
          • Optimization Techniques and Functional Equations
          • Triangles, Angles, and the Pythagorean Theorem
          • Polygons, Area, and Circles
          • Coordinate Geometry
          • Trigonometry Basics
          • Complex Number Arithmetic
          • Polar Form, Exponential Form, and Roots of Unity
          • Vectors in 2D and 3D
          • Matrices, Determinants, and Inverses
        • Four Moves, Every Problem
        • Numbers Are Sets, Operations Are Everything
        • Bits Are Sets
        • Equations Are Constraints
        • Arrays Are Curves
        • Primality and Factorization
        • The Sieve of Eratosthenes
        • Counting and Summing Divisors
        • Sieve Variations
        • GCD and LCM as Set Operations
        • GCD Variations
        • Extended Euclidean and Bezout's Identity
        • Linear Diophantine Equations
        • The Rules of Modular World
        • Binary Exponentiation
        • Modular Inverse via Fermat's Little Theorem
        • Modular Inverse: General Case and Precomputation
        • Euler's Totient Function
        • Permutations, Combinations, and Identities
        • Computing nCr Under Mod
        • Stars and Bars
        • Catalan Numbers
        • The Inclusion-Exclusion Principle
        • Derangements
        • The Pigeonhole Principle
        • Coprime Counting and the Mobius Connection
        • Probability Basics for CP
        • Linearity of Expectation
        • Expected Value DP
        • Nim and the XOR Trick
        • Sprague-Grundy Theorem
        • Game Variations
        • The Language of Divisors
        • Multiplicative Functions
        • Dirichlet Convolution and Mobius Inversion
        • The Floor Staircase
        • Large Numbers: Miller-Rabin and Pollard's Rho
        • Matrix Exponentiation
        • The Tropical Semiring
        • XOR Basis and GF(2)
        • Polynomials as Counting Tools
        • Polynomials as Points: DFT and Roots of Unity
        • FFT: The Divide-and-Conquer Algorithm
        • NTT and Modular Convolution
        • FWHT and Bitwise Convolution
        • Chinese Remainder Theorem
        • Burnside's Lemma
        • Putting It All Together
      • Primes and Factorization
      • GCD, LCM, and Modular Arithmetic
      • Overview
      • Aggregate Queue
      • Introduction
        • Graphs vs Trees
        • Representations
        • DFS on Graphs
        • BFS on Graphs
        • Bipartiteness
        • Grids as Graphs
        • Flood Fill
        • Multi-Source BFS
        • Path Reconstruction
        • Kahn's Algorithm
        • DFS Topo Sort
        • Lexicographic Ordering
        • DP on DAGs
        • Counting Orderings
        • DSU Core
        • Dynamic Connectivity
        • Weighted DSU
        • DSU Applications
        • Dijkstra
        • When Dijkstra Breaks
        • Bellman-Ford
        • Floyd-Warshall
        • All-Pairs Applications
        • Resource Expansion Principle
        • Binary Resource
        • Bounded Integer Resource
        • Resource with Refueling
        • Hop Budget
        • Time-Dependent Edges
        • Non-Linear Wait
        • Parity Toggle Layers
        • Modular Layers
        • Reverse Time
        • 0-1 BFS
        • Sliding Pieces
        • Direction and Momentum
        • Potential Functions
        • Two-Mode Graphs
        • Company Line Switching
        • Graph on Graph
        • Multi-Criteria
        • Two-Agent BFS
        • Two-Pointer Graph
        • Two-Source Combine
        • Collision Analysis
        • Arithmetic as Graph
        • Geometric Graphs
        • Set-Membership Graphs
        • Auxiliary Virtual Nodes
        • Parametric Search
        • Reverse BFS
        • Edge Necessity
        • Graph Reconstruction
        • Shortest Cycle
        • Kruskal's and Prim's
        • Cut and Cycle Property
        • MST Edge Queries
        • Virtual Nodes MST
        • Tarjan's and Kosaraju's
        • Condensation Graph
        • 2-SAT
        • Reachability Analysis
        • Euler Circuits and Paths
        • De Bruijn Sequences
        • Hamiltonian Bitmask DP
        • Max Flow
        • Min Cut and Matching
        • Functional Graph Structure
        • Binary Lifting Successor
        • Cycle Detection
        • Aggregating Truncated Election Results
        • Converting Org Tree to Engineer-Only Graph
          • Overview
          • Delete a Tree
          • Remove Edges from Tree
          • Islands in a Tree
          • Walk Through Shadow Area
          • Find Largest Connected Graph
          • Validate Sequence of Numbers
          • Blind Robot in a Maze
          • Overview
          • Electoral Tie Analysis
          • How Many Ways Can the Party Win
          • Red Card Black Card Game
          • Swiss Gondolas
          • The Jumping Game
          • Painting Fence
          • Score Combinations in Football
          • Overview
          • Global Minimum on Network
          • Domain Name Scoring
          • Counting Rate of Events
          • Dashboard for Monitoring Slow Queries
          • Implement a TCP Stream
          • Implement an Aggregator
          • Find Top N Largest Files
          • Design a Large Scale Cache
          • Overview
          • Measuring Service Success
          • Binary Search in RLE List
          • Find Largest Subsequence of K Digits
          • Splitting Cakes
          • Longest Sequence After Substitution
          • Find Number in Sorted Array
          • Google Shopping Price Retrieval
          • Overview
          • Apply Refactor to Source Code
          • Transform a C-Style String
          • Implement a Swype Keyboard
          • Best Anagram Finder
          • Find Buddies in Strings
          • Contained Characters in Grouped String
          • Find Strings with Prefix
          • Overview
          • Calculate PnL for Stock Transactions
          • Building a Market Order Book
          • Processing Highway Toll Logs
          • Find Shortest Queue
          • Overview
          • Merge Calendar Intervals
          • Schedule Car Rentals
          • Supercomputer Schedule
          • Overview
          • Screen Pattern Lock
          • Plant Flowers in Neighborhood
          • Vegetable Garden
          • Overview
          • Maximum Boxes Cut by Line
          • Largest Rectangle from Points
          • Super Prime Cut Numbers
          • Validate Date from Three Numbers
          • Overview
          • Packetize Data Optimally
          • Optimal Fun Event Selection
          • Create a Match Maker
          • Winners of a Tournament
          • Parse Paginated Results
          • Elections with Partial Information
        • Overview
        • Validate Stack Sequences
        • Overview
        • DSA Questions
        • System Design (HLD)
        • LLD / Machine Coding
        • 1-Month Roadmap
        • 3-Month Roadmap
        • Overview
        • DSA Questions
        • System Design (HLD)
        • LLD / Machine Coding
        • 1-Month Roadmap
        • 3-Month Roadmap
        • Overview
        • DSA Questions
        • System Design (HLD)
        • LLD / Machine Coding
        • 1-Month Roadmap
        • 3-Month Roadmap
        • Overview
        • DSA Questions
        • System Design (HLD)
        • LLD / Machine Coding
      • Introduction
          • The Layered Model
          • Life of a Web Request
          • UDP
          • TCP
          • TCP vs UDP — How to Pick
          • HTTP & HTTPS
          • REST APIs
          • GraphQL & gRPC
          • Server-Sent Events
          • WebSockets
          • WebRTC
          • Why Load Balancing
          • Client-Side Load Balancing
          • L4 vs L7 Load Balancers
          • Algorithms & Health Checks
          • Scaling the Load Balancer
          • Regionalization & Latency
          • Retries & Idempotency
          • Circuit Breakers
          • Tables, Rows & the Relational Model
          • How Data Lives on Disk
          • B-Trees, LSM Trees & Hash Indexes
          • Entity-Relationship Modelling
          • Normalization
          • Denormalization
          • The Relational Model
          • Document & Key-Value Models
          • Wide-Column & Time-Series Models
          • Specialized Models
          • Replication Models
          • Consistency Models & CAP
          • Concurrency Control & Isolation Levels
          • Composite & Specialized Indexes
          • Query Patterns That Break at Scale
          • Partitioning
          • Sharding
          • Consistent Hashing & Resharding
          • Cross-Shard Queries & Hot Spots
          • Distributed Transactions
          • CQRS, Event Sourcing & Materialized Views
          • Schema Evolution
          • Social Media at Scale
          • Messaging & Real-Time
          • Infrastructure at Scale
        • Interview Cheat Sheet
          • The API Landscape
          • The Decision Framework
          • Resource Modeling
          • HTTP Methods and Idempotency
          • Request and Response Design
          • Why GraphQL Exists
          • Schema Design and Queries
          • N+1 Problem and Pitfalls
          • How RPC Works
          • gRPC and Protocol Buffers
          • Streaming Patterns
          • Pagination
          • Versioning and Compatibility
          • Filtering, Sorting, and Search
          • Async, Caching, and Concurrency
          • Authentication
          • Authorization and RBAC
          • Rate Limiting and Protection
          • Designing APIs for Interviews
          • APIs at Scale
          • Common Mistakes
        • Interview Cheat Sheet
          • The Read Bottleneck
          • Optimize Before You Scale
          • Read Replicas
          • Caching
          • Cache Failures
          • CDN and Edge Caching
          • Why Writes Are Harder
          • Vertical Optimization
          • Sharding for Write Throughput
          • Queues, Batching, and Load Shedding
          • Distributed Counters
          • Race Conditions
          • Transactions, Locks, and Optimistic Updates
          • The Reservation Pattern
          • Distributed Coordination
          • Saga vs 2PC
          • The Problem with Polling
          • SSE and WebSockets
          • Fan-out
          • Presence and Connection Management
          • Why Sync Breaks Down
          • Queue Architectures
          • Retries, Dead Letters, Poison Messages
          • Job Status and Progress
          • Scaling Workers
          • Why Multi-step Is Hard
          • Evolution of Solutions
          • Workflow Orchestration
          • Idempotency and Compensation
          • Why Large Files Break
          • Presigned URLs
          • Chunked and Resumable Uploads
          • Deduplication and Processing
          • Storage Tiers and Cost
          • Architecture Patterns Cheat Sheet
          • Pattern to Question Bridge
          • Data Structures and When to Use Each
          • Persistence, Replication, and Cluster Mode
          • Redis Patterns for System Design Interviews
          • MVCC and Concurrency Control
          • Indexing — B-tree, GIN, GiST, and When to Use Each
          • Partitioning, Replication, and Connection Pooling
          • The Document Model — When Documents Beat Tables
          • Sharding, Replica Sets, and Consistency
          • Aggregation Pipeline and Schema Patterns
          • Log-Structured Storage — Why Kafka Is Fast
          • Partitions, Consumer Groups, and Ordering Guarantees
          • Exactly-Once Semantics and Transactions
          • Kafka Streams vs Flink — When to Use Each
          • Inverted Index Internals — How Lucene Works
          • Relevance Scoring — BM25, Boosting, and Tuning
          • Sharding, Replicas, and Near-Real-Time Search
          • Partition Keys, Clustering Keys, and Data Locality
          • Tunable Consistency, Hinted Handoff, and Repair
          • Cassandra vs DynamoDB — Trade-offs and When to Choose
          • RabbitMQ vs Kafka vs SQS — Choosing the Right Queue
          • Delivery Guarantees and Idempotent Consumers
          • Flink, Watermarks, and Windowed Aggregation
          • API Gateway — Rate Limiting, Auth, and Routing
          • Kong vs Envoy vs AWS API Gateway
          • The Sidecar Pattern and Service Mesh
          • ZooKeeper — Ephemeral Nodes, Watches, and Leader Election
          • etcd, Consul, and Modern Alternatives
          • When You Need Coordination and When You Don't
          • OLTP vs OLAP — Why Column Storage Wins for Analytics
          • ClickHouse vs Redshift vs BigQuery vs Snowflake
          • ETL, ELT, and the Modern Data Stack
          • Metrics — Prometheus, Pull Model, and PromQL
          • Distributed Tracing — Jaeger, Zipkin, and the Dapper Model
          • Structured Logging and Alerting Pipelines
          • Design a URL Shortener
          • Design a Cloud File Sync Service
          • Design a Photo-Sharing Platform
          • Design an Encrypted Messaging Service
          • Design a Live Stream Comment System
          • Design a Channel-Based Chat Platform
          • Design a Collaborative Text Editor
          • Design a Social Search Engine
          • Design a Proximity Search Service
          • Design a Top-K Trending System
          • Design a News Aggregation Platform
          • Design a Geo-Based Matching Service
          • Design a Type-Ahead Suggestion Service
          • Design a Ticket Booking System
          • Design an Online Auction Platform
          • Design a Stock Brokerage Platform
          • Design a Payment Processing System
          • Design a Flash Sale System
          • Design a Calendar and Scheduling Service
          • Design a Video Streaming Platform
          • Design an Online Code Judge
          • Design a Fitness Activity Tracker
          • Design a Music Streaming Service
          • Design a Distributed Rate Limiter
          • Design a Distributed Cache
          • Design a Distributed Job Scheduler
          • Design a Web Crawler
          • Design a Social Feed System
          • Design a Multi-Channel Notification Service
          • Design a Price Alert Service
          • Design a Real-Time Click Aggregation Pipeline
          • Design a Metrics Monitoring Platform
          • Design a Ride-Sharing Platform
          • Design a Local Delivery Service
          • Design a Real-Time Leaderboard
          • Design a Real-Time Geospatial Heatmap
          • Raft — Leader Election, Log Replication, and Safety
          • Paxos and Multi-Paxos — Simplified
          • Vector Clocks, Lamport Timestamps, and Causal Ordering
          • Bloom Filters — Probabilistic Set Membership
          • HyperLogLog and Count-Min Sketch
          • Skip Lists — The Engine Inside Redis Sorted Sets
          • LSM Trees vs B-Trees — Write-Optimized vs Read-Optimized
          • Geohash, Quadtree, R-tree, S2, and H3 — A Comparison
          • Time-Series Databases — Storage, Compression, and Downsampling
          • Vector Databases — HNSW, IVF, and Similarity Search
          • CRDTs — Conflict-Free Replicated Data Types
          • Distributed Transactions — 2PC, 3PC, and Saga
          • Chain Replication and Alternatives
          • Distributed File Systems — GFS and HDFS
          • Distributed Tracing Internals — The Dapper Model
          • Traffic Control — Token Bucket and Leaky Bucket at Scale
          • Feature Flags and A/B Testing Infrastructure
        • Logical Recursion ↗
        • Structural Recursion ↗
        • Structural Recursion (NP) ↗
        • Introduction
          • Networking Essentials
          • API Design
          • Data Modeling
          • Database Indexing
          • Caching
          • Sharding
          • Consistent Hashing
          • CAP Theorem
          • Numbers to Know
          • Bit.ly
          • Dropbox
          • Local Delivery Service
          • News Aggregator
          • Ticketmaster
          • FB News Feed
          • Tinder
          • LeetCode
          • WhatsApp
          • Yelp
          • Strava
          • Rate Limiter
          • Online Auction
          • FB Live Comments
          • FB Post Search
          • Price Tracking Service
          • Instagram
          • YouTube Top K
          • Uber
          • Robinhood
          • Google Docs
          • Distributed Cache
          • YouTube
          • Job Scheduler
          • Web Crawler
          • Ad Click Aggregator
          • Payment System
          • Metrics Monitoring
          • Real-time Updates
          • Dealing with Contention
          • Multi-step Processes
          • Scaling Reads
          • Scaling Writes
          • Handling Large Blobs
          • Managing Long Running Tasks
          • Redis
          • Elasticsearch
          • Kafka
          • API Gateway
          • Cassandra
          • DynamoDB
          • PostgreSQL
          • Flink
          • ZooKeeper
          • Data Structures for Big Data
          • Vector Databases
          • Time Series Databases
      • Week 1 — Foundations
      • Week 2 — Recursion & Backtracking
      • Week 3 — Trees & Graphs
      • Week 4 — Dynamic Programming I
      • Week 5 — Dynamic Programming II
      • Week 6 — Advanced Graph Algorithms
      • Week 7 — Low Level Design
      • Week 8 — System Design & Interview Prep
        • Classes, Objects, Encapsulation
        • Inheritance vs Composition
        • Polymorphism and Interfaces
        • Abstract Classes vs Interfaces
        • Java Advantages
        • C++ and Python Toolkit
        • KISS
        • DRY and YAGNI
        • Separation of Concerns
        • Single Responsibility
        • Open/Closed
        • Liskov Substitution
        • Interface Segregation
        • Dependency Inversion
        • Anatomy of an LLD Interview
        • Scoping and Requirements
        • Entity Discovery and Demotion
        • The Orchestrator Pattern
        • Derive vs Track State
        • Composite Spherical Regions Algorithm
      • Notes on Cognitive Focus
      • About

    Recursion quiz

    This quiz has moved to the interactive quiz system. Take the quiz here.

    Copyright © 2025 Algo-Science.