Implement Floyed Rivest
<p>How can you implement a online floyed rivest in c#</p>

<p>The commented code is the part which I have not manged to implement</p>

<p>So far what I Implemented is: </p>

<p>.</p>

<pre><code>  protected int Select(int[] array, int left, int right, int k)
    {
        while (right &gt; left)
        {
            if(right-left&gt;600)
            {
                int n = right - left + 1;
                int x = k - left + 1;
                //int z=ln(n)
               //int s= 0.5 *exp(2 * z / 3)
                //int sd = 0.5 * sqrt(z * s * (n - s) / n) * sign(x - n / 2)
                //int newLeft = max(left, k - x * s / n + sd)
                //int newRight = min(right, k + (n - x) * s / n + sd)

            }
            int t = array[k];
            int i = left;
            int j = right;
            Swap(array, left, k);
            if(array[right]&gt;t)
            {
                Swap(array, right, left);
            }
            while(i&lt;j)
            {
                Swap(array, i, j);
                i = i + 1;
                j = j - 1;
                while(array[i]&lt;t)
                {
                    i = i + 1;
                }
                while (array[j] &gt; t)
                {
                    j = j - 1;
                }
            }
            if(array[left]==t)
            {
                Swap(array, left, j);
            }
            else
            {
                j = j + 1;
                Swap(array, j, right);
            }
            if(j&lt;=k)
            {
                left = j + 1;
            }
            if(k&lt;=j)
            {
                right = j - 1;
            }
        }

    }
    public void Swap(this int[] a, int i, int j)
    {
        int temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }
</code></pre>

<p>Is the implementation correct?</p>

<p>How can I implement the commented code?</p>