CompTIA Tech+ (FC0-U71)Software Development ConceptsEasy

A developer is creating a program that needs to store a collection of unique email addresses. Which of the following data structures is most suitable for this requirement?

  1. ASet
  2. BList
  3. CDictionary
  4. DTuple
Show answer & explanation

Correct answer: A. Set

A Set is a data structure specifically designed to store unique elements, automatically handling duplicate entries. This directly addresses the requirement for a collection of unique email addresses.

Why the other options are wrong

  • B. A List can store duplicate elements, which is not suitable for unique email addresses.
  • C. A Dictionary stores key-value pairs and is not primarily designed for a simple collection of unique items.
  • D. A Tuple is an immutable, ordered collection that can store duplicates.

Set Data Structure

A Set is an unordered collection of unique elements. It is commonly used when membership testing, removing duplicates, and mathematical set operations (union, intersection, difference) are desired.

  • Stores only unique elements
  • Elements are unordered
  • Supports fast membership testing

Memory trick: Unique items, think 'Set' them apart!

More Software Development Concepts questions