Selection Sort in Java 1. Introduction In this tutorial, we’ll learn Selection Sort, see its implementation in Java, and analyze its performance. 2. Algorithm Overview Selection Sort begins with the element in the 1st position of an unsorted array and scans through subsequent elements to find the smallest element. Once found,… Continue Reading java-selection-sort

Example of Hill Climbing Algorithm 1. Overview In this tutorial, we’ll show the Hill-Climbing algorithm and its implementation. We’ll also look at its benefits and shortcomings. Before directly jumping into it, let’s discuss generate-and-test algorithms approach briefly. 2. Generate-And-Test Algorithm It’s a very simple technique that allows us to algorithmize… Continue Reading java-hill-climbing-algorithm

Convert Latitude and Longitude to a 2D Point in Java   1. Overview When implementing applications that use maps, we will typically run into the problem of coordinate conversion. Most of the time, we need to convert latitude and longitude to a 2D point to display. Fortunately, to solve this problem,… Continue Reading java-convert-latitude-longitude

How to Calculate Levenshtein Distance in Java? 1. Introduction In this article, we describe the Levenshtein distance, alternatively known as the Edit distance. The algorithm explained here was devised by a Russian scientist, Vladimir Levenshtein, in 1965. We’ll provide an iterative and a recursive Java implementation of this algorithm. 2.… Continue Reading java-levenshtein-distance

Round Up to the Nearest Hundred 1. Overview In this quick tutorial, we’ll illustrate how to round up a given number to the nearest hundred. For example: 99 becomes 100 200.2 becomes 300 400 becomes 400 2. Implementation First, we’re going to call Math.ceil() on the input parameter. Math.ceil() returns the smallest integer… Continue Reading java-round-up-nearest-hundred

Stable Sorting Algorithms 1. Overview In this tutorial, we’ll learn what stable sorting algorithms are and how they work. Further, we’ll explore when the stability of sorting matters. 2. Stability in Sorting Algorithms The stability of a sorting algorithm is concerned with how the algorithm treats equal (or repeated) elements. Stable… Continue Reading stable-sorting-algorithms

Finding Greatest Common Divisor in Java 1. Overview In mathematics, the GCD of two integers, which are non-zero, is the largest positive integer that divides each of the integers evenly. In this tutorial, we’ll look at three approaches to find the Greatest Common Divisor (GCD) of two integers. Further, we’ll… Continue Reading java-greatest-common-divisor