Redian新闻
>
不用处方就能买contact网站
avatar
不用处方就能买contact网站# Fashion - 美丽时尚
b*d
1
有几个题,觉得有点意思。
1. 证明任意一个7个node的无向graph,至少两个node拥有同样的degree。每个node不
能有指向自己的edge。
2. 一个array,size n,里面的数都属于range[0, n-1],有unknown的duplicates,找
到至少一个duplicate,constant space,linear time。
3. 设计一个persistence系统对外提供get(key), put(key,value)的功能,要求
每条数据3个replica,无single point of failure,能自动修复replica上的failure
。基本是distributed system的课堂讨论题。可以是p2p结构,也可以是server-worker
结构,但我给的是p2p。
avatar
y*o
2
以前有MM贴过一个不用处方就能买contact网站,忘记了,有哪个MM能一下吗?
谢谢
avatar
l*a
3

不会图
array[array[i]] ...
什么叫single point of failure?

【在 b*******d 的大作中提到】
: 有几个题,觉得有点意思。
: 1. 证明任意一个7个node的无向graph,至少两个node拥有同样的degree。每个node不
: 能有指向自己的edge。
: 2. 一个array,size n,里面的数都属于range[0, n-1],有unknown的duplicates,找
: 到至少一个duplicate,constant space,linear time。
: 3. 设计一个persistence系统对外提供get(key), put(key,value)的功能,要求
: 每条数据3个replica,无single point of failure,能自动修复replica上的failure
: 。基本是distributed system的课堂讨论题。可以是p2p结构,也可以是server-worker
: 结构,但我给的是p2p。

avatar
m*z
4
帮顶帮顶,我也想知道
avatar
N*N
5
1 贴个别人的答案:
任何node的degree<=7
所以假设degree两两不同,那么 sum(Degree)=0+1+2..+6=35
但是这个和应该是edge数目的2倍,所以不应该是奇数

【在 b*******d 的大作中提到】
: 有几个题,觉得有点意思。
: 1. 证明任意一个7个node的无向graph,至少两个node拥有同样的degree。每个node不
: 能有指向自己的edge。
: 2. 一个array,size n,里面的数都属于range[0, n-1],有unknown的duplicates,找
: 到至少一个duplicate,constant space,linear time。
: 3. 设计一个persistence系统对外提供get(key), put(key,value)的功能,要求
: 每条数据3个replica,无single point of failure,能自动修复replica上的failure
: 。基本是distributed system的课堂讨论题。可以是p2p结构,也可以是server-worker
: 结构,但我给的是p2p。

avatar
x*o
6
aalens.com
softlenseeye.com
avatar
l*c
7
1. 要是没有两个有同样的degree,那么每个node至少要有1个degree,那么7个node,
最大的degree的那个node至少degree=7. 可是一个图里面每个node最多degree是6.
是这样的吗?
avatar
y*o
8
谢谢!
avatar
N*N
9
degree可以是0,不一定是connected graph

【在 l****c 的大作中提到】
: 1. 要是没有两个有同样的degree,那么每个node至少要有1个degree,那么7个node,
: 最大的degree的那个node至少degree=7. 可是一个图里面每个node最多degree是6.
: 是这样的吗?

avatar
U*m
10
多谢,老早就想要买了!!
avatar
l*c
11
啊?我对图不了解。如果0也可以的话,
0+1+...+6 = odd
1+2+...+7 = odd, odd不可能,
这样理解应该可以了。

【在 N**N 的大作中提到】
: degree可以是0,不一定是connected graph
avatar
p*y
12
请问这两个网站可靠不?
avatar
g*y
13
第二题,只能想到linear的算法。
def find_duplicates(array):
assert array

for i in range(len(array)):
assert 0 <= array[i] < len(array)
while i != array[i]:
if array[array[i]] == array[i]:
return array[i]
else:
array[array[i]], array[i] = array[i], array[array[i]]

return None
avatar
o*o
14
同问:)谢谢
avatar
N*N
15
是不是不允许self loop?
如果不允许,那么degree最高是6
如果允许的话,这样的edge让degree+2
http://en.wikipedia.org/wiki/Loop_(graph_theory)
最高degree是8,就可以有反例了。。
比如:
a b c d e f g
a
b 1
c 1 1
d 1 1 1
e 1 1 1 1
f 1 1 2 1
g 1 1 1 1 1 2
这样a到g的degree分别是 0 1 2 3 4 5 7 。。。。。

【在 l****c 的大作中提到】
: 啊?我对图不了解。如果0也可以的话,
: 0+1+...+6 = odd
: 1+2+...+7 = odd, odd不可能,
: 这样理解应该可以了。

avatar
b*i
16
mark
avatar
b*d
17

~~~
忘了说,是的,不能指向self。

【在 N**N 的大作中提到】
: 是不是不允许self loop?
: 如果不允许,那么degree最高是6
: 如果允许的话,这样的edge让degree+2
: http://en.wikipedia.org/wiki/Loop_(graph_theory)
: 最高degree是8,就可以有反例了。。
: 比如:
: a b c d e f g
: a
: b 1
: c 1 1

avatar
y*o
18
我已经在softlenseeye.com上下订了,等货到了我来更新!
avatar
g*m
19
1应该对任何图都成立吧,不局限于7 nodes
N nodes,所有点的degree要么0...N-2,要么1...N-1,只有N-1种可能,所以至少有两
个点度数相同。
avatar
d*t
20
眼睛有散光,能用contact吗?
avatar
N*N
21
对,只要是simple grapha
http://www.student.math.uwaterloo.ca/~math239/winter2008/t7sol.

【在 g***m 的大作中提到】
: 1应该对任何图都成立吧,不局限于7 nodes
: N nodes,所有点的degree要么0...N-2,要么1...N-1,只有N-1种可能,所以至少有两
: 个点度数相同。

avatar
h*y
22
同问
avatar
g*y
23
第二题,只能想到linear的算法。
def find_duplicates(array):
assert array

for i in range(len(array)):
assert 0 <= array[i] < len(array)
while i != array[i]:
if array[array[i]] == array[i]:
return array[i]
else:
array[array[i]], array[i] = array[i], array[array[i]]

return None
avatar
s*d
24

有散光的,但不一定能fit你,一定要去验光试。

【在 d**t 的大作中提到】
: 眼睛有散光,能用contact吗?
avatar
a*x
25
第二题:
sum = SUM(array a)
rangeSum = sum from 0 to (n - 2)
sum - rangeSum = what we need
example: given [0, 3, 3, 2, 1]
we have sum = 9
rangeSum = (0 + 3) * 4 / 2 = 6
sum - rangeSum = 3
done

failure
worker

【在 b*******d 的大作中提到】
: 有几个题,觉得有点意思。
: 1. 证明任意一个7个node的无向graph,至少两个node拥有同样的degree。每个node不
: 能有指向自己的edge。
: 2. 一个array,size n,里面的数都属于range[0, n-1],有unknown的duplicates,找
: 到至少一个duplicate,constant space,linear time。
: 3. 设计一个persistence系统对外提供get(key), put(key,value)的功能,要求
: 每条数据3个replica,无single point of failure,能自动修复replica上的failure
: 。基本是distributed system的课堂讨论题。可以是p2p结构,也可以是server-worker
: 结构,但我给的是p2p。

avatar
S*y
26
奇怪,这个网站我这里显示不存在。
期待mm的更新噢。

【在 y*****o 的大作中提到】
: 我已经在softlenseeye.com上下订了,等货到了我来更新!
avatar
l*a
27
RE

【在 g***m 的大作中提到】
: 1应该对任何图都成立吧,不局限于7 nodes
: N nodes,所有点的degree要么0...N-2,要么1...N-1,只有N-1种可能,所以至少有两
: 个点度数相同。

avatar
y*o
28
看一下日期,发帖那天3/4下的单,今天3/25收到货,三个星期这样,虽然慢点,不过
东西收到了,东西也完好。明天开始用,再上来汇报。
avatar
l*a
29
It does not work on [1, 3, 3, 2, 2]
sum = 11
rangeSum = 6
sum - rangeSum = 5

【在 a********x 的大作中提到】
: 第二题:
: sum = SUM(array a)
: rangeSum = sum from 0 to (n - 2)
: sum - rangeSum = what we need
: example: given [0, 3, 3, 2, 1]
: we have sum = 9
: rangeSum = (0 + 3) * 4 / 2 = 6
: sum - rangeSum = 3
: done
:

avatar
a*x
30
好吧,我錯了

【在 l*****a 的大作中提到】
: It does not work on [1, 3, 3, 2, 2]
: sum = 11
: rangeSum = 6
: sum - rangeSum = 5

avatar
h*9
31

Yes, because degree 0 and degree 6 can not coexist in a graph with 7 nodes
without loops.

【在 l****c 的大作中提到】
: 1. 要是没有两个有同样的degree,那么每个node至少要有1个degree,那么7个node,
: 最大的degree的那个node至少degree=7. 可是一个图里面每个node最多degree是6.
: 是这样的吗?

avatar
n*s
32

failure
worker
第2个题目应该是在原数组上操作,只要一个额外的空间用来交换
一开始的时候有一个指针指向第1个元素,这个元素是几就把他跟几号位上数的互换
任何元素只可能跟他后面的互换,要是跟他前面的互换就说明有重复了

【在 b*******d 的大作中提到】
: 有几个题,觉得有点意思。
: 1. 证明任意一个7个node的无向graph,至少两个node拥有同样的degree。每个node不
: 能有指向自己的edge。
: 2. 一个array,size n,里面的数都属于range[0, n-1],有unknown的duplicates,找
: 到至少一个duplicate,constant space,linear time。
: 3. 设计一个persistence系统对外提供get(key), put(key,value)的功能,要求
: 每条数据3个replica,无single point of failure,能自动修复replica上的failure
: 。基本是distributed system的课堂讨论题。可以是p2p结构,也可以是server-worker
: 结构,但我给的是p2p。

avatar
p*e
33
Node的degree只能是0到6, 如果没有0, 那么7个node的degrees必定有两个相同的。
如果有一个是0, 剩下的6个node中如果有0 degree, 那么相同degree的node找到, 0
degree, 如果没有0 degree, 6个degree分到1-5中,必定有两个相同
avatar
e*e
34

public int findDuplicate(int[] a) {
if ( a == null || a.length < 2 )
return -1;

for ( int i = 0; i < a.length; i++ ) {
if ( a[i] == i )
continue;
else if ( a[a[i]] == a[i] || a[i] < i )
return a[i];
else {
int tmp = a[i];
a[i] = a[a[i]];
a[tmp] = tmp;
i--;
}
}

return -1;
}

【在 n*****s 的大作中提到】
:
: failure
: worker
: 第2个题目应该是在原数组上操作,只要一个额外的空间用来交换
: 一开始的时候有一个指针指向第1个元素,这个元素是几就把他跟几号位上数的互换
: 任何元素只可能跟他后面的互换,要是跟他前面的互换就说明有重复了

avatar
w*o
35
因为有i--,不能保证在循环a.length次之前结束,试试{4,0,1,2,3},要loop9次。

【在 e****e 的大作中提到】
:
: public int findDuplicate(int[] a) {
: if ( a == null || a.length < 2 )
: return -1;
:
: for ( int i = 0; i < a.length; i++ ) {
: if ( a[i] == i )
: continue;
: else if ( a[a[i]] == a[i] || a[i] < i )
: return a[i];

avatar
w*o
36
可以借用Counting Sort的思想,但是标准的Counting Sort要用O(n)的空间。稍改一
下,可以借用已有的Array的空间。也就是a[i] = x * n + y; x 是i在Array里出现的
次数,而y是原来的a[i]的值。
假设没有overflow:
public int findDuplicate(int[] a) {
if ( a == null || a.length < 2 )
return -1;

int n = a.length;
for(int i = 0; i < n; i++) {
int x = a[i] % n;
int y = a[x] / n;
if (y > 0)
return x;
else
a[x] += n;
}
return -1;
}
保证在n次loop内结束。而且可以很容易恢复到原数组。

【在 b*******d 的大作中提到】
: 有几个题,觉得有点意思。
: 1. 证明任意一个7个node的无向graph,至少两个node拥有同样的degree。每个node不
: 能有指向自己的edge。
: 2. 一个array,size n,里面的数都属于range[0, n-1],有unknown的duplicates,找
: 到至少一个duplicate,constant space,linear time。
: 3. 设计一个persistence系统对外提供get(key), put(key,value)的功能,要求
: 每条数据3个replica,无single point of failure,能自动修复replica上的failure
: 。基本是distributed system的课堂讨论题。可以是p2p结构,也可以是server-worker
: 结构,但我给的是p2p。

avatar
e*e
37
That's quite a piece of work. Good job.

【在 w***o 的大作中提到】
: 可以借用Counting Sort的思想,但是标准的Counting Sort要用O(n)的空间。稍改一
: 下,可以借用已有的Array的空间。也就是a[i] = x * n + y; x 是i在Array里出现的
: 次数,而y是原来的a[i]的值。
: 假设没有overflow:
: public int findDuplicate(int[] a) {
: if ( a == null || a.length < 2 )
: return -1;
:
: int n = a.length;
: for(int i = 0; i < n; i++) {

avatar
w*o
38
谢谢。
其实还可以再好一点。用+n有overflow的危险如果n很大的话。
可以用negative来表示该数已出现过。不过要考虑0的情况,因为 0 = -0。

【在 e****e 的大作中提到】
: That's quite a piece of work. Good job.
avatar
f*4
39
题3的failure-fix 是接口get/put的切换么, 还是生成一份新的冗余呢?

failure
worker

【在 b*******d 的大作中提到】
: 有几个题,觉得有点意思。
: 1. 证明任意一个7个node的无向graph,至少两个node拥有同样的degree。每个node不
: 能有指向自己的edge。
: 2. 一个array,size n,里面的数都属于range[0, n-1],有unknown的duplicates,找
: 到至少一个duplicate,constant space,linear time。
: 3. 设计一个persistence系统对外提供get(key), put(key,value)的功能,要求
: 每条数据3个replica,无single point of failure,能自动修复replica上的failure
: 。基本是distributed system的课堂讨论题。可以是p2p结构,也可以是server-worker
: 结构,但我给的是p2p。

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