1. Home
  2. Explore
  3. Computer Science
  4. Algorithms Problem-Solving

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Algorithms Problem-Solving

  • 54Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Asymptotic Analysis
For large nnn, the growth rate of sqrt{n} is slower than the growth rates of both nnn and n + sqrt{n}, so it is ordered
.

54 questions

  1. 1
    For large nnn, the growth rate of sqrt{n} is slower than the growth rates of both nnn 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 nnn does not change the latter function's asymptotic growth rate.

  2. 2
    The functions nnn 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 nnn, the linear term dominates n + sqrt{n}.

  3. 3
    A 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 nnn.

    Answer

    any polynomial

    Explanation

    For any positive constants aaa and bbb, (log⁡n)a(\log n)^a(logn)a is asymptotically smaller than nbn^bnb.

  4. 4
    For positive constants aaa and bbb, (log⁡n)a(\log n)^a(logn)a is asymptotically smaller than
    _____
    .
    Hint

    Consider a polynomial with a positive exponent of nnn.

    Answer

    any polynomial

    Explanation

    A logarithm raised to any fixed positive power grows more slowly than a polynomial nbn^bnb with b>0b > 0b>0.

  5. 5
    An exponential function eventually grows faster than
    _____
    .
    Hint

    Compare repeated multiplication by a fixed factor with a fixed power of nnn.

    Answer

    any polynomial

    Explanation

    For a fixed base greater than one, exponential growth eventually exceeds every polynomial growth rate.

  6. 6
    When 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.

  7. 7
    When 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.

  8. 8
    When 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.

  9. 9
    Taking 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.

  10. 10
    The binomial coefficient “nnn choose kkk” counts the number of ways to choose
    _____
    objects from nnn objects.
    Hint

    It counts selections of a specified size from a larger collection.

    Answer

    kkk

    Explanation

    The binomial coefficient counts how many distinct subsets of size kkk can be selected from a set of nnn objects.

  11. 11
    The factorial formula for a binomial coefficient is n!k!(n−k)!\frac{n!}{k!(n-k)!}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 nnn objects. Dividing by the permutations within the selected group and the remaining group gives the number of selections.

  12. 12
    Stirling's approximation estimates n!n!n! using a quantity proportional to n(n/e)n\sqrt{n}(n/e)^nn​(n/e)n; its logarithmic growth is theta of
    _____
    .
    Hint

    Take the logarithm of the dominant power in the approximation.

    Answer

    nlog⁡nn \log nnlogn

    Explanation

    Taking the logarithm of Stirling's approximation gives a dominant term nlog⁡nn\log nnlogn; the other terms have smaller growth.

  13. 13
    For a fixed positive integer kkk, the binomial coefficient “nnn choose kkk” grows asymptotically like a polynomial with leading degree
    _____
    .
    Hint

    Expand the factorial ratio and count the number of factors that grow with nnn.

    Answer

    kkk

    Explanation

    For fixed kkk, the numerator after cancellation contains kkk factors of order nnn, while k!k!k! is constant. Thus the binomial coefficient is asymptotically proportional to nkn^knk.

  14. 14
    Using Stirling's approximation, the central binomial coefficient “nnn choose n/2n/2n/2” grows asymptotically like
    _____
    divided by n\sqrt{n}n​.
    Hint

    The exponential factor in the simplified approximation has base two.

    Answer

    2n2^n2n

    Explanation

    Applying Stirling's approximation to the factorials in the central binomial coefficient gives growth proportional to 2n/n2^n/\sqrt{n}2n/n​.

  15. 15
    A 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.

  16. 16
    A 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.

  17. 17
    A 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.

  18. 18
    A 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.

  19. 19
    If 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.

  20. 20
    If 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.

  21. 21
    A 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.

  22. 22
    To shift the first kkk 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 kkk repetitions, the original first kkk items have moved behind the remaining items.

  23. 23
    A recursive shift operation should stop without moving items when kkk is
    _____
    .
    Hint

    This is the base case in which no items need to be shifted.

    Answer

    zero

    Explanation

    When kkk is zero, the requested shift is empty, so the operation returns without changing the sequence.

  24. 24
    After 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−1k - 1k−1

    Explanation

    Moving one item reduces the number of items still to move from kkk to k−1k - 1k−1. The algorithm then applies itself to the smaller subproblem.

  25. 25
    A 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.

  26. 26
    If each recursive shift call performs constant work and the input parameter decreases by one per call, shifting kkk items takes
    _____
    time.
    Hint

    Count how many calls are needed to reach the base case.

    Answer

    order kkk

    Explanation

    The recursion makes a number of calls proportional to kkk, and each call performs constant work, so the running time is proportional to kkk.

  27. 27
    When 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.

  28. 28
    A 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.

  29. 29
    A 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.

  30. 30
    In 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.

  31. 31
    Insertion 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.

  32. 32
    A 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.

  33. 33
    Unlike 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.

  34. 34
    Amortized 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.

  35. 35
    If an operation is amortized constant time, then mmm such operations take total time
    _____
    in the stated bound.
    Hint

    Multiply the constant amortized cost by the number of operations.

    Answer

    O(m)O(m)O(m)

    Explanation

    The total cost of mmm operations is bounded by a constant times mmm, even if some individual operations are more expensive.

  36. 36
    Amortized 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.

  37. 37
    Leaving 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.

  38. 38
    When 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.

  39. 39
    If 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.

  40. 40
    A 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.

  41. 41
    When 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.

  42. 42
    A 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.

  43. 43
    When 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.

  44. 44
    If 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.

  45. 45
    Rebuilding 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.

  46. 46
    A 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.

  47. 47
    The 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.

  48. 48
    To reverse the order of the last half of a list containing 2n2n2n nodes, first locate the
    _____
    node.
    Hint

    This node marks the end of the first half.

    Answer

    nnnth

    Explanation

    The nnnth node separates the first nnn nodes from the final nnn nodes that must be reversed.

  49. 49
    When 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.

  50. 50
    During 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.

  51. 51
    After 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.

  52. 52
    After 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.

  53. 53
    Under 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.

  54. 54
    Locating 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.

1 of 54
Question 1 of 54

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent