Grokking Algorithms



Download 6,4 Mb.
Pdf ko'rish
bet52/120
Sana21.12.2022
Hajmi6,4 Mb.
#893167
1   ...   48   49   50   51   52   53   54   55   ...   120
Bog'liq
Grokking Algorithms An Illustrated Guide for Programmers and Other

6
breadth-first
search
his chapter introduces graphs. First, I’ll talk about what graphs 
are (they don’t involve an X or Y axis). hen I’ll show you your irst 
graph algorithm. It’s called 
breadth-irst search
(BFS).
Breadth-irst search allows you to ind the shortest distance 
between two things. But shortest distance can mean a lot of things! 
You can use breadth-irst search to
• Write a checkers AI that calculates the fewest moves to victory


96
Chapter 6
 
 
I
 
 
Breadth-irst search
• Write a spell checker (fewest edits from your misspelling to a real 
word—for example, READED -> READER is one edit)
• Find the doctor closest to you in your network
Graph algorithms are some of the most useful algorithms I know. Make 
sure you read the next few chapters carefully—these are algorithms 
you’ll be able to apply again and again.
Introduction to graphs
Suppose you’re in San Francisco, and you want to go from Twin Peaks 
to the Golden Gate Bridge. You want to get there by bus, with the 
minimum number of transfers. Here are your options.


97
Introduction to graphs
What’s your algorithm t
o ind the path with the fewest steps?
Well, can you get there in one step? Here are all the places you can get 
to in one step.
he bridge isn’t highlighted; you can’t get there in one step. Can you get 
there in two steps?
Again, the bridge isn’t there, so you can’t get to the bridge in two steps. 
What about three steps?


98
Chapter 6
 

Download 6,4 Mb.

Do'stlaringiz bilan baham:
1   ...   48   49   50   51   52   53   54   55   ...   120




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