美国软件公司技术面试题及答案高级算法类.docx 立即下载
2024-11-05
约4.9千字
约4页
0
21KB
举报 版权申诉
预览加载中,请您耐心等待几秒...

美国软件公司技术面试题及答案高级算法类.docx

美国软件公司技术面试题及答案高级算法类.docx

预览

在线预览结束,喜欢就下载吧,查找使用更方便

20 金币

下载文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

(15Points)Drawasimple,connected,undirected,weightedgraphwith8verticesand16edges,eachwithuniqueedgeweights.IllustratetheexecutionofPrim-Jarnikalgorithmonthisgraph.(Notethatsincethegraphisconnectedwithdistinctweights,thereisonlyoneminimumspanningtreeforthisgraph.)
1
2
3
4
5
6
7
8
1
2
3
4
5
7
6
8
9
10
11
12
13
14
15
16
Answer:
1
2
3
4
5
6
7
8
1
2
3
4
5
7
6
8
9
10
11
12
13
14
15
16
	












1
2
3
4
5
6
7
8
1
2
3
4
5
7
6
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
1
2
3
4
5
7
6
8
9
10
11
12
13
14
15
16













1
2
3
4
5
6
7
8
1
2
3
4
5
7
6
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
1
2
3
4
5
7
6
8
9
10
11
12
13
14
15
16
















1
2
3
4
5
6
7
8
1
2
3
4
5
7
6
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
1
2
3
4
5
7
6
8
9
10
11
12
13
14
15
16













1
2
3
4
5
6
7
8
1
2
3
4
5
7
6
8
9
10
11
12
13
14
15
16
















(15Points)Whatistheworst-caserunningtimeoftheFord-Fulkersonifalledgecapacitiesareboundedbyaconstant?Justifyyouranswer.
Answer:
	Lettheconstantbek;sbethesource;tbethesink;theworst-caserunningtimeoftheFord-FulkersonisO(m*min{deg(s),deg(t)}).
	Proof:
	Sinceeveryedgecapacityisk,
	soifthereisanaugmentingpath,theΔmustbek;
		soaflowofkunitswillbepushedalongoneoftheoutgoingedgeofs,
		andthisflowwillbefilloneoftheingoingedgeoft.
	Sincethetotalunitsgoingoutofsareequaltothetotalunitscomingintot,
	sothemaximumflow|f*|isk*min{deg(s),deg(t)}.
	Thus,O(m*|f*|)
		=O(m*k*min{deg(s),deg(t)})
		=O(m*min{deg(s),deg(t)})(kisaconstant).
	

(15Points)Considertheproblemofelectingaleaderprocessorinaringofprocessors,eachofwhichhasauniqueid.DesignasynchronousalgorithmwhoserunningtimeandmessagecomplexityisO(nlogn).

Hint:Consideranalgorithmwithlognphases,whereyouhaveeachprocessorwho,inphasei,thinksitmightbealeader,sendouta“probe”messageineachdirectionthatgoes2ihopsandcomesbackifitfindsnoprocessorwithloweridvalue.
Answer:
AlgorithmRingLeader(id):
phase<-0
done<-false
happy<-true
repeat
	ifhappythen
		phase<-phase+1
		M<-[Candidateisid.2^phase]
		sendMtopreviousprocessorandn
查看更多
单篇购买
VIP会员(1亿+VIP文档免费下)

扫码即表示接受《下载须知》

美国软件公司技术面试题及答案高级算法类

文档大小:21KB

限时特价:扫码查看

• 请登录后再进行扫码购买
• 使用微信/支付宝扫码注册及付费下载,详阅 用户协议 隐私政策
• 如已在其他页面进行付款,请刷新当前页面重试
• 付费购买成功后,此文档可永久免费下载
全场最划算
12个月
199.0
¥360.0
限时特惠
3个月
69.9
¥90.0
新人专享
1个月
19.9
¥30.0
24个月
398.0
¥720.0
6个月会员
139.9
¥180.0

6亿VIP文档任选,共次下载特权。

已优惠

微信/支付宝扫码完成支付,可开具发票

VIP尽享专属权益

VIP文档免费下载

赠送VIP文档免费下载次数

阅读免打扰

去除文档详情页间广告

专属身份标识

尊贵的VIP专属身份标识

高级客服

一对一高级客服服务

多端互通

电脑端/手机端权益通用