April 2018
Beginner to intermediate
426 pages
10h 19m
English
Consider the following function:
function increment(num){
return ++num;
}
If we try to execute the increment(1) function, we will have an execution time equal to x. If we try to execute the increment function again with a different parameter (let's say num is 2), the execution time will also be x. The parameter does not matter; the performance of the function increment will be the same. For this reason, we can say the preceding function has a complexity of O(1) (which is constant).