Prepping for the 2027 recruiting cycle? Use code 2027RC for 10% off, valid until July 31st! Oh, and check out our members-only recruitment services.

Logo

Square Root for Small Roots

What this preview is

Square Root for Small Roots is a medium quant coding problem on language knowledge in Cpp / Python.

Difficulty
Medium
Topic
Language Knowledge
Discipline
Quant development
Languages
Cpp / Python

Implementing square root without built-in functions

This medium-difficulty coding problem tests whether you can implement a numerical method to compute square roots in C++ or Python, handling the subtle differences between inputs greater than and less than 1.0. It probes your understanding of binary search, floating-point arithmetic, and tolerance-based convergence.

The key insight is recognizing that the search interval for the root changes depending on the input's magnitude. You'll need to set up the correct bounds, apply an iterative refinement strategy, and use machine epsilon to determine when your approximation is close enough. Edge cases—zero, one, very small numbers, very large numbers—require careful initialization and loop termination logic.

  • Binary search on continuous domains
  • Floating-point tolerance and epsilon-based comparisons
  • Handling asymmetric search intervals based on input range
  • Convergence criteria for numerical approximation

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.