#Java HashMap Internals:
Initial capacity:
16 (default)
Load factor:
0.75, table resizes (doubles) when entries exceed capacity * load factor
Collision handling:
Buckets store entries in a linked list initially
Average lookup:
O(1) - due to good hash distribution
---
Treeify bucket:
If a bucket has >= 8 entries and table size >= 64, it converts to a Red-Black Tree
--> worst-case O(log n)
Small table case:
If table < 64, the table resizes (doubles) instead of treeifying
---
Untreeify:
If entries in a tree drop below 6, it converts back to a linked list
Why 6?
To prevent tree/list thrashing - frequent conversions back and forth if the bucket size fluctuates near the threshold
---
Search efficiency:
Linked list = O(n) in worst case
Red-Black Tree = O(log n) in worst case
Hack of the day: tree structure outputs of find using spotlight! `cargo install treeify` and swap find for mdfind and boom! E.g. All WebGPU code on my SSD: "mdfind requestAdapter | treeify"
We built Treeify (treeifyai.com) — an AI-powered tool that turns requirements into test cases on a mind map in minutes.
Now the big question:
👉 Who should I be selling this to?
👉 Where’s the best place to find them?
#QA#SoftwareTesting#AI
🏫Contribute to a Thesis Research on AI in Software Testing — Sponsored by Treeify!
medium.com/@treeifyai/contri…
Click the Google Form to provide your email. Your contribution will be cited in the student’s thesis.
forms.gle/ygU2i5ohvDkTN2EQ7
Enjoy one month of free trail.#Thesis#QA
📷 Calling All QA Professionals: Be the First to Try Treeify!📷
🔗Fill Google Form:
docs.google.com/forms/d/e/1F…
Fill Google form now and secure your spot on the waitlist! We can’t wait to have you on board and hear what you think. #testcase#tools#freetrail
Thanks to @TlogOfTheDay
Learned that from Java 8
Hashmap worst-case time complexity is O(logn) and not O(n)
Learned about the treeify process.
freecodecamp.org/news/how-ja…
Na implementação que eu vi (não lembro a versão) ele começa com uma lista ligada, mas após um certo número de elementos, acho que 8, ele faz o treeify e transforma numa árvore binária balanceada