Grokking Algorithms



Download 24,82 Mb.
Pdf ko'rish
bet31/122
Sana22.07.2022
Hajmi24,82 Mb.
#839971
1   ...   27   28   29   30   31   32   33   34   ...   122
Bog'liq
grokking-algorithms-illustrated-programmers-curious

EXERCISE
3.2
Suppose you accidentally write a recursive function that runs 
forever. As you saw, your computer allocates memory on the 
stack for each function call. What happens to the stack when your 
recursive function runs forever?


50
Chapter 3
 
 
I
 
 
Recursion
Recap
• Recursion is when a function calls itself.
• Every recursive function has two cases: the base case
and the recursive case.
• A stack has two operations: push and pop.
• All function calls go onto the call stack.
• The call stack can get very large, which takes up a lot of memory.


4
In this chapter
• You learn about divide-and-conquer. Sometimes 
you’ll come across a problem that can’t be solved 
by any algorithm you’ve learned. When a good 
algorithmist comes across such a problem, they 
don’t just give up. They have a toolbox full of
techniques they use on the problem, trying to 
come up with a solution. Divide-and-conquer
is the first general technique you learn.
You learn about quicksort, an elegant sorting
algorithm that’s often used in practice. Quicksort 
uses divide-and-conquer.
51
quicksort
You learned all about recursion in the last chapter. This chapter 
focuses on using your new skill to solve problems. We’ll explore 
divide and conquer
(D&C), a well-known recursive technique for 
solving problems.
This chapter really gets into the meat of algorithms. After all, 
an algorithm isn’t very useful if it can only solve one type of 
problem. Instead, D&C gives you a new way to think about solving 


52

Download 24,82 Mb.

Do'stlaringiz bilan baham:
1   ...   27   28   29   30   31   32   33   34   ...   122




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