*My takeaways:* 1. Pros and Cons in greedy algorithm 1:05 2. Brute force algorithm implementation using search tree 2:08 - Brute force algorithm is not efficient to compute, but dynamic programming can help with it 23:30
@aidenigelson98263 жыл бұрын
Can you please explain to me how the recursive procedure works in maxval? I don't fully understand withval and withoutval and the withtak and without take.
@amolizm Жыл бұрын
bro is not enjoying the show
@jacobsonokoro21734 жыл бұрын
One of the courses that I can say changed my life.
@beoptimistic58533 жыл бұрын
kzbin.info/www/bejne/joGmmHqKbqefqLM 💐.
@pfever5 жыл бұрын
My favorite instructor for this course!
@monffy587 жыл бұрын
I watched this course after 6.006, I have to say Dr John's course is much easier to understand, this one has a lot of vivid examples. Maybe I'm not smart enough to follow 6.006 and 6.046 well, but this course is really detailed and good for most people to learn.
@MrRandompersondude17 жыл бұрын
This is an introductory course, whereas in introduction to Algorithms, the word introduction is somewhat misleading because it is intended for students that have some pre-existing experience in CS.
@Pasora3 жыл бұрын
At 33:02 on line 129 of the code, it should return n instead of 1 because if it returns 1 you will be calculating one step more than what you asked for. fib(5) should return 5 but the code will return you 8 which is fib(6).
@NazriB2 жыл бұрын
Lies again? Oil Petrol
@manojnirmal92943 жыл бұрын
Wonderful lecture and I learned a lot. In the accompanying Python code the lists for values and calories are missing an element. They have 8 elements each while the names list has 9 (See 15:03).
@ArunKumar-yb2jn3 жыл бұрын
This was identified by many commentators in Lecture 1 as well. It's a mistake.
@ElVerdaderoAbejorro7 жыл бұрын
The part about the origin of the name "dynamic programming" was hilarious! \o/ Thank you, professor, for going the extra mile and researching that for us. =D
@JamesJon11873 жыл бұрын
I love how he always looks like he's possibly trying to suppress a laugh. What an awesome guy!!
@duanas6409 Жыл бұрын
In case you don't have the math background, the number of nodes is 2^(n+1)-1 (as @kev92 says) and you get it by using the geometric progression formula and adjusting the indexes en.wikipedia.org/wiki/Geometric_progression#Derivation
@ramind100015 жыл бұрын
I believe Eric Grimson, Ana Bell and JohnGuttag are one of the best lecturers at MIT.
@studywithjosh51094 жыл бұрын
Ramin Dehghan some of*
@marietaazatyan10444 жыл бұрын
Gilbert Strang
@dearharshmehra3 жыл бұрын
Same feeling bro But that may be because you only took 60001 and this course 😁
@dharmiknaik1772 Жыл бұрын
How about prof. Eric Demaine?
@hdsmsmart3 жыл бұрын
Thanks MIT OCW and Dr John Guttag !!!
@pauloflores6376 жыл бұрын
Awesome! I've got really suprised with fast fibonacci's speed. Great job!
@HibsMax3 жыл бұрын
A little bit late to the party, but at 6:36 it seems like the calorie values are messed up. If we're using the same code as before, beer should be 154 instead of 145. Also, Beer+Pizza+Burger cannot be the same as Beer+Pizza, but they both have 766 calories. I think it should be: 766, 412*, 508, 154*, 612, 258, 354, 0 (* = wrong). The answer should be Beer and Burger.
@SinCityGT37 жыл бұрын
Great lecture! Thank you for uploading these. I don't agree at all with using try/except though. The Professors reason was that it's fewer lines of code... but it's actually more. This is much easier to read and looks better... if n in memo: return memo[n] memo[n] = fib(n-1, memo) + fib(n-2, memo) return memo[n]
@akshay.m107 жыл бұрын
python programmers have a practice called "Its easier to ask forgiveness than permission" which means its easier to write try/except rather than writing C/C++ style if-else checks. So follow along
@SinCityGT37 жыл бұрын
Thanks for pointing that out. I looked into it. For others following along, this is done because if you say, "if n in memo return memo[n]" the item has to be looked up twice in the dictionary. I'm hesitant to follow along blindly with their style though, they are using getters and setters.
@atlantis_expedition_member47477 жыл бұрын
I'm with you on this one. To me, the python practice "akshay m" referred to does not have anything to do with this. This to my eyes, is uglier than the if statement method. Also, looking up a dictionary is a constant operation isn't it? So no harm in doing it as much as I like.
@Elite75552 жыл бұрын
@@akshay.m10 The thing is, he commits two sins: he uses Exceptions as normal part of the control flow, and then he even returns from the `except` clause, both of which are terrible code smell, regardless of programming language. I am a great fan of these lectures, but this is a terrible way to teach coding. He should use the `dict.get()` method, which returns `None`. He may think his solution to be "cleaner", but it is also slower. Exceptions are expensive.
@nikitasid49475 жыл бұрын
Correction (6 years after taking the course i have a correction!) regarding mutable arguments in the function's signature (31:44) - don't do that. Well known problem in Python, google for more info.
@sarthakbindal76605 жыл бұрын
But the course was taught in Fall 2016 :p. Which course were you talking about ?..
@sithembelogabela12715 жыл бұрын
@@sarthakbindal7660 probably same course different year.
@LaughingShinoo5 жыл бұрын
It’s not a “problem in Python”. It’s expected behavior, which happens to be unknown for most people. Also, in this specific example it doesn’t hurt, at most it’ll be faster across re-executions..
@letitrot95475 жыл бұрын
Thank you! I'm glad I can take this course
@aidenigelson98263 жыл бұрын
Can someone please explain the recursive procedure in maxval? Especially in the withVal and withtoTake and the opposites of the two? How is it actually exploring the tree? When does it check between withVal and withoutVal
@velzer93402 жыл бұрын
13:35 - withVal and withoutVal appear only in case when it isn't obvious what branch should we choose. Line 69: let's see what is the best achievable result if item X is taken. We call our function with updated list toConsider (without item X) and avail (restriction) decreased by the cost of item X. Respectively, for withoutVal. Eventually, toConsider list will be empty, and the function will return (0, ()). That corresponds to a decision made in a leaf, there are no alternatives. Knowing that the program can determine what decision to make in the last series of nods above leaves. It gives results to the upper level and so on. My explanation is very messy, sorry. Line 75: compare consequences of taking and not taking (withVal and withoutVal) and return the best. The function returns the best possible value and a tuple of taken items for given items and a restriction. Please, ask questions if you have some.
@nataliee7872 Жыл бұрын
@@velzer9340 Thanks for the explanation. Can you please also explain what is the point of variables with_to_take and without_to_take? I didn't quite understand what they represent.
@shobhamourya83965 жыл бұрын
@21:00 For reproducible random numbers seed(int) function is used in R
@nickskiadas73384 жыл бұрын
Is there any possible way to find an indicative solution to problem set 1?
@bjaniak1025 жыл бұрын
Does anyone know where i can find solution to The 'Roll-over' optimization problem which was included at the end of the lecture's slides?
@alute5532 Жыл бұрын
18:00 "Every Node is a legal solution to the problem" But is it better than the Best? If yes it becomes new best why ? In search tree don't actually build a tree By this trick ( backtrack) to beep track of results Is it hopeless, no ans Rand Corp Dynamic programmingr Oxnard bellman Why it didn't mean anything Issue computation seem grow faster than results Fob 3 calculated in many places We can store it! Dictionary Memoization find optimal solution If that's possibl3, we have optimal substructure (when globally optimal solution can be found How combines optimal solutions with, to local sub problems Crucial note dynamic programming won't help us for sorting Braids optimal soution Q what about other overlapping sub-problems Is there a repetition? (solving same solution?) If no overlap exist (clean solution by dynamic programming is possible I.e. run on knapsack Note zero speed up (why?) If each node the problems are different (in knapsack, things to consider) knapsack is a set (duplicate solution is highly possible Check have same problem to solve more than once Why: Solve same problem despite making different decisions (paths) How Modify max val, to use a memo: To use a 1 add third argument 1. Add a third argument :initially Empty dict Key memo: a tuple (items left, available weight) As items Left are in a list (heap or stack?) Represent it by how long it is (length) (by how long your list is) Computational complexity hcan be very subtle notion Run time fastMaxVal governed by Distinct pairs(available, to consider) Number value consider - small (bound by item's value ) Value (weight available) is hard Bounded by number of distinct (weight sums) It's about combinations, ways I can add up the units (750 call it's either that or lower) Practical problems can be optimization ones Optimal solution is exponentially hard (quadratic equation type) Subproblem Solution always correct Right circumstances: Fast Dynamic always give a good result
@notagain37322 жыл бұрын
Im glad i found this
@kev92206 жыл бұрын
Min 9.17 shouldn't the number of nodes be when there are n items: 2^(n+1) - 1 ?
@DenCato5 жыл бұрын
The -1 is correct but it is irrelevant in Big-O notation. Big-O looks at the expense of the algorithm when n gets larger and larger. If n jumps from 100 to 1000, that -1 is really insignificant.
@chickenicecream19424 жыл бұрын
Conclusion: Don't look up answers on Wikipedia xD
@anonviewerciv4 жыл бұрын
Buzzwords = government funding. (25:00) 31:31 Memoization.
@akbarrauf27417 жыл бұрын
thanks,mit
@mawkuri54964 ай бұрын
please upload new 6.100b 😅
@nassimhaddam71367 жыл бұрын
where to find the assigned readings he talked about at the end of the lecture?
@Syncromatic7 жыл бұрын
You can check the MIT OCW page for the course (in the description). The book is "Introduction to computation and programming using python:"
@nassimhaddam71367 жыл бұрын
Thanks. I'll check it.
@ebateru3 жыл бұрын
Awesome lecture once again. I wonder what is it with these students at MIT? They don't laugh at all and there are some good jokes being thrown at them.
@beoptimistic58533 жыл бұрын
kzbin.info/www/bejne/joGmmHqKbqefqLM 💐.
@Steven-lh5dx5 жыл бұрын
清晰简介,优美的讲解,致敬
@marco.nascimento5 жыл бұрын
Amazing lecture
@pandasstory7 жыл бұрын
Amazing lecture, thanks!
@FelipeArayaable4 жыл бұрын
The code he wrote in the first place it is a bit inefficient anyways, for example the fib function could have been solved with a simple for loop and it would have been as fast as his Fastfib function, but less complicated, ignoring this, I love John Guttag, he explains beautifully and very clear.
@lcsjr704 жыл бұрын
But the point was to explain dynamic programming
@jinruifoo70873 жыл бұрын
can anyone explain the withval and withtotake portion?
@beoptimistic58533 жыл бұрын
kzbin.info/www/bejne/joGmmHqKbqefqLM 💐.
@carlosfonseca1437 жыл бұрын
how is the value for each item determine?
@MrSinalta3 жыл бұрын
Hi ! Regarding the fast fib function , I don’t get how the dict memo is updated bottom to top as it is assigned new value only inside function . Is because of the fact dict is mutable ?
@Elite75552 жыл бұрын
It is. All objects are passed by reference.
@khumoyunakhmedov45627 жыл бұрын
good lecture
@stephenadams23974 жыл бұрын
A beer in the knapsack is worth 2 in the bush.
@masterchief15205 жыл бұрын
I also wanted audience reactions . XD
@RyanScarbrough Жыл бұрын
I fear no functions, but that maxVal recursive function, it scares me.
@RyanScarbrough Жыл бұрын
3 days later and I finally understand the gist of it. xD
@katiec55243 жыл бұрын
That "Kernal died" made me laugh
@nathanielsabanski38825 жыл бұрын
lol exceptions for flow control.... performance hit
@aulonsal4234 жыл бұрын
Not a performance hit in python, I think.
@gmorf334 жыл бұрын
Try/except is the norm in python.
@McAwesomeReaper Жыл бұрын
Why are there 9 names in the set, but only 8 values and calories? Don't like Cake?
@kemalware4912 Жыл бұрын
THIS IS FUCKIN GREAT. Thanks sir.
@isbestlizard4 жыл бұрын
MEMOISATION! i know this because erik told me in 6.006!
@isbestlizard4 жыл бұрын
yessssssss i was right!
@isbestlizard4 жыл бұрын
hmm what if instead of storing an exact result for a memoisation you just added it as training data for a ML model and then once you had enough stuff 'memoised' started inferencing it to speed hmmm
@quocvu9847 Жыл бұрын
34:33
@javierurena33673 жыл бұрын
Didn't know Flanders was so cultivated in the field of Computation and Data Science
@ALiJ4LIFE4 жыл бұрын
40:45
@jeremyward93636 жыл бұрын
camel case python .....
@zlatanonkovic24246 жыл бұрын
DontKnowWhatYoureTalkingAbout
@abdulhamidyusuf28485 жыл бұрын
33:00 he waited a clap guys and you made him disappointed😅
@anonviewerciv4 жыл бұрын
1:11 There's a movie the students probably haven't heard of.
@beoptimistic58533 жыл бұрын
kzbin.info/www/bejne/joGmmHqKbqefqLM 💐.
@ArunKumar-yb2jn3 жыл бұрын
Code explanations must be greedy.
@EOh-ew2qf3 жыл бұрын
hehe his jokes are too cute and funny
@ДжонКонэр Жыл бұрын
Great lecture! I hope that all Ukrainians, regardless of age, will be able to study at US universities. 🙌🥰
@lowhertzhighspl7 жыл бұрын
Getting to the root of the matter.. - plays at 06:50 mark - The professor says something similar to, "I don't know why these are drawn upside down." With all due respect, maybe it's not the "tree" that's upside down, your interpretation is. Again, getting to the to the ROOT of the matter. Perception is not only interesting, it's everything. Just ask Einstein.
@mathematicalcoffee27507 жыл бұрын
Brandon Lee Except trees actually do have a top and bottom if you go outside
@davidjames16843 жыл бұрын
How can he not know what 2 ^ 64 is? I am glad I don't have him as a teacher.
@davidjames16843 жыл бұрын
To do the same thing over and over is wasteful. Oh really? How about taking a dump, breathing, brushing your teeth, sleeping, having sex, eating....? Stupid statement. He treats his students like seals/sea lions... when they do/say something right, he throws them a "fish"/prize.