Finish exercise Nr 1
This commit is contained in:
parent
b8ea28c915
commit
8261cb6e4b
25
README.md
Normal file
25
README.md
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
# Aufgabe 1
|
||||
## Dokumentieren Sie die Ausführung des Aufrufs binary(6), indem Sie die Auswertung aller binary-Aufrufe als eigerückte Nebenrechnungen notieren.
|
||||
binary(6)
|
||||
// else
|
||||
binary(6 / 2) + (6 % 2) // wird zu binary(3) + 0
|
||||
|
||||
binary(3)
|
||||
// else
|
||||
binary(3 / 2) + (3 % 2) // wird zu binary(1) + 1
|
||||
binary(1)
|
||||
// if
|
||||
return 1
|
||||
|
||||
-> binary(3) => 1 + 1
|
||||
return 11
|
||||
|
||||
-> binary(6) = toInt("11" + "0")
|
||||
return 110
|
||||
|
||||
## Wie viele binary-Aufrufe werden bei der Auswertung von binary(n) in Abhängigkeit von n ausgeführt?
|
||||
Bei jedem Aufruf -> n/2 bis n <= 1
|
||||
tiefe = anzahl der teilungen / 2
|
||||
---> O(n) = log2(n) + 1
|
||||
+ 1 durch den letzten aufruf (Rekursions Anker)
|
||||
Loading…
x
Reference in New Issue
Block a user