Man! You are just amazing! I have coding interviews in a few days, and you just saved my ass. You have implemented almost all DS, and they are so neat and clean, the way it should be! Thanks man!
@noemanakram6581
2 жыл бұрын
what did u do
@Snake-ez1kl
Жыл бұрын
@@noemanakram6581 he is the ceo of google now
@mohammedhayyoun
5 ай бұрын
@@Snake-ez1kl LMAO
@luceracox7686
4 жыл бұрын
This was incredibly helpful. You explain each step clearly which is hard to find! Thank you:)
@MrJQ3d
2 жыл бұрын
super amazing work man, props! you're a great programmer and teacher.
@strawberrysultan
3 ай бұрын
Thank you!! This was so helpful. Supplementing my classes with your videos now - my teacher only reads from the book.
@soniasingh532
3 жыл бұрын
love the perfection. the way you type and your explanation
@killingjoyandmemeing
3 жыл бұрын
thanks
@nadiequintero9981
4 жыл бұрын
Very useful and clear video, thank you for helping me understand hash tables better.
@CodingJesus
4 жыл бұрын
No problemo
@franky0226
4 жыл бұрын
That was a neat explanantion! thanks a lot, man!
@killingjoyandmemeing
3 жыл бұрын
welcome
@chikin8895
3 жыл бұрын
This is actually ASMR lol
@jakobhuetter
Жыл бұрын
Very helpful! I do have one question tho: you are saying in the beginning, that this would be hashing with seperate chaining. But wouldnt you append the value to the list of the other ones of the same hash value instead of replacing them in seperate chaining? Line 46 in your code. Or am i missing something there?
@adnanlokhandwala9002
3 жыл бұрын
Thank you, this was quite helpful, and quite catchy too XD. Keep up the good work, and all the very best
@CodingJesus
3 жыл бұрын
Thanks
@killingjoyandmemeing
3 жыл бұрын
@@CodingJesus welcome
@nordgaren2358
2 жыл бұрын
Question: Do you actually need the keyExists bool? Couldn't you just return in the for loop if the key exists after replacing it?
@brycejohansen7114
2 жыл бұрын
Why do you put return at the end of functions that have void as their return value?
@cnp4655
2 жыл бұрын
Since perfect hashing function is assumed, why use the for loops. Doesn't that make the time complexity greater than O(1)?
@makoricodes3262
2 жыл бұрын
this guy is doing god's work
@zombiehellmonkeygaming1956
3 жыл бұрын
Thanks so much for this, it helped a lot!
@CodingJesus
3 жыл бұрын
Glad it helped! Please consider subscribing for more help :D
@ayaz.unstoppable
3 жыл бұрын
Thank u this question was asked in sprinklr interview
@ibrahimvelasquez3874
Жыл бұрын
What keyboard are you using? It sounds good!
@miclaymon
3 жыл бұрын
thanks for helping me write my first working hash function. test on this tomorrow in 12 hours...
@CodingJesus
3 жыл бұрын
Best of luck!
@alphabeta3014
3 жыл бұрын
amazing lecture man. crystal clear.
@CodingJesus
3 жыл бұрын
Thanks, please consider subscribing for more.
@ElemenTalParkour
2 жыл бұрын
Great video, thanks!! You would not have to go over all the table to check if is empty, if you found one element - return false.
@CallBlofD
2 жыл бұрын
great video man! you explained amazing!! (p.s. you forgot const on the print function)
@husein_alfil
Жыл бұрын
Great Video !! Great Job :D
@sharinganuser1539
3 жыл бұрын
didn't understood why list::erase() can lead to segfault....even if last item is erased it will simply return container end ....how getting next itr position can lead to error?
@khaledelgharbi5200
3 жыл бұрын
Great tutorial, this will help me for my interview
@khaledelgharbi5200
3 жыл бұрын
One question: can we use this hash class in std::unordered_set ?
@shawn4365
2 жыл бұрын
how would I change this if I wanted each key to hold all of the different names instead of replacing the value
@greglouis5779
3 жыл бұрын
i have a c++ project of storing 500 books from a .txt file in which there are details about the author,ISBN ,title, etc. and I have to find a convenient data structure for that to do insertion, deletion,searching can you help me out plz?
@flexo666
4 жыл бұрын
great video! Thank you!
@killingjoyandmemeing
3 жыл бұрын
welcome
@yazou1307
2 жыл бұрын
great video!
@epicjr7260
3 жыл бұрын
For the private member variable list hashTable, this is just a containter that is in an index of the array right? If so, are we able to use a vector or a linked list instead?
@CodingJesus
3 жыл бұрын
We want to have a set number of groupings, hence we want a container that cannot be resized. An array communicates that intent.
@maishananjeeba7436
Жыл бұрын
is this code also considers the collison problem?
@panicineurope
3 жыл бұрын
Thanks guy! Very nice tutorial. Here's my go at the search function: string HashTable::searchTable(int key) { int hashValue = hashFunction(key); auto& cell = table[hashValue]; auto bItr = begin(cell); bool keyExists = false; for (; bItr != end(cell); bItr++) { if (bItr->first == key) { keyExists = true; return bItr->second; } } if (!keyExists) return "Result Not Found"; }
@ilanogaming5034
2 жыл бұрын
Hi there, how do i search for the other same key? for example : HT.insertTable(99, "Jim"); HT.insertTable(99, "Tim"); how do i search for value "Tim"? cause if i search for key 99 it displays "Jim"
@erlisibraimi5267
2 жыл бұрын
@@ilanogaming5034 you can't have 2 different values with the same key, that's why your value gets overridden
@halily.2626
3 жыл бұрын
thanks a lot. But I think using C sytle array is bad practice. The books always say use vector: I mean instead of this: list table[hashGroups]; isn't this better ? : using listType = list; vector table; Maybe, I am wrong, what do you think ?
@grapesalt
2 жыл бұрын
std::vector will be slower than C style array's.
@carlosniederauer1874
3 жыл бұрын
Great tutorial!
@killingjoyandmemeing
3 жыл бұрын
thx
@MeriemStudentDjidjeli
Жыл бұрын
awesome video
@japde2694
Жыл бұрын
what keyboard are you using ?!??!?!
@jasmeetsingh7499
3 жыл бұрын
isEmpty can be implemented in a better way (O(1) as opposed to O(hashGroups)), You could create a variable that stores number of empty hashGroups. So, numEmptyHashGroups = hashGroups initially. On insert, decrement numEmptyHashGroups if it is the first node in the list. Similarly when removing the item, increment numEmptyHashGroups if it is the last value. Implementation of isEmpty will become as simple as numEmptyHashGroups == hashGrorups. Also, in current implementation you don't need to calculate the sum, you could just return false if at any point the list is not empty. Aggregating the sum can cause overflow.
@CodingJesus
3 жыл бұрын
You can keep count of the amount of items successfully added and removed. Call isEmpty() will check whether itemCount is 0 or not.
@prabhjotsingh3172
3 жыл бұрын
Did you not implement SearchTable function?
@processorbot8761
3 жыл бұрын
this is a great video
@CodingJesus
3 жыл бұрын
Thank you! Make sure to check out my other videos.
@nathansantos7421
7 ай бұрын
Muito obrigado Jesus Cristo dos códigos, você é o cara, a main.
@sharuns917
3 жыл бұрын
Nice n quick...thanks
@brendankacic6066
3 жыл бұрын
Thanks so much!!
@santiagomickelleoliverague2337
2 жыл бұрын
what is iterator ? im almost at fourth cicle and still without recognise some words
@nnewram9936
4 жыл бұрын
in isEmpty, you dont need a sum. Just return true whenever the size is non zero in the loop, it will on average save a lot of execution time
@CodingJesus
4 жыл бұрын
Yeah, others have brought it up below. That's a good approach.
@nnewram9936
4 жыл бұрын
@@CodingJesus oof, didn't catch that. Well, great video anyways! Thanks for it.
@chuyinghe7953
3 жыл бұрын
great tutorial! I encountered a problem for using the function emplace_back(), IDE says it "no member named 'emplace_back' in 'std::__1::list
@jarreed0
3 жыл бұрын
May need to tell your compiler to use c++11
@banabana4691
4 жыл бұрын
Awesome.
@divyanshr1
3 жыл бұрын
Thanks man, I have searched google, youtube, your video is the only source of hashmap implementation in c++. But one thing is that as we are using for loops in this code, it doesnot mean O(1) operations, right?
@getsuha
3 жыл бұрын
for loop gets used when there is collision and the worst case time complexity for collision is actually O(n), i.e. when all the values have collided. It would be O(logn) if implemented with an AVL tree.
@rohitk2629
4 жыл бұрын
The keyboard sounds like asmr. relaxing..
@vaibhavgupta8048
4 жыл бұрын
thanks for the video, but i think in worst case time complexity for searching the value be O(n) in your code which is violating the concept of hash table , if yes ,can it be improved for getting the value in constant time.
@nagarjunvinukonda162
3 жыл бұрын
Hi Jesus, Does Separate changing mean Open addressing? What is the point of checking HT isempty( )or not at start of int main? We are creating Ht from start so of course it will be empty before inserting....
@CodingJesus
3 жыл бұрын
Just checking whether IsEmpty is coded correctly. And yes, separate chaining and open addressing are different.
@user-vz6wb7bj1c
3 жыл бұрын
in line 44 , dont you need to check if Bitr->first == hashFunction(key) instead of key?
@CodingJesus
3 жыл бұрын
bItr points to key-value pair. bItr->first points to the key. bItr->second points to the value. We are checking whether the key exists, so we need to use bItr->first
@reverse2190
2 жыл бұрын
How do you implement an iterator class for this? anyone got ideas?
@highxavito4875
Жыл бұрын
hola buenas tu video me sirvio mucho, pero me gustaria saber como implementar un sistema de busqueda atravez de la key
@mryup6100
4 жыл бұрын
I have the same setup as you! VS code with ubuntu subsytem terminal
@marflage
4 жыл бұрын
Just what I was looking for. Amazing explanation. However, I can see that some beginners can get confused because of list, iterators and i{}. Nonetheless, it was a great video. PS: That keypresses and mouse clicks were hypnotic.
@CodingJesus
4 жыл бұрын
I was actually afraid that people would not like the typing sound and it would annoy them. But people seem to love it. I have another video coming out on Wednesday at 5:30 CST with more typing sounds. :D
@austintaylor5372
4 жыл бұрын
Yeah could you explain the i{} and how he did the iterator. I'm also trying to learn c++ i only code in c#
@CodingJesus
4 жыл бұрын
@@austintaylor5372 int x declares x but doesn't initialise it. By that I mean that 'x' has junk in it, and by junk I mean it can have anything in it. int x{} default-initialises x to int's default value, that being 0. Iterators are like pointers in a sense, except they are used on collections and there are several types of them. They allow you to iterate over a collection and, in some cases (non-const iterators), modify the contents of that collection. Hope this helped.
@austintaylor5372
4 жыл бұрын
@@CodingJesus yeah that makes alot of sense thank you :)
@naufalmuhadzdzib7338
3 жыл бұрын
Big thanks :))
@grayscale-bitmask
2 жыл бұрын
Great video! Especially in covering effective collision handling, since not all tutorials do that very well. FWIW, 1:25 should be "what it looks like" or just "how it looks". "Like" sounds a bit redundant if you pair it with "How". One of the best tutorials on this topic in any case.
@arvinbrian7107
2 жыл бұрын
can anyone tell me which IDE is this?
@unknownsahb1670
3 жыл бұрын
display function?? i didnt see it
@srihari5605
3 жыл бұрын
should have added a key-value pair that gets the same hash! excellent work though!
@Bristol-MyersSquibb
3 жыл бұрын
Hey u ever get a gpu?
@Hoserzzz
Ай бұрын
is the video completely corrupted for anyone else?
@Anubis10110
4 жыл бұрын
Amazing
@killingjoyandmemeing
3 жыл бұрын
ikr
@quickyfast-sz9xc
4 ай бұрын
bruh I copy line by line and it doesn't run at all.... tells me there's a lot of errors... I don't understand why it doesn't work..
@pranavnyavanandi9710
2 жыл бұрын
Man, can you make videos like this for java...?
@user-qh9xl9ry7d
9 ай бұрын
Umm... How do you overcome Hash Collision? I can't find it. How to overcome Hash Collision in this code
@user-wz5rk7eq2i
2 ай бұрын
Just using a list. Cell.emplace_back(key, value)
@SuperWhatusername
2 жыл бұрын
Thank you @Coding Jesus
@mockingbird3809
3 жыл бұрын
For remove function, Doesn't this work? value_at_index.remove_if([&](std::pair capture) -> bool { if(capture.first == key){return true;} else{return false;} });
@CodingJesus
3 жыл бұрын
Why don't you try it out and test for yourself? That's the essence of learning :)
@garrettbellinghausen8389
2 жыл бұрын
Did he forget to write the code for the search function?
4 жыл бұрын
Very good explanation!! what IDE is that?
@CodingJesus
4 жыл бұрын
Visual Studio Code
4 жыл бұрын
@@CodingJesus thanks
@killingjoyandmemeing
3 жыл бұрын
@ welcome
@pranavbelgaonkar8634
3 жыл бұрын
Hi , I learned a lot from this video but i did not understand why you defined variable and then placed a curly bracket after it. Why not just leave it blank. thanks!
@CodingJesus
3 жыл бұрын
Google the difference between defining a variable and initializing it.
@haiderpall4907
2 жыл бұрын
plz attach the source file for helping out
@mrkunalgoswami2010
2 жыл бұрын
can someone code it in c++ ?
@emperorcleon89
2 жыл бұрын
Thank you Jesus
@babaa5701
3 жыл бұрын
nice, video. Wish I had contrast, so I can see () {} [] better.
@kantocoder5046
3 жыл бұрын
Why are you using {} instead of = in the variables initialization? To make your code harder to comprehend?
3 жыл бұрын
better convention for OOP , it's recommended to use it this way by the standard because it reduce time complexity by avoiding useless operation
@kantocoder5046
3 жыл бұрын
@ >> recommended to use it this way by the standard >because it reduce time complexity by avoiding useless operation
@brainyfool4846
3 жыл бұрын
@ please please tell more or put a link when to use variable{} for initialization or @Coding Jesus please explain.
@zackjohnson9387
2 жыл бұрын
I don't understand the purpose of the for loop for the insert function if you're just replacing the value. Why would you need to iterate the cell if you just look at the first value of cell to see if it's the key and if it is replace the second value with the value. Seems unnecessary to me.
@zackjohnson9387
2 жыл бұрын
Same with the remove function* Unless you are using chaining what is the point of the for loop?
@jozsefnagy9192
Жыл бұрын
Amen
@hezhu4851
4 жыл бұрын
hi, could I know if you miss writing the search function
@CodingJesus
4 жыл бұрын
Yes, I left it as homework for you in particular. But only for you, not for anyone else.
@hezhu4851
4 жыл бұрын
@@CodingJesus And one more thing is here we use separate chaining method. But when we insert, if there's a conflict. You just erase the original value but not adding the value into next node of list. So maybe it is wrong here?
@happynewyear6123
2 жыл бұрын
coding jesus man that name does suit you well
@nbavideos4487
3 жыл бұрын
amazing explanation thanks a lot but tell me why use & in auto& cell = table [hashvalue]; to give you the address of each hash value or what explain with my all respect
@CodingJesus
3 жыл бұрын
We take a reference to that have because we want to alter it, as opposed to altering a copy of it. Hastable[hashKey] returns a reference to the item being held at that index.
@gourav.barkle
3 жыл бұрын
can anyone please tell me what is that sum followed by { }.
@CodingJesus
3 жыл бұрын
Brace initialization. It sets sum to 0. Please consider subscribing for more content!
@samiulislamsharan
2 жыл бұрын
how can I implement the searchTable function?
@jamespolaroid4856
2 жыл бұрын
I gave it a try, seems to work, if its the best piece of code - i dont think so. string HashTable::searchTable(int key){ int hashValue = hashFunction(key); auto& cell = table[hashValue]; auto bItr = begin(cell); bool keyExists = false; string searchValue; for (; bItr != end(cell); bItr++) { if (bItr->first == key) { keyExists = true; searchValue = bItr->second; cout
@aryanparekh9314
3 жыл бұрын
I really love this. One thing I am not able to understand is why the code will not work if you don't put a "&" operator in front of cell = hashFunction(key). Can anybody explain it to me?
@CodingJesus
3 жыл бұрын
What do you mean? Paste the code into Godbolt and share the generated link with me
@aryanparekh9314
3 жыл бұрын
@@CodingJesus I can't believe you replied!! I didn't know the concept of references in c++ so I didn't understand why you used a & operator in front of a variable. Well I understood it now but I do have a few doubts. Is this method faster than using a plain vectors? What is the best scenario in which I should use this?
@CodingJesus
3 жыл бұрын
@@aryanparekh9314 I still don't know what part of the video you're talking about.
@aryanparekh9314
3 жыл бұрын
@@CodingJesus Okay I'm sorry for being unclear, here is the time stamp 6:52 line:40 When you used cell as a reference
@CodingJesus
3 жыл бұрын
@@aryanparekh9314 You should use references when you want to change the value stored in the hash-table. Not aliasing the hash-table element with a reference will lead to you crating a copy of it. When you go to assign cell = something, it won't be stored in the hashtable, because 'cell' isn't a reference.
@alexchen6847
2 жыл бұрын
What's that IDE he's using? P.S. Kinda new to C++
@jamespolaroid4856
2 жыл бұрын
thats visual studio code (VSC)
@alexvallex5487
Жыл бұрын
@@jamespolaroid4856 do you know why my VSC does not like pointers? everytime i use -> it breaks
@jamespolaroid4856
Жыл бұрын
@@alexvallex5487 maybe wrong dash, maybe wrong 'bigger then'-sign - u can use (*variablenameBeforeArrow).variableAfterArrow instead, its just a different representation of the same concept
@alexvallex5487
Жыл бұрын
@@jamespolaroid4856 thank youu
@hros2671
2 жыл бұрын
Lmao this guy is called Coding Jesus
@sigterm9ki11
4 жыл бұрын
no string searchTable(int key) function?
@CodingJesus
4 жыл бұрын
Nope, that's homework for you. ;)
@sigterm9ki11
4 жыл бұрын
@@CodingJesus lol, You sound like me. I just noticed the difference in signatures. Great work and discussion.
@CodingJesus
4 жыл бұрын
@@sigterm9ki11 Subscribe if you want to see more. What would you be interested in? Concurrent queue?
@hypermeero4782
3 жыл бұрын
where is the search function?
@CodingJesus
3 жыл бұрын
It's homework. If you subscribe I may consider making a data structure with ONLY search ability, nothing else. Not even insert.
No. The point is to watch and learn, not watch and copy-and-paste.
@simple_user000
2 жыл бұрын
Should've zoomed in the screen a little bit......
@TechnologyRules
3 жыл бұрын
Is that your real name?
@CodingJesus
3 жыл бұрын
Yes, my first name is Coding and my last name is Jesus
@NISHANTRAJ-rl9lf
2 ай бұрын
You Didn't Implemented the SearchTable method😄
@focker0000
2 жыл бұрын
now next tutorial CPP CON 17: kzitem.info/news/bejne/z5l-03mLpnyLmWk
@sp1xa
3 жыл бұрын
rip Rick
@sp1xa
3 жыл бұрын
rip Bob
@salimrahman2247
2 жыл бұрын
Not see clearly plz zoom the screen
@satyagyaparashar2575
4 жыл бұрын
So no one is going to talk bout that double intro?
@CodingJesus
4 жыл бұрын
Haahaha, I'll crop the intro out. I mentioned in the description to start at 0:16
@satyagyaparashar2575
4 жыл бұрын
Good content tho..keep it up bro.
@akashmeshram8715
10 ай бұрын
Your teaching is amazing, but the Tabla that you are playing while typing is somewhat irritating.
@aryanparekh9314
3 жыл бұрын
yadi yadi yada....
@Canyldrm3566
3 жыл бұрын
you like pressing buttons dont you
@solsticeprojekt1937
6 ай бұрын
Audio volume needs to be at least 30% higher, better 40%. It's easy for us to turn the volume lower to acceptable levels, but it's impossible for us to go beyond 100% on both youtube and system volume. Lowering the volume always allows to reach acceptable levels, but the opposite doesn't.
Пікірлер: 175