GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Mindmap

Binary Search Trees 3

Eithne O'Sullivan Englisch

Inhalt der Mindmap

Binary Search Trees 3

  1. implementation contd.

    • boolean contains(T element), boolean contains(T element, BTNode<T> current)
      • recursion used : return contains(element, root);
        • code in note->
          • &nbsp;&nbsp; if (current ==null){return false;} // 3 conditions : if (element.compareTo(current.element) == 0){ &nbsp; &nbsp;// we can confirm that the element is in the tree so&nbsp; &nbsp; &nbsp;return true; } else if (element.compareTo(current.element) == -1){ // this means the element has lesser value than the is found at the current node // as such we would traverse the left subtree to look for the element &nbsp; &nbsp; &nbsp;return contains(element, current.left); } else { &nbsp;&nbsp;&nbsp; // this covers the final condition where element is of greater value than is in the current node &nbsp; &nbsp;&nbsp;return contains(element, current.right); } &nbsp;&nbsp;

Informationen

Beschreibung
Mindmap am Binary Search Trees 3, erstellt von Eithne O'Sullivan am 04/03/2018.
Erstellt von
Eithne O'Sullivan
Aufrufe
1
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck