Data Structures & Algorithms Basics
- 32Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
32 questions
- 1The primary purpose of Big O notation is to describe the_____of an algorithm.
Hint
Consider what aspect of an algorithm we evaluate as input grows.
Answer
performance
- 2An algorithm that prints only the first element of an array has a runtime complexity of_____.
Hint
Think about whether the runtime depends on the array size.
Answer
O(1)
- 3A loop that iterates over all n elements of an array runs in_____time.
Hint
Consider how runtime changes as n increases.
Answer
O(n)
- 4When simplifying Big O expressions, we drop constants because we only need an_____of the cost relative to input size.
Hint
Think about what Big O provides—exact or rough estimate?
Answer
approximation
- 5For an algorithm with two separate loops over two different input arrays of sizes n and m, the runtime complexity is_____.
Hint
Think about how runtime depends on both inputs individually.
Answer
O(n + m)
- 6Nested loops that each iterate over the same array result in_____runtime complexity.
Hint
Consider the number of operations per outer loop iteration.
Answer
O(n^2)
- 7Binary search on a sorted array runs in_____time.
Hint
Think about how the search space shrinks with each step.
Answer
O(log n)
- 8An algorithm with exponential growth is represented as_____.
Hint
Think of the opposite of logarithmic growth—very fast growth.
Answer
O(2^n)
- 9Space complexity that is constant, independent of input size, is denoted as_____.
Hint
Consider if the extra memory needed grows with input.
Answer
O(1)
- 10When analyzing space complexity, we count only the_____space allocated by the algorithm, not the input itself.
Hint
Think of the extra memory beyond the input data.
Answer
additional
- 11In an array, items are stored_____in memory.
Hint
Think about how array elements are arranged in RAM.
Answer
sequentially
- 12Looking up an element in an array by its index has a runtime complexity of_____.
Hint
Consider the memory address calculation.
Answer
O(1)
- 13Arrays in Java have a_____size that cannot be changed after creation.
Hint
Think about whether you can add elements beyond initial capacity.
Answer
fixed
- 14Removing the first element from an array requires shifting all remaining elements, making it an_____operation.
Hint
Consider the number of shifts needed in the worst case.
Answer
O(n)
- 15In Java, the_____
lengthfield of an array returns theof the array.Hint
Think about what number that field holds.
Answer
size
- 16A dynamic array (like our custom_____
Arrayclass) uses acountfield to track the number ofitems.Hint
Distinguish between capacity and number of elements stored.
Answer
actual
- 17When our dynamic array is full and a new item is inserted, we create a new array of_____the current size.
Hint
Think about the growth factor used in the example.
Answer
twice
- 18In the_____
removeAtmethod of our dynamic array, after shifting elements we decrement thefield.Hint
Which field tracks the number of items?
Answer
count
- 19The_____
indexOfmethod in our dynamic array has a worst-case runtime complexity of.Hint
Consider the case when the item is at the end or not present.
Answer
O(n)
- 20Java's_____
Vectorclass grows bypercent of its size when full.Hint
Think about the growth factor: double? Or 50%?
Answer
100
- 21Java's_____
ArrayListgrows bypercent of its size when full.Hint
This is the growth factor for ArrayList.
Answer
50
- 22Methods in Java's_____
Vectorclass are, meaning they can only be accessed by one thread at a time.Hint
Think about thread safety.
Answer
synchronized
- 23A linked list consists of a group of_____in sequence, each holding a value and a reference to the next node.
Hint
What are the building blocks of a linked list?
Answer
nodes
- 24The first node in a linked list is called the_____.
Hint
Think of the starting point of the list.
Answer
head
- 25The last node in a linked list is called the_____.
Hint
Think of the end of the list.
Answer
tail
- 26In a singly linked list, looking up an element by index has a runtime complexity of_____.
Hint
Consider whether you can access by index directly.
Answer
O(n)
- 27Inserting a new node at the beginning of a linked list is an_____operation.
Hint
Think about whether you need to shift elements.
Answer
O(1)
- 28Inserting a node at the end of a linked list is_____if we maintain a tail reference.
Hint
Consider if we need to traverse the list.
Answer
O(1)
- 29Deleting the first node from a linked list is an_____operation.
Hint
Think about which references need updating.
Answer
O(1)
- 30Deleting the last node from a singly linked list is an_____operation because we need to find the node before the tail.
Hint
Consider the need to traverse the list.
Answer
O(n)
- 31In our custom_____
LinkedListclass, theisEmptymethod returns true ifis null.Hint
Which field indicates an empty list?
Answer
first
- 32When removing the only node from a linked list, we set both first and last to_____.
Hint
What should the references be for an empty list?
Answer
null

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