title: Bubble sort worst case, best case and average case complexity
body: <p>What is the (a) worst case, (b) best case, and (c) average case complexity of the following function which does bubble sorting</p>
  
  <pre><code>for i=1 to n-1 do
      for j=i to n-1 do
          if x[j]&gt;x[j+1] then
              temp=x[j]
              x[j]=x[j+1]
              x[j+1]=temp
          end {if}
      end {for}
  end {for}
  </code></pre>
  
  <p>How would you justify the complexity?</p>