Time Complexity Search Algorithm Quiz Quiz

  1. Linear Search Complexity

    What is the worst-case time complexity of a linear search algorithm?

    1. O(log n)
    2. O(1)
    3. O(n log n)
    4. O(n)
    5. O(n^2)
  2. Binary Search Requirement

    What crucial property must an array possess for binary search to function correctly?

    1. It must be sorted.
    2. It must contain only unique elements.
    3. It must be dynamically allocated.
    4. It must be a linked list.
    5. It must be of a fixed size.
  3. Binary Search Complexity

    What is the time complexity of a binary search in the best-case scenario?

    1. O(n)
    2. O(log n)
    3. O(n log n)
    4. O(1)
    5. O(n^2)
  4. Linear Search vs. Binary Search

    For searching an unsorted array, which search algorithm is generally more efficient?

    1. Binary search
    2. Linear search
    3. Both are equally efficient
    4. Depends on the size of the array
    5. Ternary Search
  5. Binary Search Iterations

    Approximately how many iterations would binary search take to find an element in a sorted array of 1024 elements in the worst case?

    1. 10
    2. 20
    3. 512
    4. 1024
    5. 1000
  6. Linear Search on a Sorted Array

    If a linear search is performed on a sorted array, can its best-case time complexity ever be better than O(n)?

    1. No, it will always be O(n)
    2. Yes, it can be O(1)
    3. It depends on the specific array
    4. Yes, it can be O(log n)
    5. Yes, it can be O(n/2)
  7. Complexity comparison

    Which search algorithm performs faster on average for very large, sorted datasets?

    1. Linear search
    2. Binary search
    3. Sequential Search
    4. They perform equally
    5. Depends on the processor speed
  8. When Binary Search Fails

    Under what condition will binary search fail to find the target value in a sorted array?

    1. If the array is empty.
    2. If the target value is at the last index.
    3. If the array contains duplicate values.
    4. If the array is too large.
    5. Binary Search never fails
  9. Time Complexity Linear Search Best Case

    What is the best case time complexity for linear serach?

    1. O(n)
    2. O(log n)
    3. O(1)
    4. O(n/2)
    5. O(n^2)
  10. When to use Linear Search

    In which scenario is a linear search generally preferred over a binary search?

    1. When searching a small, unsorted list
    2. When searching a large, sorted array
    3. Wen the data size is too large
    4. Whenever Speed is important
    5. When memory is limited