Binary search - int middle=(first last/2...

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

View Full Document Right Arrow Icon
Binary search Int bSearch(const int arr[], const int size, const int value) { assert(size>=0); int index=-1 int first=0; int last = size-1; while (first<=last &index==-1);
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 middle=(first+last)/2; if(arr[middle]==value)index=middle; else if (arr[middle<value) first=middle+1; else last = middle-1; } return index; }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online