]], also known as , is a simple and basic for locating an within an . The algorithm sequentially compares each element in the list until it finds a match or reaches the end of the list. To perform the search, an is used to keep track of the current position in the list. When a match is found, the search concludes and returns a value indicating whether the element was found or not.
This search algorithm is quite efficient for small lists or when the element being searched is located near the beginning of the list. However, as the size of the list grows, the of Sequential Search increases linearly. In the , where the target element is located at the end of the list or is not present at all, the search must iterate through all n elements in the list. Hence, the worst-case runtime complexity is , giving it a .
On the other hand, in the , where the target element is found at the very first index, the search terminates immediately, resulting in a runtime complexity of O(1). However, it is essential to consider the , as it provides a more realistic representation of the algorithm's . In the average-case scenario, Sequential Search examines approximately half of the list, resulting in a runtime complexity of O(n/2), which is still considered linear.
To measure the efficiency of search algorithms like Sequential Search, is utilized. It quantifies the algorithm's time or space complexity in terms of the input size. For Sequential Search, the linear time complexity is expressed as O(n), indicating that the algorithm's performance is directly proportional to the size of the list.
When performing a Sequential Search, the list can be implemented using various data structures, with an being a commonly used choice. Each element in the array can be accessed by its index, facilitating the process. This algorithm scans through the array, element by element, comparing each with the target element until a match is found.
Keywords
linear time complexity | sequential [[search | average-case scenario | array | big o notation | linear search | efficiency | complexity | algorithm | element | index | worst-case scenario | comparison | runtime | unordered | best-case scenario | boolean | o(n) | list |