javascript-algorithms
javascript-algorithms copied to clipboard
read-black-tree
let tree = new RedBlackTree(); tree.insert(5); tree.insert(10); tree.insert(8); At this time, the parent pointer of 10 is null;
let tree = new RedBlackTree(1); tree.insert(5); tree.insert(10); tree.insert(8); At this time, the parent pointer of 10 is null;
let tree = new RedBlackTree(1); tree.insert(5); tree.insert(10); tree.insert(8);
if (!tree.root.right || !tree.root.right.right) { console.error("The parent pointer of 10 is null"); }
This version of the code uses a conditional statement to check if the parent pointer of 10 is null, and if so, it logs an error message.