Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
20
Task/AVL-tree/JavaScript/avl-tree-2.js
Normal file
20
Task/AVL-tree/JavaScript/avl-tree-2.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
function dumptree(t) {
|
||||
switch (t.depth) {
|
||||
case 0: return '';
|
||||
case 1: return t.val;
|
||||
default: return '('+dumptree(t.less)+','+t.val+','+dumptree(t.more)+')';
|
||||
}
|
||||
}
|
||||
function example() {
|
||||
let t= node(0);
|
||||
for (let j= 1; j<20; j++) {
|
||||
t= insert(node(j), t);
|
||||
}
|
||||
console.log(dumptree(t));
|
||||
t= remove(2, t);
|
||||
console.log(dumptree(t));
|
||||
console.log(dumptree(lookup(5, t)));
|
||||
console.log(dumptree(remove(5, t)));
|
||||
}
|
||||
|
||||
example();
|
||||
Loading…
Add table
Add a link
Reference in a new issue