I have one more question. This is another interative loop in the chapter on searching that I had to convert to a recursive function.
Should I rewrite this function and break it into to two as I did with the sequential search?
I have the same problem of incrementing the position in the list.
//Function written for Test 5 Question 22
int orderedArrayListType<elemType>::binarySearch(const elemType& item)
static int first = 0;
static int last = length - 1;
static int mid = (first + last) / 2;
if(first > last || mid == last || mid == first)
if(list[mid] == item)
else if (list[mid] > item)
It looks like I have to rewrite this one two for the same reason. Declaring static variables is ok for the first time through the function but the second time the number, that is in the list, is not found!