Question: Looking at the following code, write the missing piece of code: public int find(long searchKey) {int lowerBound = 0; int upperBound = nEleros-1; int curln;

 Looking at the following code, write the missing piece of code:

Looking at the following code, write the missing piece of code: public int find(long searchKey) {int lowerBound = 0; int upperBound = nEleros-1; int curln; while(true) {curln = (lowerBound + upperBound)/2; if(a[curIn]==searchKey) return curln;//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 steps

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!