Does anybody know what means doubled-star in complexity algorithm like this O(N**3)
? I found that one in PHP's similar_text() function and do not understand it.
thx
Does anybody know what means doubled-star in complexity algorithm like this O(N**3)
? I found that one in PHP's similar_text() function and do not understand it.
thx
** means power. Hence, n**3 means n^3. Complexity is of the order n^3 or O(n^3)
This double star is the exponentiation operator in PHP(^ operator in general for exponentiation).
As per PHP manual,
$a ** $b ---- Exponentiation Operator
Result of raising $a to the $b'th power. Introduced in PHP 5.6.
hence, here the complexity is O(n^3),i.e., O of (n raised to power 3) OR cubic complexity.
It's not always easy to write mathematics when you're only allowed ASCII, so often writers resort to using operators found in programming languages as a way of concisely representing the mathematics.
In some languages, **
means exponentiation, and this is what it means here. ASCII doesn't have a superscript, so it's impossible to represent exponentiation in standard mathematical notation if you're restricted to ASCII. The fact that you found this in a PHP context is a further clue, since PHP is one of the languages that uses **
for exponentiation.
O(n**3)
means O(n3).
**
star is short hand for raise to power(and also a valid operator in some languages). This is the same as N^3
. Thus the function has cubic complexity.