Question: Assume that you are using linear search algorithm to find the position of element x=9 in the list L={1,2,3,4,5,6,7,8,9,10). What is the number of comparisons

Assume that you are using linear search algorithm to find the position of element x=9 in the list L={1,2,3,4,5,6,7,8,9,10). What is the number of comparisons done by the algorithm until it finds the position of x? (Include all comparisons in your count!) Linear search algorithm is given as: procedure linear search(x:integer, a1, 42,...,n: distinct integers) i:=1 while (is n and x * a;) i:=i+1 ifis n then location :=i else location :=0 return location Select one: O a. 18 O b. 10 O c. 19 d. 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
