Straight Selection Sort using C

Selection sorting refers to a class of algorithms for sorting a list of items using comparisons. These algorithms select successively smaller or larger items from the list and add them to the output sequence. This is an improvement of the Simple Selection Sort and it is called Straight Selection Sort. Therefore, instead of replacing the selected element by a unique…

Simple Selection Sort using C

The simplest possible technique based on the principle of repeated selection makes use of “n” passes over an array elements. In the i-th pass, the i-th smallest element is selected from the given array and it is placed in the i-th position of a separate output array. The already selected element is not selected next time and in order to…

Shell Sort using C

I will show here an example on shell sort (invented by Donald Shell) using C programming language. This method makes repeated use of straight insertion or shuttle sort. The method starts by sorting pairs of elements far apart from each other, then progressively reducing the gap between elements to be compared. An array with n elements, in each pass, an…

Straight Insertion Sort using C

Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. More details can be found here at https://en.wikipedia.org/wiki/Insertion_sort Let’s say we have an array a, so at each i-th pass, a[i] is successively compared with a[i-1], a[i-2], etc. until an element smaller than a[i] is found or the beginning of…

Shuttle Sort using C

In Shuttle Sort technique for n elements in an array a, it requires n-1 passes. When i-th pass(1<=i<=n) begins, the first i elements, i.e., elements a[0] to a[i-1] have been sorted and these occupy the first i positions of the array. To insert (i+1)th element, a[i] is compared with a[i-1] and if the value of a[i] is smaller than a[i-1]…

Tomcat load balancing with Apache using mod proxy

This tutorial will show you how to configure Tomcat Load Balancing with Apache webserver (http server) using Mod Proxy. I have listed here the following steps on how to configure Apache with Tomcat to configure Load Balancer using Mod Proxy. Having load-balanced is always recommended in production environment for better availability and performance of your application resources. Load balancing improves…

Binary Search using C

This example shows how Binary Search Algorithm works and I am going to implement it using C programming language. Binary search, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array….

Sequential Search using C

This example shows how Sequential Search algorithm works. In sequential or linear search an element is searched or found in a list. Simple way to search for a key value k in an array a is to compare the values of the elements in a with k. The process starts with the first element of the array and k and…

Move Non-Zero Array Elements to Left using Java

Introduction This examples shows how to move all non-zero elements (if any) in an array to the left and all zero elements to the right of the array using Java. Your integer array may hold zero (0) and non-zero (1, 2, 4, etc.) elements. You have a requirement to have all non-zero elements first followed by 0 elements in the…

Solving Josephus Problem using Java

Introduction The Josephus problem (or Josephus permutation) is a theoretical problem related to a certain counting-out game. The problem is described as below. People are standing in a circle waiting to be executed. Counting begins at a specified point in the circle and proceeds around the circle in a specified direction. After a specified number of people are skipped, the…