title: No implicit ordering defined for A in binary tree
body: <p>I am trying to develop a binary tree structure in Scala, but i have a error that say:</p>
  
  <pre><code> Error:(15, 54) No implicit Ordering defined for A.
  
   override def add[A](new_value: A): BinaryTree[A] = new Node(NullNode,new_value,NullNode)
  </code></pre>
  
  <p>Can any one explain me how i can fix it? Here is the code, the problem is in the <strong>add</strong> method of the <strong>NullNode</strong> object, this method is called when you try to create a left for a <strong>Node</strong>. </p>
  
  <pre><code>sealed abstract class BinaryTree[+A] {
    def isEmpty: Boolean
    def isValid: Boolean
    def add[B &gt;: A](new_value: B): BinaryTree[A]
    def isLeaf: Boolean
    def length: Int
  }
  
  case object NullNode extends BinaryTree[Nothing] {
    override def isEmpty: Boolean = true
    override def isValid: Boolean = true
    override def isLeaf: Boolean = false
    override def add[A](new_value: A): BinaryTree[A] = new Node(NullNode,new_value,NullNode)
    override def length: Int = 0
  }
  
  case class Node[A] (
        var left  : BinaryTree[A],
        var value : A,
        var rigth : BinaryTree[A] )
      ( implicit ord: Ordering[A] ) extends BinaryTree[A] {
    override def isEmpty: Boolean = false
    override def isValid: Boolean = {
      import ord._
  
      def isValidWith (f: A =&gt; Boolean, t: BinaryTree[A]): Boolean = t match {
        case NullNode =&gt; true
        case Node(_,valueNode,_) =&gt; f(valueNode) &amp;&amp; t.isValid
      }
  
      isValidWith(value &lt; _, left) &amp;&amp; isValidWith(value &gt; _, rigth)
    }
  
    override def isLeaf: Boolean = left.isEmpty &amp;&amp; rigth.isEmpty
    override def add[B &gt;: A](new_value: B): BinaryTree[A] = {
      import ord._
  
      def travel (t: BinaryTree[A]): BinaryTree[A] = t match {
        case NullNode =&gt; t.add(new_value)
        case Node (left,nodeValor,rigth) =&gt; {
          if (new_value &gt; nodeValor) new Node(travel(left),nodeValor,rigth)
          else if (new_value &lt; nodeValor) new Node(left,nodeValor, travel(rigth))
          else throw new Exception("Valor ya introducido")
        }
      }
  
      travel(this)
    }
    override def length: Int = {
      def travel (t: BinaryTree[A]): Int = t match {
        case NullNode =&gt; t.length
        case Node(left,_,rigth) =&gt; left.length + rigth.length + 1
      }
  
      travel(this)
    }
  
  }
  
  object BinaryTree {
    def apply[A] (value: A)(implicit ord: Ordering[A]): BinaryTree[A] = new Node(NullNode,value,NullNode)
  }
  </code></pre>
  
  <p>For the moment, I have tried different implementations, adding <strong>Ordering</strong> to the generic type of the <strong>abstract class</strong> or making the <strong>abstract class</strong> a <strong>trait</strong>, but none of that has worked as I would like. I would be very grateful if someone could explain why this error.</p>