#include <stdio.h>
#include <stdlib.h>
#include "Proto.h"
int main()
{
/* Accepts number of elements from user */
scanf("%d", &elements);
/* Creates dynamic array */
array = (char *) calloc(elements, sizeof(char));
/* Copies sorted values to the dynamic array */
for(i = 0; i < elements; i++)
{
scanf("%s", &array[i]);
}
/* Accepts number of elements to search */
scanf("%d", &search);
/* Searches for elements in sorted array one at a time */
for(i = 1; i <= search; i++)
{
/* Accepts value to search */
scanf("%s", &value);
/* Resets counter to 0 */
count = 0;
/* Finds location of element in the sorted list using binary search */
location = binarySearch(array, value, 0, (elements-1));
/* Checks if element is present in the sorted list */
if (location == -1)
{
printf("%4s not found!\n", value);
}
else
{
printf("%4s found at %4d iteration during iteration %4d\n", value, location, count);
}
}
free(array);
}