Redian新闻
>
你永远不能理解一只猫的思维 zz
avatar
你永远不能理解一只猫的思维 zz# pets - 心有所宠
a*o
1
从geeksforgeeks看得
Two elements of BST are swapped by mistake. You have to restore the tree
without changing its structure.
avatar
l*g
2
有些引用的文章要付费才能得到,有的被一本书的一章引用,而这本书要买才可以看到
内容,在这些情况下大家是怎么办的?
谢牛人指点
avatar
z*u
3
金缕梅爽肤水(玫瑰花瓣和芦荟保湿型),不知道哪里有卖的呢
avatar
v*n
5
in order travel so to build a sorted array and find the two elements first?
avatar
z*b
6
这点小钱还在乎什么啊

【在 l**********g 的大作中提到】
: 有些引用的文章要付费才能得到,有的被一本书的一章引用,而这本书要买才可以看到
: 内容,在这些情况下大家是怎么办的?
: 谢牛人指点

avatar
s*e
7
GNC,drugstore都有,店里网上都可
avatar
b*s
8
黑猫总是很可爱!!猫咪睡觉那张让人捏一把汗
avatar
v*d
9
有个想法:
按照inorder遍历这个bst,存到一个数组。在数组中找到这两个数(e.g.二分查找直到
发现局部最大和最小),然后swap它们在bst上的位置。
avatar
l*n
10
看看图书馆有没有
看看google book里的展示页是否正好有引用页
直接问chapter的作者要个reprint应该是可以的吧
最后,如果引用对你的文章有详细的介绍和推荐,花钱买也值得;但是如果只是
footnote,move on,多一个少一个没什么意义

【在 l**********g 的大作中提到】
: 有些引用的文章要付费才能得到,有的被一本书的一章引用,而这本书要买才可以看到
: 内容,在这些情况下大家是怎么办的?
: 谢牛人指点

avatar
y*n
11
最后一张最有意味

【在 b******s 的大作中提到】
: 黑猫总是很可爱!!猫咪睡觉那张让人捏一把汗
avatar
v*d
12
和你的方法重了,呵呵。

【在 v***n 的大作中提到】
: in order travel so to build a sorted array and find the two elements first?
avatar
r*l
13
找个在学校的人帮忙。文章学校应该都买了相应的数据库;书图书馆应该有,接到后复
印相应的页面。另外很多学校如果没有你要的数据库/书,可以通过校际互借,基本上
应该可以搞到所有东西。
avatar
z*e
14
很多很经典,赞~
avatar
a*y
15
inorder is not necessary, just use recursion to make sure min<=p->data < max
, update min and max depending on left or right, save the two nodes and swap
the data.
avatar
T*y
16
There's one more tip, besides getting the copies from university libraries.
You could email this person to ask for a copy. If you see that his response
is kind and quick, you can further ask for a reference letter from him as a
follow-up, and this kind of recommendation letter is better than the one
from a totally unrelated person.
Big Bless!

到内容,在这些情况下大家是怎么办的?

【在 l**********g 的大作中提到】
: 有些引用的文章要付费才能得到,有的被一本书的一章引用,而这本书要买才可以看到
: 内容,在这些情况下大家是怎么办的?
: 谢牛人指点

avatar
u*g
17
看得乐呵呵,lz转的好~
avatar
a*o
18
For example,
2
/ \
3 4
/
1
Actually, we need to swap 2 and 3. However, 2 is valid because initial min=
INT_min and max= INT_MAX. How to deal this case?

max
swap

【在 a*******y 的大作中提到】
: inorder is not necessary, just use recursion to make sure min<=p->data < max
: , update min and max depending on left or right, save the two nodes and swap
: the data.

avatar
a*n
19
3楼说得对
除非引用对你的文章有详细的介绍和推荐,
否则不需要他的原文
尤其是引用多的情况下
google或其他引用搜索结果页打印出来就行了
你想, 如果你有100个引用, 难道全打出来?
avatar
P*o
20
睡觉那两张太搞了
avatar
p*2
21

=
左树错误,右树正确,它自己一定是错误的。

【在 a****o 的大作中提到】
: For example,
: 2
: / \
: 3 4
: /
: 1
: Actually, we need to swap 2 and 3. However, 2 is valid because initial min=
: INT_min and max= INT_MAX. How to deal this case?
:
: max

avatar
l*g
22
多谢各位的热心回答
avatar
p*2
23

max
swap
我基本也是这个思路。

【在 a*******y 的大作中提到】
: inorder is not necessary, just use recursion to make sure min<=p->data < max
: , update min and max depending on left or right, save the two nodes and swap
: the data.

avatar
p*2
24
写了一下,不好写。
avatar
i*e
25
这题最坏情况要O(n)吧,必须检查每一个节点。
基本思路就是 inorder traversal 和保存前一个节点,但不用额外的空间。
TreeNode *first, *second, *prev;
void recoverHelper(TreeNode *p) {
if (!p) return;
recoverHelper(p->left);
if (prev && prev->val > p->val) {
if (!first)
first = prev;
second = p;
}
prev = p;
recoverHelper(p->right);
}
void recover(TreeNode *root) {
first = second = prev = NULL;
recoverHelper(root);
swap(first->val, second->val);
}
avatar
p*2
26

赞。确实是这个规律。

【在 i**********e 的大作中提到】
: 这题最坏情况要O(n)吧,必须检查每一个节点。
: 基本思路就是 inorder traversal 和保存前一个节点,但不用额外的空间。
: TreeNode *first, *second, *prev;
: void recoverHelper(TreeNode *p) {
: if (!p) return;
: recoverHelper(p->left);
: if (prev && prev->val > p->val) {
: if (!first)
: first = prev;
: second = p;

avatar
i*e
27
刚加了这道题 “Recover Binary Search Tree".
递归的解法可行吗?我感觉好像不太行得通。
avatar
p*2
28

你这个不就是递归吗?
我当时没想到用global variable, 搞了半天没搞对。用global variable 看起来就好
多了。

【在 i**********e 的大作中提到】
: 刚加了这道题 “Recover Binary Search Tree".
: 递归的解法可行吗?我感觉好像不太行得通。

avatar
p*2
29

你这个不就是递归吗?
我当时没想到用global variable, 搞了半天没搞对。用global variable 看起来就好
多了。

【在 i**********e 的大作中提到】
: 刚加了这道题 “Recover Binary Search Tree".
: 递归的解法可行吗?我感觉好像不太行得通。

avatar
i*e
30
我意思是你们之前讨论那个递归的思路 - 传 min,max 到下面。

【在 p*****2 的大作中提到】
:
: 你这个不就是递归吗?
: 我当时没想到用global variable, 搞了半天没搞对。用global variable 看起来就好
: 多了。

avatar
p*2
31

那个好像不行。我就按照那个思路没搞定。后来在那个思路上修修补补总是不通。我觉
得你的才是正确的思路。规律很清晰,很好理解。

【在 i**********e 的大作中提到】
: 我意思是你们之前讨论那个递归的思路 - 传 min,max 到下面。
avatar
N*n
32

如果只有两个的话应该好办。假设是升序,错位的两个数的特征是一个比
它身后的数大,另一个比它身前的书小。那么你就写一个的遍历程序找到
这两个节点然后交换一下就可以了。O(N)复杂度。

【在 a****o 的大作中提到】
: For example,
: 2
: / \
: 3 4
: /
: 1
: Actually, we need to swap 2 and 3. However, 2 is valid because initial min=
: INT_min and max= INT_MAX. How to deal this case?
:
: max

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。