MIT 6.006 Introduction to Algorithms, Fall 2011 View the complete course: ocw.mit.edu/6-006F11 Instructor: Erik Demaine License: Creative Commons BY-NC-SA More information at ocw.mit.edu/terms More courses at ocw.mit.edu
@ everyone saying this guy is amazing, and wishing their teacher was like this, this guys is insanely good, he started university when he was 12, got his bachelors degree when he was 14, and completed his PhD thesis when he was 20. He's the youngest every teacher at MIT
Example= MIA(2*2)------>4, M-77 I-105 A-97, Equation= sum of axes divided by array boxes and then 77+105+97 / divided by 11, which is the number of array boxes. 279/11=8 , I know afterwards I would find the next index number for the new key/name given , its just that I wrote this down about a year ago , but the part about how I found the axes 77,105,& 97 is missing , so can u renew my memory on how I go about finding the axes again?
This guy is a genius. He founded his first software company when he was 8 with his dad. At 10 he graduated high school (not validictorian) and went on to university. At 13 he graduated university and sold his company for 1.2 million dollars. He went on to win a Politzer prize and patent for a computerized fabrics machine. MIT asked him to start teaching at the age of 16 and here we are.
Awesome lecture! I can't imagine the number of books he have read and the skills he have mastered to be this good. So much respect sir. You are worth emulating!
Example= MIA(2*2)------>4, M-77 I-105 A-97, Equation= sum of axes divided by array boxes and then 77+105+97 / divided by 11, which is the number of array boxes. 279/11=8 , I know afterwards I would find the next index number for the new key/name given , its just that I wrote this down about a year ago , but the part about how I found the axes 77,105,& 97 is missing , so can u renew my memory on how I go about finding the axes again?
So many cool things going on beyond the lecture content. First, the movable boards. That is so cool. Never saw anything like this before in my 53 years. Second, Erik's writing style on the board is very clear. Headings underlined, numbers circled, etc. It's all very on-purpose and makes me wonder if that comes from formal training or if Erik devised it on-the-fly. The content is great too. He explains the concepts with the ease of someone with deep understanding. Loving this series.
my professor just gave us about 6 simple very dry PP slides, gave us starter code with data structure and gave us a pop quiz. I wish this guys was my professor.
@siddarth kamaria There is a Collection of hash functions you can use. 'a' and 'b' are random chosen in the beginning. Since then you must use the same hash function.
I can read here many people are complaining that if they had teacher like this lecturer,they would be happy. But the matter of fact is they all have him. Eric is teaching that's what teacher does , it's your job to make as much use of it and donate for such causes once you succeed in life.
@@patmaloyan620 yeah yeah. it's awesome to listen the courses at 1.5 or 2.0 speeds and it's increasing the focus. absolutely great. and we're finishing it in less time too. tons of time saved, thanks for the youtube videoplayer.
MIT is so freaking lucky. At UPenn and Temple, I had to write notes like a madman because no lectures were recorded. I wasted sooo much time writing notes and trying to write fast enough that the lecture was pretty much pointless, and resulted in me basically reviewing notes and asking questions at a later time.
Gary C I never took notes ever and graduated top of my class; it's best just to pay attention to the lecture in class and then use a textbook for anything concrete.
He's right! In Python, the id of an object is equal to the hash of the id. d = { 'a': 1, 'b': 2, 'c': 3 } for key,value in d.items(): print(key) print(id(key)) print(hash(id(key))) Output: a 5045920 5045920 b 5044240 5044240 c 4964624 4964624
hash("\b0")=hash("\0\0C")=64 means that two different keys map to the same thing, 64. ideally you want if hash(x)=hash(y) then x=y that means the keys are the same. but sometimes we can have a collision where x!=y.
If teaching in 2022 was like this I would really be mf Genius in Data structure and IT, unfortunately they only stream videos and you MUST UNDERSTAND IT ALONE
If a and b are random, does that make the hash function non-deterministic? Do we have to cache the calculated hashes in order to look items up in a hash table after they've been inserted?
At 33:15 Erik draws a linked list to store multiple items where their key collides. How does one retrieve the correct item on a lookup? The keys themselves seem to be absent from the linked list, so how do you know which item to return?
I think the assumption is that the item is a tuple with the key and corresponding value. As in the Python implementation explained earlier in the video.
The key is immutable for each object. Otherwise you couldn't reconstruct it later on. So either you calculate the key for each object in the list anew or you save tuples.
@MIT Opencourseware While explaining simple uniform hashing, Erik suggested that independence is necessary but is independence really necessary? The expected length of a chain comes out the same whether you assume independence or not. My solution without assuming independence: let R1 be indicator random variable for the event that a random key falls into the 1st bucket. R2 be the independent random variable for the event that a random key falls into the 2nd bucket and so on. Initially assume all slots or buckets are empty. A chain length becomes length one when a random key falls into one of the slots and remains the same when it falls into any other bucket. So, l1 be the length of chain in the first slot; l2 be the length of chain in the second slot and so on. So, total length of chain would be l= l1+l2+l3+...+lm. So, expected length of chain E(l)= E(l1+l2+l3+...+lm)= E(l1)+ E(l2)+ E(l3)+...+E(m).... (by linearity of expectation which does not need independence). E(l1)= 1.1/m+ 0.(1-1/m)= 1/m = E(l2)= E(l3)=...=E(lm) So, E(l) would be n/m. I did not assume independence. Where did I go wrong? Someone please explain.
Does anyone feel why the lecture is bounded by time, I just he feel he explains whatever knowledge he has in how much ever time he needs for it. Awesome lecture @ErikDemaine
How can 'a' and 'b' be random? If we call the hash function another time it might generate another values for 'a' and 'b'. I'm unclear what is he referring to by describing 'a' and 'b' as random...Any help would be appreciated.
Example= MIA(2*2)------>4, M-77 I-105 A-97, Equation= sum of axes divided by array boxes and then 77+105+97 / divided by 11, which is the number of array boxes. 279/11=8 , I know afterwards I would find the next index number for the new key/name given , its just that I wrote this down about a year ago , but the part about how I found the axes 77,105,& 97 is missing , so can u renew my memory on how I go about finding the axes again?
Pillows?! Wow that's peculiar. I almost thought that was some sort of secret invitation to a underground brainiac party held by him (he has that cult leader quality).
Example= MIA(2*2)------>4, M-77 I-105 A-97, Equation= sum of axes divided by array boxes and then 77+105+97 / divided by 11, which is the number of array boxes. 279/11=8 , I know afterwards I would find the next index number for the new key/name given , its just that I wrote this down about a year ago , but the part about how I found the axes 77,105,& 97 is missing , so can u renew my memory on how I go about finding the axes again?
halfway through this lecture, just wondering , can i use this information if im coding in c++ or will some of the stuff be different. Im currently learning hashing for my advanced algorithms class, someone let me know so i don't waste my time or go off in a tangent.
No tangent, you're probably kind of screwed. And yes it will be different by vast margins, C++ has std::hash_map and std::unordered_map. However if you need to implement a hash map, it's not the same.
Yeah I've never heard of a prehash and hash the way he describes it. I know it as: the hash function turns an object into an integer. And the compression function gives you some integer within the bounds of the underlying array. A google search doesn't give that many results for pre-hash or prehash so... my guess is the are less popular terms (?)
From my understanding, prehash merely turns your non-int keys into integers but does not address the problem of space, so you hash the resultant integer using a more complex hash function which should theoretically convert the integer into another integer within a specific set of integers with m as the upper bound
The "prehash" is a function that converts the state of the key object to an integer; the "hash" function converts it to a hash table index. This is a logical division of labor; the key type "knows" how to convert the object to an integer, and the hash table "knows" how to convert that integer to a hash table index. But neither of them has to know anything about the other. What he's calling the prehash is done in Java, for example, by overriding the Object.hashCode() method; in C++, it is generally done by define a hash class and implementing operator(). The hash function then generally uses either the division method or the multiplication method, as described in the video. I personally prefer the multiplication method since it works with hash table sizes that are powers of 2, and that allows you to use the table resizing discussed in the next lecture in this series.
Thank you for the video. I have question. Why don't we instead of using hash table and liked list together, use two hash tables and link them with a unique queue.
They are actually seat cushions.... Srini explains that the seats in the hall are uncomfortable to sit on for long durations. So a cushion is a perk one earns for answering questions. I wouldn't be surprised if there a cult angle to the scenario though.
the issue with collision, if the developers had just taken the string of bytes, appended itself, for example /0B and /0/0C, turn that into /0B + B0/, and /0/0CC0/0/ so that you have palindromes, the collision should occur less if at all, instead of using the raw string of hash.
For that useless piece of paper that says doing some shitty handwork by some professor is a better way to be recognized on the job market than learning by your self .
+Gherbi Hicham Employer doesn't have time to test every job applicant so he/she wants a proof of knowledge issued by institutions which he/she trusts same way you want to use medicine approved by official institution for testing medicine.
ionezgb I didn't say every job , sure i won't go to someone without a medicine degree if i felt pain , some jobs just need to be certified by an institution , some can only be proven by institution , again how on earth are you going to prove that you can prescribe drugs without a university degree ? that's not my point , my point is that a lot of jobs don't need a university degree at all and its good respectable well payed jobs as well, being a programmer for example can have multiple other proofs of knowledge other than a University degree , good projects on Github , a good Stackoverflow reputation count , even down right list of the projects you've built and several other things can land you a job as a developer in a lot of places, infact some jobs will even require things like your programming profile. This misconception that you need college in order to work a proper or a well paying job is just getting ridiculous, a lot of people don't have the time nor the financial resources to engage in a university program, and a lot of people who enrole in college for a useless liberal arts degree only find themselves several years later with no job and a massive loan , University shouldn't be for every one , and not everything needs a degree . This is coming from someone who spent 5 years at college for a masters in Computer Science .
I understand how to put stuff in the hashtable, what I don't understand is how to look it back up. If your key is random, how do you know which key to look up?
Where are the videos for 6046? EDIT: It was suggested for me one time. Here's the link for one video related to this: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-z0lJ2k0sl1g.html