In this case front vs. back makes no difference because append-in-place does not support boxed arrays. Otherwise I would agree with you: making the end of the array the top of the stack would be the way to go.
As for scaling up, a stack size of 120 should not matter. 2e5 iterations should scale up too, if 2e5 iterations taking 2e5 times as long as 1 iteration is considered to be scaling up well. ----- Original Message ----- From: John Randall <[EMAIL PROTECTED]> Date: Thursday, November 20, 2008 15:54 Subject: Re: [Jprogramming] Project Euler Problem 216 To: Programming forum <[email protected]> > Roger Hui wrote: > >> I agree with the general point. Project Euler has a number > of big > >> depth-first searches which I do not know how to program > >> efficiently in J. > > > > Is the following "efficient" according to your criteria? > > <dfs_queens deleted> > > This is efficient. I think the problems may come on > scaling up. The > example given requires about 200,000 iterations through the main > loop with > a maximum stack size of 120. In my experience these are > the main > parameters affecting things. Please note that my ignorance > is probably > the major factor in writing efficient programs. For > Project Euler #216 I > will shortly have a separate query about preventing integers > from being > promoted. > > I can write the stack-oriented program illustrated, but I find > some of it > surprising. I always make my stacks go the other way, with > pushes and > pops at the end of the array. My rationale is that push > then can be > implemented by append in place, and for pop there is no curtail > in place, > but if I do them at the beginning, the stack gets copied every > time. Is > this true? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
