GoConqr has a new look! Let us know what you think.

Mind map

Binary Search Trees 3

Eithne O'Sullivan English

Map content

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;

Information

Description
Mind Map on Binary Search Trees 3, created by Eithne O'Sullivan on 04/03/2018.
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?