Laufzeitkomplixistät |
lilie
Grünschnabel
Dabei seit: 22.03.2016
Beiträge: 2
|
|
public static bool zahlenschloss(Integer[] code, int position) {
if(position == code.length()){
return codeIsCorrect(code);
}
for(int i=0; i<=9; i++){
code[position]=i;
if(zahlenschloss(code,position+1)){
return true;
}
}
return false;
}
kann jemand mir erklären warum der Aufwand hier O(10^n) ist?
|
|
27.03.2016 04:13 |
|
|
ed209
Routinier
Dabei seit: 07.09.2006
Beiträge: 324
|
|
Zuerst einmal:
1. Kannst Du mir sagen, was in deinem Fall n ist?
2. Wie oft wird "codeIsCorrect" aufgerufen, wenn n=1, wie oft wenn n=2 usw?
|
|
27.03.2016 07:05 |
|
|
lilie
Grünschnabel
Dabei seit: 22.03.2016
Beiträge: 2
|
|
eig ist die Aufageb so gegeben .
aber n kann ein normal Zahl.
|
|
27.03.2016 16:30 |
|
|
|