Practice Flashcards
Flip to reveal answersWhat two guarantees does a set make?
Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.
All 5 Flashcards — Sets
Sign up free to track progress and get spaced-repetition review schedules.
Question
What two guarantees does a set make?
Answer
**No duplicates** and **no order** — both enforced by the structure rather than by the programmer.
Question
Union, intersection, difference — what are they?
Answer
**Union** everything in either · **intersection** only what is in both · **difference** in the first and not the second.
Question
Is a − b the same as b − a?
Answer
**No.** With a = {1,2,3} and b = {3,4}: a − b = {1,2} but b − a = {4}. Difference is the one operation whose order matters.
Question
Why is set membership O(1) on average?
Answer
The value itself computes where it would be stored, so nothing is searched for. A list must compare against every element — O(n).
Question
When is a set the wrong choice?
Answer
When the program needs **position or order** — a set has neither, and no index to ask with.
Read the notes
Full study notes for Sets
Topic 8.1 hub
Fundamentals of ADTs
More from Topic 8.1
All flashcards in this topic
Computer Science exam skills
Paper structures & tips
Track your progress with spaced repetition
Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.
Start Free