Grokking Algorithms



Download 24,82 Mb.
Pdf ko'rish
bet81/122
Sana22.07.2022
Hajmi24,82 Mb.
#839971
1   ...   77   78   79   80   81   82   83   84   ...   122
Bog'liq
grokking-algorithms-illustrated-programmers-curious

EXERCISES
8.6
A postman needs to deliver to 20 homes. He needs to find the 
shortest route that goes to all 20 homes. Is this an NP-complete 
problem? 
8.7
Finding the largest clique in a set of people (a 
clique
is a set of people 
who all know each other). Is this an NP-complete problem?
8.8
You’re making a map of the USA, and you need to color adjacent 
states with different colors. You have to find the minimum number 
of colors you need so that no two adjacent states are the same color. 
Is this an NP-complete problem?


160
Chapter 8
 
 
I
 
 
Greedy algorithms
Recap
• Greedy algorithms optimize locally, hoping to end up with a global 
optimum. 
• NP-complete problems have no known fast solution. 
• If you have an NP-complete problem, your best bet is to use an 
approximation algorithm. 
• Greedy algorithms are easy to write and fast to run, so they make 
good approximation algorithms.


161
In this chapter
• You learn dynamic programming, a
technique to solve a hard problem by
breaking it up into subproblems and
solving those subproblems first.
• Using examples, you learn to how to come up
with a dynamic programming solution to a
new problem.
dynamic
programming
9
The knapsack problem
Let’s revisit the knapsack problem from chapter 8. 
You’re a thief with a knapsack that can carry 4 lb 
of goods.


162
Chapter 9

Download 24,82 Mb.

Do'stlaringiz bilan baham:
1   ...   77   78   79   80   81   82   83   84   ...   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