Informatiker Board (http://www.informatikerboard.de/board/index.php)
- Themengebiete (http://www.informatikerboard.de/board/board.php?boardid=1)
--- Praktische Informatik (http://www.informatikerboard.de/board/board.php?boardid=6)
---- Algorithmen (http://www.informatikerboard.de/board/board.php?boardid=17)
----- Laufzeitkomplixistät (http://www.informatikerboard.de/board/thread.php?threadid=2928)


Geschrieben von lilie am 27.03.2016 um 04:13:

  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?



Geschrieben von ed209 am 27.03.2016 um 07:05:

 

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?



Geschrieben von lilie am 27.03.2016 um 16:30:

 

eig ist die Aufageb so gegeben .
aber n kann ein normal Zahl.



Geschrieben von eulerscheZahl am 27.03.2016 um 16:33:

 

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?


Forensoftware: Burning Board, entwickelt von WoltLab GmbH