Category Archives: Algorithm

Algorithm explained

Levenshtein distance(Basic algorithm)

The Levenshtein distance (also known as edit distance) is a metric for measuring the similarity between two strings. It’s defined as the minimum number of operations required to transform one string into the other using insertion, deletion, and substitution operations. We can efficiently calculate the Levenshtein distance using dynamic programming. Example: Levenshtein Distance between “kitten” and “sitting” Let’s… Read More »

Quicksort (Basic Algorithm)

Quicksort is an efficient sorting algorithm based on the divide-and-conquer paradigm. It works as follows: Example of Quicksort: Let’s consider sorting the following array [5, 2, 8, 1, 9, 4, 7]. Python Code Example Quicksort Characteristics: Pivot Selection Strategies: The choice of pivot significantly impacts Quicksort’s performance. Quicksort is widely used due to its relatively simple implementation and… Read More »

Bubble Sort (Basic algorithm)

Bubble sort is one of the simplest sorting algorithms. It works by repeatedly stepping through the list, comparing adjacent elements and swapping them if they are in the wrong order. Larger elements “bubble” to the end of the list with each pass. This process continues until the entire list is sorted in ascending (or descending) order. Example: Let’s… Read More »

k-Means Clustering (basic algorithms -machine learning )

k-means clustering is an unsupervised learning algorithm used to partition a given dataset into several groups (clusters). It works by iteratively updating the “centroids” – the center points of each cluster – and assigning data points to the closest centroid. Features: Steps of k-Means Clustering Let’s consider the following 2D dataset as an example: We want to cluster… Read More »