Saturday, September 7, 2013

3.1 --- Describe how you could use a single array to implement three stacks.

Q: Describe how you could use a single array to implement three stacks. A: 1) for three stacks, top1, top2,top3, where top1= 3*i top2= 3*i+1 top3= 3*i+2 2) devide array into 3 parts, part 1: 0- array.length()/3; part 2: array.length()/3+1 - 2* array.length()/3; part 3: 2* array.length()/3+1 - array.length() 这个,要好好看看书上的, clean, maintainable 的例子。

No comments:

Post a Comment