The Heap data structure is an array that can be viewed as a complete Binary Tree. Each node in the tree corresponds to an element of the array A[]. We already discussed Heap data structure in this – post. However in this post we would learn about, how to build min/max Heaps […]

In the last post we discussed about C++ Standard Template Library (STL) Linked List. In this post we will learn about STL Priority queue and using it as Max/Min Heap. Priority Queue A priority queue is a data structure for maintaining a set of elements having an associated value. Priority Queue […]

Huffman codes are a widely used technique for compressing data. Huffman codes is a greedy algorithm to build up an optimal way of representing each character as a binary string. Suppose we have a 10,000 character data file that we wish to store. And we observe a character ‘a’ occurs very […]

Problem Statement Let’s given n points in a plane. We’ve to find k nearest neighbors of a given point ‘p’ from the given n points. Problem Naive Solution O(nlogn) Let’s call the given point be P and set of points be S. Iterate over S and find euclidean distance between each […]