← Retour au blog
tech 8 July 2026

A Classic Software Engineering Interview Question: Computing the Median

In the realm of technical interviews, certain questions stand out for their ability to delve into deeper concepts. Computing the median is one such question. Discover why it's so favored.

Article inspired by the original source
a software engineering interview question I like: computing the median ↗ krisshamloo.com

Introduction

In the world of technical interviews, some questions have the knack for revealing not only a candidate's basic skills but also their ability to think critically and solve complex problems. One question I particularly like is about computing the median. So, why is this question so popular among software engineering recruiters?

Why the Median?

The median, unlike the mean, is resilient to extreme values. In many applications, it offers a truer representation of the "central value" of a data set. This simple question tests several fundamental skills in a candidate.

Basic Skills

At the most basic level, computing the median requires the candidate to know how to sort an array and manipulate indexes. This might seem basic, but it's a good indicator that the candidate can actually code, much like the "Fizz Buzz" test.

API Design and Performance

This question also opens the door to deeper discussions. For instance, who should sort the array, the function or the caller? If the array is passed by reference, is it acceptable to modify it? These questions touch on API design and performance implications.

Error Handling

What happens if the list is empty? Should an exception be raised, or should a sentinel value be returned? How a candidate approaches these questions can reveal much about their rigor and approach to error handling.

Python Implementation

Here's a simple Python implementation to compute the median:

``python def median(numbers: list[float]) -> float: if not numbers: raise ValueError("median called with empty list") numbers = sorted(numbers) length = len(numbers) mid = length // 2 if length % 2 == 0: return (numbers[mid - 1] + numbers[mid]) / 2.0 else: return numbers[mid] ``

This implementation raises several discussion points, ranging from handling empty lists to using sorting methods.

Statistical Discussions

Finally, the median question allows for statistical discussions. Why prefer the median to the mean in some cases? In salary data, for instance, the median is often more representative of reality than the mean, which can be skewed by exceptionally high salaries.

Conclusion

Ultimately, computing the median is a question that, while simple on the surface, opens the door to a multitude of technical and conceptual discussions. That's why it remains a valuable tool in the arsenal of technical recruiters.

Let's discuss your project in 15 minutes.

median technical interviews API design error handling statistics
Deepthix newsletter · 100% AI · every Monday 8am

An AI agent reads tech for you.

Our AI agent scans ~200 sources per week and ships the best articles to your inbox Monday 8am. Free. One click to unsubscribe.

Visit the newsletter page →

Want to automate your operations?

Let's talk about your project in 15 minutes.

Book a call