Mind map
Binary Search Trees 3
Map content
Binary Search Trees 3
implementation contd.
- boolean contains(T element), boolean contains(T element, BTNode<T> current)
- recursion used : return contains(element, root);
- code in note->
- if (current ==null){return false;} // 3 conditions : if (element.compareTo(current.element) == 0){ // we can confirm that the element is in the tree so 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 return contains(element, current.left); } else { // this covers the final condition where element is of greater value than is in the current node return contains(element, current.right); }
- code in note->
- recursion used : return contains(element, root);
- boolean contains(T element), boolean contains(T element, BTNode<T> current)
Information
- Description
- Mind Map on Binary Search Trees 3, created by Eithne O'Sullivan on 04/03/2018.
- Created by
- Eithne O'Sullivan
- Views
- 1
- Rating