What are running times (Big O notaton) for the common operations (get, put, size) on HashTable and HashMap, is there a difference?
What are running times (Big O notaton) for the common operations (get, put, size)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is not a difference between the asymptotics of
HashtableandHashMap, and they are the predictable expected amortizedO(1)forputand expectedO(1)forget, assuming that you have a good hash function.The biggest difference is that
Hashtableincurs gratuitous overhead synchronizing accesses from concurrent threads, which a) you usually don’t need, and b) is done more efficiently byConcurrentHashMap. You should basically never useHashtablein new code.