title: How to implement priority queue in C programming?
body: <p>I need to implement a priority queue in C programming using singly linked list. </p>
  
  <p>I do not have a clear idea about priority queue. I googled but didn't fully understand what I found. My understanding is that a priority queue is a queue whose elements are ordered by priority. Insertions into the list are positioned within the list on the basis of the element priorities.</p>
  
  <p>Lets say,we have following scenario. (Note : I assume, higher value goes with higher priority):</p>
  
  <pre><code>Element--&gt;2 (priority=2)  (Now in position 0)
  </code></pre>
  
  <p>If another element needs to be inserted, say <code>Element--&gt;3 (priority=3)</code> which has a higher priority.</p>
  
  <p>I can move the previous element, <code>Element--&gt;2 (priority=2)</code>, and insert this new <code>Element--&gt;3 (priority=3)</code> at position 0 with <code>Element--&gt;2 (priority=2)</code> moved to position 1 in the list.</p>
  
  <p>Now the list becomes,</p>
  
  <pre><code>Element--&gt;3 (priority=3) followed by Element--&gt;2 (priority=2)
  </code></pre>
  
  <p>Similarly, on the basis of insertion, do I have to shift all the elements in the list?</p>
  
  <p>Is this correct?</p>