Software Engineering Intern Interview Question

What is Big O notation, and how would you work out the complexity of your own code?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Big O describes how an algorithm's running time or memory grows as the input grows, ignoring constants and keeping the dominant term. To work it out, count how many times the main operations run relative to the input size: one loop over n items is linear, a loop inside a loop is quadratic, halving the problem each step is logarithmic, and good sorting is n log n. Do the same for extra memory.

Why interviewers ask this

Interns are expected to reason about efficiency, not just produce working code. The interviewer wants a clear definition, the common complexity classes, and the ability to analyse a real piece of code, including space as well as time. They also like to hear that Big O describes growth rather than actual speed, so a simpler quadratic solution can be perfectly fine when the input is always small.

How to structure your answer

  • Define Big O as a description of growth.
  • Name the common classes with an example of each.
  • Show how you analyse loops and library calls.
  • Mention space complexity and when Big O matters less.

Example answer

Spoken example, first person

Big O describes how the work an algorithm does grows as the input gets bigger. It ignores constants and smaller terms, so if a function does three n plus five steps we just call it order n, because for large inputs the n is what matters. The ones I see most are constant time, like reading an array element by index; logarithmic, like binary search, where you halve the range each step; linear, like a single loop over a list; n log n for good sorting algorithms; and quadratic, like comparing every pair with nested loops. To analyse my own code I look at the loops and how many times each runs relative to the input. Two separate loops over a list are still linear, but a loop inside a loop over the same list is quadratic. I also check what library calls cost, because checking whether an item is in a Python list is itself a linear search. Then I think about memory, for instance whether I create a copy of the input. And I keep it in perspective: for a list of twenty items, the simpler quadratic version is often fine.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • What is the complexity of binary search, and why?
  • What is the difference between best, average and worst case?
  • Can you give an example where a faster algorithm is not worth it?

Related software engineering intern questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot