Question: Searching unsorted array with duplicate data items. Given array int B[10] = {10, 70, 20, 30, 25, 70 , 10, 25, 70, 50}; Design algorithm
-
Searching unsorted array with duplicate data items.
Given array int B[10] = {10, 70, 20, 30, 25, 70 , 10, 25, 70, 50};
-
Design algorithm int SearchUnsorted_First(int L[], int n, int k) that finds and returns the index of the first occurrence of k in L. If k is not found, -1 is returned. For example, the call SearchUnsorted_First(B, 10, 70); should return 1 (index of the first occurrence of 70 in the above array B).
The call: SearchUnsorted_First(B, 10, 15); should return -1.
-
Design algorithm int SearchUnsorted_L(int L[], int n, int k) that finds and returns the index of the last occurrence of k in L. If k is not found, -1 is returned. For example, the call SearchUnsorted_L(B, 10, 70); should return 8 (index of the last occurrence of 70 in the above array B).
The call: SearchUnsorted_L(B, 10, 20); should return 2.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
