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).
@@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.
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.
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.
@@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.
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 !
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.
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.
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.
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.
??? 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.
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.
transforming the 0 into 1 was too greedy :)
Hahaha
😂😂
Xdd😂
is that a mistake tho?
I don't get it
😭😭😭😭
Hi Tim. Today is my birthday. I love your content
Happy birthday🥳 2 u
Happy birthday❤️
Happy birthday!
happy birthday! 🥳
No one cares it’s your birthday
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).
The grocery budget is typically a range, so I think the greedy algorithm may be quite helpful.
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(
why isn't it 4,3,2,0 for a sum of 9? at 3:12
It also confuses me. Where does the 1 come from?
@@shdwshdw-mu6vo If 4 = 4 and 3 = 3, then 0 does not = 1
@@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.
it shouldn t he messed up :)
I'm sure it was a mistake
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.
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.
@@dylanwilliams9860 This. Most people dont realize that they get literal days of work for absolutely free on TH-cam
@@dylanwilliams9860 Yes, I realize, but anyone can spend 15-20 minutes for creating video to discuss only one competitive programming problem.
@@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.
Or maybe you could create your own youtube channel and let people upload the content that they want?
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 !
Thanks for the help brother.
Hi Tim can we expect more questions on algoexpert?
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.
3:12
you said: we select 0 but how can you get 1 then 😕😁😢
Yeh I was thinking the same... max total would be 9?
@@RobertPorterNZ yes🙄
I think it's an error, you should bring down 0, which would make the sum 9, like @Robert Porter said.
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.
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 )
Why 1 instead 0
1 is not in the array
It's a mistake
Should be 1, I think
Should be 0 I think again
Can we expect a playlist on greedy or DP?
Tons of thanks.. I hope you will continue to more algorithms
We're greedy more algorithms in future 🔥
I would like to see contents on dynamic programming too tim
Thank you very much!!
I'll try implementing this in a c++ program.
Love the content. Fair play to you keep it coming
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.
I loved this video. Please continue this algorithms and data structures series
Algorithm: *Laughs* *in* *Mr* *Krabs*
I'm all in for an algorithm series from Tim ! I'll even pay for that!!
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))
Greedy means the solution is self-similar - it works at smaller scales (subsets) within the same input.
thank you so much!
Now this is more like it!! 🔥
Awesome ty for the explanation! Any chance on going over a flow (vector) field in the future?
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.
Good video dude, how would you implemnt this algo in python, can you do a practical example
Great video. I have this exact problem in Skyrim.
Expecting more ds and algo
NEED MORE DS AND ALGO!❤❤❤❤
yeaaaaaa boii tim made an algorithm video
this gonna be amazing
love how you explain
please make a algoithm and data structures tutorial
Pretty big topic lol
funny thing is 18 is also the optimal solution for non-fractional units, isn't it? A lucky example :p
please more videos like this
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.
??? 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.
I would solve it with recursion just like the coins exchange problem
tim when are you doing more podcasts? pls reply
the handwriting is not so bad man.
Its better than mine 😆
And what about the code how they look like?
Are we just suppose to ignore his cat? 0:09
Wassup Fresca? How's life on Tim's keyboard?
I've never thought that a fractional knapsack problem could be much easier to solve than a original DP knapsack problem 😂
The Hamster Kombat problem
Will Dynamic Programming (DP) be explained in the video? hahaha
Hi Tim
Can You make tutorial about implemate ai to some game(like birds example) in python? It was super.
Awesome 😎
Hey tim! what's up!
Brother Mico graddy solution please
Like for the cat:3
that's a backpack of holding (for the tibia player 🤪)
my hash rate is 0.053mh/s why ;-; rx 470 4gb binance
hey there 😃
not clearly able to understand
Hi Tim. Today is my bathday. I like your
can you put indonesian text translite plz🥺
Bruteforce
KITTY.
😍😍😍♥♥
Thank you for wasting my 17 minutes and 47 seconds
Why so cheesed lol
KITTY
First
9 mins ago.
Yayyy cattt :)
too much yapping
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.