Hash Table - Data Structures & Algorithms Tutorials In Python #5
Вставка
- Опубліковано 21 лип 2024
- Hash map or hash table is a very popular data structure. It allows to store key, value pairs and using key you can locate a value in O(1) or constant time. We will implement simple hash table in python in this tutorial and in part 2 we will see how to handle collisions.
Code: github.com/codebasics/data-st...
Topics
00:00 Introduction
00:34 Array vs hashmap Scenario
03:52 Memory presentation (array vs hashmap)
04:15 Hash function
07:09 Big O Analysis
07:17 Hashmap in Python/JAVA/C++
07:47 Implement Hash Table in python
#HashTable #HashMap #hashmappython #datastructures #algorithms #python
Do you want to learn technology from me? Check codebasics.io/?... for my affordable video courses.
Next Video: • Collision Handling In ...
Previous video: • Linked List - Data Str...
Complete playlist: • Data Structures And Al...
🌎 My Website For Video Courses: codebasics.io/?...
Need help building software or data analytics and AI solutions? My company www.atliq.com/ can help. Click on the Contact button on that website.
#️⃣ Social Media #️⃣
🔗 Discord: / discord
📸 Dhaval's Personal Instagram: / dhavalsays
📸 Codebasics Instagram: / codebasicshub
🔊 Facebook: / codebasicshub
📱 Twitter: / codebasicshub
📝 Linkedin (Personal): / dhavalsays
📝 Linkedin (Codebasics): / codebasics
🔗 Patreon: www.patreon.com/codebasics?fa...
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
Part 2: ua-cam.com/video/54iv1si4YCM/v-deo.html
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
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!
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. ❤💖
An explanation about conflicts and how they are implemented like doing a linear search at each index would be great to show!
Thank you for being an amazing teacher, i was running around like a headless chicken with hash functions, you explanation is simply amazing
best explanation around!! and i've been through many hash table and dictionary videos. Thank you!!
It is unbelievable that learning all of these take really short time , thank you so much for that much clear explanation 😊
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😁
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?
finally i got the concept of hash table. thank you so much.
Thanks.. I have designed my hashmap by getting idea from you and that's good enough for basic understanding... Thanks
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! 😀😀😀
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
Loved your crisp and clear teaching
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.
☺️👍
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.
Great implementation, you got a subscriber !
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.
very nice sir..i have seen many videos on hashing but none of them were not as good as this video for begginers
Thank you so much for your video!! Well explained and it really let me better understand the concepts.
Top quality free education right here!!
Question:
So, if I have to different string keys that hash function on them return same value, how can we distinguish between them? lets say 'march 6' returns 9 as the example here shows and 'MQ' also returns 9, how can I differ?
Superb. Very clean and understandable.
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.
Hi sir. Thank You for amazing content! my que is: so (in other words) are you simply saying we can use *keywords* and *dictionary-style operations* if we opt for standard operators? or is there any other conventions also?
Good vid. Thanks!
I loved implementing methods for standard operator library! Nice job!
Glad it helped!
Amazing content.Subscribed.
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?
Easy to follow and good video
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?
Thanks. Very Nice and elaborative video on this topic.
Thank you very much It's really very informative : )).
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?
Very excellent explanation
Thanks a lot man ! I hope the best for your channel
You have been incredibly helpful to me and many others. Thank you!
👍☺️
8:10 , why not use the hash function instead of ord(). Are there trade offs for using either?
Excelent!! Thank you for this tutorial!!
This was a great explanation, thank you very much now I understand
this chanel is massively underrated.
Can you please share how the retrieving function is changing when the add function is changed to __getitem__?
Thank you very much, for your work!
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 a doubt, if i want to assign the keys 'tea' and 'ate' how will the ascii method work as they give me the same sum of ascii ?
Thank You so much Sir. You are awesome. I do all the exercises.
Well done!
Thank you codebasics!
mind blowing! this man is amazing......
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 video that explains what hash tables do under the hood!
🤗🤗👍
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.
👍👍👍
Loved it. Thank you so much.
Great video. Great explanation.
@codebasics so, the hashmap looks to be using dynamic arrays, instead of like what we saw with dequeue. Is there a way to build a hashmap using something like dequeue then?
awesome sir
What should we do, when we dont know the self.MAX value, and it varies based on data in the given csv. How can we handle this?
thanks for the amazing content!
thanks very much for taking the time
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!
hello there, Great content. at 6:40 you said the size of the array is 10 for "march 6", but I think it should be 7 instead. I didn't get the same values as you got in the collision handling video. can you help me make that explanation of the length of the array out?
This is a very useful video, thank you alot!
Amazing explanation to be honest
Great work
if we insert as 'March 1' and '1 march' both will have same hash value so it will overwrite the previous value and we will lose the prev value.
Anyone knows how to overcome this..??
Or is thr any solution for this...??
Thank You Sir.
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
the best tutorial i have ever listen great explanation tqq sir
Glad it was helpful!
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!
superb vid!!
Iam soo glad i found this channel.
Glad it was helpful!
if i skip self.arr step, i still get the same answer, so why should id use self.arr statement?
Dude, you are cool and your videos are awesome. Best wishes from NYC.
Thanks hamid. I live one hour away from nyc in NJ
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.
Thank you sir:)
very well explained...
Thank you sir
Glad it was helpful!
hey...
how are you using __setitem__, __getitem__ and all??
u didn't even import operators library
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
Sir you are the BEST
Hi How do i download the files for practices ?
can I use pycharm instead of jupyter?
This dictionary is not showing key error likewise in python
how size of array can be 10. I can't understand(6:24)
very well explained.
Glad it was helpful!
hello sir, is this full course for dsa with python
very nice explanation!
Glad it helped!
Thankyou sir
thank you sir
Hello Sir, can you please create a video developing of project using only DSA ?
thank You !
If hash value of 2 name is same then one exchanges other know 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 😊
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)?
what if i want to check whether if key exist in dictionary or not then i have to use in operator and it will going to take o(n) time so how to overcome from it
in operation for a given key will not take o(n). Look up in a hashmap by a key is O(1) on average.
Great!