previous | start

## Searching and Sorting Real Data

- Real programs rarely need to search through a collection of integers.
- The procedures above can be modified to easily search through real data.

  >     int binary_search(vector<Employee>& v, int from, int to, string n)
  >     {
  >        if (from > to)
  >           return -1;
  >        int mid = (from + to) / 2;
  >        if (v[mid].get_name() == n)
  >           return mid;
  >        else if (v[mid].get_name() < n)
  >           return binary_search(v, mid + 1, to, n);
  >        else
  >           return binary_search(v, from, mid -1 , n);
  >     }

previous | start