FastPrepFind a Function Root by Bisection
Problems/Find a Function Root by Bisection

Find a Function Root by Bisection

JP Morgan Chase logoJP Morgan Chase● MediumNEW GRADONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for Python code that finds a function root with binary search. The polynomial representation, bounded monotone bracket, endpoint rules and tolerance are supplied for practice. The root-finding capability matches the report at about 80%.

Find the root of a polynomial inside a supplied bracket using bisection.

For this exercise, assume coefficients lists integer coefficients from highest degree to constant term. For example, [1, 0, -2] represents x² - 2. The polynomial is strictly monotone on [left, right], its derivative has absolute value at least 1 there, and the endpoint values bracket a root. An endpoint may itself be the root.

Return the root as a floating-point value. The judge accepts an absolute error of at most 10⁻⁶ × max(1, |expected result|). You may evaluate the polynomial with Horner’s rule and repeatedly halve the bracket; no expression parser is needed.

Function

findRoot(coefficients: int[], left: int, right: int) → double

Examples

Example 1

coefficients = [1,0,-2]left = 1right = 2return = 1.4142135623730951

The polynomial is x² - 2. It changes sign from -1 at 1 to 2 at 2, and the unique root in the bracket is √2, about 1.41421356237.

Example 2

coefficients = [-2,1]left = 0right = 1return = 0.5

The decreasing polynomial -2x + 1 has value 0 at x = 0.5.

Example 3

coefficients = [1,0]left = 0right = 4return = 0.0

The left endpoint is already a root of f(x) = x, so the result is 0.

Constraints

  • 2 <= coefficients.length <= 6
  • -100 <= coefficients[i] <= 100
  • -10 <= left < right <= 10
  • The leading coefficient is nonzero.
  • The endpoint values have opposite signs, or an endpoint is a root.
  • Throughout the bracket, either the derivative is at least 1 or it is at most -1.

More JP Morgan Chase Onsite Interview questions

  • LFU CacheONSITE INTERVIEW · Seen Nov 2026
  • LRU CacheONSITE INTERVIEW · Seen Nov 2026
  • Employees Above Average SalaryONSITE INTERVIEW · Seen Sep 2026
  • Highest-Earning Employees By DepartmentONSITE INTERVIEW · Seen Sep 2026
  • K Largest Integers in Descending OrderONSITE INTERVIEW · Seen Aug 2026
  • Tile a Three-Row Board with DominoesONSITE INTERVIEW · Seen Jan 2026
  • Two SumONSITE INTERVIEW · Seen Nov 2025
  • Intersection of Two ListsONSITE INTERVIEW · Seen Jan 2025
  • Maximum Subarray SumONSITE INTERVIEW · Seen Jan 2025
  • Fibonacci NumberONSITE INTERVIEW · Seen Nov 2024

Similar questions at other companies

  • Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Koko Eating BananasTekion · ONSITE INTERVIEWTekion interview questions
  • Koko Eating BananasAmazon · ONSITE INTERVIEW
  • Maximum Supplier ProfitExpedia · ONSITE INTERVIEWExpedia interview questions
  • First Register Overflow TickNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
  • Two Eggs: Minimum Worst-Case DropsApple · ONSITE INTERVIEWApple interview questions
  • Integer Square RootMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • K-th Amount a Payout Machine Can GiveRippling · ONSITE INTERVIEWRippling interview questions
  • Integer Square Root with Error ChecksBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions

JP Morgan Chase interview experiences

  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)
  • JPMorgan Code for Good India: 10 Experiences (Part 4 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public double findRoot(int[] coefficients, int left, int right) {
        // Write your code here.
    }
}
Checking account…