r******r 发帖数: 700 | 1 Complexity 是多少? 别运行,试试看。
public static void mysteriousAlgorithm(String st, String chars) {
if (chars.length() == 1)
System.out.println(st + "" + chars);
else
for (int i = 0; i < chars.length(); i++) {
String newString = chars.substring(0, i) + chars.
substring(i + 1);
mysteriousAlgorithm(st + chars.charAt(i), newString);
}
} | p*****r 发帖数: 56 | 2 simple permutation? O(n!)
【在 r******r 的大作中提到】 : Complexity 是多少? 别运行,试试看。 : public static void mysteriousAlgorithm(String st, String chars) { : if (chars.length() == 1) : System.out.println(st + "" + chars); : else : for (int i = 0; i < chars.length(); i++) { : String newString = chars.substring(0, i) + chars. : substring(i + 1); : mysteriousAlgorithm(st + chars.charAt(i), newString); :
| r******r 发帖数: 700 | 3 你很熟悉啊。像这种 complexity, 该怎么分析呢?
从程序不容易看出来吧。难道从数学的角度?
【在 p*****r 的大作中提到】 : simple permutation? O(n!) : :
| p*****r 发帖数: 56 | 4 EN. 就是從數學角度.
專做 complexity的那些人多數連程序都不寫. 就是個數學家
~
【在 r******r 的大作中提到】 : 你很熟悉啊。像这种 complexity, 该怎么分析呢? : 从程序不容易看出来吧。难道从数学的角度?
|
|