a. Write a non-recursive method to sequentially search for an element into a por
ID: 3656715 • Letter: A
Question
a. Write a non-recursive method to sequentially search for an element into a portion of an input array. You can use two indices (low and high) as inputs to your method in order to limit the search area within the input array. b. Repeat part (a) using a recursive method. c. Perform simulations to compare the observed performance of your two implementations of sequential search (parts a and b). Use N randomly generated integers to compare the running time of both implementations (you should use the same input for the two methods), where N takes the values: 1000, 5000, 10000, 20000, 30000, 40000 and 50000. Insert these N randomly generated integers into your input array. Then, for every value of N, compute the average time taken to search for an element into the input array. To compute this average, you should randomly generate 10 elements and search for them. Make sure that at least 30% of your generated search elements are already exist in your input array (This represent the successful search cases). This can be achieved by randomly picking elements from the input array itself (i.e. you can generate random array indices and pick the corresponding array elements). Finally, plot the running time for both methods as a function of the input size N. Comment on the results.Explanation / Answer
a) Non Recursive #include int main(){ int a[10],i,n,m,c=0,l,u,mid; printf("Enter the size of an array: "); scanf("%d",&n); printf("Enter the elements in ascending order: "); for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.