BBackend CourseLeroy Labs
0/0
Search the course

Data structures & algorithms in real backends

Big-O for backend work, and where hash maps, trees, heaps, queues, graphs, tries, Bloom filters and consistent hashing actually show up, including inside your own projects.

● intermediateHostel-Web-AppSperoTek (in dev)Report-Manager-2IR3D (Kontentt)

Big-O, the backend view

Operation Complexity Real example
HashMap get/put O(1) avg ConcurrentHashMap of emitters and buckets
B-tree index lookup O(log n) WHERE email = ?
Sequential scan O(n) A missing index
Sort O(n log n) ORDER BY without an index
Nested loop over two lists O(n·m) N+1 queries, or list.contains inside a loop

Where the structures live

Structure Where you meet it
Hash table Java HashMap, Postgres hash joins, Redis, caches
B-tree / B+tree Every Postgres index; filesystems
R-tree / GiST PostGIS spatial index (Hostel)
Inverted index GIN on arrays and tsvector, Elasticsearch
Queue / Deque Hostel’s sliding-window rate limiter (Deque<Long>), thread-pool queues, RabbitMQ
Heap / priority queue Scheduled executors (next job to run), top-K queries, Dijkstra
Tree / recursion RM’s ReportUnit hierarchy; SperoTek’s chart of accounts (parent accounts); recursive CTEs
Graph + DFS/BFS / topological sort Spring’s bean dependency graph and cycle detection, Modulith module cycles, Liquibase ordering, approval chains
Trie Autocomplete, IP routing tables
Bloom filter “Definitely not present” checks: username taken, caches, Cassandra SSTables
Consistent hashing Sharding and distributed caches
Merkle tree Git, replica sync, tamper-evident audit logs
Ring buffer Logging (Log4j2 async appenders use LMAX Disruptor)
Token bucket SperoTek’s Bucket4j rate limiter
IR3D (Kontentt)clip/infrastructure/contentmatching/PerceptualHasher

Perceptual hashing maps similar frames to similar hashes, and Hamming distance compares them. Finding near-duplicates efficiently at scale is a nearest-neighbour search, using BK-trees or LSH (locality-sensitive hashing).

SperoTek (in dev)JournalRules.check (balance) · gap-free numbering

Validating a journal is an O(n) sum over its lines. Gap-free numbering is a serialised counter, which is why it needs a lock (concurrency is an algorithmic constraint too).

How much LeetCode?

For backend interviews, be fluent in:

  • Arrays and strings, hash maps, two pointers, sliding window (which is a rate limiter!).
  • Stacks and queues, BFS/DFS, binary search, heaps (top-K).
  • Basic DP, intervals (booking overlaps!), and topological sort.

You already practise in Desktop/Lexa/DSA.

Check yourself

1. Checking membership in a List inside a loop over another list is…
2. Overlapping booking dates is which classic problem type?
3. Postgres B-tree lookup complexity?