# What counts as an operation?

Apologies for the newbie question, but I am a bit confused about what exactly counts as a "simple operation" when working out the time complexity of an algorithm. In particular, why do we consider all operations to be equal?

Surely, dividing two very large numbers is more time-consuming than adding one to a number (as in each iteration of a for loop). Multiplication, for example, can consist of any number of small additions. So, instead of just adding them up shouldn't we be applying some kind of weight to each operation depending on the type of operation (addition, multiplication, etc) and the size of the numbers involved?

My problem is that I am being asked to prove that the complexity of my algorithm is $O(f)$ (for some function $f$) and I am not sure how to do this in a mathematically rigorous fashion because of the inherent vagueness in the definition of a "simple operation". So how would I go about this?

• Welcome to the site! This is a very simplified explanation and I'm not sure it addresses the issue very well. In particular, there are multiple models of computation. With Turing machines, for example, you can't even index into an array in constant time; with word models, you can do arithmetic on $O(\log n)$-bit numbers in constant time, where $n$ is the length of the input. One needs to select an appropriate model for the thing that's been analyzed and the situations in which the analysis will be used. Mar 19, 2018 at 10:49