What does it mean for an array to have incremented element in square brackets?
<p>In the following algorithm for merge-sort, within the 3rd definition, first while loop there is:</p>

<pre><code>a[k++] = (a[j] &lt; b[i]) ? a[j++] : b[i++].
</code></pre>

<p>I understand that the RHS is a conditional statement stating that if the first operand is satisfied, then we should perform the second operand, and if it is not satisfied, we should perform the third operand.</p>

<p>What element does <code>a[k++]</code>, <code>a[j++]</code> and <code>b[i++]</code> correspond to?</p>

<p>From my understanding, it should mean in each successive while loop, the element is incremented. </p>

<p>ie. beginning with the initialised values (<code>i=1</code>, <code>j=m+1</code>, <code>k=1</code>) for the first while loop, the next while loop will consist of (<code>i=2</code>, <code>j=m+2</code>, <code>k=2</code>), and so on.</p>

<p>Here is the entire algorithm:</p>

<pre><code># split in half
m = n / 2

# recursive sorts
sort a[1..m]
sort a[m+1..n]

# merge sorted sub-arrays using temp array
b = copy of a[1..m]
i = 1, j = m+1, k = 1
while i &lt;= m and j &lt;= n,
    a[k++] = (a[j] &lt; b[i]) ? a[j++] : b[i++]
    → invariant: a[1..k] in final position
while i &lt;= m,
    a[k++] = b[i++]
    → invariant: a[1..k] in final position
</code></pre>