MCPcopy Create free account
hub / github.com/TheAlgorithms/JavaScript / search

Method search

Data-Structures/Tree/BinarySearchTree.js:24–33  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

22
23 // Search the tree for a value
24 search(val) {
25 if (this.value === val) {
26 return this
27 } else if (val < this.value && this.left !== null) {
28 return this.left.search(val)
29 } else if (val > this.value && this.right !== null) {
30 return this.right.search(val)
31 }
32 return null
33 }
34
35 // Visit a node
36 visit(output = (value) => console.log(value)) {

Callers 2

searchMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected