Week 3: Algorithms
- 34Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
34 questions
- 1In linear search, after checking every element without finding the target, the algorithm returns_____.
Hint
Think about the Boolean value returned when the search fails.
Answer
false
- 2Binary search requires the data to be_____in order to work correctly.
Hint
What property of the phone book allowed divide-and-conquer?
Answer
sorted
- 3In binary search, if the target is less than the middle element, the algorithm searches the_____half.
Hint
Which side contains smaller numbers?
Answer
left
- 4Returning false inside the linear search loop (instead of after it) causes the function to return_____prematurely.
Hint
What Boolean value is returned incorrectly on the first mismatch?
Answer
false
- 5The base case in recursive binary search occurs when_____doors are left.
Hint
When can we definitively say the target is absent?
Answer
no
- 6Big O notation describes the_____bound on an algorithm's running time.
Hint
Think 'worst-case' or 'maximum' steps.
Answer
upper
- 7Linear search in the worst case has a running time of O(_____).
Hint
It may need to check every element.
Answer
n
- 8Binary search in the worst case has a running time of O(_____).
Hint
Think about dividing the problem in half repeatedly.
Answer
log n
- 9The symbol for the lower bound on running time is_____.
Hint
It's a Greek letter often used for 'best-case' scenarios.
Answer
omega
- 10When an algorithm's upper and lower bounds are the same, we say it is_____of that function.
Hint
It's the Greek letter that represents both O and Ω together.
Answer
theta
- 11Selection sort has a worst-case running time of O(_____).
Hint
Think about nested loops: one to pick each element, one to find the smallest.
Answer
n²
- 12In selection sort, at each step we find the_____element in the unsorted portion.
Hint
What value are we looking for to place at the front?
Answer
smallest
- 13Bubble sort works by comparing_____elements and swapping them if they are out of order.
Hint
Think of neighbors in the array.
Answer
adjacent
- 14An optimization for bubble sort is to stop early if a pass makes_____swaps.
Hint
If we check all pairs and none are swapped, what does that mean?
Answer
no
- 15The worst-case running time of bubble sort (without early stop) is O(_____).
Hint
It uses nested loops similar to selection sort.
Answer
n²
- 16Merge sort has a running time of O(_____).
Hint
Think about dividing and then merging.
Answer
n log n
- 17The three steps of merge sort are: sort the left half, sort the right half, and_____the sorted halves.
Hint
It's the step that combines two sorted lists into one.
Answer
merge
- 18The number of levels in merge sort's recursion tree is log₂_____.
Hint
How many times can you halve n until you get to 1?
Answer
n
- 19Merge sort requires additional_____to perform the merge step, unlike selection sort.
Hint
Yuliia used extra shelves to hold numbers temporarily.
Answer
space
- 20In C, an array's elements are stored_____in memory.
Hint
They are placed side-by-side without gaps.
Answer
contiguously
- 21If an array has n elements, the last element is at index_____.
Hint
Remember zero-indexing.
Answer
n-1
- 22To iterate over all elements of an array of size n, a for loop condition is typically i <_____.
Hint
The loop should stop before the index goes out of bounds.
Answer
n
- 23In the linear search C code, after finding the target, the program returns 0 to signal_____.
Hint
What return value indicates everything went well?
Answer
success
- 24An array can be initialized with specific values by enclosing them in_____braces.
Hint
These braces look like { and }.
Answer
curly
- 25If an array is not initialized, its elements contain_____values.
Hint
What leftover data might be in that memory?
Answer
garbage
- 26The function used to compare two strings in C is_____.
Hint
It's in the string.h library and returns an integer.
Answer
strcmp
- 27The strcmp function returns_____if the two strings are equal.
Hint
It's a specific integer value, not non-zero.
Answer
0
- 28To use strcmp, you must include the header file_____.
Hint
It's the header for string manipulation functions.
Answer
string.h
- 29A struct allows you to create a custom data type that_____multiple data types together.
Hint
It bundles related variables under one name.
Answer
encapsulates
- 30To access a field of a struct variable, you use the_____operator.
Hint
It's a period between the variable name and field name.
Answer
dot
- 31A recursive function is one that calls_____.
Hint
It's a self-referential definition.
Answer
itself
- 32In a recursive algorithm, the condition that stops the recursion is called the_____case.
Hint
It's the simplest instance that can be solved directly.
Answer
base
- 33In the recursive implementation of drawing a pyramid, the base case is when height equals_____.
Hint
What height pyramid requires no bricks?
Answer
0
- 34The iterative approach uses loops, while the recursive approach uses_____calls.
Hint
What kind of calls does recursion rely on?
Answer
function

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