0
0
Intro to Computingfundamentals~20 mins

Choosing the right data structure in Intro to Computing - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Data Structure Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Choosing the best data structure for fast lookup

You want to store a collection of unique items and check if an item exists quickly. Which data structure is best?

AStack because it adds and removes items from one end
BList (array) because it keeps items in order
CSet because it allows fast membership testing
DQueue because it processes items in order
Attempts:
2 left
💡 Hint

Think about which structure lets you check if an item is inside without looking at every element.

Comparison
intermediate
2:00remaining
Comparing list and dictionary for data storage

You need to store student names and their grades. Which data structure is better to quickly find a student's grade by name?

ADictionary with names as keys and grades as values
BList of tuples (name, grade) because it keeps data together
CSet of names because it stores unique names
DQueue of grades because it processes grades in order
Attempts:
2 left
💡 Hint

Think about which structure lets you find a grade by name without searching through all items.

trace
advanced
2:00remaining
Trace the output of stack operations

Given the following operations on an empty stack, what is the final content of the stack?

Intro to Computing
stack = []
stack.append(10)
stack.append(20)
stack.pop()
stack.append(30)
stack.pop()
stack.append(40)
A[10, 40]
B[10, 20, 30, 40]
C[40]
D[10, 20]
Attempts:
2 left
💡 Hint

Remember that pop() removes the last item added (LIFO).

identification
advanced
2:00remaining
Identify the data structure from behavior

You have a data structure that adds items at one end and removes items from the other end, processing items in the order they were added. What is it?

AStack
BSet
CDictionary
DQueue
Attempts:
2 left
💡 Hint

Think about the order items come out compared to the order they went in.

🚀 Application
expert
3:00remaining
Choosing data structure for a phone book application

You are designing a phone book app that stores names and phone numbers. Users often search by name, add new contacts, and delete contacts. Which data structure is best to use internally?

AList of tuples (name, number) because it keeps order
BDictionary with names as keys and numbers as values for fast search, add, and delete
CSet of names because it stores unique names
DStack because it allows adding and removing contacts easily
Attempts:
2 left
💡 Hint

Consider which structure supports fast search, addition, and deletion by key.