[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
linked lists and trees
From: |
Jason Stover |
Subject: |
linked lists and trees |
Date: |
Wed, 24 Sep 2008 11:28:05 -0400 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
I have a question about implementing linked lists or trees. I'm not
sure which to use. Also, I don't know if I should write my own or if there
are any in the pspp source I can already use.
Here are the details:
I'm writing a one-pass function to compute the covariance matrix. It
needs to be able to handle categorical variables before the number of
categories is known, and that isn't known until after the data pass.
I have a solution to this problem. It involves using a "simple"
temporary data structure to keep the values for the covariance matrix
until the data pass is complete, then it will translate the values and
put them in the proper matrix data structure.
I'm not sure how to make this "simple" temporary data structure.
I started out making a linked list, then thought maybe I should use
a tree.
One node in the tree would look like this:
struct node
{
struct variable *v1;
struct variable *v2;
double covariance_element;
double center;
union value *val1;
union value *val2;
size_t count;
struct node *right;
struct node *left;
};
The reason I didn't want to use a tree is that I don't want to
recursively search it. It could be quite large, and I remember
overflowing the stack in the past by recursing many times (say, 5000)
in a Lisp program. But I'm not writing in Lisp. So: how much stack
space do I have to recurse?
And is there already an implementation of trees or linked lists in, say,
src/data?
-Jason
- linked lists and trees,
Jason Stover <=
- Re: linked lists and trees, Ben Pfaff, 2008/09/24
- Re: linked lists and trees, Jason Stover, 2008/09/24
- Re: linked lists and trees, Ben Pfaff, 2008/09/24
- Re: linked lists and trees, Jason Stover, 2008/09/26
- Re: linked lists and trees, Jason Stover, 2008/09/26
- Re: linked lists and trees, Jason Stover, 2008/09/26
- Re: linked lists and trees, Jason Stover, 2008/09/26
- Re: linked lists and trees, Ben Pfaff, 2008/09/26