Linear Search
What are the steps of linear search?
1. Check if the current element is the item being searched for 2. If it isn't move to the next element in the array 3. Repeat the previous steps until the item is found or the entire array has been searched
Write the pseudocode for linear search
Check your VINs for answers
Describe the Linear Search Algorithm
Each item in an array is visited and checked against the search term. This is done until the item is found or the end of the array is reached
What are the advantages of the linear search?
Fast for small-medium arrays The array doesn't need to be sorted Easy to code
What are the disadvantages of the linear search?
It is slow for large lists
What are the complexities of Linear Search?
Time: Linear- O(n) Space: Constant O(1)
For what is Linear Search used?
When data cannot be sorted or when sorting takes too much time To search for real-time data (sensor readings) Finding strings in a text