title: Top 5 elements in an unsorted array
body: <p>An unsorted array is given and we need to find top 5 elements in an efficient way and we cannot sort the list .</p>
  
  <p>My solution :</p>
  
  <ul>
  <li><p>Find the max element in the array. O(n)</p></li>
  <li><p>Delete this max element after processing/using it.</p></li>
  <li><p>Repeat step 1 &amp; 2 , k times ( 5 times in this case ).</p></li>
  </ul>
  
  <p>Time Complexity : <strong>O(kn)</strong> / <strong>O(n)</strong> , Space Complexity : <strong>O(1)</strong>.</p>
  
  <p>I think we can find the max element in <strong>O(logN)</strong> , So it can be improved to <strong>O(klogN)</strong>. Please correct me if I am wrong.</p>
  
  <p>Can we do better than this ? Using max-heap would be inefficient I guess? </p>
  
  <p>PS - This is not any homework.</p>