Category Archives: Algorithm

Minimum block jumps to reach destination

Given N lines and one starting point and destination point in 2-dimensional space. These N lines divide the space into some blocks. We need to print the minimum number of jumps to reach destination point from starting point. We can jump from one block to other block only if they share a side. Examples: Input… Read More »

K-Nearest Neighbours

K-Nearest Neighbours is one of the most basic yet essential classification algorithms in Machine Learning. It belongs to the supervised learning domain and finds intense application in pattern recognition, data mining and intrusion detection. It is widely disposable in real-life scenarios since it is non-parametric, meaning, it does not make any underlying assumptions about the… Read More »

3-way Merge Sort

Prerequisite – Merge Sort Merge sort involves recursively splitting the array into 2 parts, sorting and finally merging them. A variant of merge sort is called 3-way merge sort where instead of splitting the array into 2 parts we split it into 3 parts. Merge sort recursively breaks down the arrays to subarrays of size… Read More »

Tabulation vs Memoizatation

Prerequisite – Dynamic Programming, How to solve Dynamic Programming problems? There are following two different ways to store the values so that the values of a problem can be reused. Here, will discuss two patterns of solving DP problem: Tabulation: Bottom Up Memoization: Top Down Before getting to the definitions of the above two terms… Read More »

Minimum lines to cover all points

Given N points in 2-dimensional space, we need to print the count of the minimum number of lines which traverse through all these N points and which go through a specific (xO, yO) point also. Examples: If given points are (-1, 3), (4, 3), (2, 1), (-1, -2), (3, -3) and (xO, yO) point is… Read More »

How to solve a Dynamic Programming Problem ?

Dynamic Programming (DP) is a technique that solves some particular type of problems in Polynomial Time. Dynamic Programming solutions are faster than exponential brute method and can be easily proved for their correctness. Before we study how to think Dynamically for a problem, we need to learn: Overlapping Subproblems Optimal Substructure Property Steps to solve… Read More »