(root, val, tree)
| 227 | } |
| 228 | // search tree for a element |
| 229 | const searchAVLTree = function (root, val, tree) { |
| 230 | if (root == null) { |
| 231 | return null |
| 232 | } |
| 233 | if (tree._comp(root._val, val) === 0) { |
| 234 | return root |
| 235 | } |
| 236 | if (tree._comp(root._val, val) < 0) { |
| 237 | return searchAVLTree(root._right, val, tree) |
| 238 | } |
| 239 | return searchAVLTree(root._left, val, tree) |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * A Code for Testing the AVLTree |