Binary code Error help <p>I forgot to insert my code, sorry on my behalf..</p> <p>I have a Binary Search going in my program, but when I enter 10 student records into an Array and sort them, the last element of Student ID will not be picked up from my binary search.</p> <p>Say when I sort the Array and 232 was the last element in the Array, when I go to Search 232 the Binary Search Function gives me back not found and I look for any other ID with in the array and give it back with the records.</p> <pre><code> else if ( choice == 4) // Binary Search... This Also Force Array to be Sorted If Array is not Sorted. { merge_sort(0,N_STUDENT-1); cout&lt;&lt;" \n\t Enter the student number to search :"; // Ask user to Input Student ID. cin&gt;&gt;key; k=binarySearch(record, 0, N_STUDENT-1, key); // Serach Array if(k&gt;=0) cout&lt;&lt;"Student Details with student Number\n " &lt;&lt;key&lt;&lt; "exists at the position \n" &lt;&lt; k &lt;&lt; " Student Number\n" &lt;&lt; record-&gt;student_number &lt;&lt; " " &lt;&lt; " Student Name \n" &lt;&lt; record-&gt;studentname &lt;&lt; " " &lt;&lt; " Student Address \n" &lt;&lt; record-&gt;Address &lt;&lt; " " &lt;&lt; " Course Code \n" &lt;&lt; record-&gt;CourseCode &lt;&lt; " " &lt;&lt; " Course Name \n" &lt;&lt; record-&gt;CourseName; //Displays Position of Student And Student Details. else cout&lt;&lt; "Not found "; // if Record is not Found _____________________________________________________________________________________________________ //function binary search using the key value to serach int binarySearch(student sorted[], int first, int upto, int key) { // Sort Array if not Sorted... while (first &lt; upto) { int mid = (first + upto) / 2; // Compute mid point. if (key&lt;sorted[mid].student_number) { upto = mid; // repeat search in bottom half. } else if (key&gt;sorted[mid].student_number) { first = mid + 1; // Repeat search in top half. } else { return mid; // Found it. return position } } return -(first + 1); // Failed to find key } </code></pre>