title: Pseudocode for Binary search tree
body: <p>In a binary search tree, the predecessor of a key x is a key y that is smaller than 
  x, and for which there is no other key z such that z is smaller than x and greater 
  than y. </p>
  
  <p>Give the pseudocode for an algorithm that takes a key x and returns the 
  predecessor y or nil if x is the smallest key in the tree. Assume that the binary 
  search tree is represented using arrays left, right, and parent. Give the pseudocode 
  for any subsidiary functions that are used. </p>
  
  <p>I'm not really sure how to approach this question. But heres my attempt:</p>
  
  <p>Pseudocode:</p>
  
  <pre><code>//Takes in key x
  
  BST(x)
  {
  
  if ( x &lt; parent[x] )
  
      return nil
  
  if( parent[x] &lt; x )
  
     return parent[x] // parent[x] = y
  }
  </code></pre>