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


#LC226 - Inversion Of Binary Tree Using Recursion
Following the last post on the binary tree traversals, in this post we will try to invert a given binary tree. Binary tree is a data...
Ankit Agrahari
Nov 27, 20212 min read
Β
Β
Β


#LC105 - Binary Tree from In-Order and Pre-Order Traversal
In this post we will create a binary tree from the given in-order and pre-order traversal. You can find the details on the question here...
Ankit Agrahari
Nov 26, 20214 min read
Β
Β
Β


#LC746 - Minimum Cost Of Climbing Stairs
In this post we will look into the the leetcode #746 problem to find the minimum cost of climbing stairs. This is also a good example to...
Ankit Agrahari
Nov 24, 20212 min read
Β
Β
Β


Using Twilio for Sending WhatsApp Message in Java
In this blog post, we will try to send WhatsApp message in Java using Twilio account. Prerequisite: Create a free account in Twilio. Once...
Ankit Agrahari
Nov 24, 20212 min read
Β
Β
Β


Binary Tree Traversal
In this post we will look into the different ways to traverse a Binary Tree. In a binary tree, you can traverse in two different ways:...
Ankit Agrahari
Nov 23, 20212 min read
Β
Β
Β


Target Machine Actively Refused it - MongoDB Issue
In this post we will discuss one of the issue encountered after installing MongoDB on my windows machine. This from the previous post...
Ankit Agrahari
Nov 19, 20212 min read
Β
Β
Β


CRUD operation in MongoDB
In this post we will create a Java application which will interact with MongoDB to perform all the CRUD operations. What is NoSQL...
Ankit Agrahari
Nov 18, 20214 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&ccb=7-5&_nc_sid=18de74&efg=eyJlZmdfdGFnIjoiQ0xJUFMuYmVzdF9pbWFnZV91cmxnZW4uQzMifQ%3D%3D&_nc_ohc=sHS26D2JjxgQ7kNvwEEnhLM&_nc_oc=AdqSzKOQg4bdv3His6yUKkrka-i-MIjbalWlPf-56KrKU0e9wrE3rAooNUXaVS7deD4&_nc_zt=23&_nc_ht=scontent-den2-1.cdninstagram.com&edm=ANo9K5cEAAAA&_nc_gid=qJIBKbZv9ua-NMOgiH5NJw&_nc_tpa=Q5bMBQGnqi_bsNDg8RYVVTXvTozh9xC6FsOMZST7lsQZvcK6_Q9ztgYqnZ_bqpNphSOgOwGdRej8syO0&oh=00_AQG5HwkzW-sdUCayEx3RvaNHrnqqPVNFsX5HgMxQuYmrVQ&oe=6A75C3AF)























![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&ccb=7-5&_nc_sid=18de74&efg=eyJlZmdfdGFnIjoiQ0xJUFMuYmVzdF9pbWFnZV91cmxnZW4uQzMifQ%3D%3D&_nc_ohc=Zj_aKX1aeSsQ7kNvwHr48TR&_nc_oc=Adr1_Uv9zvDTiIFRHtzBtp09WUKupQH3U1xKnUhdVdDSp14LWuhUkEzt-ugRPt1x6U4&_nc_zt=23&_nc_ht=scontent-den2-1.cdninstagram.com&edm=ANo9K5cEAAAA&_nc_gid=qJIBKbZv9ua-NMOgiH5NJw&_nc_tpa=Q5bMBQGcSkwCIQfHGm31SP_fIAUf7plLzWNsA5p4zmCwEFQ8RC8PkbO3hvxbQOjo9MaLIQQ1AWG-v0F4&oh=00_AQH79iLnAhWqv9AYMURvT0OWb7XEl0HZtoZ0k-7LTGKqYg&oe=6A75F03E)


