top of page


Tutorials, Errors and Exceptions
Its a journey to understand things better. It will have tutorials, any error/exceptions encountered, its resolutions and lots of learning.

Search


Junit5 with Mockito Framework
In this blog post we will talk about one of the testing framework which I wanted to try it on, and rather use it in my day to day coding....
Ankit Agrahari
Apr 18, 20227 min read
Β
Β
Β


AES Algorithm with GCM Mode in Java
In this post we will encrypt and decrypt a given phrase using AES algorithm in GCM mode. This will be more on how to do it. I am not an...
Ankit Agrahari
Apr 9, 20226 min read
Β
Β
Β


Spring4Shell - Zero Day Vulnerability in Spring Framework
In the days of Vulnerabilities, the famous Spring framework is the latest victim, which has quite a turns of event for the CVE identified...
Ankit Agrahari
Apr 1, 20223 min read
Β
Β
Β


Day to Day Lambda & Functional Programming in Java 8
If you have seen lately, everyone has shifted to Java 8 and is more or less trying to move from lengthy code blocks to few lines/precise...
Ankit Agrahari
Mar 28, 202212 min read
Β
Β
Β


Custom Iterators in Java
This is a bit embarrassing to start with, but lets say I got this question and was quite dumb stuck on how to write a custom iterator....
Ankit Agrahari
Feb 12, 20224 min read
Β
Β
Β


Multi Release Functionality
In this post we will explore one of the best feature provided by Java 9, its importance in present day development and how it will be a...
Ankit Agrahari
Feb 10, 20224 min read
Β
Β
Β


Web Socket Client - Receiving Stream of Messages
In this post we will be creating a Web Socket Client which will receive all messages coming from the Web Socket Server. Web Sockets The...
Ankit Agrahari
Jan 23, 20223 min read
Β
Β
Β
Contact
bottom of page



![If this shifted how you think about AI β
you're ready to Harness it. π₯
π¬ Comment "HARNESS" below
β I'll DM you the open-source agent template
π Save this carousel β refer back when you build
π€ Share with one engineer who's still copy-pasting
Follow @backendbrilliance for more content on
AI agents, Spring Boot architecture & backend systems
that actually scale.
#AIHarnessing #BackendBrilliance #JavaDeveloper
#SpringBoot #SpringAI
[AIAgents SystemDesign BackendEngineering SoftwareDevelopment LLMOps]](https://scontent-den2-1.cdninstagram.com/v/t51.71878-15/729219604_894359219640315_5276418046541229917_n.jpg?stp=dst-jpg_e35_tt6&_nc_cat=102&ig_cache_key=MzkyNjU3ODk3MzMyNzMxMTg2Mw%3D%3D.3-ccb7-5&ccb=7-5&_nc_sid=a54f6b&efg=eyJlZmdfdGFnIjoiYmVzdF9pbWFnZV91cmxnZW4uQ0xJUFMuQzMifQ%3D%3D&_nc_ohc=F0bKHT3b24oQ7kNvwGiqcHm&_nc_oc=Adpnbt0bxRephKx_Ht9hQctS3DBPNiQTlmyPwd8G2jbT4Imu4hVVv3_mjcSTlIr9Z_M&_nc_zt=23&_nc_ht=scontent-den2-1.cdninstagram.com&edm=ANo9K5cEAAAA&_nc_gid=p2026n5LG2Byz5KEsYwQuA&_nc_tpa=Q5bMBQLXVXOTYqiF_H-7Bl9bQAIZVPpcpnDK_mce_aZAxQucOzcFXUTNQk8sXKDngG96f1KrK9MgF0tc&oh=00_AQKmEv_pCX0OImMXo-Iu_3lRI1Z_AS937ntI3SgAlhhwbA&oe=6AAC096F)























![You think HashMap is always O(1).
It isn't. Here's what actually happens. π§΅
HashMap stores pairs using `index = hash(key) % capacity` β direct slot access, no scanning. Pure O(1). Until two keys land on the same slot. That's a collision β not a bug, a math inevitability.
Two ways to fix it π
π Chaining β each bucket holds a linked list. Collisions append to the list. Simple, handles high load, easy deletion. Downside: pointer overhead, poor cache performance, chains degrade to O(n) at high load. Java's fix? At 8 nodes, the list auto-converts to a Red-Black Tree β O(log n) worst case.
π¦ Open Addressing β no linked lists. Collision at slot X? Probe X+1, X+2 until empty. Cache-friendly, zero memory overhead. Downside: deletion needs tombstone markers, and keys cluster together making future collisions worse. Used by C++, Go, Redis.
βοΈ Load Factor = entries Γ· capacity
π’ Below 0.5 β rare collisions, wasted memory
π 0.75 β Java's sweet spot, triggers resize + rehash
π΄ Above 0.9 β collision cascade, O(n) territory
Double hashing kills clustering by varying the probe step per key:
`probe(i) = (h1 + i Γ h2) % m`
Elements scatter evenly. No bunching. O(1) preserved.
The truth: HashMap is O(1) until a bad hash function, wrong load factor, or wrong strategy turns it into O(n).
Three things protect you:
β Well-distributed hash function
β Load factor under 0.75
β Right collision strategy for your use case
π¬ Java interview question: what happens when a chain hits 8 nodes?
Drop your answer below π
π Save this before your next interview.
#java #hashmap #datastructures #dsa #algorithms
[codinginterview programming 100daysofcode]](https://scontent-den2-1.cdninstagram.com/v/t51.71878-15/641188820_1859196944673752_5535080284006983284_n.jpg?stp=dst-jpg_e35_tt6&_nc_cat=102&ig_cache_key=Mzg0NDY4MjE0NzAzMTAyMzAyNA%3D%3D.3-ccb7-5&ccb=7-5&_nc_sid=a54f6b&efg=eyJlZmdfdGFnIjoiYmVzdF9pbWFnZV91cmxnZW4uQ0xJUFMuQzMifQ%3D%3D&_nc_ohc=YADKDR4ithUQ7kNvwHGCLP9&_nc_oc=AdomqPplzmxJRxqj5DrSHKjeCn4m8iQ8KBhYwLRCWYX-XgXq1bR06DpL7lqblCHEEeE&_nc_zt=23&_nc_ht=scontent-den2-1.cdninstagram.com&edm=ANo9K5cEAAAA&_nc_gid=p2026n5LG2Byz5KEsYwQuA&_nc_tpa=Q5bMBQJhNt5KBTuwCbOxjOHpH4ExUholPvBP9wNdNayki6ujEca3f2_7aCLnkdLjdktnAj49wN-Lnvoq&oh=00_AQLASLTTjn-aqAs7Wq82NDkNpHhJWw50H47a2RKP7fyeQA&oe=6AABFDBE)


