Skip to main content

Sets

Sets are a simple, nifty little data structure. They're similar to arrays with one key difference: They only hold unique values.

There are two components to this lesson:

  1. myGA module: Sets
    • If the above link does not take you to the correct module, you can find the lesson in your myGA dashboard.
  2. In-Class Exercise: Implementing a Set

The myGA module contains a link to an exercise in CodePen. The code in CodePen is the exact same as the code in the in-class exercises. Try out the exercise in CodePen and see how far you can get with it. Leave off where you get stuck and we'll review the solution in class.

Learning Objectives

By the end of this lesson, you'll be able to:

  • Define a set and how it’s used in programming.
  • Distinguish between a set, an array, and a linked list.
  • Implement a set and common methods used in sets.

Prerequisites

  • Big O Notation

  • Linked Lists

Duration

1.5 hours total:

  • 0.5 hour myGA
  • 1 hour in class

Additional Resources