The REAL Solution can be found in this post!:
http://studenterfilosofi.blogspot.com/2013/11/the-solution-to-fail.html
I tried to make a "find" overhead algorithm to find how many of the dublicates there are in an array.
For example there would be 3 overheads if there the array looked like this:http://studenterfilosofi.blogspot.com/2013/11/the-solution-to-fail.html
I tried to make a "find" overhead algorithm to find how many of the dublicates there are in an array.
{1,2,3,4,6,6,6}
and here is the code:
public static void OverheadCounter(int[] A, int L, int R)
{
int overHead = 0;
//compare L==R????
if (L < R)
{
//divide
int mid = (int)Math.Floor((double)(R + L) / 2); //Remember R = A.lenght = 5 = the index. (this is zero based)
OverheadCounter(A, L, mid); //Check left side first
OverheadCounter(A, mid + 1, R); //Check right side
//conquer
overHead = Overhead(A, L, R, overHead);
}
else if (L == R)
{
overHead += Overhead(A, L, R, overHead);
}
Console.WriteLine(overHead);
}
public static int Overhead(int[] A, int L, int R, int overhead)
{
if (A[L] == A[R])
{
overhead++;
//Console.WriteLine(overhead);
}
return overhead;
}
}