Comparing two bubble sort algorithms I'm learning C and I've got to a point learning about different sorting algorithms.  Before seeing how it was done, I wanted to try doing it myself based on what I read on how it's working.

int temp;
    for(int i = 0; i &lt; SIZE - 1; i++)
    {
        for(int j = 0; j &lt; SIZE - 1 - i; j++)
        {
            if (arr[j] &gt; arr[j + 1])
            {
                temp = arr[j + 1];
                arr[j + 1] = arr[j];
                arr[j] = temp;
            }
        }
    }


This is what the code from where I learn looks like:


for(int i = 0; i &lt; SIZE; i++)
{
       if((i &lt; SIZE - 1) &amp;&amp; (arr[i] &gt; arr[i+1]))
       {
                  int tmp = arr[i];
                  arr[i] = arr[i + 1];
                  arr[i + 1] = tmp;
                  i = -1;
       }
}



Now, obviously they're different, but is one more efficient in someway than the other?  Did I do something that is less efficient than their code?
Your implementation

Your implementation is mostly pretty good.  I'd just make a few minor changes:


int temp should be declared in the tightest scope possible — namely, inside the if block.  Localizing the variable further makes it harder to misuse and easier to understand.  I'd also rename temp to swap to make its purpose clearer.  (Naming a variable temp is usually a bad idea, in my opinion.)
int temp is at the wrong level of indentation.  Maybe you just made an error when pasting the code here?
There is a space after if, but not after for.  Be consistent.  I recommend putting the space there to distinguish those keywords from function calls.
The j &lt; SIZE - 1 - i condition is a bit hard to follow.  You could apply the transformation ii = SIZE - 1 - i, and have the outer loop count backwards instead.

for (int ii = SIZE - 1; ii &gt; 0; ii--)
{
    /* Let the largest element bubble up to the end */
    for (int j = 0; j &lt; ii; j++)
    {
        if (arr[j] &gt; arr[j + 1])
        {
            int swap = arr[j + 1];
            arr[j + 1] = arr[j];
            arr[j] = swap;
        }
    }
}