feat(codes/cpp/include/TreeNode.cpp): add 'parent' and 'height' field
This commit is contained in:
parent
e9996b37d6
commit
641cf74afc
@ -11,10 +11,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct TreeNode {
|
struct TreeNode {
|
||||||
int val;
|
int val{};
|
||||||
TreeNode *left;
|
int height = 1;
|
||||||
TreeNode *right;
|
TreeNode *parent{};
|
||||||
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
|
TreeNode *left{};
|
||||||
|
TreeNode *right{};
|
||||||
|
TreeNode() = default;
|
||||||
|
explicit TreeNode(int x, TreeNode *parent = nullptr) : val(x), parent(parent) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user