#🔒 hw help
34 messages · Page 1 of 1 (latest)
@icy meteor
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
the python dictionary implementation is quite complicated
it’s not done with linked lists
no, the hash table itself is a contiguous buffer of memory, and for collisions it uses open addressing. to my knowledge linear probing
linked lists would be too slow and cause too much overhead
oh wow thanks very much
much appreciated lads
line 92 of the C file starts a comment that describes how insertion order is maintained, specifically
for dictnotes.txt?
no, dictobject.c
oh yes thank you very much
are there any sources that would state this?
or could i just find the running time of hash tables and linear linked lists and compare
the problem with linked lists is that theyre O(n) lookups
while a hash table is O(1)
ohh right
this is partially true, but not the full answer. some hashmaps use linked lists for hash collision. this algorithm is called chaining
ig this is just about the hash table used by pthon dictionaries
linked lists are slow because they have poor cache locality, require allocations for each node, and have large overhead for small values because they must store 1-2 pointers per node
thanks a lottt
the document zerointensity linked alludes to this
there are two places where a linkedlist might come up in a hashmap
the underlying buffer which stores the buckets and also in the chaining collision resolution algorithm, each bucket contains a linked list
for example the java hashmap does actually use a singly linked list to store buckets, https://stackoverflow.com/questions/30957699/why-does-hashmap-internally-use-linkedlist-instead-of-arraylist
ohh right
but it's the only serious hashmap implementation i'm aware of that uses this strategy. you should basically never use linked lists unless you're implementing an lru cache or a similar structure and really, truly need it. https://stackoverflow.com/questions/34170566/bjarne-stroustrup-says-we-must-avoid-linked-lists
I saw this video on YouTube: https://www.youtube.com/watch?v=YQs6IC-vgmo
in which Bjarne says it is better to use vectors, rather than linked lists. I am unable to grasp the entire thing, so could ...
Learning Rust With Entirely Too Many Linked Lists
sweet thanks a lot this clears everything up appreacite it
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.