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 != ...
The [record][1] library provides the ability to create compound terms with named fields. The directive :- record/1 <spec> compiles to a collection of predicates that initialize, set and get fields in the term defined by <spec>.
For example, we can define a point data structure with nam...
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...
WRITE record-buff
WRITE indexed-record
WITH LOCK
ON INVALID KEY
DISPLAY "Key exists, REWRITING..." END-DISPLAY
PERFORM rewrite-key
END-WRITE
IF indexed-file-status NOT EQUAL ZERO THEN
DISPLAY "Write problem: " indexed-file-status UPON SYSERR
...
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;
}
}
quickSort :: Ord a => [a] -> [a]
quickSort [] = []
quickSort (x:xs) = quickSort [ y | y <- xs, y <= x ]
++ [x]
++ quickSort [ z | z <- xs, z > x ]
Few of the eclipse classic versions don't come pre-installed with marketplace, this maybe installed using the following steps:
Goto Help → Install new Software
Add new Repository(site specified below)
General Purpose Tools → Marketplace Client
Click Finish and you are done.
Marketplace upda...
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,...