Clear explanations of key ideas in computer science, one concept at a time.
Topics: All articles | Computer Science Explained | Exam Preparation | Problems and Solutions | Studies and Careers | Competition News

What Is a Stack in Computer Science and How Does Undo Use It?
Follow three edits through an undo history to see what push, pop, and peek do and why a stack reverses the newest edit first. Read more

How to Read a Confusion Matrix for a Spam Filter
A spam filter can make two very different mistakes. Read the axis labels to see which count means spam got through and which means a real message was flagged. Read more

How Does Run Length Encoding Work?
Six black pixels in a row can share one count. But when black and white alternate, storing a count for every pixel can make the encoded row bigger. Read more

Why Does Dijkstra Fail With Negative Weights?
Dijkstra settles a node at distance 2. A route through a node it has not processed yet costs just 1. Three edges show exactly where the algorithm's guarantee breaks. Read more

How Does a Hash Table Work When Two Keys Share a Slot?
Follow two library book IDs into the same slot of a tiny hash table. Then look up each ID by checking the entries in that slot. Read more

What Is a Loop Invariant in a Search for the Largest Number?
A variable called best starts with the first number in a list. Prove that it holds the largest number seen so far, and you can explain why the loop returns the right answer. Read more