Looking at the following code, write the missing piece of code://...............
ID: 3939292 • Letter: L
Question
Looking at the following code, write the missing piece of code://................-............................. public int find(long searchKey) {int lowerBound = 0; int upperBound = nElems-1; int curIn; while(true) {curln = (lowerBound + upperBound)/2; if(a[curln]==searchKey) return curIn;//found it else if(lowerBound > upperBound) return nElems;//can't find it else//divide range lowerBound = curln + 1;//it's in upper half else upperBound = curln - 1;//it's in lower half}//end else divide range}//end while}//end find()//..................//insert using linear insert - average N stepsExplanation / Answer
Missing part:
if(a[curIn] < searchKey)
Note:Please let me know in case of any doubt,Thanks.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.