First we need to make sure the input, the given arguments for our function, that is two binary trees. And the output is a merged tree.

**Problem**

```
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.
You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherwise, the NOT null node will be used as the node of new tree.
```

Example input:

trees javascript merge-two-trees leetcode depth-first-search

For our last She’s coding data structure and algorithm event I chose minimum depth of binary tree problem to practice tree traversing with our participants. It can be challenging at first, with the help of depth first search and breadth first search we can solve it easily.

Javascript String search() is an inbuilt function that executes the search for a match between a regular expression and this String object.

Prerequisite: Binary Search Tree In JavaScript. Deletion in Binary Search Tree with JavaScript. Deletion in binary search tree can be tricky, since we’re not working with just leafs but having to restructure all of a node’s children. Node to be deleted is leaf. To delete a leaf node, simply remove it from the tree. Since it was a leaf node we deleted it from the tree without making any other changes.

Binary search tree, as shown in its name, is a ordered tree data structure. Every parent nodes has at most two children, every node to the left of a parent node is always less than the parent and every node to the right of the parent node is always greater than the parent.

How does JavaScript implement a binary search tree? The following article will introduce you the method of implementing binary search tree using JavaScript.