Lab09.7 - int binSearch(int input int start int end int key int mid if(start> end return-1 mid =(start end 2 if(input[mid> key

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <stdio.h> #include <stdlib.h> #include <time.h> int binSearch(int input[], int start, int end, int key) int main(){ srand(time(NULL)) int array[300] int count for(count = 0 count < 300 count++) array[count] = count for(count = 0 count < 1000000 count++) binSearch(array, 0, 299, (rand() % 300)) return (0)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } int binSearch(int input, int start, int end, int key){ int mid if(start > end) return (-1) mid = (start + end)/ 2 if(input[mid] > key) return (binSearch(input, start, mid - 1, key)) else if(input[mid] < key) return (binSearch(input, mid + 1, end, key)) else return mid }...
View Full Document

This lab report was uploaded on 04/06/2008 for the course CISC 105 taught by Professor Mcgeary during the Spring '08 term at University of Delaware.

Ask a homework question - tutors are online