3.1.3 Searching algorithms

Cards (25)

  • The two main types of searching algorithms are linear search and binary search
    True
  • Linear search has a time complexity of O(n), while binary search has a time complexity of O(log n)
    True
  • Binary search requires the data to be sorted, while linear search does not
    True
  • Linear search has a time complexity of O(n), while binary search has a time complexity of O(log n)
    True
  • If the end of the list is reached in linear search without finding the target, the algorithm returns -1
    True
  • Binary search repeatedly divides the search space by comparing the middle element

    True
  • Linear search sequentially checks each element
  • What is the time complexity of linear search?
    O(n)
  • Binary search uses a divide and conquer approach.

    True
  • Binary search requires data to be ordered.
  • If a match is found in linear search, the index of the element is returned.

    True
  • Why is binary search more efficient than linear search for large datasets?
    Halves the search space
  • Searching algorithms are used to find a specific item or value
  • Linear search checks each element sequentially until the target is found or the end
  • Binary search is suitable for ordered data structures, while linear search is suitable for unordered data structures.
  • Linear search is best for unordered data, while binary search requires data to be ordered
  • Linear search checks each element of a list sequentially until the target is found or the end is reached.
  • Linear search sequentially checks each element until the target is found or the end is reached.
  • What are searching algorithms used for?
    Locating items in data
  • Binary search repeatedly divides the search space in half.

    True
  • Linear search is suitable for unordered data.
  • What is the time complexity of binary search?
    O(log n)
  • What does linear search do until the target is found or the end is reached?
    Checks each element sequentially
  • Binary search has a time complexity of O(log n).
  • Match the searching algorithm with its best use case:
    Linear Search ↔️ Small, unordered datasets
    Binary Search ↔️ Large, sorted datasets