Mapa mental
Binary Search Trees 3
Contenido del mapa
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)
Información
- Descripción
- Mapa Mental sobre Binary Search Trees 3, creado por Eithne O'Sullivan el 04/03/2018.
- Creado por
- Eithne O'Sullivan
- Visitas
- 1
- Valoración