Understanding and implementing a Hash Table (in C)

  Рет қаралды 371,202

Jacob Sorber

Jacob Sorber

Күн бұрын

Пікірлер
@leokiller123able
@leokiller123able 3 жыл бұрын
The fastest guy to solve a segfault on earth x)
@ramprasad7
@ramprasad7 3 жыл бұрын
Absolutely.
@dimi5862
@dimi5862 2 жыл бұрын
It's not hard lol, you just get used to it after some time in c
@leokiller123able
@leokiller123able 2 жыл бұрын
@@dimi5862 yeah now I ve reached this level its been 10 month since the comment 😂
@julengirard8611
@julengirard8611 2 жыл бұрын
I'm dead 💀
@Ryan-xq3kl
@Ryan-xq3kl 2 жыл бұрын
there is no segfault, only bad code
@RustedCroaker
@RustedCroaker 2 жыл бұрын
For those who might get the idea of storing age as a data field literally, never do that! Store the date of birth instead, and calculate the age at the time of the output, otherwise your data will be invalid in less than a year.
@Amy-mo9ki
@Amy-mo9ki Жыл бұрын
thank you for reminding me
@urisinger3412
@urisinger3412 Жыл бұрын
Its better to check every frame if the year changed
@RustedCroaker
@RustedCroaker Жыл бұрын
@@urisinger3412 I'm sure you know that not everyone was born on January 1, right?
@urisinger3412
@urisinger3412 Жыл бұрын
@@RustedCroaker then ask for age in years and days
@RustedCroaker
@RustedCroaker Жыл бұрын
@@urisinger3412... or just date of birth as I said in the first comment.
@ileanagheorghisor
@ileanagheorghisor 3 жыл бұрын
It's amazing how nicely you explained this! You didn't just dump some code on us, you explained the whole thinking process, making adjustments on the way, teaching us how to think the hashtable, not just how to copy it. I am so looking forward to watch your other videos, I really hope they will help me improve my data structures implementing abilities. Online college classes weren't too favorable for me and I am having a hard time doing my assignments in time.
@JacobSorber
@JacobSorber 3 жыл бұрын
Glad it was helpful!
@velim6597
@velim6597 Жыл бұрын
He did exactly the opposite. Started off good but messed it throughput the way. Not the best at teaching I guess, however it was a valiant effort to show people how to be shit at teaching.
@mario7501
@mario7501 4 жыл бұрын
Man, I’m surprised you don’t have a million subscribers yet. This is the best channel on programming out there. I am currently reading “the Linux programming interface” which is a massive book and I always find myself coming to your channel if I don’t quite understand a certain topic! I hope a lot more people will recognize the value you provide here!
@yuvaraj9268
@yuvaraj9268 3 жыл бұрын
Good move to go through Linux Programming Interface, which you can always refer to, for Programming on the Linux Platform.
@Daniel95221
@Daniel95221 2 жыл бұрын
He is held back by his loud keyboard ;)
@edwardmacnab354
@edwardmacnab354 2 жыл бұрын
@@Daniel95221 mario or jacob ? or both !
@AshleyBaker75
@AshleyBaker75 Жыл бұрын
Everything is going so quickly I had to slow it down to 0.75x playtime, so then you sounded drunk so I thought I'd have a beer too. Now I'm watching Star Wars drunk.
@smrtfasizmu6161
@smrtfasizmu6161 2 жыл бұрын
These videos make me fall in love more and more into programming. Although programming was my love at first sight. Great, clear and fun explanation. It was a pleasure to code along. As a beginner it was a miracle to me that you got only 1 segmentation fault (as I am not used to that lol).
@rosiearasa9818
@rosiearasa9818 3 жыл бұрын
probably the only channel I watch at speed of .75! Thanks for the great tutorial!
@drcl7429
@drcl7429 2 жыл бұрын
best typing sound of all tutorials on youtube
@ayoubmentag9883
@ayoubmentag9883 2 жыл бұрын
In 11:44 in strncmp() function You need to put MAX_NAME instead of TABLE_SIZE ; Thanks a lot Jacob that was super useful :)
@LinuxJediMaster
@LinuxJediMaster 2 жыл бұрын
I instantly saw this as well lol.
@blankspace1959
@blankspace1959 2 жыл бұрын
yeah was confused for a bit there as to why put the table size
@karimkohel3240
@karimkohel3240 5 жыл бұрын
i love that you started on data structures thank you so much this is helping me in my courses a lot
@JacobSorber
@JacobSorber 5 жыл бұрын
Glad I could help.
@cadenjosiah9515
@cadenjosiah9515 3 жыл бұрын
i dont mean to be off topic but does anyone know of a way to get back into an Instagram account?? I was dumb forgot my password. I would love any assistance you can offer me
@AkimboFennec
@AkimboFennec Жыл бұрын
This is the best video on Hash Tables that i ever encountered. Thank you so much for making it so clear to understand.
@rafaelbrustolin4687
@rafaelbrustolin4687 Ай бұрын
Probably the best video i've seen about hash tables recently
@ntuindip5042
@ntuindip5042 Жыл бұрын
This is the best video on KZbin on this topic. Thanks very much sir
@RPBiohazard
@RPBiohazard 3 жыл бұрын
Wow, this is an excellent tutorial. Trying to brush up on my C and this content is exactly what I wanted!
@otterowen2867
@otterowen2867 4 жыл бұрын
deym! You code really fast. I'm getting movie hacker vibes whenever I hear you typing the code
@soroushmasoodian
@soroushmasoodian 3 жыл бұрын
It’s fastforwarded
@Mythic_Echoes
@Mythic_Echoes 3 жыл бұрын
@@soroushmasoodian Nope, he utilized the text editor well and has fast hands.
@pasy_g
@pasy_g 3 жыл бұрын
he definitely fastforwards at some points
@mandyratta6970
@mandyratta6970 4 жыл бұрын
I saw your video because i had no other choice for hashing implementation in C. I was scared of you being fast So I had to watch it at 0.8 x.Now I have implemented my first hash code because if your help.Thank You so much . God Bless You. And one more thing You are really HandSome.
@JacobSorber
@JacobSorber 4 жыл бұрын
Wow. There are comments, and then there are comments. I'm glad you enjoyed it. :)
@elpatotengu31
@elpatotengu31 4 жыл бұрын
Love the video, but i absolutely love watching you code with that keyboard sound. Its so satisfying
@youthfull3616
@youthfull3616 Жыл бұрын
Hello Jacob, I am already subscriber of your channel and I find it very informative everytime I watch your videos. Though i have been working in C from last 16 years, but still I learn something new every time I watch your videos. Keep up your good work and keep adding good stuffs as you have been doing, for your fans like me.
@JacobSorber
@JacobSorber Жыл бұрын
Thanks. I'm glad it's helped.
@rustycherkas8229
@rustycherkas8229 2 жыл бұрын
Not mentioned is that clients using this facility to retrieve & modify any 'person record' must NOT change the value(s) in the field(s) used by the hash function. Correcting the spelling of "Jane" to "June" would likely leave that person's record filed in the wrong location, never to be found again... Because delete() returns the ptr to the record, to modify safely is to delete, {modify} and re-insert. The "Open" version mistakenly used "TABLE_SIZE" for strncmp(). Corrected to "MAX_NAME" in "linear probing" version.
@cheseremtitus5989
@cheseremtitus5989 2 жыл бұрын
what Mario said.. "Amazing no one teaches programming like you do" - Must've taken a lot of hard work on your part.. Love the content.
@JacobSorber
@JacobSorber 2 жыл бұрын
Thanks.
@silvermonad1
@silvermonad1 4 жыл бұрын
The other day I read the chapter in CLRS about hash tables and it left me quite confused at some points now everything is clearer thanks alot !
@JacobSorber
@JacobSorber 4 жыл бұрын
Glad I could help.
@demoosaad8579
@demoosaad8579 4 жыл бұрын
Initially, I was looking for a simple explanation for hash tables for my CS50 class; they barely touched on it and it felt a bit ambiguous; yet, you are making it almost water-clear simple, thank you good sir for this great content and deep knowledge. I actually took an excessive tour in your very informative channel that I completely forgot about the problem set. Love you
@JacobSorber
@JacobSorber 4 жыл бұрын
Thanks. I'm glad it helped.
@vladimirleon2487
@vladimirleon2487 10 ай бұрын
That was super awesome. Working on a small project that uses all this info. THANK YOU.
@owenwexler7214
@owenwexler7214 2 жыл бұрын
This mad lad is actually writing his own hash functions! Egads!
@trombonaught
@trombonaught 3 жыл бұрын
Been bumping across channels looking for... this! Best hash table tutorial vid out there right now. Thank you!
@JacobSorber
@JacobSorber 3 жыл бұрын
You're welcome. Thanks for the support.
@marcotroster8247
@marcotroster8247 2 жыл бұрын
I'm really impressed how casually you're hacking this code. I was always afraid of implementing my own dictionary. Maybe I'll give it a try next time I need a dict. Well done! Of course you've still got lots of issues: - dynamic table size - table memory management (create / destroy / grow / shrink) - abstract linked list node as struct for carrying arbitrary data - create hash function for arbitrary data - ...
@austecon6818
@austecon6818 3 жыл бұрын
This is so freaking great! Thank you for this! I'm a python programmer but I am always taking a peek at C because I have unaddressed urges to dabble in low-level programming sometime (maybe for C extensions to optimize my python projects). What a great way to learn C - making hash tables.
@JacobSorber
@JacobSorber 3 жыл бұрын
You're welcome. Let me know if there are other topics you would like to see on here.
@drkwrk5229
@drkwrk5229 2 жыл бұрын
C is amazing!
@BonelishOfficial
@BonelishOfficial 2 жыл бұрын
Scripting language programmers, including the unix shell, are a bit spoiled because the interpreters ships with excellent built-in hash-like data structures, like Bash associative arrays, Perl hashes, and Ruby and Python dictionaries. Even Windows Powershell ships with a fast associative array implementation. It's very useful, and practically mandatory, for certain algorithms in C to implement hashtables, and I wonder how the gcrypt library "stacks" up against simpler home-brewed hashing functions. You can't memoize a function without a implementing a hashtable in your program.
@gruchenstein9163
@gruchenstein9163 2 жыл бұрын
the more i have experience in c and c++ the less i think about it as low level programming. There should be another term for that. Most of time when programming in C you are disconnected from cpu architecture.
@OneBoyIs2Big
@OneBoyIs2Big 5 жыл бұрын
Man I love the way you teach
@JacobSorber
@JacobSorber 5 жыл бұрын
Thanks.
@velmaniranganathan930
@velmaniranganathan930 3 жыл бұрын
Simply awesome.. C is even more beautiful with your code ..
@JacobSorber
@JacobSorber 3 жыл бұрын
Thanks. Glad you're enjoying it.
@gowrimajayaramu1243
@gowrimajayaramu1243 4 жыл бұрын
Should the size in strncmp be 'MAX_NAME' instead of 'TABLE_SIZE', since we are limiting the strcmp to MAX_NAME? strncmp(hash_table[try]->name, name, MAX_NAME) instead of strncmp(hash_table[try]->name, name, TABLE_SIZE)?
@ChrisBNisbet
@ChrisBNisbet 3 жыл бұрын
Yes.
@Schannel012
@Schannel012 2 жыл бұрын
Mistakes like that can happen to anybody, as far as I understand yes, it should be MAX_NAME, since MAX_NAME is the limit to the number of characters of name, while TABLE_SIZE is the maximum number of elements in the hash table, it has nothing to do with the size of the name.
@theandrefilipe90
@theandrefilipe90 3 жыл бұрын
best introduction video Ive seen in the internet for that matter. thank you!
@ayu12641
@ayu12641 4 жыл бұрын
The best tutorial so far on hash function in C. Thank you. How do we come up with an optimal hash function for the data structure? Is maximum randomness the target?
@JacobSorber
@JacobSorber 4 жыл бұрын
Usually. If you're trying to minimize collisions, then maximum randomness (and fast) is usually the goal.
@joseville
@joseville 4 жыл бұрын
Is there a procedure one can follow to find a good/optimal hash function? I usually use something like Effective Java's hashcode impl like the one mentioned in [1] and assume it's good enough. [1] stackoverflow.com/questions/113511/best-implementation-for-hashcode-method-for-a-collection
@austinhastings8793
@austinhastings8793 3 жыл бұрын
FYI: There is a thing called a "perfect hash." This is a hash that is tailored for a specific set of inputs, and will produce distinct values for each of them. If you know *all* the possible inputs in advance -- like when you are parsing language keywords -- then perfect hashes can be useful. (Ask the Duck about "gperf" for a software package that provides these functions.) For any other scenario, you are looking at doing the best you can with what you've got. Some "cryptographic hash" functions are really good at providing seemingly random output for small changes in input, but they are slow. Now you're trading off speed vs. behavior. Most commonly-used hash functions opt for some simple rules: use 2**n buckets, use prime numbers to multiply, etc. If you really want to find good hash functions, look at the source code for programming languages that provide "associative array" or "hash" or "dictionary" data types: awk, perl, ruby, python, java, c++. You can find hash functions that have been looked at and tweaked by a lot of people over many years, which hopefully provides a good performance vs. behavior.
@ingiford175
@ingiford175 2 жыл бұрын
@@austinhastings8793 Just one note. you do not use simply 'prime numbers', to multiply, you need a number that is relatively prime to the table size. If you have a size 100 table, you do not want to use 5 as your multiplier as it will map 100 objects into 20 spaces which will give more collisions. Now 3 or 7 in that case will be better.
@aldairacosta4393
@aldairacosta4393 Жыл бұрын
I just love how your keyboard sounds
@khomo12
@khomo12 10 ай бұрын
Very nice!👍👍👍Thank you! As an undergrad, we mostly used sedgewick's algorithms book(in java). Nice to see it done in c!
@LoayAl-Said-o9v
@LoayAl-Said-o9v Жыл бұрын
Leaving a comment is like, helping others that need help as this increases the reach of the video as well as the like, so make a habit of commenting on videos you find helpful even if it's just a period '.' and also, remind others with that
@HansBezemer
@HansBezemer Жыл бұрын
My favorite "hash" structure is either an array (fixed size) or (when allocating) a binary tree. If I use an array I add a binary search. Sure, you keep on moving memory when inserting or deleting, but [a] searching is O(log n) and [b] the code is pretty straight forward. Binary trees also feature a O(log n) lookup, but due to the pointers, it requires about twice the memory. Both structures hardly suffer from performance degradation. My favorite hash is FNV-1a. It's got both 32bit and 64bit versions, easy to implement, very fast and collisions are very rare. E.g. costarring collides with liquid, declinate collides with macallums, altarage collides with zinke. I think you catch my drift. ;-) I did "classical" hash tables, but buckets are simply too much of a hassle - so I can't bother anymore. I find myself using the binary search/hashtable cross-over most of the time. Very often "good is good enough".
@funkykong9001
@funkykong9001 4 жыл бұрын
Thank for this great tutorial. For future videos, please give an additional second or two after writing a function to allow the viewer time to pause to see the code. It's extremely distracting with all the Visual Studio Code popups that cover the code you're writing as well and it's sometimes tough to find a split second to pause the video to see the code before you jump to something else.
@Schannel012
@Schannel012 2 жыл бұрын
I was coding in parallel with him and I had no problem pausing videos. I was suprirsed I wasn't getting segmentation faults all the time, but that's because every time I would wrote code which ended up being different than his, I would rewrite that part of the code lol
@sharontzu5
@sharontzu5 2 жыл бұрын
You can run the video slower!
@futuza
@futuza 2 жыл бұрын
Why though? You can just pause the video? Or the play speed.
@funkykong9001
@funkykong9001 2 жыл бұрын
@@futuza I usually do pause videos, but the cut happens quickly from when the last line of code is written and the next scene begins, so it's more challenging than should be to pause just in time
@RyanMartinRAM
@RyanMartinRAM 2 жыл бұрын
He probably wants you to pay for his Patreon to view the code.
@cloudlee1027
@cloudlee1027 2 жыл бұрын
At 12:20 the third parameter of strncmp should be MAX_NAME not TABLE_SIZE right?
@kc2838
@kc2838 4 жыл бұрын
Are you a professional teacher because you explained this perfectly. Subscriber and waiting for more data structures and C videos.
@JacobSorber
@JacobSorber 4 жыл бұрын
Thanks. Glad you enjoyed it. And, yes, I'm a professor by day.
@RT-od2ct
@RT-od2ct 2 жыл бұрын
This was really helpful for me, thanks! I started my project using arrays for hash table and I could already tell midway I was gonna have a hard time doing anything with the elements.
@MrMikeydrum
@MrMikeydrum 3 жыл бұрын
Been a while since i done hash tables, used a few before in work though, i do prefer external chaining think they were called buckets, quadratic is the way to go though, in large structures you can get bad clustering so what i used to do was have a variable quadratic based on the amount of objects with room to add more then just rehash when it filled up to much, the rehashing was inefficient but it did keep the structure performant for lookups and clustering to a minimum. Nice video
@JacobSorber
@JacobSorber 3 жыл бұрын
Thanks. Glad you enjoyed it. And, thanks for the added perspective.
@santiagosuarez465
@santiagosuarez465 2 жыл бұрын
Awesome-ly put! Great explanations
@ssisispei
@ssisispei 4 жыл бұрын
Your thoughts is super fast! lol It's helpful for me to do cs50 problem set 5, thanks!
@megaraph5551
@megaraph5551 4 жыл бұрын
lmao, I'm also doing it for pset5. What do you think was the hardest pset you've done in cs50 (except for tideman)?
@TMerica199
@TMerica199 Жыл бұрын
Should your lookup function strncmp() be MAX_NAME instead of TABLE_SIZE?
@drimodramo6567
@drimodramo6567 2 жыл бұрын
0:20 why would you mention a hash table to a non programmer person?
@md.hossain693
@md.hossain693 Жыл бұрын
I was looking for this exact thing. Thank you very much for Explaining this concept in the most effective way.
@ighsight
@ighsight 3 жыл бұрын
I finally get it. For a long time I've been 'accepting' that hash tables have faster look ups than arrays without understanding why that is.
@fontanot
@fontanot 4 жыл бұрын
Thanks for sharing, you just earned another subscriber
@JacobSorber
@JacobSorber 4 жыл бұрын
Awesome, thank you!
@pseudolemon8272
@pseudolemon8272 Жыл бұрын
very well explained. the only thing i think could've been clarified better was the optimization with "deleted". it was brushed off as obvious but i had to pause and think why
@FreemonSandlewould
@FreemonSandlewould 2 жыл бұрын
Woot! Was that sped up a bit? Strangely enough it seems like it makes it easier to understand. ( I'll be watching it again )
@whatdoyouthink9449
@whatdoyouthink9449 11 ай бұрын
This video is very helpful to me, thank so much!
@adityachandran7002
@adityachandran7002 2 жыл бұрын
the speed is a little faster for me, like i wasnt able to keep up with the speed of typing. but i understood the whole concept. so this video is a miracle for me.
@kvsubbareddy
@kvsubbareddy 2 жыл бұрын
Fantastic explanation Jacob.
@rpfifer
@rpfifer 4 жыл бұрын
I noticed you're not malloc() ing any space for the nodes. Is it not necessary to do so or will that depend on the size of the table? I have to create a has table for a spell checker function that will hold 143,000 words.
@JacobSorber
@JacobSorber 4 жыл бұрын
Hi Reagan. The way I wrote this one, you're just passing in a pointer and the table is storing the pointer. That leaves allocation and freeing (however you decide to do it) up to the code that is using the hash table. So, in my example, all of the nodes were allocated as local variables in main. So, they were created when main was called, and they will disappear (go out of scope) when main returns. This is fine for a little example, since the hash table is only used in main, and I don't have very many nodes. If you're holding 145k nodes, you probably need to use malloc to allocate some memory. Otherwise, that could be a lot of typing. 🙂
@joseville
@joseville 4 жыл бұрын
Sounds like you're also on week 5 of cs50x lol
@rpfifer
@rpfifer 4 жыл бұрын
@@joseville Sure am! And I am drowning. Haha
@KelliWestwood
@KelliWestwood Ай бұрын
I really appreciate your efforts! Could you help me with something unrelated: My OKX wallet holds some USDT, and I have the seed phrase. (alarm fetch churn bridge exercise tape speak race clerk couch crater letter). What's the best way to send them to Binance?
@mytube4440
@mytube4440 3 жыл бұрын
11:44 is TABLE_SIZE the correct value? should be MAX_NAME i feel
@thybaochau
@thybaochau Жыл бұрын
Thank you so much! To me this is the best explaination ! It actually helps me a lot with my project at university.
@Rafa-tt8ee
@Rafa-tt8ee 2 жыл бұрын
You r a BIG TOP G.
@diogosilva5739
@diogosilva5739 2 жыл бұрын
i agree
@leopoldomolina1664
@leopoldomolina1664 Жыл бұрын
Super creative! Thank you for opening my mind limits! :D
@andrewdunbar828
@andrewdunbar828 8 ай бұрын
Hash tables is a favourite. watch out for modulo bias!
@rtzstvn
@rtzstvn 5 жыл бұрын
great explanation, of a hash table by starting out with a simple example and building on it.!!!!
@CyroTheSpider
@CyroTheSpider 4 жыл бұрын
You are an excellent teacher. Thank you for these videos.
@JacobSorber
@JacobSorber 4 жыл бұрын
You're welcome.
@48_subhambanerjee22
@48_subhambanerjee22 2 жыл бұрын
Thanks bro... Love from india
@youssefsabbagh4341
@youssefsabbagh4341 2 жыл бұрын
Your videos have taught me a lot !! THANK YOU !
@TornadoeJoe
@TornadoeJoe 4 жыл бұрын
You've helped me tremendously in my computer science course, thank you.
@JacobSorber
@JacobSorber 4 жыл бұрын
Welcome. Glad I could help.
@yega3k
@yega3k 2 жыл бұрын
Wow I don’t even know C and I understand this video perfectly! Clear concise explanation ! Probably also because every language I know is based on C in some shape or form haha.
@khalfanathman7150
@khalfanathman7150 Ай бұрын
can we use bst instead of linkedlist in place of chaining?
@karimdhrif6679
@karimdhrif6679 Жыл бұрын
This is just blowing me mind
@leopoldomolina1664
@leopoldomolina1664 Жыл бұрын
One question from a newbie here: Expert programmers usually show/execute this kind of GREAT CODE (C in this case) working with a Terminal window. How do you implement this (C code) into an application with a nice user interface or specially a mobile app, with buttons, nice looking, etc. and not a terminal window? Do you need to encapsule this code into modules, make them understandably (black box of inputs and outputs) to any other more graphical programming framework like React Native for example?
@bruno-zy3dn
@bruno-zy3dn 2 жыл бұрын
why havent you used malloc when storing the values in a linked list?
@lirong2
@lirong2 3 жыл бұрын
Super clear explanation! The playback speed is such a great feature.. I normally use it while trying to pick up on a fast guitar lick and here it helps to slow your speedy typing down. Easier to follow ;-) Thanks
@marwahmaher8574
@marwahmaher8574 4 жыл бұрын
as I know, strlen() is a function that takes a string as an argument and returns its length. But here 5:46 how we've put two strings and what's the point of doing that? Thanks for sharing this video.
@JacobSorber
@JacobSorber 4 жыл бұрын
The first argument is a string. The other is an int (the max length). Check out the documentation for strnlen for more details on how it works.
@mohamedALI-en3ic
@mohamedALI-en3ic 3 жыл бұрын
@@JacobSorber undefined reference to `strnlen' collect2.exe: error: ld returned 1 exit status
@dj_mk_crazy
@dj_mk_crazy 2 жыл бұрын
As a C++ programmer I use the std::map and std::unordered_map for this purpose but this video will be useful for me if in some situations I would not be allowed to use them. Thanks!
@yevheniibatiievskyi
@yevheniibatiievskyi 3 жыл бұрын
what is strnlen() function and what header I have to unclude for that? And whats the difference between strlen and strnlen? Thanks in advance.
@xrafter
@xrafter 3 жыл бұрын
String.h header file . The difference is that you can specify the n max size for the function even if the function didn't find the null terminator for some reason it will stop at n max Usually u use this function if you know the maximum size of a string. And there Is a difference between the length of the string and the maximum size
@paulobueno1
@paulobueno1 2 жыл бұрын
Great content. You've earned another subscriber :)
@morgengabe1
@morgengabe1 2 жыл бұрын
I never thought about hash functions, or tables, in that way; which is surprising because i used to be quite enthusiastic about brown rocks from morrocco.
@veto_5762
@veto_5762 Жыл бұрын
I was lately studying data structures wondering my head around what witchcraftery hash tables use and this video just pop out in my recommends lol
@EhabSmH0
@EhabSmH0 9 ай бұрын
less amount of likes because of your fast speech, is someone running after you? 😃 Thanks for your effort btw!
@vladkirakosyan4987
@vladkirakosyan4987 2 жыл бұрын
First time i used 0.75x to get smth clear is here. I appreciate it.
@rameshb5987
@rameshb5987 3 жыл бұрын
U deserve more popularity n views sir....
@joaogabrielonofre7297
@joaogabrielonofre7297 4 жыл бұрын
Thanks for the video, man! I'm doing Harvad's CS50 course, we have to use a hashtable in one of the problems and your explanation is much clearer and more in depth than the one provided in the course =) I have a silly question that is not relationed to hashtables itself, but I think will help me understand more of C in general: why in this video you used strnlen/strncmp and not the usual strlen and strcmp? What do the 'n' in the strnlen method stands for? I've read a bit of it online but couldn't understand it well.
@JacobSorber
@JacobSorber 4 жыл бұрын
Thanks, Joao. Glad it helped. For the question, check out this video about strings and security concerns. kzbin.info/www/bejne/bZ6ul4qog7aWoJI
@demirmahir
@demirmahir 2 жыл бұрын
Good job noticing the "n" in strnlen! I was also wondering why MAX_NAME was passed to the function and came here to post the question in the comments. Glad I went trough them first. I am also doing the CS50 and try to go line by line with Jacob's hash first to better undestand the implementation of the data structures. His examples were quite useful troughout the course. The stnlen() function though cannot be used by the makefile CS50x implemented as default since strnlen seems not to be a part of the standard C99. You can compile the code differently of course, but for the sake of playing around in CS50x I'm not sure that is necessary. In real world implementation strnlen is quite important as Jacob explains in the video.
@adityavsx
@adityavsx 3 жыл бұрын
it takes time, but someday ALOT of people will start subscribing to u
@4115steve
@4115steve 10 ай бұрын
why does the big o complexity not change? you had mentioned that hash tables are faster , then you had mentioned that it might not always be fast? I'm confused to why it would be slow
@abhayraj695
@abhayraj695 4 жыл бұрын
Thank you for giving this tutorial...man you are awesome.....
@JacobSorber
@JacobSorber 4 жыл бұрын
Thanks. Glad it was helpful!
@caskka
@caskka 2 ай бұрын
i think you should use MAX_NAME for the third parameters of strncmp strncmp(const char *str1, const char *str2, size_t n) it takes the max size of characters instead of table_size
@frozenfar7231
@frozenfar7231 4 жыл бұрын
this was a good video and thanks for the effort, but it was by far one of the hardest videos to follow for me, most of it comes from me but imo there are things that can improve the quality of videos in the future, first please close the file browser tab if it is not needed and capture scene is small so more of the code is visible, second please scroll a bit slow or all and all slow the explanation process so noobs like me can follow, and last but not least programming videos without source code imo are half useful and of course, you can opt to put that as a feature for a paid option but I think that would reduce the impact of your work. all and all thank you so much and keep up the good work.
@walternyc
@walternyc 4 жыл бұрын
Thanks, very well explained. I am taking CS50 and new in C. In CS50 they allocate memory for each new node, so yours looks like a different implementation. What am i missing? The for loop setting the pointers to NULL avoids using malloc?
@hetsmiecht1029
@hetsmiecht1029 3 жыл бұрын
The memory allocation happens in main(), not in insert() I think.
@zxuiji
@zxuiji 2 жыл бұрын
8:36, why did you not just use ``` = {NULL};``` to initialise the array?
@eliodecolli
@eliodecolli 2 жыл бұрын
What keyboard are you using? Great video btw 👍🏻
@fruud
@fruud 2 жыл бұрын
+1 Also wants to know
@JacobSorber
@JacobSorber 2 жыл бұрын
Just my laptop keyboard
@sunstrumsharam5388
@sunstrumsharam5388 6 ай бұрын
The 0xFFFFFFFFFFFFFFFFUL value in the macro is -1 right? I don't understand UL at the end, and why it's an hexadecimal value, instead of -1, I'm a bit confuse.
@ericxue3244
@ericxue3244 2 жыл бұрын
it's not a constant time operation... it is linear with the size of the key
@user-vs9uf3ny8z
@user-vs9uf3ny8z 3 жыл бұрын
Fantastic coverage of this! Thanks so much!
@rostamboroumandrad7703
@rostamboroumandrad7703 3 жыл бұрын
very nicely done
@ScioFantasia
@ScioFantasia 4 жыл бұрын
3 questions: What editor are you using here, what is the font set at, and what keyboard do you have?
@JacobSorber
@JacobSorber 4 жыл бұрын
VS Code. The default font setting (Menlo, Monaco, 'Courier New', monospace), and the keyboard built into my laptop.
@oPatrickVico
@oPatrickVico Жыл бұрын
Great video! Thanks a lot
@OpeLeke
@OpeLeke 3 жыл бұрын
Great video, i loved how you avoided using pointers to keep things simple
@liumeilin9837
@liumeilin9837 3 жыл бұрын
This video is SOOOO helpful to me!!! Thank you so much!
@qber_272
@qber_272 Жыл бұрын
What font is he using , looks neat.
@nimishthakkar
@nimishthakkar 4 жыл бұрын
Best explanation.....don't need better than this. thumsp up!!!!
@zehaia
@zehaia 2 жыл бұрын
when you insert a new string in a deleted place, how can you know it doesnt have a duplicate in a further key?
How to Blink LEDs with Timers and Interrupts in C (MSP430, Arduino)
14:32
Faster than Rust and C++: the PERFECT hash table
33:52
strager
Рет қаралды 612 М.
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Understanding and implementing a Linked List in C and Java
18:15
Jacob Sorber
Рет қаралды 250 М.
Hash Table in C
2:11:31
Tsoding Daily
Рет қаралды 72 М.
Hash Tables and Hash Functions
13:56
Computer Science Lessons
Рет қаралды 1,6 МЛН
Bit Fields in C. What are they, and how do I use them?
13:26
Jacob Sorber
Рет қаралды 85 М.
Pulling Back the Curtain on the Heap
21:38
Jacob Sorber
Рет қаралды 37 М.
Emulating a CPU in C++ (6502)
52:28
Dave Poo
Рет қаралды 1 МЛН
Advanced C: The UB and optimizations that trick good programmers.
1:12:34
Eskil Steenberg
Рет қаралды 178 М.
Learn Hash Tables in 13 minutes #️⃣
13:26
Bro Code
Рет қаралды 404 М.
How to make memory read-only in your C programs.
12:57
Jacob Sorber
Рет қаралды 21 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2,3 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН