javascript binary search tree 2
1.0.0
簡單的純JavaScript BST結構強制,使用線性無返回遞歸調用來添加或刪除項目。這使代碼略大,但減少了多個遞歸節點更新事件。
var tree = new BST ( ) ; // Initialize
tree . add ( value ) ; // Add a new node
tree . remove ( value ) ; // Remove an existing node
tree . print ( ) ; // Print the tree as a text-pyramid in console
tree . min ( ) ; // Find smallest node
tree . max ( ) ; // Find largest node
tree . find ( value ) ; // Find node with given value
tree . destroy ( ) ; // Clears the root注意:要在使用tree.print()時保持間距,任何大於2位數/字符的值都將轉換為標記為“ A”至“ Z”的傳奇。標籤和鑰匙將被分開打印。
根據GNU通用公共許可證v3.0許可。它可以免費複製,使用和分發。