26
loading...
This website collects cookies to deliver better user experience
big(O)
measure, the amount of work a program has to do as the input scales. Big(O)
in other can be used to define both time and space complexitiesBig(O)
starting from best case scenarios to worst case scenarios.D
at the index of 3 in the array).getAlphabetAt
method gets a particular element at a constant position in an array.getAlphabetAt
method always performs two steps.First, get the element at a certain position.
Second, console.logs()
the result to the console.
getCubicValues()
will take 3 steps to complete.params
to getCubicValues()
method, the method finds the cube of each of the item in the array and then logs it to the console
.getProductValue
method multiplies each element in that array with other elements.N*N
where N
is the number of elements in the arrayBest case scenarios
Worst case scenarios
O(1)
.nth index
(last) in this case we can say the complexity would be an O(N)
where N
is the total number of items in the array.