Class MyArray contains an array of n integers(n<=100) that are already arranged in ascending order. The subscripts of the array elements vary from 0 to n-1. Some of the members functions/methods of MyArray are given below:
Class name : MyArray
Data members/instance variables:
arr - an array of n integers
n - size of the array
Member functions/methods:
MyArray( ) : constructor to initialize n=nm and the array arr
void readArray( ) : read n integers that are arranged in ascending order
void displayArray( ) : display n integers
int binarySearch(int value) : searches for the value in the array using the binary
search technique. It returns the subscript of the array
element if the value is found, otherwise it returns -999.
(a) Specify the class MyArray giving the details of the void displayArray( ) and int binarySearch( int value) only. You may assume that the other functions/methods are written for you. You do not need to write the main function.
(b) What changes would be necessary in the method/function binarySearch(int value) if the given array was arranged in descending order?
(c) When will binary search technique fail to work?