Data Structures

At the end of each article, press the "Mark this article as read" button to have the site remember you've read it.

Stacks

24:20

Stacks

There are many data structures in computing, but stacks are one of the most fundamental – they get used in so many places, often without us even realizing. Helpfully, they are also one of the easiest types to learn, which makes them a great starting point for this new series on data structures.

Linked lists

29:22

Linked lists

If there’s one data structure they just love teaching you at school, it’s linked lists. In this article we’re going to look at why linked lists are so appealing, walk through how to build a linked list with Swift, and look at an alternative approach using enums.

Queues and deques

28:18

Queues and deques

Now that we’ve covered stacks and linked lists, queues and deques ought to be easier. In this article we’ll build both data structures in just a few lines of Swift, then explore interesting additions such as contains().

Trees

31:55

Trees

Trees are an extraordinarily simple, extraordinarily useful data type, and in this article we’ll make a complete tree data type using Swift in just a few minutes. But rather than just stop there, we’re going to do something quite beautiful that I hope will blow your mind while teaching you something useful.

Binary trees

33:11

Binary trees

We already looked at trees, where each node can have zero or more children, and now I want to look at a specialized version called binary trees, where each node has zero, one, or two children. In particular we’re looking to look at how these lead to binary search trees and the remarkable performance advantages they can bring.

Ordered sets

22:31

Ordered sets

Arrays and sets have their own advantages and disadvantages, but what if we could combine them both to make an ordered set? We can! And in this article that’s exactly what we’ll do.

Sorted arrays

15:34

Sorted arrays

A sorted array is one that retains a correct sort order no matter how and when you add items. Although this sounds simple enough to implement, in this article you’ll see that it’s actually quite fun to explore because there are a number of interesting challenges we’ll face.