Chapter 10 Recursion Instructor: Kun-Mao Chao (台大資工 趙坤茂) Rekursiv funksiya



Download 1,08 Mb.
bet7/8
Sana01.01.2022
Hajmi1,08 Mb.
#285851
1   2   3   4   5   6   7   8
Bog'liq
2 5400013869605195795

Recursive fibonacci Function

  • Copyright ©2004 Pearson Addison-Wesley. All rights reserved.
  • 10-
  • In our midterm, you are required to write a fibonacci function.
    • It can be easily solved by the recursive function
    • But the recursive function is inefficient because the same fibonacci values may be computed more than once.

Recursive gcd Function

  • Copyright ©2004 Pearson Addison-Wesley. All rights reserved.
  • 10-
  • Generally speaking, if the algorithm to a problem is defined recursively in itself, we would tend to use the recursive function.
  • e.g., the greatest common divisor (GCD) of two integers m and n can be defined recursively.
    • gcd(m,n) is n if n divides m evenly;
    • gcd(m,n) is gcd(n, remainder of m divided by n) otherwise.

Download 1,08 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish