由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
CS版 - any suggestions to my solutions
相关主题
PostDoc Position in UCIrvineWhy it is constant time for accessing array's element?
请问怎么计算两种clustering之间的差异求教一个算法题.
求教,急computerworld subscription error
请教怎样尽快看明白同事的程序?如何提高 writing能力
[转载] 请问一个有关选择数据结构的问题如何避免permutation中的重复计数
在线等答案,写信MacLeod’s hierarchy of corporate employees (转载)
[转载] CS interview questiondetails 2nd smallest element in an array
有人去印度参加 IJCAI-2007 吗?求教一个 Java 泛型的问题 !
相关话题的讨论汇总
话题: employee话题: array话题: supervisor话题: element话题: list
进入CS版参与讨论
1 (共1页)
x****3
发帖数: 5
1
Here is the question
Question1:
An array is being used to represent an organizational hierarchy. This is
done by using the array subscript to map to the employee-id and the value in
each element to represent the employee-id of the supervisor of the employee
.
For example the first element in the array maps to the supervisor of
employee-id 1, the second element maps to the supervisor of employee id 2.
The corresponding value for the top person in the organization is set to -1.

For example the f
x****3
发帖数: 5
2
Here is the solution I come out, any suggestions. Thanks a lot!
int[] employees= new Array[N]
int topid=0;
private List getListofEmployee(int level)
{
if(level==1)
{
List temp=new ArrayList();
for(int i=0; i {
if(employees[i]==-1)
topid=i+1;
}
for(int i=0; i {
if(employees[i]=topid)
temp.add(i);
}
return temp;
}else{
List temp=getListofEmployee(level-1);
List temp1=new ArrayList();
for(int i=0; i
1 (共1页)
进入CS版参与讨论
相关主题
求教一个 Java 泛型的问题 ![转载] 请问一个有关选择数据结构的问题
find Kth Largest Element 有没有更简化的解法在线等答案,写信
lintcode 上的 Count of Smaller Number before itself[转载] CS interview question
peak element II 怎么做有人去印度参加 IJCAI-2007 吗?
PostDoc Position in UCIrvineWhy it is constant time for accessing array's element?
请问怎么计算两种clustering之间的差异求教一个算法题.
求教,急computerworld subscription error
请教怎样尽快看明白同事的程序?如何提高 writing能力
相关话题的讨论汇总
话题: employee话题: array话题: supervisor话题: element话题: list