会 计 法 律 建 筑 医 学 自 考 成 考 考 研 外 语 帮 助
 


 
标题: 英国IT业找工作面试题

Rank: 10Rank: 10Rank: 10Rank: 10 白金会员
网站:法律教育网


UID 904
精华 1
积分 6283
帖子 2099
经验 3134
金钱 2118
鲜花 3
阅读权限 80
注册 2006-5-29
状态 离线
 
发表于 2007-1-8 09:32  资料  主页 短消息  加为好友 
英国IT业找工作面试题

  友情提示 递归算法简单但速度慢

  请在两天内作答。

  Elixent’s Placement Problem

  Write a program (in C or C++) that places an arbitrary netlist represented as a directed graph G = (V, E) with vertices V and edges E over a 1D array of N processors:

  p_1 p_2 p_3 ... p_N

  Each vertex should be placed on a single processor and no processor can hold more than one vertex (you can assume there are as many processors as you need). For example vertex v_1 might be placed on processor p_1 and v_2 on p_4:

  -----------

  v_1 v_2

  p_1 p_2 p_3 p_4 ... p_N

  If there were an edge between v_1 and v_2, then it would automatically be routed along the 'shortest' path between the respective processors (as shown). The distance of this edge is 4-1 = 3. The cost of an overall placement is simply the sum of all edge distances. Placements with lower cost as these are 'better', but the computational complexity of your placement algorithm also matters (you might need to place very large netlists).

  The graph should be read in from standard input in the form

  10

  1,3 2,4 4,5 ...

  In the first line '10' gives the number of vertices, the second line defines which pairs of vertices are connected by edges (the first vertex is numbered 1).

  The program should output the placement cost and results on standard output, giving the vertex allocated to each processor in turn, or - if a processor is empty. For example:

  21

  2 4 - 3 1 ...

  would mean the placement cost was 21 and vertex 2 was allocated to p_1, 4 to p_2, p_3 was empty, 3 to p_4 etc.

  You might optionally want to consider a more complex problem with a non-linear notion of cost that accounts for congestion in the case when there are multiple overlapping edges. For example, the cost function could be redefined as the sum of the squares of the number of edges spanning each pair of neighbouring processors. In this case the following configuration of edges:

  --- ---

  p_1 p_2 p_3 p_4 p_5 .... p_N

  would have cost:

  1 edge spanning p_1 to p_2

  2^2 edges spanning p_2 to p_3

  1 edge spanning p_3 to p_4

  1 edge spanning P_4 to p_5

  ---

  7

  Again, lower cost is better, but computational complexity also matters.

顶部

Rank: 20Rank: 20 站点管理员
网站:法律教育网


UID 1803
精华 10
积分 33294
帖子 8717
经验 16607
金钱 4890
鲜花 16
阅读权限 100
注册 2004-5-9
来自 北京
状态 离线
 
发表于 2007-3-21 13:04  资料  主页 短消息  加为好友 
???




顶部
 


当前时区 GMT+8, 现在时间是 2008-12-5 12:08

 Powered by Discuz!
清除 Cookies - 联系我们 - 正保教育论坛 - Archiver