FAL 第16期量化風(fēng)控全線條訓(xùn)練營(yíng)2.0-遠(yuǎn)程班
叉搜索樹(shù)可以高效進(jìn)行查找、添加和刪除節(jié)點(diǎn)操作,時(shí)間復(fù)雜度均和樹(shù)高有關(guān)。如果共有 n 個(gè)元素,平均時(shí)間復(fù)雜度O(logn)
public class BinarySearchTree {
? ?private TreeNode root;
? ?public BinarySearchTree(TreeNode root) {
? ? ? ?this.root = root;
? ?}
? ?public BinarySearchTree(int value) {
? ? ? ?this.root = new TreeNode(value);
? ?}
? ?public TreeNode getRoot() {
? ? ? ?return root;
? ?}
? ?public void setRoot(TreeNode root) {
? ? ? ?this.root = root;
? ?}
標(biāo)簽: