Question: (10 pts) Design recursive algorithm countLess (A, p, r, x) that takes a sorted integer array A[p] through A[r], an integer x, and computes the
(10 pts) Design recursive algorithm countLess (A, p, r, x) that takes a sorted integer array A[p] through A[r], an integer x, and computes the number of elements in A[p] A[r] that are smaller than x. When invoked as countLess (A, 1, n, x) (i.e., on a sorted array of size n), your algorithm must run in O(log n) time. Present a complete algorithm in pseudocode form.
(4) (10 pts) Design recursive algorithm countless (A, p, r, x) that takes a sorted integer array A[p] through A[r], an integer x, and computes the number of elements in A[p] ... A[r] that are smaller than x. When invoked as countless (A, 1, n, x) (i.e., on a sorted array of size n), your algorithm must run in O(log n) time. Present a complete algorithm in pseudocode form
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
