The Cardinality of Natural Numbers and Integers

Both the set of natural numbers and the set of integers are infinite in size. Amazingly, though, they’re exactly the same size. In this blog post, we’ll explore a technique for showing that these two infinite-sized sets have equal cardinality: creating a bijection between them. We’ll use this technique to show that, counter to all intuition, there are exactly as many natural numbers as there are integers.

The Ambiguous Subset Symbol

A common question students face on exams is to determine whether one set, A, is a subset of another set, B. Similarly, a question might ask if set A is a strict subset of B. Questions like these often contain symbols that look similar, and one symbol that has an ambiguous meaning altogether. In this blog post, we work to demystify the symbols used for subsets and strict subsets, to help us better understand different textbooks and online resources on the topic.

Helper Methods and Code Readability

Helper methods, or helper functions, are smaller pieces of code that perform part of an overall task. Often, when we write helper methods, it’s because we want to factor out a piece of code that’s common across multiple higher-level methods. But, we shouldn’t be afraid to write helper methods just for the sake of improved readability in a single algorithm as well.

Aborting on Programming Errors

Programming errors can be as small and subtle as an off-by-one error in a loop, or as large as a flaw in the implementation or design of an important algorithm. What should our code do when it runs into this type of error? In most cases, we shouldn’t be afraid just to make our program abort.