Die letzten 4 Beiträge |
eulerscheZahl |
Im Zusammenhang ist auch klar, was mit n gemeint ist.
ed wollte wohl, dass du selbst nachdenkst, wofür n steht.
"ein normal Zahl" ist mir zu ungenau.
Für welche "Variable" steht n? |
lilie |
eig ist die Aufageb so gegeben .
aber n kann ein normal Zahl. |
ed209 |
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? |
lilie |
Laufzeitkomplixistät
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? |
|
|