Question: Consider two algorithms for searching an integer x in a sequence of integers arranged in increasing order. For both the algorithms, complete the tables using

Consider two algorithms for searching an integer x in a sequence of integers arranged in increasing order. For both the algorithms, complete the tables using this input: a = {1, 2, 5, 7, 12}, first with x = 12 and then x = 5. Algorithm_2(int* a, int n, int x) i = 0: j = n - 1: while (i a[m]) then i = m + 1: if (x == a[m]) return m;} return 0;//{x is not found} Algorithm_3 (int* a, int n, int x) i = 0: j = n - 1: while (i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
