Put the steps in the correct order
Searching is the process of finding a specific item within a collection of data. Unlike sorting (which rearranges data), searching looks through existing data to locate a target value. Different search algorithms have different requirements and speeds.
Linear Search (also called Sequential Search) is the simplest search algorithm. It checks each element in the list one by one from the beginning until it finds the target or reaches the end.
✅ Advantages: Simple, works on unsorted data, no preprocessing needed.
❌ Disadvantages: Slow for large lists, checks every element in worst case.
Binary Search is a highly efficient "divide and conquer" search algorithm. It works by repeatedly dividing the search space in half.
⚠️ Important: Binary Search ONLY works on SORTED lists! The data must be in order before you can use this algorithm.
Each comparison eliminates half of the remaining elements. For a list of 1000 elements:
✅ Advantages: Very fast, efficient for large datasets, ideal for repeated searches.
❌ Disadvantages: List MUST be sorted first, more complex than linear search, sorting has its own cost.
Use Linear Search when: List is small, list is unsorted, you're only searching once.
Use Binary Search when: List is large, list is already sorted, you're searching multiple times.