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.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started