You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
-
8Allow me to just say: fantastic answer.– CRThazeCommented Jan 5, 2017 at 21:20
-
@Tony Delroy Thanks for the amazing answer. I still have one open point in my mind though. You say that even if there are 100 million buckets,lookup time would be O(1) with load factor 1 and a cryptographic strength hash function. But what about finding the right bucket in 100 million? Even if we have all the buckets sorted,isn't it O(log100.000.000)? How can finding the bucket be O(1) ?– selmanCommented Dec 21, 2018 at 10:14
-
@selman: your question doesn't provide many details to explain why you think it might be O(log100,000,000), but you do say "even if we have all the buckets sorted" - keep in mind that values in hash table buckets are never "sorted" in the usual sense: which value appears in which bucket is determined by applying the hash function to the key. Thinking the complexity is O(log100,000,000) implies you imagine doing a binary search through sorted buckets, but that's not how hashing works. Maybe read a few of the other answers and see if it starts to make more sense.– Tony DelroyCommented Dec 26, 2018 at 12:08
-
@TonyDelroy Indeed,"sorted buckets" are the best-case scenario that I imagine. Hence O(log100,000,000) . But if this is not the case,how can the application find related bucket among millions? Does hash function generate a memory location somehow?– selmanCommented Dec 27, 2018 at 10:01
-
1@selman: because computer memory allows constant time "random access": if you can calculate a memory address you can retrieve the memory contents without having to have accessed memory in other parts of the array. So, whether you access the first bucket, the last bucket, or a bucket anywhere in between, it will have the same performance characteristics (loosely, take the same amount of time, albeit subject to CPU L1/L2/L3 memory caching impacts but they only work to help you quickly re-access recently accessed or coincidentally nearby buckets, and can be ignored for big-O analysis).– Tony DelroyCommented Dec 28, 2018 at 8:37
|
Show 15 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_`
- quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>
[example](https://example.com)
<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. python-3.x), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you