Queue
A linear structure where the first element in is the first out, like a line at the bank.
Example
A, B and C join the line. A is served first, then B and finally C.
Test yourself: Queue
Queues
In a queue, the first element in is the ___ out.
A, B and C go in. A comes out 1st, B 2nd and C 3rd: the same order they arrived in.
Queues
You enqueue 5, 8 and 2 and dequeue twice. What's left in the queue is ___.
5 and 8 come out, since they arrived first. Only 2 is left.
Queues
What do you need to keep so enqueueing is O(1) in a linked list?
Without that reference, enqueueing in a queue of 10,000 would mean walking all 10,000 nodes to the end.
0/3
â–¶ PlayLessons that use it
DNS records
Each domain's instructions
Kinds of load balancers
Not all load balancers are alike
Evicting and spreading the cache
The cache fills up
Iteration and recursion
2 ways to repeat
Space complexity
How much memory it asks for
Types of structures
How they relate and where they live
Arrays
Adjacent cells
Linked lists
Links of a chain
Queues
First in, first out
Deques
In and out at both ends
Walking a tree
By levels or by branches
Trees in an array
No references, just math
Heaps
The smallest, always on top
Walking a graph
BFS and DFS, now with cycles
Message brokers
A middleman for messages
Message queues
Don't keep them waiting
Publish-subscribe
1 message, many listeners
Service bus (ESB)
One hub to integrate everything
Event-driven architecture
Announcing what happened
Rate limiting
A cap on requests
Rate limiting algorithms
5 ways to count
Generating unique keys
Where 3I71d3o comes from
Designing WhatsApp
2 billion messages a day
Designing Netflix
1 billion videos watched a day
