Lecture 1:a. Correctnes b. Applets c. Tables Lecture 2 a.Applets b.Tables c.Exercises Lecture 3Lecture 4a. Appletsb. ProblemsLecture 5 Lecture 6 Lecture 7 Lecture 8 Test 1 Test 2

 

public static int mystery(int x) {
if (x > 0) {

return mystery(x-1) + 2*x - 1;

}
else {

return 0;

}
}

La Funcion Mystery(int x) retorna el cuadrado de x, por ejemplo:

mystery(x) = (mystery (x-1)+2x-1)
Mystery(x) =
((mystery(x-2)+2(x-1)-1)+2x-1)
Mystery(x) = (mystery(x-2) + 2x-2-1+2x-1)
Mystery(x) =

mystery (x-2) + 4x – 4

Mystery(x) =

mystery (x-3) + 6x – 9

Mystery(x) = mystery (x-4) + 8x –16
Mystery(x) = mystery (x-5) + 10x –25
Mystery(x) =
...
Mystery(x) = 2 (n^2) + n^2

observamos que la forma cerrada para este algoritmos es:

 

 

 

Algorithms | Blackboard | UNAL | SIA |Bibliotecas|UNALdotNET

Hosted by www.Geocities.ws

1