lab21 - Lab 21 Due Date: Monday, October 10, 2011 Source...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Lab 21 Due Date: Monday, October 10, 2011 Source File: ~/2305/lab21.C Input: under control of main function Output: under control of main function Value: 2 Write a recursive template function whose prototype is given by 1 template<typename T> 2 const T *BinarySearch(const T *first, const T *last, T itemToFind); The function performs a binary search of the range [first, last] for itemToFind . The function returns an address i in the range [first, last] such that *i == itemToFind . The function returns NULL if no such address exists. A main function for testing your function is shown in Figure 1. The expected output from executing this code is shown in Figure 2. To use the Makefile as distributed in class, add a target of lab21main to targets1srcfile . 1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 6 // template function prototype 7 template<typename T> 8 const T *BinarySearch(const T *first, const T *last, T itemToFind); 9 10 #include "lab21.C" 11 12 template<typename T> 13 void PrintArray(const T *array, int count)...
View Full Document

Page1 / 3

lab21 - Lab 21 Due Date: Monday, October 10, 2011 Source...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online