Start at the first element. 2. Compare the current element with the target. 3. If they match, return the index. 4. If not, move to the next element. 5. Repeat steps 2-4 until the target is found or the end of the list is reached. 6. If the end is reached without finding the target, return -1.
Flip to see [answer/question]
Flip to see [answer/question]
1
2
3
4
5
6
7
8
Flip
Revise later
SpaceTo flip
If confident
All Flashcards
What are the steps of Linear Search?
Start at the first element. 2. Compare the current element with the target. 3. If they match, return the index. 4. If not, move to the next element. 5. Repeat steps 2-4 until the target is found or the end of the list is reached. 6. If the end is reached without finding the target, return -1.
What is the definition of Linear Search?
A searching algorithm that sequentially checks each element in a list until the target element is found or the list is exhausted.
What is the definition of Sequential Search?
A searching algorithm that sequentially checks each element in a list until the target element is found or the list is exhausted.
What is the definition of an ArrayList?
A resizable array implementation of the List interface.
What is the definition of 'index' in the context of searching?
The position of an element within a list or array.
What does it mean to 'search' in the context of data structures?
To find a specific element within a data structure and potentially return its location.
What is the return value if an element is not found in Linear Search?
-1
How is Linear Search applied in real-world scenarios?
Searching for a specific product in a small online store inventory, finding a specific contact in a small phone book, or searching for a file in a directory.