Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume an array of structures is in order by the customerIDfield of the record,

ID: 3611087 • Letter: A

Question

Assume an array of structures is in order by the customerIDfield of the record, where customer IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to finda record with a customer ID near the end of the IDs, say 494, ifnot every single customer ID in the range of 101 to 500 is used andthe array size is only 300. Assume an array of structures is in order by the customerIDfield of the record, where customer IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to finda record with a customer ID near the end of the IDs, say 494, ifnot every single customer ID in the range of 101 to 500 is used andthe array size is only 300.

Explanation / Answer

Observe the Java code given below to understand thebinary search algorithm in arrays.

We simply start from the middle of the array and check if wehave found a match. If not, we check to see if what we've gotis greater or lesser than the required value. If it be lesserthen we can confidently ignore all the values greater than ( andincluding ) the mid point. This goes on until we either finda match or when the "low" point is greater than the "high"point.

This algorithm, as must be evident, assumes the array itreceives as input to be in a perfectly sorted state, i.e., it worksonly so long as it is ensured that the array to be searched is inascending sorted order.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote