On Sun, Feb 27, 2011 at 11:25 AM, Justin Paston-Cooper
<[email protected]> wrote:
> A lot of what I've tried to use J for has involved trees, like trying to 
> generate
> game trees for card games, or to generate all elements of a mathematical
> group. I was doing these things with stacks and boxed elements and this
> turned out to be rather slow.

These might help:

http://www.jsoftware.com/jwiki/Essays/Tree%20Sum
http://www.jsoftware.com/jwiki/Essays/Minimal%20Spanning%20Tree

Note that natural representations of a tree structure in J can either
be a list of indices (each node has the index of its parent) or a
binary matrix (which can also represent a cyclic or acyclic directed
graph -- 1 shows a connection, 0 shows its absence).  You can use a
sparse matrix, if size is an issue and connectivity is low.

Note also that J tends to favor "whole tree at a time" operations over
"one node at a time" operations.

Note also that it's fairly natural, in J, to have a "tree structure"
split out over several variables (one might represent the tree
structure, another might represent the data at each node, and so on).

In other languages, people have gotten into the habit of doing things
differently, and even enshrine that as "best practice" but I think
computer architecture favors homogeneous data over heterogeneous data.
 For example: 
http://software.intel.com/en-us/articles/how-to-manipulate-data-structure-to-optimize-memory-use-on-32-bit-intel-architecture/

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to