[solved]-Write C Function Implements Liner Search Algorithm Instead Binary Search However Linear Se Q38996107
Write a C function that implements the Liner Search algorithminstead of Binary Search.
However, this linear search algorithm returns the indices of thelongest sorted subset of numbers in
an array of integers of size n. The longest sorted subset ofnumbers must satisfy three conditions.
First, the subset consists of unique numbers (no duplicate);second, all the numbers in this subset is
divisible by m, the minimum size of the subset is two elements. Inthe main method print all values
of all the discovered longest sorted subsets.
Notes there could be more than one longest sorted subset (e.g., twosubsets that satisfy the
previously stated conditions). The subsets could exist in ascendingor descending order. We
always scan the array from left to right ( 0 to n-1 indices)
Examples, find the longest sorted subset that is divisible by3
5 3 2 8 12 6 9 9 21 30
The longest sorted subset that is divisible by 3 is {9, 21, 30}. Itexists between indices [7 – 9]. Note
{6, 9, 9, 21, 30} is not the longest because the value 9 existstwice.
Examples, find the longest sorted subset that is divisible by2
2 6 8 0 3 12 14 20 3 5
The longest sorted subset that is divisible by 2 are {2, 6, 8} and{12, 14, 20}. The exist between
indices [0-2] and [5-7]. Note {6, 9, 9, 21, 30} is not the longestbecause the value 9 exists twice.
Examples, find the longest sorted subset that is divisible by3
19 0 13 11 2 9 17 1 3 5
The longest sorted subset that is divisible by 2 is empty or null.
Examples, find the longest sorted subset that is divisible by5
5 15 50 3 19 80 50 10 2 7
The longest sorted subset that is divisible by 5 are {5, 15, 50}and {80, 50, 10}. The exist between
indices [0-2] and [5-7].
Elements are not sorted.
Expert Answer
Answer to Write a C function that implements the Liner Search algorithm instead of Binary Search. However, this linear search algo… . . .
OR

