title: Find the Kth smallest element in the list using Partition - Help me understand
body: <p>Okay I have an assignment to find the Kth smallest element in the list using several different methods....</p>
  
  <p>first method is to sort the list, then return the Kth smallest element. easy, my mentality is say the list = 10 elements, sort the list in ascending order, then return the element in the 10th position</p>
  
  <p>next method uses the Partition from Quicksort:</p>
  
  <p><em>"The second algorithm is to apply the procedure Partition used in Quicksort.  The procedure  partitions an array so that all elements smaller than some pivot item come before it in the array and all elements larger than that pivot item come after it.  The slot at which the pivot item is located is called the pivotposition.  We can solve the Selection Problem by partitioning until the pivot item is at the kth slot.  We do this by recursively partitioning the left subarray if k is less than pivotposition, and by recursively partitioning the right subarray if k is greater than pivotposition.  When k = pivotposition, we're done."</em></p>
  
  <p>Say I have a list of 10 items:</p>
  
  <p>3 8 9 2 4 5 1 7 10 6, with 5 being the pivot.. I know I would normally would have 2 arrays</p>
  
  <p>3 2 4 1  and 8 9 7 10 6</p>
  
  <p>but what I don't understand is: <em>"We can solve the Selection Problem by partitioning until the pivot item is at the kth slot."</em></p>
  
  <p>what is the kth slot?  to me i keep thinking kth = the length of the array, so in this case 10.  which would have the 6 value in it, which is obviously not the lowest... and isn't correct.</p>
  
  <p>can someone use this sample array and kinda just show me what this algorithm means and how it finds the kth/smallest element?  thanks</p>