PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Uber

Compute square root to 1 decimal

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's understanding of numerical methods, floating-point precision, and implementation of approximate functions when producing a square root rounded to one decimal place.

  • Medium
  • Uber
  • Coding & Algorithms
  • Data Scientist

Compute square root to 1 decimal

Company: Uber

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

## Problem Given a non-negative real number `x`, implement a function `sqrt1dp(x)` that returns \(\sqrt{x}\) rounded (or truncated—clarify with interviewer) to **one digit after the decimal point**. ### Requirements - Do **not** call a built-in square root function. - Your answer must be accurate to **1 decimal place** (e.g., error < 0.05 if rounding). - Discuss how you would **optimize** the algorithm (time complexity and convergence). ### Examples - `x = 2` → `1.4` - `x = 9` → `3.0` - `x = 0` → `0.0` ### Clarifications to ask - Rounding vs truncation to 1 decimal. - Input range (e.g., up to 1e9?) and whether `x` can be non-integer. - Acceptable error tolerance if not using decimal formatting.

Quick Answer: This question evaluates a candidate's understanding of numerical methods, floating-point precision, and implementation of approximate functions when producing a square root rounded to one decimal place.

Related Interview Questions

  • Maximize Throughput and Count Trigger Components - Uber (medium)
  • Replace Dashes With Nearest Letters - Uber (medium)
  • Find Earliest Column With One - Uber (easy)
  • Solve Wonderful Strings and Grid Queries - Uber (hard)
  • Count Islands After Land Additions - Uber (medium)
Uber logo
Uber
Sep 16, 2025, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
13
0

Problem

Given a non-negative real number x, implement a function sqrt1dp(x) that returns x\sqrt{x}x​ rounded (or truncated—clarify with interviewer) to one digit after the decimal point.

Requirements

  • Do not call a built-in square root function.
  • Your answer must be accurate to 1 decimal place (e.g., error < 0.05 if rounding).
  • Discuss how you would optimize the algorithm (time complexity and convergence).

Examples

  • x = 2 → 1.4
  • x = 9 → 3.0
  • x = 0 → 0.0

Clarifications to ask

  • Rounding vs truncation to 1 decimal.
  • Input range (e.g., up to 1e9?) and whether x can be non-integer.
  • Acceptable error tolerance if not using decimal formatting.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Uber•More Data Scientist•Uber Data Scientist•Uber Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.