title: sorting a string using counting sort
body: <p>I looked at the counting sort algorithm to sort a string here: <a href="https://www.geeksforgeeks.org/counting-sort/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/counting-sort/</a>. I have a few questions:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#define RANGE 255  
  </code></pre>
  
  <p>What is the function of <code>RANGE</code>? Why do we have to specifically define the <code>RANGE</code> to 255?</p>
  
  <pre class="lang-cpp prettyprint-override"><code>int count[RANGE + 1], i;  
  </code></pre>
  
  <p>Why do we have to declare the size of <code>count[]</code> as <code>RANGE+1</code>? Why couldn't it be just 256?</p>
  
  <pre class="lang-cpp prettyprint-override"><code>// Store count of each character  
  for(i = 0; arr[i]; ++i)  
      ++count[arr[i]];
  </code></pre>
  
  <p>The array stores the count of the specified digit, but here we have characters in a string, so how does the above code convert the characters to numeric equivalents to be stored in the array?</p>