Greedy Algorithms Explained

  Рет қаралды 119,369

Tech With Tim

Tech With Tim

Күн бұрын

Пікірлер: 117
@evgiz0r
@evgiz0r 3 жыл бұрын
transforming the 0 into 1 was too greedy :)
@shubhamg9495
@shubhamg9495 3 жыл бұрын
Hahaha
@Im.justsayin
@Im.justsayin 3 жыл бұрын
😂😂
@agiopneuma33
@agiopneuma33 2 жыл бұрын
Xdd😂
@MahmoudSayed-hg8rb
@MahmoudSayed-hg8rb 2 жыл бұрын
is that a mistake tho? I don't get it
@danagharz90
@danagharz90 2 жыл бұрын
😭😭😭😭
@sumukhjagirdar5860
@sumukhjagirdar5860 3 жыл бұрын
Hi Tim. Today is my birthday. I love your content
@venkatesanjayaraman2987
@venkatesanjayaraman2987 3 жыл бұрын
Happy birthday🥳 2 u
@kiw.
@kiw. 3 жыл бұрын
Happy birthday❤️
@TechWithTim
@TechWithTim 3 жыл бұрын
Happy birthday!
@DewasSquid
@DewasSquid 3 жыл бұрын
happy birthday! 🥳
@shemdogga2845
@shemdogga2845 3 жыл бұрын
No one cares it’s your birthday
@Rebeljah
@Rebeljah 3 жыл бұрын
I already had the answer to optimal solution but only because this is EXACTLY what you do in your head when you are comparing prices at a grocery store. Maximizing the value/size ratio to stay within a certain limit (your grocery budget).
@radicalpotato666
@radicalpotato666 Жыл бұрын
The grocery budget is typically a range, so I think the greedy algorithm may be quite helpful.
@mintlatte1376
@mintlatte1376 11 ай бұрын
well, in my head I don't have to write a code to make it work, every one walks through the logic and no one shows how on earth I should code all this(
@whyisknight6taken
@whyisknight6taken 3 жыл бұрын
why isn't it 4,3,2,0 for a sum of 9? at 3:12
@woolfool
@woolfool 3 жыл бұрын
It also confuses me. Where does the 1 come from?
@daverobertson8399
@daverobertson8399 3 жыл бұрын
@@shdwshdw-mu6vo If 4 = 4 and 3 = 3, then 0 does not = 1
@sukhmandersingh4306
@sukhmandersingh4306 3 жыл бұрын
@@shdwshdw-mu6vo no that's not true, 0 and 1 are completely different. Values other than 0 maybe treated as 1 in some cases but i have never seen 0 treated as 1. Tim most likely just made a mistake there.
@antoine_9667
@antoine_9667 2 жыл бұрын
it shouldn t he messed up :)
@samcarter9111
@samcarter9111 2 жыл бұрын
I'm sure it was a mistake
@736939
@736939 3 жыл бұрын
Tim, please more videos like this. 20-30 videos of Greedy algorithms then 20-30 videos of Dynamic programming, then Divide and Conquer - this is the real programming: Django, Flask, React everyone can learn fast, but Algorithms are more important.
@dylanwilliams9860
@dylanwilliams9860 3 жыл бұрын
Do you realise how much work goes into even a single video? The research and fact checking, development, storyboarding, editing and all the steps I didnt mention mean a 20 minute video for us takes 2-4 days each to make. 20 videos is way way way overkill for just about anything you could want to learn. You would actually want like 3-5 videos on it as thats an hour and a half of lectures, is more than enough to explain a topic, and won't take him a full year to get out.
@rortox1539
@rortox1539 3 жыл бұрын
@@dylanwilliams9860 This. Most people dont realize that they get literal days of work for absolutely free on KZbin
@736939
@736939 3 жыл бұрын
@@dylanwilliams9860 Yes, I realize, but anyone can spend 15-20 minutes for creating video to discuss only one competitive programming problem.
@dylanwilliams9860
@dylanwilliams9860 3 жыл бұрын
@@736939 first off, competitive programming is fun. But its full of bad practices that should never be within 300 light-years of production code. Secondly, I just said the videos take days to create and check. Most Vlogs even take several hours worth of takes for big channels. The only time something takes "20 minutes" is in your head or on stream.
@joshk9328
@joshk9328 3 жыл бұрын
Or maybe you could create your own youtube channel and let people upload the content that they want?
@ofiryaffe8223
@ofiryaffe8223 3 жыл бұрын
Nice video, also a good example because I actually understood on my own the greedy algorithm of the fractional knapsack problem. Keep making videos about algorithms !
@raghaventrarajaram
@raghaventrarajaram 6 ай бұрын
Thanks for the help brother.
@Raghav1205
@Raghav1205 3 жыл бұрын
Hi Tim can we expect more questions on algoexpert?
@futhedude4848
@futhedude4848 Жыл бұрын
this is just explain for "Fractional Knapsach Problem" solved by "Greedy Algorithms", there are many more Problems we can use "Greedy" to resolve. but this clip is good at explaining so well done.
@khimleshgajuddhur6892
@khimleshgajuddhur6892 3 жыл бұрын
3:12 you said: we select 0 but how can you get 1 then 😕😁😢
@RobertPorterNZ
@RobertPorterNZ 3 жыл бұрын
Yeh I was thinking the same... max total would be 9?
@khimleshgajuddhur6892
@khimleshgajuddhur6892 3 жыл бұрын
@@RobertPorterNZ yes🙄
@rbrojas2040
@rbrojas2040 2 жыл бұрын
I think it's an error, you should bring down 0, which would make the sum 9, like @Robert Porter said.
@ashleydean9350
@ashleydean9350 3 жыл бұрын
Hello . I am new to this topic - however with your explanation and some maths background this is easy topic to understand. Excellent explanation. Tim you are doing a superb job- keep it up.
@dominator1699
@dominator1699 3 жыл бұрын
You always upload a video on the topic I wanna learn haha. (btw idk if you knew this but fresca in arabic means a type of sweet snacks :D )
@ajaswanth6607
@ajaswanth6607 3 жыл бұрын
Why 1 instead 0
@ajaswanth6607
@ajaswanth6607 3 жыл бұрын
1 is not in the array
@clashgamers4072
@clashgamers4072 3 жыл бұрын
It's a mistake
@Andycheong-ei4es
@Andycheong-ei4es Ай бұрын
Should be 1, I think
@Andycheong-ei4es
@Andycheong-ei4es Ай бұрын
Should be 0 I think again
@pythonenthusiast9292
@pythonenthusiast9292 3 жыл бұрын
Can we expect a playlist on greedy or DP?
@r125l6
@r125l6 3 жыл бұрын
Tons of thanks.. I hope you will continue to more algorithms
@codeaperture
@codeaperture 3 жыл бұрын
We're greedy more algorithms in future 🔥
@aravindhang1264
@aravindhang1264 3 жыл бұрын
I would like to see contents on dynamic programming too tim
@yvanbrunel9734
@yvanbrunel9734 3 жыл бұрын
Thank you very much!! I'll try implementing this in a c++ program.
@kian180
@kian180 3 жыл бұрын
Love the content. Fair play to you keep it coming
@pedrorequio5515
@pedrorequio5515 3 жыл бұрын
Do a series on Metaheuristics, the video simplifies alot what I know is a very difficult subject, not all problems are small enough to solve like this in code or have simple heuristics to solve. I am interested in more videos on this kind of algorithms of optimization.
@ananthramvijayaraj4554
@ananthramvijayaraj4554 3 жыл бұрын
I loved this video. Please continue this algorithms and data structures series
@Cookie-mv2hg
@Cookie-mv2hg 3 жыл бұрын
I'm all in for an algorithm series from Tim ! I'll even pay for that!!
@justins7796
@justins7796 3 жыл бұрын
Algorithm: *Laughs* *in* *Mr* *Krabs*
@korsik4559
@korsik4559 3 жыл бұрын
def algorithm(items, capacity): ratio = sorted([(size, value, value / size) for size, value in items], key=lambda tup: tup[2], reverse=True) total_size = total_value = 0 for size, value, _ in ratio: new_size = total_size + size if new_size > capacity: break total_size = new_size total_value += value else: return total_value return total_value + (capacity - total_size) / size * value items = ((22, 19), (10, 9), (9, 9), (7, 6)) capacity = 25 print(algorithm(items, capacity))
@heh2k
@heh2k 3 жыл бұрын
Greedy means the solution is self-similar - it works at smaller scales (subsets) within the same input.
@kietphamhoanganh5641
@kietphamhoanganh5641 3 жыл бұрын
thank you so much!
@judedavis92
@judedavis92 3 жыл бұрын
Now this is more like it!! 🔥
@Jkindelb
@Jkindelb 3 жыл бұрын
Awesome ty for the explanation! Any chance on going over a flow (vector) field in the future?
@sunitmody6064
@sunitmody6064 2 жыл бұрын
This is really useful Tim, but you might want to be slightly more careful with the numbers you say and write on the screen lol. A couple of times you misspoke or mis-wrote.
@CodeWithJoe
@CodeWithJoe 3 жыл бұрын
Good video dude, how would you implemnt this algo in python, can you do a practical example
@evantoomey6712
@evantoomey6712 3 жыл бұрын
Great video. I have this exact problem in Skyrim.
@mohitjain4943
@mohitjain4943 3 жыл бұрын
NEED MORE DS AND ALGO!❤❤❤❤
@ajaswanth6607
@ajaswanth6607 3 жыл бұрын
Expecting more ds and algo
@noobypro4560
@noobypro4560 3 жыл бұрын
yeaaaaaa boii tim made an algorithm video this gonna be amazing
@sanduchicu7545
@sanduchicu7545 3 жыл бұрын
love how you explain
@unknownman5296
@unknownman5296 3 жыл бұрын
please make a algoithm and data structures tutorial
@billowen3285
@billowen3285 3 жыл бұрын
Pretty big topic lol
@cuteflygon
@cuteflygon 6 ай бұрын
funny thing is 18 is also the optimal solution for non-fractional units, isn't it? A lucky example :p
@kasyapdharanikota8570
@kasyapdharanikota8570 3 жыл бұрын
please more videos like this
@ys98110
@ys98110 3 жыл бұрын
??? If you can get fractions of item, why not just select the best value/size item for all? What's the point in just getting one of it? Really don't understand how this derives any optimal solution.
@pv9060
@pv9060 3 жыл бұрын
Fun Fact: Texting robots on Mars use python to send images to the earth. It uses request module to communicate with the API on mars.
@odocic
@odocic 2 жыл бұрын
I would solve it with recursion just like the coins exchange problem
@shawnbeans7389
@shawnbeans7389 3 жыл бұрын
tim when are you doing more podcasts? pls reply
@vishwakamps
@vishwakamps 3 жыл бұрын
the handwriting is not so bad man. Its better than mine 😆
@DaigoMatsuoka
@DaigoMatsuoka 2 жыл бұрын
And what about the code how they look like?
@Ben-jw7yw
@Ben-jw7yw 3 жыл бұрын
Are we just suppose to ignore his cat? 0:09
@harshit.chitkara
@harshit.chitkara 3 жыл бұрын
Wassup Fresca? How's life on Tim's keyboard?
@TheKiryu.
@TheKiryu. 3 жыл бұрын
I've never thought that a fractional knapsack problem could be much easier to solve than a original DP knapsack problem 😂
@phivebee
@phivebee 5 ай бұрын
The Hamster Kombat problem
@HuanYinKoh1995
@HuanYinKoh1995 3 жыл бұрын
Will Dynamic Programming (DP) be explained in the video? hahaha
@PP-tc1zp
@PP-tc1zp 3 жыл бұрын
Hi Tim Can You make tutorial about implemate ai to some game(like birds example) in python? It was super.
@demonslayer8502
@demonslayer8502 3 жыл бұрын
Awesome 😎
@mrolivernone4040
@mrolivernone4040 3 жыл бұрын
Hey tim! what's up!
@fojifojigurjar2461
@fojifojigurjar2461 3 жыл бұрын
Brother Mico graddy solution please
@criss5404
@criss5404 3 жыл бұрын
Like for the cat:3
@flyte9844
@flyte9844 2 жыл бұрын
that's a backpack of holding (for the tibia player 🤪)
@thenewelegance7772
@thenewelegance7772 3 жыл бұрын
my hash rate is 0.053mh/s why ;-; rx 470 4gb binance
@Knuddelfell
@Knuddelfell 3 жыл бұрын
hey there 😃
@raghunathmahakud3725
@raghunathmahakud3725 3 жыл бұрын
not clearly able to understand
@GenericInternetter
@GenericInternetter 3 жыл бұрын
Hi Tim. Today is my bathday. I like your
@lonelyboy8640
@lonelyboy8640 3 жыл бұрын
can you put indonesian text translite plz🥺
@scrutinyng3018
@scrutinyng3018 3 жыл бұрын
Bruteforce
@pshr2447
@pshr2447 3 жыл бұрын
KITTY.
@AMIN-yn5nl
@AMIN-yn5nl 3 жыл бұрын
😍😍😍♥♥
@islomkhujaakhrorov6668
@islomkhujaakhrorov6668 4 ай бұрын
Thank you for wasting my 17 minutes and 47 seconds
@hassassinator8858
@hassassinator8858 4 ай бұрын
Why so cheesed lol
@skyricq
@skyricq 3 жыл бұрын
KITTY
@dydigaming
@dydigaming 3 жыл бұрын
First
@mastersrikavipriyan280
@mastersrikavipriyan280 3 жыл бұрын
9 mins ago.
@nickchourchoulis
@nickchourchoulis 3 жыл бұрын
Yayyy cattt :)
@gurkeeratsinghgarrysangha2433
@gurkeeratsinghgarrysangha2433 Ай бұрын
too much yapping
@emonymph6911
@emonymph6911 3 жыл бұрын
Tim, with all due respect. Pretty please invest in a digital inkpad your handwriting is worse then a busy doctors... Writing with the mouse is hard but I think you will be fine with a e-pad.
What Is Dynamic Programming and How To Use It
14:28
CS Dojo
Рет қаралды 1,6 МЛН
Jump Game - Greedy - Leetcode 55
16:28
NeetCode
Рет қаралды 268 М.
УНО Реверс в Амонг Ас : игра на выбывание
0:19
Фани Хани
Рет қаралды 1,3 МЛН
진짜✅ 아님 가짜❌???
0:21
승비니 Seungbini
Рет қаралды 10 МЛН
Greedy Algorithms with real life examples | Study Algorithms
14:02
Nikhil Lohia
Рет қаралды 22 М.
7 Outside The Box Puzzles
12:16
MindYourDecisions
Рет қаралды 512 М.
3. Greedy Method -  Introduction
12:02
Abdul Bari
Рет қаралды 1,5 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 786 М.
Interval Scheduling Maximization (Proof w/ Exchange Argument)
20:20
Back To Back SWE
Рет қаралды 67 М.
Dynamic Programming Explained (Practical Examples)
29:00
Tech With Tim
Рет қаралды 109 М.
How Dijkstra's Algorithm Works
8:31
Spanning Tree
Рет қаралды 1,4 МЛН
Mastering Python - Everything You Need To Know To Become a Python Master
16:02
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 737 М.
12. Greedy Algorithms: Minimum Spanning Tree
1:22:10
MIT OpenCourseWare
Рет қаралды 231 М.
УНО Реверс в Амонг Ас : игра на выбывание
0:19
Фани Хани
Рет қаралды 1,3 МЛН