Redian新闻
>
lot 的grading好调整吗
avatar
lot 的grading好调整吗# Living
t*3
1
给定了interface。
public static boolean delete(Node root, int value){
//fill your code here
}
class Node{
Node left;
Node right;
int val;
Node(int value){
val=value;
}
}
这个怎么写比较好呢?
avatar
d*8
2
新房。盖到中期我们和builder签的合同。定金2万。盖好后,请了inspector检查,说
是negative grading. 有点往地基方向坡。将来地下室会漏水。买的时候没经验,本身
lot比较平。加一点settling,就grading向里了。builder 给修了修,我们觉得后院还
是中间稍高一点。将来做landscaping时可以调整一点吗?
新房,花了很多时间和精力,不想轻易放弃了。现在房子也不好买的。
avatar
g*e
3
不就是delete right most left child node or left most right child node么

【在 t*******3 的大作中提到】
: 给定了interface。
: public static boolean delete(Node root, int value){
: //fill your code here
: }
: class Node{
: Node left;
: Node right;
: int val;
: Node(int value){
: val=value;

avatar
c*z
4
grading是大工程,花费以万计算。Landscaping所作的grading,通常是指房前、墙角
的花圃的grading,对于改造整个房子的地势是杯水车薪。
avatar
t*3
5
算法很简单。 但是用java写起来很难。
你试着test一下。
用其它语言可能比较容易。

【在 g**e 的大作中提到】
: 不就是delete right most left child node or left most right child node么
avatar
t*3
6
这是看似容易, 但是实际实现起来不容易的。 尤其是没有parent这样的指针的情况下。
avatar
r*k
7
找到那个节点,然后一直跟最大孩子交换,到叶子后delete

【在 t*******3 的大作中提到】
: 给定了interface。
: public static boolean delete(Node root, int value){
: //fill your code here
: }
: class Node{
: Node left;
: Node right;
: int val;
: Node(int value){
: val=value;

avatar
p*p
8
public boolean delete(int val) {
if (_remove(val, root) != null) {
return true;
}
else {
return false;
}
}
private Node _remove(int val, Node t) {
if (t == null) {
return null;
}
else if (val < t.val) {
t.left = _remove(val, t.left);
}
else if (val > t.val) {
t.right = _remove(val, t.right);
}
else if (t.left != null && t.right != null){
//two children
t.val = _findMin(t.right).val;
t.right = _remove(t.val, t.right);
}
else {
//one child
Node old = t;
if (t.left != null) {
t = t.left;
}
else {
t = t.right;
}
old = null;
}
return t;
}
private Node _findMin(Node t) {
if (t.left == null) {
return t;
}
else {
return _findMin(t.left);
}
}
其实还是递归
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。