## Splitting and Merging B Tree Nodes

This post is to be read in conjunction with another post Introduction to B Trees. Here we learn that in certain operations the B Tree properties might get disturbed and it will need a fix. Splitting and Merging B Tree Nodes are the only operations which can re-establish the properties of the B Tree. How does a B Tree get unbalanced? The tree is not just to read and search data. There are operations which update the tree either by deleting a key, inserting a new key or just updating the values stored against the key. The Insert and Delete operations tend to modify the structure of the tree...

## Finding K nearest distances

Problem Statement You are given millions of two dimensional point and a utility method to calculate their distances from the origin. Write a code to return the nearest K unique distances from the origin. If there are more than one point at the same distance, the distance must be just returned once. For e.g. If there are five points (1,1), (2,1), (1,2), (2,2) and (3,3) and the value of K is 3, then we need to return the following: 1.414 - distance of (1,1) from origin. 2.236 - distance of (2,1) or (1,2) from origin as both will be same. 2.828 - distance of (2,2) from origin Test ...