We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Self Balancing Tree
Self Balancing Tree
Sort by
recency
|
180 Discussions
|
Please Login in order to post a comment
I keep getting this error and I dont know how to reslove PLease help!! avl.java:319: error: cannot find symbol root=root.insert(root,nv); ^ symbol: method insert(Node,int) location: variable root of type Node 1 error class Solution {
Js solution
class Node { constructor(value) { this.value = value; this.left = null; this.right = null; this.height = 1; } }
function insert(root, data) { if (!root) return new Node(data);
}
function getHeight(node) { return node ? node.height : 0; }
function getBalance(node) { return node ? getHeight(node.left) - getHeight(node.right) : 0; }
function rightRotate(y) { const x = y.left; const T2 = x.right;
}
function leftRotate(x) { const y = x.right; const T2 = y.left;
}
function sortedArrayToAVL(arr) { if (arr.length === 0) return null;
}
function inOrderTraversal(node, result = []) { if (!node) return result;
}
function preOrderTraversal(node, result = []) { if (!node) return result;
}
function processData(input) { const lines = input.trim().split('\n'); const rootPointer = parseInt(lines[0]); const values = lines[1].split(' ').map(Number); const valueToAdd = parseInt(lines[2]);
}
processData("4\n3 2 4 5\n6");
Fully working python solution
Python template
My Java Solution with code explanation: https://github.com/tuphan22028238/DSA/blob/main/BT10/06_AVLTree/Solution.java