Click here to Skip to main content
15,895,606 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Algorithm or not? Pin
Alan Balkany17-Oct-08 3:54
Alan Balkany17-Oct-08 3:54 
QuestionMonte carlo Rabin_Karp Search Pin
Angelinna2-Oct-08 14:17
Angelinna2-Oct-08 14:17 
AnswerRe: Monte carlo Rabin_Karp Search Pin
Robert.C.Cartaino2-Oct-08 16:23
Robert.C.Cartaino2-Oct-08 16:23 
GeneralRe: Monte carlo Rabin_Karp Search Pin
Angelinna2-Oct-08 17:07
Angelinna2-Oct-08 17:07 
GeneralSign of the times... PinPopular
CPallini2-Oct-08 21:52
mveCPallini2-Oct-08 21:52 
GeneralRe: Monte carlo Rabin_Karp Search Pin
Paul Conrad3-Oct-08 6:28
professionalPaul Conrad3-Oct-08 6:28 
GeneralRe: Monte carlo Rabin_Karp Search PinPopular
Tim Craig3-Oct-08 18:34
Tim Craig3-Oct-08 18:34 
GeneralArray Rearrangement trick [modified] Pin
abhigad1-Oct-08 9:53
abhigad1-Oct-08 9:53 
Let’s say we have an array of integers

int[] myArray = new int[] {1,2,3,4,5};

So the length of this array is 4 [i.e. n=4] since C# array index starts at 0

Yes the length will be 5 and not 4 as pointed out in the next post. Its my bad - Sorry!

Define integer k such that 0<= k < n [n = length of an array]

For example, If k = 2 then the output should be
{3,4,5,1,2} i.e starting from kth position move all the array elements to the top of an array.

If k = 3, output would be
{4,5,1,2,3}

Here is the challenge.
Yes this is trivial if we write a loop that starts at 0 and goes up to n like

for(int i =0;i<n;i++){}

We want to optimize this loop so that it would not loop till n-1. anything less than n-1 is a good solution.

[Tip: if you want to reverse this array like 5,4,3,2,1 – you can use the loop like
for(int i=0;i<n/2;i++)

modified on Wednesday, October 1, 2008 5:23 PM

GeneralRe: Array Rearrangement trick Pin
CPallini1-Oct-08 10:16
mveCPallini1-Oct-08 10:16 
GeneralRe: Array Rearrangement trick Pin
Alan Balkany2-Oct-08 3:42
Alan Balkany2-Oct-08 3:42 
GeneralRe: Array Rearrangement trick Pin
Mark Churchill2-Oct-08 5:16
Mark Churchill2-Oct-08 5:16 
QuestionDigit combination string [modified] Pin
z33z30-Sep-08 21:25
z33z30-Sep-08 21:25 
QuestionExternal sorting: Which algorithm to select Pin
lizardking3d29-Sep-08 1:45
lizardking3d29-Sep-08 1:45 
AnswerRe: External sorting: Which algorithm to select Pin
Alan Balkany1-Oct-08 3:36
Alan Balkany1-Oct-08 3:36 
GeneralRe: External sorting: Which algorithm to select Pin
lizardking3d5-Oct-08 20:48
lizardking3d5-Oct-08 20:48 
GeneralRe: External sorting: Which algorithm to select Pin
Alan Balkany6-Oct-08 3:29
Alan Balkany6-Oct-08 3:29 
GeneralRe: External sorting: Which algorithm to select Pin
lizardking3d6-Oct-08 4:08
lizardking3d6-Oct-08 4:08 
GeneralRe: External sorting: Which algorithm to select Pin
Alan Balkany6-Oct-08 4:22
Alan Balkany6-Oct-08 4:22 
GeneralRe: External sorting: Which algorithm to select Pin
Mark Churchill6-Oct-08 5:23
Mark Churchill6-Oct-08 5:23 
GeneralRe: External sorting: Which algorithm to select Pin
supercat921-Oct-08 12:49
supercat921-Oct-08 12:49 
GeneralRe: External sorting: Which algorithm to select Pin
lizardking3d22-Oct-08 1:57
lizardking3d22-Oct-08 1:57 
GeneralRe: External sorting: Which algorithm to select Pin
supercat922-Oct-08 7:38
supercat922-Oct-08 7:38 
NewsHuge new prime number discovered Pin
73Zeppelin27-Sep-08 22:41
73Zeppelin27-Sep-08 22:41 
GeneralRe: Huge new prime number discovered Pin
Bassam Abdul-Baki28-Sep-08 15:16
professionalBassam Abdul-Baki28-Sep-08 15:16 
JokeRe: Huge new prime number discovered Pin
Nelek14-Oct-08 0:52
protectorNelek14-Oct-08 0:52 

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.