title: Finding k smallest elements in a min heap - worst-case complexity
body: <p>I have a minimum heap with <code>n</code> elements and want to find <code>k</code> smallest numbers from this heap. What is the worst-case complexity?</p>
  
  <p>Here is my approach: somewhere on the stackoverflow I read that complexity of finding i-th smallest number in a min heap is <code>O(i)</code>. So if we would like to find <code>n-1</code> smallest numbers (n is pointless, since it would be the entire heap), the total complexity would look something like this:</p>
  
  <p><code>O(n-1)+O(n-2)+O(n-3)+…+O(2)+O(1)=O((1+n-1)*(n/2))=O(n^2)</code> </p>
  
  <p>Is this correct?</p>