Maximum subarray problem is the method to find the contiguous subarray within a one-dimensional array of numbers which has the largest sum.
The problem was originally proposed by Ulf Grenander of Brown University in 1977, as a simplified model for maximum likelihood estimation of patterns in digiti...
public class MaximumSubarray
{
private static int Max(int a, int b)
{
return a > b ? a : b;
}
static int MaxSubArray(int[] input, int n)
{
int max = input[0];
int currentMax = input[0];
for (int i = 1; i < n; i++)
{
...
(input)
output = 0
for cycleStart from 0 to length(array) - 2
item = array[cycleStart]
pos = cycleStart
for i from cycleStart + 1 to length(array) - 1
if array[i] < item:
pos += 1
if pos == cycleStart:
continue
while item == array[pos]:
...
public class CycleSort
{
public static void SortCycle(int[] input)
{
for (var i = 0; i < input.Length; i++)
{
var item = input[i];
var position = i;
do
{
var k = input.Where((t, j) => position != ...
Constraints:
Input (an array to be sorted)
Number of element in input (n)
Keys in the range of 0..k-1 (k)
Count (an array of number)
Pseudocode:
for x in input:
count[key(x)] += 1
total = 0
for i in range(k):
oldCount = count[i]
count[i] = total
total += oldCount
for...
public class CountingSort
{
public static void SortCounting(int[] input, int min, int max)
{
var count = new int[max - min + 1];
var z = 0;
for (var i = 0; i < count.Length; i++)
count[i] = 0;
foreach (int i in input)
co...
public class HeapSort
{
public static void Heapify(int[] input, int n, int i)
{
int largest = i;
int l = i + 1;
int r = i + 2;
if (l < n && input[l] > input[largest])
largest = l;
if (r < n && input[r] ...
public class PigeonholeSort
{
private static void SortPigeonhole(int[] input, int n)
{
int min = input[0], max = input[n];
for (int i = 1; i < n; i++)
{
if (input[i] < min) min = input[i];
if (input[i] > max) max = input[i];
...
insertSort :: Ord a => [a] -> [a]
insertSort [] = []
insertSort (x:xs) = insert x (insertSort xs)
insert :: Ord a => a-> [a] -> [a]
insert n [] = [n]
insert n (x:xs) | n <= x = (n:x:xs)
| otherwise = x:insert n xs
public class CatalanNumber
{
public static int Main(int number)
{
int result = 0;
if (number <= 1) return 1;
for (int i = 0; i < number; i++)
{
result += Main(i)*Main(number - i - 1);
}
return result;
}
}
Dynamic Time Warping(DTW) is an algorithm for measuring similarity between two temporal sequences which may vary in speed. For instance, similarities in walking could be detected using DTW, even if one person was walking faster than the other, or if there were accelerations and decelerations during ...
quickSort :: Ord a => [a] -> [a]
quickSort [] = []
quickSort (x:xs) = quickSort [ y | y <- xs, y <= x ]
++ [x]
++ quickSort [ z | z <- xs, z > x ]
Before getting started on Processing for Android, make sure you have Processing installed.
Open Processing
Click on Add Mode... located in the top right of the window:
Search for "android" in the Contribution Manager and choose the option that has the author "The Processing Fou...
Launch standalone player activity
Intent standAlonePlayerIntent = YouTubeStandalonePlayer.createVideoIntent((Activity) context,
Config.YOUTUBE_API_KEY, // which you have created in step 3
videoId, // video which is to be played
100, //The time,...
The binder gives you an opportunity to inspect what types are being loaded in your application domain
Create a class inherited from SerializationBinder
class MyBinder : SerializationBinder
{
public override Type BindToType(string assemblyName, string typeName)
{
if (typeName.Eq...
To be able to use the P3D renderer you must specify it in the size() function
size(200, 200, P3D);
Now, there are three axes: x, y and z.
Now you can proceed in drawing in 3D.
One of the most interesting Number Patterns is Pascal's Triangle. The Name "Pascal's Triangle" named after Blaise Pascal, a famous French Mathematician and Philosopher.
In Mathematics, Pascal's Triangle is a triangular array of binomial coefficients.The rows of Pascal's triangle are conve...