A hash table takes the fast random access of an array and the flexibility of a linked list, so insert, delete and look-up all get close to constant time. Cut from the lesson "Hash tables" in the CS50 Shorts courses. Source: CS50 Shorts, "Hash Tables" by CS50, Harvard University Original: https://cs50.harvard.edu/x/2024/shorts/hash_tables/ Licence: CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/) Changes: Cut to about a minute, reformatted to vertical with a blurred background and re-encoded; captions, summary and thumbnail generated by Upgram. Not endorsed by CS50 or Harvard University. Shared under the same licence.
And this sort of lends to the idea of a hash table. So in a hash table, we're going to sort of try and combine an array with a linked list. We're going to take the advantage of the array, like random access, being able to just go to array element 4 or array element 8 without having to iterate across. That's pretty fast, right? But we also want to have our data structure be able to grow and shrink. We don't want to be restricted. We want to be able to add and remove things very easily, which, if you recall, is very complex with an array. And we can call this new thing a hash table. And if implemented correctly, we're sort of taking the advantages of both data structures we've already seen, arrays and linked lists. When average insertion into a hash table can start to get close to constant time. And deletion can get close to constant time. And lookup can get close to constant time. We don't have a data structure yet that can do that. And so this already sounds like a pretty great thing. We've.
Чтобы продолжить, установите приложение
Ставьте «Нравится», комментируйте, подписывайтесь на авторов и следите за прогрессом в приложении Upgram.
Скачать Upgram
Комментарии