CS50 Data Structures Overview
- 20Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
20 questions
- 1An abstract data type like a queue or stack offers certain properties and characteristics, but the underlying_____details are left to the programmer.
Hint
Think about the difference between what a data structure does and how it actually works inside the computer.
Answer
implementation
- 2Queues adhere to the_____(first in, first out) property, meaning the first element added is the first one removed.
Hint
Think of a line at a store; the first person in line is the first to be served.
Answer
FIFO
- 3In a stack, the_____(last in, first out) property means the most recently added element is removed first.
Hint
Think of a stack of plates; the last plate placed on top is the first to be taken off.
Answer
LIFO
- 4The two primary operations on a queue are_____and dequeue.
Hint
Think of adding a person to the end of a line and removing them from the front.
Answer
enqueue
- 5The two primary operations on a stack are_____and pop.
Hint
Think of placing a plate onto a stack and removing the top plate.
Answer
push
- 6A key characteristic of an array is that it stores data_____in memory.
Hint
Think about memory addresses of consecutive elements in an array.
Answer
contiguously
- 7When a fixed-size array is full and a new element is needed, the array must be copied to a new, larger chunk of memory, which takes_____steps.
Hint
Consider the number of elements that need to be moved when resizing.
Answer
O(n)
- 8A linked list node contains two values: the actual data (e.g., an integer) and a_____to the next node in the list.
Hint
This is the mechanism that links nodes together, allowing them to be scattered in memory.
Answer
pointer
- 9When inserting a new node at the beginning of a linked list (prepending), the running time is_____regardless of the list size.
Hint
Think about how many operations are needed regardless of how many nodes are already in the list.
Answer
O(1)
- 10Searching for an element in a singly linked list requires_____time in the worst case.
Hint
Think about how many nodes you might have to visit to find the target.
Answer
O(n)
- 11In a binary search tree, each node has at most two children, and for any node, all values in its left subtree are_____than the node's value.
Hint
Think about the ordering property that enables efficient searching.
Answer
smaller
- 12The recursive search function for a binary search tree checks if the number is less than the root, then searches the_____subtree.
Hint
Remember the property: smaller values go to the left.
Answer
left
- 13A binary search tree can degrade to a linked list if values are inserted in_____order (e.g., 1, 2, 3).
Hint
Think about what happens when each new value is larger than the previous one.
Answer
sorted
- 14A hash table combines an array with_____to handle collisions.
Hint
When two keys hash to the same index, they are stored in a chain starting at that index.
Answer
linked lists
- 15A hash function takes an input (e.g., a name) and returns a_____value that determines where the key-value pair is stored in the hash table.
Hint
Think of the output as a number that maps to an array index.
Answer
hash
- 16In the worst case, a hash table's search time is_____because all keys could collide into the same bucket.
Hint
Consider what happens if every key maps to the same index, forming a long linked list.
Answer
O(n)
- 17A dictionary is an abstract data type that stores_____pairs.
Hint
Think of a real dictionary: words (keys) and definitions (values).
Answer
key-value
- 18A trie (short for retrieval) is a tree of arrays where each node represents a_____of the key.
Hint
Think about how words share common beginnings.
Answer
prefix
- 19Searching for a key in a trie takes_____time, because the number of steps is bounded by the key's length, which is constant.
Hint
Think about the maximum number of steps compared to the number of keys stored.
Answer
O(1)
- 20The main disadvantage of a trie compared to a hash table is its_____usage, as many pointers in each node are null.
Hint
Think about all the empty slots in each array of a trie node.
Answer
memory

Ask anything
We've read this whole study set, so questions about it get the best answers.