




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































vectors + grids
stacks + queues
sets + maps
Object-Oriented Programming
arrays
dynamic memory management
linked data structures
algorithmic testing analysis
recursive problem-solving
C++ basics
Diagnostic
real-world algorithms
Core Tools
User/client Implementation
Object-Oriented Programming
arrays
dynamic memory management
linked data structures
algorithmic testing analysis
recursive problem-solving
C++ basics
Diagnostic
real-world algorithms
Core Tools
Implementation
vectors + grids
stacks + queues
sets + maps
User/client
Today’s
question
Review
(sets and maps)
● A set is a collection of elements with no duplicates.
● Sets are faster than ordered data structures like vectors – since there are no duplicates, it’s faster for them to find things. ○ (Later in the quarter we’ll learn about the details of the underlying implementation that makes this abstraction efficient.) ○ We’ll formally define “faster” on Thursday.
● Sets don’t have indices!
Elements accessible by indices:
● Vectors (1D) ● Grids (2D)
Elements not accessible by indices:
● Queues (FIFO) ● Stacks (LIFO)
● Sets (elements unique) ● Keys (keys unique)
Activity:
Counting Sort
● Sorting is a fundamental topic in computer science and one that we will revisit in more depth later this quarter
● For now, let's consider this question: how would you efficiently sort all the letters in a word in alphabetical order? ○ How can we take advantage of some of the data structures we've recently learned about to meaningfully structure the data that we want to sort?
● Sorting is a fundamental topic in computer science and one that we will revisit in more depth later this quarter
● For now, let's consider this question: how would you efficiently sort all the letters in a word in alphabetical order? ○ How can we take advantage of some of the data structures we've recently learned about to meaningfully structure the data that we want to sort?
● Idea: If we can tally up how many times each of the letters from 'a' to 'z' shows up, we can then build a new string composed of the correct number of 'a's, followed by the correct number of 'b's, … etc.