Question: Consider the following description of an algorithm: Given a list of n integers and 3 target integers, a, b, and c: First, perform linear search
Consider the following description of an algorithm: Given a list of n integers and 3 target integers, a, b, and c: First, perform linear search for element a; if it is found, return its index, otherwise continue. Next, perform linear search for element b; if it is found, return its index, otherwise continue. Last, perform linear search for element c; if it is found, return its index, otherwise return -1. What is the best big O estimate of the algorithm runtime?
O(3n)
O(n)
O(n3)
O(3n)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
