Technical Interview

Home
Technical Interview
Interview Process
Introduction Questions
Quantitative Problems
Google & Microsoft
Algorithms
Object Oriented
C/C++ Questions
Java Questions
Data Structures
Fundamental Questions
Puzzles
Resume Tips
Added Recently
Links
Contact Us
Submit Question/Answer

 

Implement the body of the following function using a binary search of the array. You do not need to check the precondition.   




public static boolean has42(int[ ] data, int start, int end)

    // Precondition: The elements data[start]...data[end] are sorted from smallest

    // to largest. This array segment might be empty (indicated by end being less

    // than start).

    // Postcondition: A true return value indicates that the number 42 appears in

    // data[start]...data[end]. A false return value indicates that 42 doesn’t 

    // appear.
   


 

Solutions: