Data Structure Review(1)

Triangle Array:
Assume location (i, j,k)

The first case 0<=i

One example of array is

0 1 2| 0 1 3| 0 1 4
0 2 3 0 2 4
1 2 3 0 3 4
1 2 4
1 3 4
2 3 4

The first element of a column is (0, 1, k)

We have to go through k choose 3 elements to reach the point (since the range is from 0 to k-1, after choose the three elements, the order is fixed)
After that is (0,j,k), we have to go through j chose element to reach that
At last (i,j,k) we have to go another i choose i element, So total cost for reaching that point is: k choose 3 + j choose 2 + i choose i


I do not think the triangle array has any advantage

评论

此博客中的热门博文

Embedded System interview Question

MicroKernel & Exokernel 操作系统未来可能的发展

中国城市房地产分析