1. Home
  2. Explore
  3. Computer Science
  4. Algorithm Complexity Analysis

Study methods

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

Algorithm Complexity Analysis

  • 65Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Search Algorithms
A search algorithm is used to find an item or group of items from a
.

65 questions

  1. 1
    A search algorithm is used to find an item or group of items from a
    _____
    .
    Hint

    Think of the set of possible items being examined.

    Answer

    collection

  2. 2
    A collection that is represented through a range of possible values rather than stored items is called an
    _____
    collection.
    Hint

    Square-root approximation was an example involving possible values rather than a stored list.

    Answer

    implicit

  3. 3
    A collection containing explicitly stored data records, such as student records, is an
    _____
    collection.
    Hint

    The data items are directly present and can be examined one by one.

    Answer

    explicit

  4. 4
    Exhaustive enumeration, bisection search for square roots, and Newton-Raphson are examples of search over an
    _____
    collection.
    Hint

    These methods search among possible numerical values.

    Answer

    implicit

  5. 5
    Linear search examines list elements one at a time until it finds the target or reaches the
    _____
    of the list.
    Hint

    This is a sequential walk through every possible position.

    Answer

    end

  6. 6
    Linear search can operate on a list in
    _____
    order.
    Hint

    The method does not rely on elements being arranged from small to large.

    Answer

    arbitrary

  7. 7
    The worst-case complexity of linear search is
    _____
    in the length of the list.
    Hint

    In the worst case, every element must be examined.

    Answer

    linear

  8. 8
    In a sorted-list linear search, the algorithm can stop when the current element is
    _____
    than the target.
    Hint

    All later elements are even larger because the list is sorted.

    Answer

    bigger

  9. 9
    Although early stopping improves the average behavior of sorted-list linear search, its worst-case complexity remains
    _____
    .
    Hint

    A worst-case target may still require examining nearly the entire list.

    Answer

    order n

  10. 10
    Bisection search requires the list to be
    _____
    before it can repeatedly discard half of the remaining elements.
    Hint

    The algorithm uses relative ordering to decide which half may contain the target.

    Answer

    sorted

  11. 11
    At each step of bisection search, the algorithm examines the
    _____
    element of the remaining list.
    Hint

    It chooses the element halfway between the current boundaries.

    Answer

    midpoint

  12. 12
    If the target is larger than the midpoint element during bisection search, the algorithm continues with the
    _____
    half.
    Hint

    The target must be among the values greater than the midpoint.

    Answer

    upper

  13. 13
    If the target is smaller than the midpoint element during bisection search, the algorithm continues with the
    _____
    half.
    Hint

    The target must be among the values less than the midpoint.

    Answer

    lower

  14. 14
    Bisection search reduces the remaining problem by a factor of
    _____
    at each step.
    Hint

    One of two equal portions is discarded after each comparison.

    Answer

    two

  15. 15
    The number of bisection-search steps is logarithmic because the search ends when 1/2k1/2^k1/2k of the original problem equals
    _____
    .
    Hint

    The process stops when only one candidate remains.

    Answer

    1

  16. 16
    Bisection search makes only one of its two possible recursive calls because it decides which
    _____
    contains the target.
    Hint

    The other half is discarded after comparing with the midpoint.

    Answer

    half

  17. 17
    The work performed inside each bisection-search step is constant because the algorithm passes
    _____
    rather than copying the list.
    Hint

    The implementation tracks boundaries into the original list.

    Answer

    pointers

  18. 18
    The resulting complexity of bisection search is
    _____
    in the length of the list.
    Hint

    The number of steps grows as a logarithm of the input size.

    Answer

    logarithmic

  19. 19
    For a single search, sorting first is worthwhile only if the cost of sorting plus logarithmic search is less than the cost of
    _____
    search.
    Hint

    Compare sorting followed by bisection with checking elements one by one.

    Answer

    linear

  20. 20
    Any sorting algorithm must take at least linear time because it must inspect each of the
    _____
    input elements.
    Hint

    The algorithm must determine where every element belongs.

    Answer

    n

  21. 21
    Sorting once and then performing many searches spreads or
    _____
    the cost of sorting across those searches.
    Hint

    The one-time expense is distributed over repeated operations.

    Answer

    amortizes

  22. 22
    For kkk bisection searches on a list of length nnn, the search portion costs order
    _____
    .
    Hint

    Multiply the logarithmic cost of one search by the number of searches.

    Answer

    k log n

  23. 23
    When the number of searches is sufficiently large, the one-time sorting cost can become
    _____
    compared with the repeated search cost.
    Hint

    Repeated searches dominate the total cost.

    Answer

    irrelevant

  24. 24
    The hierarchy discussed ranks constant, logarithmic, linear, log linear, quadratic, and exponential algorithms from more desirable to less desirable as growth becomes
    _____
    .
    Hint

    Algorithms with slower growth are preferred for large inputs.

    Answer

    faster

  25. 25
    An algorithm with order nnn log nnn complexity is described as a
    _____
    algorithm.
    Hint

    Its growth combines linear and logarithmic factors.

    Answer

    log linear

  26. 26
    The worst-case performance of a sorting algorithm is emphasized because a favorable average case does not guarantee good behavior in the
    _____
    case.
    Hint

    This case represents the greatest possible cost for the algorithm.

    Answer

    worst

  27. 27
    BOGO sort repeatedly generates permutations until it finds one that is
    _____
    .
    Hint

    The algorithm stops when the randomly arranged elements are in the desired order.

    Answer

    sorted

  28. 28
    BOGO sort is also known as monkey sort, stupid sort, slow sort, permutation sort, and
    _____
    sort.
    Hint

    This name suggests randomly trying arrangements until one works.

    Answer

    shotgun

  29. 29
    Because BOGO sort can examine all possible arrangements, its average complexity is
    _____
    .
    Hint

    The number of permutations of nnn elements is n!n!n!.

    Answer

    n factorial

  30. 30
    The best-case complexity of BOGO sort is order
    _____
    because the list may already be sorted.
    Hint

    Even in the best case, the algorithm must verify the ordering.

    Answer

    n

  31. 31
    Bubble sort compares neighboring elements in pairs and swaps them when the earlier element is
    _____
    .
    Hint

    The larger value is moved toward the end of the list.

    Answer

    bigger

  32. 32
    Bubble sort continues making passes until it completes one full pass with no
    _____
    .
    Hint

    No exchanges means that no adjacent pair is out of order.

    Answer

    swaps

  33. 33
    After each complete pass of bubble sort, the largest unsorted element is placed at the
    _____
    of the list.
    Hint

    Repeated swaps move the larger element rightward.

    Answer

    end

  34. 34
    Bubble sort performs at most order nnn passes, with each pass doing order nnn work, giving quadratic complexity of order
    _____
    .
    Hint

    Multiplying two linear factors produces a quadratic factor.

    Answer

    n squared

  35. 35
    In bubble sort, the flag tracking whether a swap occurred is initially set to
    _____
    before each pass.
    Hint

    The algorithm must enter the loop at least once.

    Answer

    true

  36. 36
    Selection sort repeatedly finds the
    _____
    remaining element and places it at the next position in the sorted prefix.
    Hint

    The algorithm builds the sorted portion from left to right.

    Answer

    smallest

  37. 37
    After iii steps of selection sort, the first iii elements form a sorted
    _____
    .
    Hint

    A prefix is the beginning portion of a sequence.

    Answer

    prefix

  38. 38
    After each selection-sort step, every element in the unsorted suffix is at least as large as every element in the sorted
    _____
    .
    Hint

    The sorted portion contains the smallest elements found so far.

    Answer

    prefix

  39. 39
    The loop invariant for selection sort states that the sorted prefix is ordered and no element in it is larger than the smallest element in the
    _____
    .
    Hint

    The suffix is the remaining unsorted part of the list.

    Answer

    suffix

  40. 40
    The base case for the selection-sort loop invariant is an empty
    _____
    .
    Hint

    Before any elements have been selected, the sorted portion contains nothing.

    Answer

    prefix

  41. 41
    The selection-sort loop invariant is established for all steps by using
    _____
    .
    Hint

    Prove the base case and then show that one valid step preserves the property.

    Answer

    induction

  42. 42
    Selection sort has quadratic complexity because it performs order nnn passes and compares elements in the remaining list during each
    _____
    .
    Hint

    The amount of remaining work decreases, but the total still has quadratic growth.

    Answer

    pass

  43. 43
    Merge sort uses the divide-and-conquer strategy by splitting a problem into smaller versions of the same problem and then
    _____
    their results.
    Hint

    The solutions to the smaller subproblems are brought back together.

    Answer

    combining

  44. 44
    A list containing zero or one element is already
    _____
    and serves as the base case for merge sort.
    Hint

    No pair of elements can be out of order in such a list.

    Answer

    sorted

  45. 45
    When a list has more than one element, merge sort divides it into
    _____
    sublists.
    Hint

    The list is split approximately in half.

    Answer

    two

  46. 46
    To merge two sorted lists, compare their
    _____
    remaining elements and append the smaller one to the result.
    Hint

    The smallest unprocessed element must be at the front of each sorted sublist.

    Answer

    first

  47. 47
    When one sorted sublist becomes empty during a merge, the remainder of the other list can be copied directly to the
    _____
    of the result.
    Hint

    The remaining elements are already in increasing order.

    Answer

    end

  48. 48
    The merge operation examines each element of the two sublists at most once for copying, making its complexity
    _____
    in the total list length.
    Hint

    The work is proportional to the combined number of elements.

    Answer

    linear

  49. 49
    In a merge, the maximum number of element comparisons is bounded by the number of elements in the
    _____
    sublist.
    Hint

    Once one list is empty, the merge stops comparing.

    Answer

    longer

  50. 50
    Merge sort keeps dividing until each sublist has zero or
    _____
    elements.
    Hint

    A sublist of this size is automatically sorted.

    Answer

    one

  51. 51
    At each level of merge sort, the total number of elements processed remains order
    _____
    even though the number of sublists changes.
    Hint

    All sublists together still contain the original elements.

    Answer

    n

  52. 52
    The number of levels in merge sort is logarithmic because the problem size is repeatedly divided by
    _____
    .
    Hint

    Each division creates two approximately equal subproblems.

    Answer

    two

  53. 53
    Because merge sort performs order nnn work across order log⁡n\log nlogn levels, its complexity is order
    _____
    .
    Hint

    Multiply the linear work per level by the logarithmic number of levels.

    Answer

    n log n

  54. 54
    The lecture presents merge sort as the best known
    _____
    -case sorting performance discussed.
    Hint

    The claim concerns guaranteed performance rather than average behavior.

    Answer

    worst

  55. 55
    Data structures such as tuples, lists, dictionaries, and more complicated structures provide ways to
    _____
    knowledge.
    Hint

    They organize information so a program can work with it.

    Answer

    represent

  56. 56
    Iteration and loops are described as computational
    _____
    for approaching problems.
    Hint

    They are ways of thinking about repeated computation.

    Answer

    metaphors

  57. 57
    Recursion breaks a problem into simpler versions of the
    _____
    problem.
    Hint

    A recursive subproblem has the same structure as the original.

    Answer

    same

  58. 58
    Abstraction captures a computation in a procedure while hiding its internal
    _____
    .
    Hint

    Users of the procedure need only know what it promises to do.

    Answer

    details

  59. 59
    Classes and methods help modularize systems by combining data with the operations that act on
    _____
    .
    Hint

    The operations belong with the data they manipulate.

    Answer

    them

  60. 60
    The three A's of computational thinking are abstraction, automation, and
    _____
    .
    Hint

    The final A concerns step-by-step procedures for solving problems.

    Answer

    algorithms

  61. 61
    Automation means mechanizing an abstraction into a sequence of
    _____
    that a machine can execute.
    Hint

    A program specifies actions in an ordered process.

    Answer

    steps

  62. 62
    Thinking clearly about how to describe an algorithm helps
    _____
    or clarify one's thinking about a problem.
    Hint

    A precise description makes an idea more definite and easier to inspect.

    Answer

    crystallize

  63. 63
    Divide and conquer, recursion, abstraction, and algorithmic complexity are examples of computational modes of
    _____
    .
    Hint

    They are mental approaches for analyzing and solving problems.

    Answer

    thinking

  64. 64
    Computational thinking asks how to take a problem from biology, chemistry, mathematics, or another field and design an
    _____
    to simulate or evaluate it.
    Hint

    The desired solution is a precise sequence of computational steps.

    Answer

    algorithm

  65. 65
    The lecture suggests that some problems are inherently more difficult than others because they belong to different complexity
    _____
    .
    Hint

    Constant, linear, quadratic, and exponential are examples of these categories.

    Answer

    classes

1 of 65
Question 1 of 65

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent