Too many arrays

Report a typo

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:

  1. If the number from the first array is in the second array, then you will need to perform ii comparison operations, where ii is the position of this number in the second array.

  2. Every number that you can't find in the second array adds as many comparison operations as there are elements in the second array.

Put the items in the correct order
[ 19, 6, 5]
[ 19, 6, 3, 5]
[6, 9, 5, 19]
[ 9, 19, 5, 6]
___

Create a free account to access the full topic