Algorithms Problem-Solving
- 54Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
54 questions
- 1For large n, the growth rate of sqrt{n} is slower than the growth rates of both n and n + sqrt{n}, so it is ordered_____.
Hint
Compare the dominant growth rates of the three functions.
Answer
first
Explanation
The square root grows more slowly than a linear function. Also, adding sqrt{n} to n does not change the latter function's asymptotic growth rate.
- 2The functions n and n + sqrt{n} have the same asymptotic growth rate, so they are_____.
Hint
A lower-order additive term does not change a function's leading growth rate.
Answer
asymptotically equivalent
Explanation
Because sqrt{n} grows more slowly than n, the linear term dominates n + sqrt{n}.
- 3A logarithmic factor grows more slowly than any positive-degree polynomial factor; in particular, log n grows more slowly than_____.
Hint
Compare logarithmic growth with powers of n.
Answer
any polynomial
Explanation
For any positive constants a and b, (logn)a is asymptotically smaller than nb.
- 4For positive constants a and b, (logn)a is asymptotically smaller than_____.
Hint
Consider a polynomial with a positive exponent of n.
Answer
any polynomial
Explanation
A logarithm raised to any fixed positive power grows more slowly than a polynomial nb with b>0.
- 5An exponential function eventually grows faster than_____.
Hint
Compare repeated multiplication by a fixed factor with a fixed power of n.
Answer
any polynomial
Explanation
For a fixed base greater than one, exponential growth eventually exceeds every polynomial growth rate.
- 6When comparing two positive functions using their ratio, a ratio that tends to infinity indicates that the numerator grows_____than the denominator.
Hint
The ratio becomes arbitrarily large as the input grows.
Answer
asymptotically faster
Explanation
If the numerator divided by the denominator tends to infinity, the numerator eventually dominates the denominator in growth.
- 7When the ratio of two positive functions tends to zero, the numerator grows_____than the denominator.
Hint
A vanishing ratio means the numerator is negligible relative to the denominator.
Answer
asymptotically slower
Explanation
If the ratio tends to zero, the denominator grows asymptotically faster than the numerator.
- 8When the ratio of two positive functions tends to a positive constant, the functions are_____.
Hint
A constant multiplicative difference does not change asymptotic growth.
Answer
asymptotically equivalent
Explanation
A ratio approaching a positive constant shows that the two functions have the same asymptotic growth rate.
- 9Taking the logarithm of a ratio can make a limit-based comparison of growth rates_____.
Hint
Logarithms turn products into sums and powers into factors.
Answer
easier
Explanation
Taking logarithms can simplify the expression whose limit is being analyzed, while preserving the comparison of growth rates.
- 10The binomial coefficient “n choose k” counts the number of ways to choose_____objects from n objects.
Hint
It counts selections of a specified size from a larger collection.
Answer
k
Explanation
The binomial coefficient counts how many distinct subsets of size k can be selected from a set of n objects.
- 11The factorial formula for a binomial coefficient is k!(n−k)!n!, so the denominator removes the permutations within the chosen group and the_____group.
Hint
The objects are divided into selected and nonselected groups.
Answer
unchosen
Explanation
The numerator counts permutations of all n objects. Dividing by the permutations within the selected group and the remaining group gives the number of selections.
- 12Stirling's approximation estimates n! using a quantity proportional to n(n/e)n; its logarithmic growth is theta of_____.
Hint
Take the logarithm of the dominant power in the approximation.
Answer
nlogn
Explanation
Taking the logarithm of Stirling's approximation gives a dominant term nlogn; the other terms have smaller growth.
- 13For a fixed positive integer k, the binomial coefficient “n choose k” grows asymptotically like a polynomial with leading degree_____.
Hint
Expand the factorial ratio and count the number of factors that grow with n.
Answer
k
Explanation
For fixed k, the numerator after cancellation contains k factors of order n, while k! is constant. Thus the binomial coefficient is asymptotically proportional to nk.
- 14Using Stirling's approximation, the central binomial coefficient “n choose n/2” grows asymptotically like_____divided by n.
Hint
The exponential factor in the simplified approximation has base two.
Answer
2n
Explanation
Applying Stirling's approximation to the factorials in the central binomial coefficient gives growth proportional to 2n/n.
- 15A data structure's public interface specifies which operations are available, while its_____specifies how those operations are carried out.
Hint
Arrays and linked lists can realize the same interface in different ways.
Answer
implementation
Explanation
An interface describes supported behavior abstractly; an implementation is the underlying representation and mechanisms used to provide that behavior.
- 16A sequence interface organizes items according to an_____order determined by their positions, not by the items' values.
Hint
The order comes from how items are arranged in the sequence.
Answer
extrinsic
Explanation
A sequence has a first item, a next item, and a last item based on position. This order is independent of the nature or value of the stored items.
- 17A sequence can be implemented with either an array or a linked list because these are different_____of the same abstract interface.
Hint
The interface does not prescribe the underlying representation.
Answer
implementations
Explanation
An array and a linked list can both store an ordered sequence while providing the operations required by the sequence interface.
- 18A black box data structure can be used through its stated operations without needing to know its internal_____.
Hint
Focus on the difference between a public interface and hidden internals.
Answer
implementation
Explanation
Treating a structure as a black box means relying on its abstract interface and guarantees rather than inspecting how it works internally.
- 19If a sequence structure supports insertion and deletion at both ends in constant time, swapping the first and last items can be done by deleting both and then_____them in opposite positions.
Hint
Temporarily save the two removed items, then use the end operations.
Answer
inserting
Explanation
Delete the first and last items, save their values, insert the former last item at the front, and insert the former first item at the back.
- 20If swap ends uses a fixed number of operations and each operation takes constant time, its running time is_____.
Hint
A fixed number of constant-time steps does not grow with sequence length.
Answer
constant time
Explanation
The total cost is a constant number of constant-time operations, so it is constant regardless of the sequence size.
- 21A delete operation in the described sequence interface returns_____that was removed.
Hint
The returned value can be saved temporarily for a later insertion.
Answer
the deleted item
Explanation
The delete operations return the deleted item, allowing an algorithm to retain and reuse it.
- 22To shift the first k items of a sequence to its back, repeatedly delete the first item and_____it at the back.
Hint
Move one leading item to the opposite end on each repetition.
Answer
insert
Explanation
Each repetition removes the current first item and appends it at the back. After k repetitions, the original first k items have moved behind the remaining items.
- 23A recursive shift operation should stop without moving items when k is_____.
Hint
This is the base case in which no items need to be shifted.
Answer
zero
Explanation
When k is zero, the requested shift is empty, so the operation returns without changing the sequence.
- 24After moving one item in a recursive shift, the remaining subproblem is to shift_____items.
Hint
One of the requested items has already been moved.
Answer
k−1
Explanation
Moving one item reduces the number of items still to move from k to k−1. The algorithm then applies itself to the smaller subproblem.
- 25A recursive algorithm is often easier to reason about when each call handles a smaller subproblem and maintains a clear_____.
Hint
This is a property that remains true as the algorithm proceeds.
Answer
invariant
Explanation
A maintained invariant helps explain why each recursive step preserves correctness while reducing the problem toward a base case.
- 26If each recursive shift call performs constant work and the input parameter decreases by one per call, shifting k items takes_____time.
Hint
Count how many calls are needed to reach the base case.
Answer
order k
Explanation
The recursion makes a number of calls proportional to k, and each call performs constant work, so the running time is proportional to k.
- 27When presenting an algorithm, prose or pseudocode is useful only if the reader can understand what the variables and steps_____.
Hint
The goal is to communicate the algorithm clearly, not merely to write code-like text.
Answer
mean
Explanation
A description must make the algorithm's actions and the roles of its variables understandable; unclear pseudocode does not adequately communicate the method.
- 28A nontrivial algorithm should generally include an argument that it is_____.
Hint
The argument should show that the method achieves the requested result.
Answer
correct
Explanation
For nontrivial algorithms, especially recursive ones, a correctness argument explains why the algorithm produces the required output.
- 29A dynamic array supports worst-case constant-time_____by using direct access to positions.
Hint
This operation retrieves an item at a specified position.
Answer
indexing
Explanation
An array can access a position using its index directly, giving worst-case constant-time indexing in the described model.
- 30In the described dynamic array, insertion and removal at the back take_____constant time.
Hint
Occasional expensive resizing is balanced against many inexpensive operations.
Answer
amortized
Explanation
A resizing operation can take linear time, but over a sequence of operations, the average cost per end operation is constant.
- 31Insertion at the front of an array is inefficient because existing items may need to be_____.
Hint
Making room at the beginning changes the positions of the stored items.
Answer
shifted
Explanation
To insert at the front of a contiguous array, the existing elements generally must move to make space for the new first item.
- 32A linked list can support insertion and deletion at both ends in_____time when the required end references are maintained.
Hint
End operations can change a few links without shifting all the items.
Answer
constant
Explanation
A linked list can add or remove an end item by updating a constant number of pointers, provided the relevant ends are accessible.
- 33Unlike an array, finding an arbitrary item in a linked list may take_____time because pointers must be followed one by one.
Hint
The search may traverse a number of nodes proportional to the list length.
Answer
linear
Explanation
Linked-list nodes need not be adjacent in memory, so reaching a position generally requires following the chain of next pointers.
- 34Amortized analysis bounds the total cost of a sequence of operations rather than requiring every individual operation to be_____.
Hint
Some operations can be expensive while the sequence as a whole remains efficient.
Answer
fast
Explanation
An individual operation may take a long time, such as a resize, while the total cost over many operations is still bounded efficiently.
- 35If an operation is amortized constant time, then m such operations take total time_____in the stated bound.
Hint
Multiply the constant amortized cost by the number of operations.
Answer
O(m)
Explanation
The total cost of m operations is bounded by a constant times m, even if some individual operations are more expensive.
- 36Amortized running time is different from average-case running time because it does not require averaging over a_____of possible inputs.
Hint
Average-case analysis depends on assumptions about which inputs are likely.
Answer
distribution
Explanation
Amortized analysis studies the total cost of a sequence of operations on a data structure. Average-case analysis instead averages over inputs according to a distribution.
- 37Leaving extra capacity at the back of a dynamic array delays rebuilding until a linear number of_____have occurred.
Hint
The reserved space absorbs operations before the array must grow again.
Answer
insertions
Explanation
With a linear amount of spare capacity, a linear number of insertions can occur before another expansion is necessary.
- 38When a dynamic array is expanded after filling its capacity, the expensive copying cost can be spread across the many inexpensive_____since the previous expansion.
Hint
Use the earlier cheap work to pay for the occasional costly rebuild.
Answer
operations
Explanation
The charging argument assigns portions of the expensive resize cost to the operations that occurred since the previous resize, yielding constant amortized cost.
- 39If a dynamic array is only shrunk when its occupancy is sufficiently low, it avoids immediately growing again after a small number of_____.
Hint
A little unused capacity after shrinking helps prevent repeated rebuilding.
Answer
insertions
Explanation
Shrinking to leave spare capacity creates a buffer, so a few subsequent insertions do not immediately force an expansion.
- 40A dynamic sequence with efficient operations at both ends can reserve a linear amount of extra space at the_____and the back.
Hint
The two ends need room for insertions in both directions.
Answer
front
Explanation
Keeping spare capacity at both ends lets insertions proceed without immediately shifting or rebuilding the whole structure.
- 41When a two-ended dynamic array uses a linear amount of spare space, it can perform a linear number of end operations before needing to_____.
Hint
The reserved space postpones the costly capacity adjustment.
Answer
rebuild
Explanation
The spare capacity absorbs many insertions or removals; after a linear number of operations, the structure can be rebuilt and the amortized argument applied again.
- 42A dynamic sequence can be represented using two dynamic arrays, one for each half, with one half viewed in_____order.
Hint
The halves can face toward the middle while supporting opposite ends.
Answer
reverse
Explanation
One array can store its portion in reverse order, so its array end corresponds to the opposite end of the overall sequence.
- 43When indexing a sequence represented by two arrays, the algorithm must use_____to map a sequence position to the appropriate array position.
Hint
Positions in the overall sequence do not directly equal positions in either component array.
Answer
index arithmetic
Explanation
The representation divides the sequence across two arrays, so accessing items requires calculating their location from the relevant array and orientation.
- 44If one of the two arrays becomes empty, the remaining items can be split between newly arranged arrays to restore the representation's_____.
Hint
The representation requires both portions to be arranged in a usable way.
Answer
invariant
Explanation
Reorganizing the remaining items restores the intended two-part arrangement, allowing end operations to continue under the same representation rules.
- 45Rebuilding the two-array representation after many end operations can still yield amortized constant-time operations because the rebuild cost is paid for by a linear number of prior_____operations.
Hint
The costly rebuild follows a substantial number of inexpensive steps.
Answer
constant-time
Explanation
A linear-time rebuild is amortized across the linear number of constant-time operations that occurred before the representation needed repair.
- 46A singly linked list node stores an item and a_____pointer to the next node.
Hint
This field links the node forward through the list.
Answer
next
Explanation
Each node in a singly linked list contains its item and a pointer to the next node in the sequence.
- 47The list-level information described for a singly linked list includes its size and a_____pointing to the first node.
Hint
This reference marks the beginning of the list.
Answer
head
Explanation
The linked list stores its size and its head, which points to the first node.
- 48To reverse the order of the last half of a list containing 2n nodes, first locate the_____node.
Hint
This node marks the end of the first half.
Answer
nth
Explanation
The nth node separates the first n nodes from the final n nodes that must be reversed.
- 49When reversing linked-list pointers one node at a time, save the current node's original next pointer before_____it.
Hint
The saved reference is needed to continue traversing the unreversed portion.
Answer
changing
Explanation
After changing a next pointer to point backward, the original forward link would otherwise be lost. Saving it first allows traversal to continue.
- 50During pointer reversal, each node after the midpoint is redirected to point to its_____node rather than its original successor.
Hint
The links are changed to run backward through the segment.
Answer
previous
Explanation
Reversing a singly linked segment changes each node's next pointer to refer to the node that preceded it in the original order.
- 51After reversing the second half, reconnect the midpoint node to the new_____of that reversed segment.
Hint
The first node of the reversed portion used to be its last node.
Answer
head
Explanation
The midpoint's next pointer must point to the original final node of the second half, which becomes the head of the reversed segment.
- 52After reversing the final segment, the node that was originally last must have its next pointer set to_____.
Hint
This node becomes the endpoint of the whole list.
Answer
none
Explanation
The original last node becomes the last node of the reversed segment, so its next pointer must indicate that there is no following node.
- 53Under a restriction against creating nodes or nonconstant-sized auxiliary structures, the linked-list reversal must rearrange existing_____.
Hint
Change the links rather than copying the items into another collection.
Answer
nodes
Explanation
The algorithm is required to modify the existing linked structure using only a constant amount of additional storage, so it relinks the original nodes.
- 54Locating the midpoint and reversing the final half by traversing its nodes takes_____time overall.
Hint
The algorithm visits a number of nodes proportional to the list size.
Answer
linear
Explanation
Finding the midpoint requires a traversal, and reversing the second half visits each of its nodes once, so the total work is proportional to the list length.

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