145k views
5 votes
Choose the correct term to complete the sentence.

A_____ search compares the first item to the goal, then the second, and so on.

linear or binary?

1 Answer

4 votes

Answer:

Linear

Step-by-step explanation:

In a linear search, you're going through each element, for example in an array. This is done in O(n) time complexity, n being the amount of elements in the array. You go through each elements comparing if it is the goal.

In a binary search, you divide and conquer until you reach your answer, making the question into smaller subproblems until you solve it. Note that you can only perform a binary search on a sorted array and it is in O(log(n)) (base 2) time complexity.

User Charma
by
5.4k points