All language subtitles for 26 - Introduction to Greedy Algorithms English

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:08,880 --> 00:00:12,610 ‫High in this video I'm going to introduce greedy algorithms. 2 00:00:12,750 --> 00:00:14,950 ‫How they work on a high level. 3 00:00:14,970 --> 00:00:16,920 ‫Give some examples on how they work. 4 00:00:16,980 --> 00:00:23,110 ‫And then also some scenarios to show you when a greedy algorithm is not a good idea. 5 00:00:23,280 --> 00:00:30,400 ‫And so essentially how a greedy algorithm works is it takes the highest value first. 6 00:00:30,420 --> 00:00:39,000 ‫And so here on the left hand side I have some American currency in coin values of 25 cents ten cents 7 00:00:39,150 --> 00:00:41,090 ‫five cents and a penny. 8 00:00:41,370 --> 00:00:48,640 ‫If you're watching from the U.S. you know that's a quarter a dime a nickel and Penny one equals one 9 00:00:48,670 --> 00:00:51,300 ‫cent on the right hand side. 10 00:00:51,330 --> 00:01:00,810 ‫I have a made up currency that has values of 1 3 and 4 and I'm going to show you how a greedy algorithm 11 00:01:00,900 --> 00:01:06,450 ‫can be a great thing to implement in order to figure out a problem efficiently. 12 00:01:06,450 --> 00:01:11,050 ‫And then also give a situation where it wouldn't be a good idea. 13 00:01:11,250 --> 00:01:22,440 ‫And so in the first scenario I'm going to have a goal of getting 31 cents and I want to use the fewest 14 00:01:22,530 --> 00:01:30,840 ‫number of coins possible and in order to do that on the left hand side here I can take a quarter 15 00:01:34,790 --> 00:01:36,640 ‫plus a nickel 16 00:01:39,330 --> 00:01:45,220 ‫Plus a penny and that's going to give me 31 cents. 17 00:01:45,270 --> 00:01:53,070 ‫And in this case by going to the highest value first which is what a greedy greedy algorithm is always 18 00:01:53,070 --> 00:01:53,710 ‫going to do. 19 00:01:53,850 --> 00:02:04,370 ‫So I went to the quarter first and that was the best way of doing it because this only took three coins 20 00:02:05,030 --> 00:02:10,460 ‫some other ways of doing it would have been to use 21 00:02:14,330 --> 00:02:25,630 ‫three dimes and one penny which would have given us still 31 cents but it would have required four coins. 22 00:02:25,640 --> 00:02:28,670 ‫And so that would not have been the optimal solution. 23 00:02:28,670 --> 00:02:35,240 ‫Now there are times even in this scenario where this would not be the best way of going about it and 24 00:02:35,780 --> 00:02:41,690 ‫the way to do that would be to say that we're not allowed to use nickels in the case where we're not 25 00:02:41,690 --> 00:02:43,220 ‫allowed to use nickels. 26 00:02:43,310 --> 00:02:55,940 ‫We'd have to use a quarter and then we'd have to use six pennies in order to get our goal of 31. 27 00:02:56,120 --> 00:03:06,170 ‫And this would equal seven coins and you can see with the example above we were able to get to 31 cents 28 00:03:06,170 --> 00:03:08,350 ‫using only four coins and no nickels. 29 00:03:08,350 --> 00:03:15,510 ‫So a very important thing in understanding greedy algorithms are making one work is that you know the 30 00:03:15,910 --> 00:03:21,810 ‫the data that you're using because it will not work in a lot of different cases. 31 00:03:21,980 --> 00:03:28,760 ‫I'm going to go in the right hand side and show you another case where this would not work and where 32 00:03:28,760 --> 00:03:32,800 ‫this case would not work is where we're trying to get to the value 6. 33 00:03:32,870 --> 00:03:37,400 ‫And so this is a made up currency so we don't have any threes or fours. 34 00:03:37,400 --> 00:03:42,170 ‫However I wanted to give another example on when a greedy algorithm are you know taking the largest 35 00:03:42,170 --> 00:03:44,350 ‫value would not be a good idea. 36 00:03:44,600 --> 00:03:51,590 ‫If we want to use the smallest number of coins and we took a greedy algorithm to get to the value of 37 00:03:51,590 --> 00:04:01,700 ‫six we would take one for and then we would have to take two ones in order to get to six. 38 00:04:01,700 --> 00:04:05,680 ‫Now this takes three coins. 39 00:04:05,680 --> 00:04:15,080 ‫However the better choice would have been to just take two of this coin of three value which would equal 40 00:04:15,080 --> 00:04:16,050 ‫six. 41 00:04:16,070 --> 00:04:23,620 ‫And in this case we'd only use two coins and this would have been the optimal solution. 42 00:04:23,660 --> 00:04:29,830 ‫So hopefully that gives you a good idea and how greedy algorithms work at least on a very high level. 43 00:04:29,840 --> 00:04:36,140 ‫Well we'll work on actually implementing some of these and seeing some real world examples on how these 44 00:04:36,140 --> 00:04:36,580 ‫could work. 45 00:04:36,580 --> 00:04:42,440 ‫But the main principles that you want to understand is a greedy algorithm always takes the highest value 46 00:04:42,710 --> 00:04:53,420 ‫and then it essentially selects other items that are secondary in value until it reaches its goal and 47 00:04:53,420 --> 00:04:55,580 ‫it will work in some cases. 48 00:04:55,580 --> 00:04:58,490 ‫However you do have to know your data. 49 00:04:58,550 --> 00:05:02,840 ‫You need to know your values to ensure that it actually is the optimal solution. 50 00:05:02,840 --> 00:05:07,700 ‫So as always please let me know if you have any questions in the comments and I'll see you in the next 51 00:05:07,700 --> 00:05:08,790 ‫video. 5703

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.