An array of integers is given:
[ 8, 19, 12, 7, 6, 5 ]Imagine we searched for every value of the first array in a second array using linear search. We've established that the numbers 19, 6 and 5 are also found in the second array.
Below you see the possible values of the second array. Arrange the given arrays in ascending order, based on the number of comparison operations needed.
Hint: Consider the following observations while solving the problem:
If the number from the first array is in the second array, then you will need to perform comparison operations, where is the position of this number in the second array.
Every number that you can't find in the second array adds as many comparison operations as there are elements in the second array.