Содержание
- 2. Factorial: trace A subroutine is said to be recursive if it calls itself, either directly or
- 3. Recursive objects in the world. Fractal objects A huge amount of of things in the real
- 4. Recursion A subroutine is said to be recursive if it calls itself, either directly or indirectly.
- 5. Recursive functions: main principles Important to check that recursion terminates. Code should contain: One or more
- 6. Recursive functions: main principles Recursion has same power as iteration: Every recursive function can be written
- 7. Direct and indirect recursive call A recursive subroutine is one that calls itself, either directly or
- 8. Example: towers of Hanoi Goal: move all the disks from Stack 0 to Stack 1 Stack
- 9. towers of Hanoi Move two elements So we have an algorithm to move two elements
- 10. towers of Hanoi Move three elements Use al algorithm to move two elements: notice evrywhere either
- 11. towers of Hanoi Move n elements Use al algorithm to move n-1 elements: notice evrywhere either
- 12. Recursive binary search static int binarySearch(int[] A, int loIndex, int hiIndex, int value) { if (loIndex
- 13. Binary search Look for 15 1, 2, 5, 8, 13, 15, 23, 25, 45 1, 2,
- 14. Deklaratiivne vs imperatiivne Programmeerimiskeeli ja -meetodeid saab klassifitseerida mitmel moel. Selle loengu kontekstis sobib jaotada programmeerimiskeeled
- 15. Deklaratiivsed vs imperatiivsed keeled Deklaratiivsed keeled sobivad algoritmi esitamiseks käskude jadast abstraktsemal viisil. Programmeerija ei pruugi
- 16. Plussid ja miinused Deklaratiivsed keeled võimaldavad enamikku programme kiiremini ja mugavamalt kirjutada, kui imperatiivsed keeled -
- 17. Funktsionaalsed ja loogilised keeled Deklaratiivsed keeled jaotatakse Funktsionaalse programmeerimise keelteks (näide: Haskell), kus lahendus kirjeldatakse funktsioonide
- 18. Alus: lambda-arvutus Lambda-arvutuse keel on Alonzo Churchi poolt 1930. aastatel leiutatud lihtne ja universaalne meetod funktsioonide
- 19. Annonüümsed funktsioonid üks harilikumaid praktikas kasutatavaid funktsioonide kirjapaneku viise on selline: f(x) = x*x + 1
- 21. Скачать презентацию