We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9191b73 commit 6f8965cCopy full SHA for 6f8965c
DataStruct/dataStruct-zh.md
@@ -371,3 +371,22 @@ breadthTraversal() {
371
}
372
```
373
374
+接下来先介绍如何在树中寻找最小值或最大数。因为二分搜索树的特性,所以最小值一定在根节点的最左边,最大值相反
375
+
376
+```js
377
+getMin() {
378
+ return this._getMin(this.root).value
379
+}
380
+_getMin(node) {
381
+ if (!node.left) return node
382
+ return this._getMin(node.left)
383
384
+getMax() {
385
+ return this._getMax(this.root).value
386
387
+_getMax(node) {
388
+ if (!node.right) return node
389
+ return this._getMin(node.right)
390
391
+```
392
0 commit comments