Click here to Skip to main content
15,898,134 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Algorithm running time Pin
Matthew Dennis5-Dec-15 22:09
sysadminMatthew Dennis5-Dec-15 22:09 
QuestionOptimize algorithm arrange an array with items with even-indexs are on left side of array, items with odd-indexs are on right side of array Pin
Hồng Chấn Phát30-Nov-15 22:11
Hồng Chấn Phát30-Nov-15 22:11 
AnswerRe: Optimize algorithm arrange an array with items with even-indexs are on left side of array, items with odd-indexs are on right side of array Pin
Richard MacCutchan1-Dec-15 2:47
mveRichard MacCutchan1-Dec-15 2:47 
GeneralRe: Optimize algorithm arrange an array with items with even-indexs are on left side of array, items with odd-indexs are on right side of array Pin
Patrice T1-Dec-15 8:32
mvePatrice T1-Dec-15 8:32 
GeneralRe: Optimize algorithm arrange an array with items with even-indexs are on left side of array, items with odd-indexs are on right side of array Pin
Hồng Chấn Phát1-Dec-15 16:06
Hồng Chấn Phát1-Dec-15 16:06 
GeneralRe: Optimize algorithm arrange an array with items with even-indexs are on left side of array, items with odd-indexs are on right side of array Pin
Patrice T1-Dec-15 16:18
mvePatrice T1-Dec-15 16:18 
AnswerRe: Optimize algorithm arrange an array with items with even-indexs are on left side of array, items with odd-indexs are on right side of array Pin
Daniel Pfeffer1-Dec-15 21:54
professionalDaniel Pfeffer1-Dec-15 21:54 
AnswerRe: Optimize algorithm arrange an array with items with even-indexs are on left side of array, items with odd-indexs are on right side of array Pin
BillWoodruff5-Dec-15 20:31
professionalBillWoodruff5-Dec-15 20:31 
C#
using System.Linq;

private int[] ints = new int[]{0,1,2,3,4,5,6,7,8,9,10};

// in some method
int[] sints = ints.Where(val => (val%2 == 0)).Concat(ints.Where(val => (val%2 == 1))).ToArray();
I'm not claiming that is optimal in terms of speed of code execution; but it's faster in terms of my valuable time writing code !

If I could not use Linq:
C#
private string[] strs = new string[]{"a1","b1","a2","b2","a3","b3","a4","b4"};

private string firstOddValue = strs[1];

// in some method
List<string> strList = new List<string>{strs[0]};

for (int i = 1; i < strs.Length; i++)
{
    if (i%2 == 1)
    {
        strList.Add(strs[i]);
    }
    else
    {
        strList.Insert(strList.IndexOf(firstOddValue), strs[i]);
    }
}

«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.

QuestionAssociation Rule Algorithm:dynamic god capabilities. Pin
shuga25-Nov-15 6:16
shuga25-Nov-15 6:16 
AnswerRe: Association Rule Algorithm:dynamic god capabilities. Pin
Patrice T28-Nov-15 10:05
mvePatrice T28-Nov-15 10:05 
GeneralRe: Association Rule Algorithm:dynamic god capabilities. Pin
shuga28-Nov-15 17:57
shuga28-Nov-15 17:57 
GeneralRe: Association Rule Algorithm:dynamic god capabilities. Pin
shuga28-Nov-15 17:57
shuga28-Nov-15 17:57 
GeneralRe: Association Rule Algorithm:dynamic god capabilities. Pin
shuga28-Nov-15 17:57
shuga28-Nov-15 17:57 
QuestionHow do I solve the recurrence T(n) = T (n - 1) + c substitution method? Pin
axeemg17-Nov-15 4:12
axeemg17-Nov-15 4:12 
AnswerRe: How do I solve the recurrence T(n) = T (n - 1) + c substitution method? Pin
Patrice T17-Nov-15 17:53
mvePatrice T17-Nov-15 17:53 
QuestionAlgorithm query + request Pin
Member 1214387716-Nov-15 6:53
Member 1214387716-Nov-15 6:53 
AnswerRe: Algorithm query + request Pin
Chris Losinger16-Nov-15 7:01
professionalChris Losinger16-Nov-15 7:01 
AnswerRe: Algorithm query + request Pin
Patrice T17-Nov-15 18:00
mvePatrice T17-Nov-15 18:00 
GeneralHash table load factor Pin
Member 1180386012-Nov-15 13:04
Member 1180386012-Nov-15 13:04 
QuestionAlgorithm needed to find a point on A4 size plane Pin
Member 1213438812-Nov-15 3:45
Member 1213438812-Nov-15 3:45 
AnswerRe: Algorithm needed to find a point on A4 size plane Pin
Richard Deeming12-Nov-15 4:05
mveRichard Deeming12-Nov-15 4:05 
AnswerRe: Algorithm needed to find a point on A4 size plane Pin
Chris Maunder12-Nov-15 4:15
cofounderChris Maunder12-Nov-15 4:15 
QuestionFastest way to count nested loops Pin
Member 113783027-Nov-15 2:32
Member 113783027-Nov-15 2:32 
AnswerRe: Fastest way to count nested loops Pin
Patrice T7-Nov-15 4:57
mvePatrice T7-Nov-15 4:57 
GeneralRe: Fastest way to count nested loops Pin
Member 113783027-Nov-15 5:02
Member 113783027-Nov-15 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.