Do you want to learn python from me with a lot of interactive quizzes, and exercises? Here is my project-based python learning course: codebasics.io/courses/python-for-beginner-and-intermediate-learners
@@zack176 It is ASCII table, it is a fixed table of characters . in this table every alphabet has a specific number in which that number is converted to binary number
I got a little upset at how long it took me to learn the other one, but I read online that a good timeline for the whole topic of DSA can take up to a year. That actually makes me feel better, since spending a few days on a topic doesn't seem like too slow now. Hopefully I can get through these videos and start on leetcode and have a job by the end of the year. I wasted a lot of time in my younger years, but I'm ready to get this journey fully started. Thank you for the videos!
I watched this video and now my understanding of dict is much more clear how behind the scenes are actually handled . Thank you so much sir Please keep it up
My university doesn't give me DSA as they said they doesn't have teaching staff(for electrical engineering students). But I really want to learn it and I'm doing the same because of you. Thanku so much sir for this playlist, it means a lot to students like me. And also shared this playlist to my friends as well😁
Really very happy about finding such an obvious and understood funny video series about data structures and algorithms. Everything is 100% clear with deeply explained theories and well-understood practicals. Also, the exercise series with the videos are highly appreciated. Dear sir thank you so much for the fantastic video series. ❤💖
I have been python developer for past 4 years. Just used dictionary many times. But never knew how the internals of it worked. This was great explanation. Thanks.
Too Good. Last time I attended your Pandas Tutorial. Its been more than 4 years since. And I am reliving my Pandas Memories through this Videos. Thank You. You continue to inspire and improve life of mine. :-)
Great explanation of the difference between a dictionary and a list. I'm new to programming. I've only just begun using libraries in some practice problems and I've been struggling to understand why the time is O(1). I'm still not sure how this is the case, but I'm hoping it becomes clear after the next video and a little more practice!
Okay few questions: 1. Where is the hash table stored? 2. Are these objects(key, value) pairs stored contiguously in memory? 3. If my self.arr has 5 elements and I try to add the 6th one the first added hash-value is overwritten in self.arr but I can still access the new value with the first added hash, why is that so?
Thanks for your effort! May I ask about why and when would I, as a python programmer, need to use hash tables data structure while I already have the dictionary data structure already implemented for my in python?
This is just for your own understanding on how data structures work internally. This understanding will be helpful when you are writing bit python programs and you can choose your data structures such as dictionary , list wisely. You are right that you will be using already available data structures such as dictionary
another advantage of hash over dictionary is that you can make your storage according to your choice where as in dictionary if we want to store 1000 values the process is lengthy so i think hash is good
Hello there. This is a great video and I really enjoy the series on data structures. I suppose that there are more sophisticated hash functions that deal with collisions for example key: "Dec 1" has the same hash value with key: "1 Dec". My question is what is the initial memory allocation of a dictionary d = {} (for example 100 slots?) and what happens when this memory allocation is exceeded. Is it handled like the list. Thank you in advance
I would like to suggest a concept over here, which was wrong in the video if we use the map in C++ that means it is an ordered map which implements red-black tree hence the order becomes O(log(n)) for searching and other operations thus it is not the hash map and hash map for C++ is unordered_map.
What if two keys have same hash values after applying the hash function Thank You so much Sir. You are awesome. I do all the exercises. Great work sir Iam soo glad i found this channel. very well explained. Thanks for such a comprehensive explanation of how a dictionary works in python. I do have one query - Why is it that only the final hash map shows in my output and all the other operations done prior to the last one do not? Only the del item array is shown in the output and not those when we added the item in final call. Is it something to do with mutable and immutable datatypes? i have a question w/ hashmaps/tables, in your example of using h = 0 and h += ord(char), and h % 100, isn't it possible for multiple occurrences of different h values getting the same h % 100, for example h = 309, 209, 109 all equal h % 100 = 9, additionally I would imagine there are multiple waysof getting the sum_total h = 309 depending on the characters, wouldn't these multiple occurrences overwrite each other in the hash table?
8:25 : what "h % 100" does is divide h by 100 and returning the remainder: "march 9" in ascii is 609 so "609 / 100 = 6.09", the remainder is 09, so the result shown is 9
I have a technical interview on Python for the Data engineer position. I would grateful If you could give me an overview which topic should I cover or mainly focus on. Thanks in advance for your suggestion
I have one question - 1. for ex there are 50,000 records and from that for 20,000 keys hash value is 9 (after doing modulo) . Then how we will store that 20,000 records in 9th location. 2. Then for searching what is the mechanism so that for the point no 1 it is 0(1) 3. If we will do linear probing or quadratic probing, how come complexity is 0(1) in hashing.
1. If I understood your question it's like if we already have a value in position 9 and we want to add a new value and the index generated by the hash function was the same how can we deal with? Yeah, I'm also learning but I know that we have methods and ways to solve this issue, this problem is called collision and has ways to solve! 2. I really didn't understand very well your question! 3. Because imagine we have 100,000 elements in our array and we need to look up for an element remember that we are looking to array with 100,000 elements the 100,000 is our n and in the worst case we need to look each position and only find the element in the last position or we can also no find the element in the array it will cost for us a complexity of O(n) it's not good! But with hash table, we just give a key and hash function will convert it in one index and we can easily access this index of the array and see if in that position has something stored if it has something stored it will return to us this thing but else we can say that we didn't find anything! And we avoid the necessity of go through all array!
Hello, That was really a nice illustration. I have a question if you could help me with that...I have to store binary matrices and further, I want to retrieve that matrices on some similarity(exact or approximate) basis with the query matrix, not on the index basis. Can you suggest a suitable data structure for this task? I mean should I use the Hash-table or Tree or any user-defined data structure?
At 6:34, you said "mode operation"...please note that is very dangerous. A mode() operation finds the most frequent number in a series of values, but what you're doing in code is MODULUS operation (spoken as "MAWD", not "mode") which returns the remainder. A data scientist will surely lose her job if she can't express the difference between them and is misunderstood by, say, marketing or management to make a decision. Enjoy your videos because you hit all the important areas, so don't take it personally, it's to point this out for you and students so they can avoid an inevitable pitfall. It's worth practicing the difference in both communicating and in code. Cheers.
Tony, thanks for pointing it out. Not being a native English speaker sometimes this happens sometimes Thanks for teaching the correct pronunciation. I would pronounce this as a modulo operator to keep it safe and avoid confusion ☺️👍🙏
I'm confused, aren't dictionaries in python hash tables? Plus dictionaries will do the hashing and will deal with collisions. Why would you want to do this?
@codebasics.. I really like and Appreciate your effort and i understand much better now.. thank you for that... while i have a qq: Q: what if the modulo returns a value which is out of the 100 (MAX) like 101.. or some thing..? i mean if ord(char) returns a value which is out of bounds..?
When you use modulo operator it will guarantee that your value remain in the limits. For example when I call n modulo 100, the return value is guaranteed to be between 0 and 99
Really nice video. TY! Could it happen that using your hash function (ascii code sum and modulo), we get the same modulo result for two different strings? E.g., string x results in 709 mod 100 = 9 and string y results in 809 mod 100 = 9? TY!
Thanks for such a comprehensive explanation of how a dictionary works in python. I do have one query - Why is it that only the final hash map shows in my output and all the other operations done prior to the last one do not? Only the del item array is shown in the output and not those when we added the item in final call. Is it something to do with mutable and immutable datatypes?
Do you want to learn python from me with a lot of interactive quizzes, and exercises? Here is my project-based python learning course: codebasics.io/courses/python-for-beginner-and-intermediate-learners
What if hash function returns same value for 2 different keys
@@piyushkumarsahoo8771 it is collision
"Dictionary is the python specific implementation of the hash table" This is gold!
yes
5:55 bro i couldn't get this first method what does it called i can't hear it can you tell whats that table at right
@@zack176 It is ASCII table, it is a fixed table of characters .
in this table every alphabet has a specific number in which that number is converted to binary number
I got a little upset at how long it took me to learn the other one, but I read online that a good timeline for the whole topic of DSA can take up to a year. That actually makes me feel better, since spending a few days on a topic doesn't seem like too slow now. Hopefully I can get through these videos and start on leetcode and have a job by the end of the year. I wasted a lot of time in my younger years, but I'm ready to get this journey fully started. Thank you for the videos!
how did your job application go after learning dsa?
Any updates? Don't leave us hanging bruh
Wow, I'm surprise. The way you explain the concept, how to use it, how to use it in the better way is so easy to understand. Thank you so much!
I watched this video and now my understanding of dict is much more clear how behind the scenes are actually handled .
Thank you so much sir
Please keep it up
it is an insanely awesome explanation. this I guess is the best explanation in youtube..
My university doesn't give me DSA as they said they doesn't have teaching staff(for electrical engineering students). But I really want to learn it and I'm doing the same because of you.
Thanku so much sir for this playlist, it means a lot to students like me.
And also shared this playlist to my friends as well😁
Really very happy about finding such an obvious and understood funny video series about data structures and algorithms. Everything is 100% clear with deeply explained theories and well-understood practicals. Also, the exercise series with the videos are highly appreciated. Dear sir thank you so much for the fantastic video series. ❤💖
I have been python developer for past 4 years.
Just used dictionary many times. But never knew how the internals of it worked.
This was great explanation. Thanks.
☺️👍
best explanation around!! and i've been through many hash table and dictionary videos. Thank you!!
Thank you for being an amazing teacher, i was running around like a headless chicken with hash functions, you explanation is simply amazing
Too Good. Last time I attended your Pandas Tutorial. Its been more than 4 years since. And I am reliving my Pandas Memories through this Videos. Thank You. You continue to inspire and improve life of mine. :-)
Glad to hear that Ritish and wish you a happy learning
An explanation about conflicts and how they are implemented like doing a linear search at each index would be great to show!
i paid 30,000 for a course. i didn't understand what the guy was trying to tell. i saw this video and everything is clear. love you sir.
👍👍👍
Part 2: th-cam.com/video/54iv1si4YCM/w-d-xo.html
It is unbelievable that learning all of these take really short time , thank you so much for that much clear explanation 😊
Great Video! Really helped me understand Hash Tables. After watching this video I made my own video on the topic. You just got a new sub! 😀😀😀
this chanel is massively underrated.
Great explanation of the difference between a dictionary and a list. I'm new to programming. I've only just begun using libraries in some practice problems and I've been struggling to understand why the time is O(1). I'm still not sure how this is the case, but I'm hoping it becomes clear after the next video and a little more practice!
You made this comment a year ago how are you faring now?
@@josiahdavid7735 he quit programming
@@ruubesh3678 Are you serious?
This was a very helpful video for anyone struggling in DS
Thank you so much for your data structures video explanations!! Your explanation is amazing and I understand the material a lot better!
I am happy this was helpful to you.
Top quality free education right here!!
Thanks.. I have designed my hashmap by getting idea from you and that's good enough for basic understanding... Thanks
Great video that explains what hash tables do under the hood!
🤗🤗👍
finally i got the concept of hash table. thank you so much.
awesome sir
Thank you so much for making this video! It's very informative and very well-explained. Really appreciate the effort!
Glad it was helpful Wilmer :)
Dear Sir, You explain really well. I request you to kindly upload more videos of DSA in python if possible.
Loved your crisp and clear teaching
the best tutorial i have ever listen great explanation tqq sir
Glad it was helpful!
Iam soo glad i found this channel.
Glad it was helpful!
Easy to follow and good video
Good vid. Thanks!
I loved implementing methods for standard operator library! Nice job!
Glad it helped!
Great implementation, you got a subscriber !
Thank you so much for the simplify the hash map and dictionary concept, please keep making videos.
I am happy this was helpful to you.
Thanks. Very Nice and elaborative video on this topic.
You have been incredibly helpful to me and many others. Thank you!
👍☺️
Sir you are the BEST
mind blowing! this man is amazing......
This was a great explanation, thank you very much now I understand
Amazing explanation to be honest
Siempre😊 un turco enseña excelente programación
Amazing content.Subscribed.
Superb. Very clean and understandable.
Thank you very much, for your work!
Very excellent explanation
Thank you so much for your video!! Well explained and it really let me better understand the concepts.
very well explained...
Thank you sir
Glad it was helpful!
Excelent!! Thank you for this tutorial!!
Thanks a lot man ! I hope the best for your channel
Great work sir
Glad it was helpful!
@@codebasics sir I want to become data scientist after dropping out for 4 years after college do I have any chance of getting a job
Dude, you are cool and your videos are awesome. Best wishes from NYC.
Thanks hamid. I live one hour away from nyc in NJ
Great video. Great explanation.
very nice explanation!
Glad it helped!
very well explained.
Glad it was helpful!
Loved it. Thank you so much.
This is a very useful video, thank you alot!
Thank you codebasics!
Thank you very much It's really very informative : )).
Thank You Sir.
The joke at the end got me laughing out loud XD
ha ha.. to be honest I am not good in cracking jokes but I am making an attempt to learn that skill 😊
Okay few questions:
1. Where is the hash table stored?
2. Are these objects(key, value) pairs stored contiguously in memory?
3. If my self.arr has 5 elements and I try to add the 6th one the first added hash-value is overwritten in self.arr but I can still access the new value with the first added hash, why is that so?
Excellent, good sir
Many thanks
thanks for the amazing content!
thanks very much for taking the time
Thanks for your effort! May I ask about why and when would I, as a python programmer, need to use hash tables data structure while I already have the dictionary data structure already implemented for my in python?
This is just for your own understanding on how data structures work internally. This understanding will be helpful when you are writing bit python programs and you can choose your data structures such as dictionary , list wisely. You are right that you will be using already available data structures such as dictionary
another advantage of hash over dictionary is that you can make your storage according to your choice where as in dictionary if we want to store 1000 values the process is lengthy so i think hash is good
@@codebasics thank you, 2 years later this response is still helping people!
You're amazing dude!
Thanks for your kind words my friend
Well done!
Hello there. This is a great video and I really enjoy the series on data structures.
I suppose that there are more sophisticated hash functions that deal with collisions for example key: "Dec 1" has the same hash value with key: "1 Dec".
My question is what is the initial memory allocation of a dictionary d = {} (for example 100 slots?)
and what happens when this memory allocation is exceeded. Is it handled like the list.
Thank you in advance
5:55 whats thata table called on the right
I would like to suggest a concept over here, which was wrong in the video if we use the map in C++ that means it is an ordered map which implements red-black tree hence the order becomes O(log(n)) for searching and other operations thus it is not the hash map and hash map for C++ is unordered_map.
What if two keys have same hash values after applying the hash function
Thank You so much Sir. You are awesome. I do all the exercises.
Great work sir
Iam soo glad i found this channel.
very well explained.
Thanks for such a comprehensive explanation of how a dictionary works in python. I do have one query - Why is it that only the final hash map shows in my output and all the other operations done prior to the last one do not? Only the del item array is shown in the output and not those when we added the item in final call. Is it something to do with mutable and immutable datatypes?
i have a question w/ hashmaps/tables, in your example of using h = 0 and h += ord(char), and h % 100, isn't it possible for multiple occurrences of different h values getting the same h % 100, for example h = 309, 209, 109 all equal h % 100 = 9, additionally I would imagine there are multiple waysof getting the sum_total h = 309 depending on the characters, wouldn't these multiple occurrences overwrite each other in the hash table?
bro any other channel for DSA in python ???
Thank You so much Sir. You are awesome. I do all the exercises.
great content
Glad it was helpful!
amazing video thank you so so much
I am glad you liked it
Bomb video dude 🔥
ha ha ... what a comment. I like it Stones. :)
8:25 : what "h % 100" does is divide h by 100 and returning the remainder:
"march 9" in ascii is 609 so "609 / 100 = 6.09", the remainder is 09, so the result shown is 9
array : you need element which is at index 9 , use loop
hash: i can just print(array[9])
bro any other channel for DSA in python ???
bro any other way of extracting price based on day using loop only
@@PIYUSH-lz1zq may be ofcouse
@@PIYUSH-lz1zq r u working on trading application?
@@protecz5370 no .. want to improve python by solving data structure
I have a technical interview on Python for the Data engineer position. I would grateful If you could give me an overview which topic should I cover or mainly focus on. Thanks in advance for your suggestion
I have one question -
1. for ex there are 50,000 records and from that for 20,000 keys hash value is 9 (after doing modulo) . Then how we will store that 20,000 records in 9th location.
2. Then for searching what is the mechanism so that for the point no 1 it is 0(1)
3. If we will do linear probing or quadratic probing, how come complexity is 0(1) in hashing.
1. If I understood your question it's like if we already have a value in position 9 and we want to add a new value and the index generated by the hash function was the same how can we deal with? Yeah, I'm also learning but I know that we have methods and ways to solve this issue, this problem is called collision and has ways to solve!
2. I really didn't understand very well your question!
3. Because imagine we have 100,000 elements in our array and we need to look up for an element remember that we are looking to array with 100,000 elements the 100,000 is our n and in the worst case we need to look each position and only find the element in the last position or we can also no find the element in the array it will cost for us a complexity of O(n) it's not good! But with hash table, we just give a key and hash function will convert it in one index and we can easily access this index of the array and see if in that position has something stored if it has something stored it will return to us this thing but else we can say that we didn't find anything! And we avoid the necessity of go through all array!
This video is amazing thank you
Glad you liked it!
class MyHashMap(object):
def __init__(self):
self.arr = [-1] * 1000001
def put(self, key, value):
self.arr[key] = value
def get(self, key):
if self.arr[key] in self.arr:
return self.arr[key]
else:
return -1
def remove(self, key):
self.arr[key] = -1
Hello, That was really a nice illustration. I have a question if you could help me with that...I have to store binary matrices and further, I want to retrieve that matrices on some similarity(exact or approximate) basis with the query matrix, not on the index basis. Can you suggest a suitable data structure for this task? I mean should I use the Hash-table or Tree or any user-defined data structure?
Great work
Thank you 💕 sir 😊
Glad it was helpful!
superb vid!!
At 6:34, you said "mode operation"...please note that is very dangerous. A mode() operation finds the most frequent number in a series of values, but what you're doing in code is MODULUS operation (spoken as "MAWD", not "mode") which returns the remainder. A data scientist will surely lose her job if she can't express the difference between them and is misunderstood by, say, marketing or management to make a decision. Enjoy your videos because you hit all the important areas, so don't take it personally, it's to point this out for you and students so they can avoid an inevitable pitfall. It's worth practicing the difference in both communicating and in code. Cheers.
Tony, thanks for pointing it out. Not being a native English speaker sometimes this happens sometimes Thanks for teaching the correct pronunciation. I would pronounce this as a modulo operator to keep it safe and avoid confusion ☺️👍🙏
@@codebasics You're MOST welcome...yes, I was going to suggest the same...modulo is safest bet ;)
ngl theroy and implimentations are both perfect
I'm confused, aren't dictionaries in python hash tables? Plus dictionaries will do the hashing and will deal with collisions. Why would you want to do this?
Yes they are hashtables. I did this so that you can an understanding of inner workings of it.
Sometimes interviewers would not be happy with using dictionaries directly
good explanation!
😊👍
Thank you sir:)
Thanks Sir
Welcome
instead of asci we can use
index=int(key[-2:-1])-5
thank you sir
this is gold
@codebasics.. I really like and Appreciate your effort and i understand much better now.. thank you for that... while i have a qq:
Q: what if the modulo returns a value which is out of the 100 (MAX) like 101.. or some thing..? i mean if ord(char) returns a value which is out of bounds..?
When you use modulo operator it will guarantee that your value remain in the limits. For example when I call n modulo 100, the return value is guaranteed to be between 0 and 99
Really nice video. TY! Could it happen that using your hash function (ascii code sum and modulo), we get the same modulo result for two different strings? E.g., string x results in 709 mod 100 = 9 and string y results in 809 mod 100 = 9? TY!
Thanks for such a comprehensive explanation of how a dictionary works in python. I do have one query - Why is it that only the final hash map shows in my output and all the other operations done prior to the last one do not? Only the del item array is shown in the output and not those when we added the item in final call. Is it something to do with mutable and immutable datatypes?
Now I have really understood how the dictionary works in Python... But what will happen when you will try to add more element than 100 (self. MAX)?
8:10 , why not use the hash function instead of ord(). Are there trade offs for using either?
Thanks sir but you’d made background dark coz I have karataconus and light hurts.
Hey Amran, sorry about that. I made my later videos in dark background with big fonts.