algorithm complexity - what double star means

蹲街弑〆低调 提交于 2019-12-05 12:28:58

** 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!