simplify # trees: Catalan trees -> Wedderburn–Etherington trees
This commit is contained in:
37
lceb.h
37
lceb.h
@@ -1,8 +1,11 @@
|
||||
#include <time.h>
|
||||
|
||||
#define MAXINPUT 6 /* max numbers as input */
|
||||
#define ALLOCSIZE 1024 /* # of elements to alloc when needed */
|
||||
#define EMPTY -1
|
||||
#define MAXINPUT (6) /* max numbers as input */
|
||||
#define ALLOCSIZE (1024) /* # of elements to alloc */
|
||||
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#define ABS(a) (((a)<0)?-(a):(a))
|
||||
|
||||
typedef enum {
|
||||
Nop='N',
|
||||
@@ -21,7 +24,7 @@ typedef struct stack {
|
||||
int stack[MAXINPUT+1];
|
||||
} STACK;
|
||||
|
||||
#define TREE_UNDEF (-1) /* should not happen */
|
||||
#define TREE_UNDEF (-1) /* should not happen */
|
||||
#define TREE_LEAF 0
|
||||
#define TREE_NODE 1
|
||||
#define TREE_LEFT 'L'
|
||||
@@ -31,22 +34,25 @@ typedef struct stack {
|
||||
#define EMPTY -1
|
||||
|
||||
typedef struct node {
|
||||
int type; /* TREE_LEAF or TREE_NODE */
|
||||
int op;
|
||||
int val;
|
||||
int eval;
|
||||
int type; /* TREE_LEAF or TREE_NODE */
|
||||
int op; /* operator (nodes only) */
|
||||
int val; /* value (leafs only) */
|
||||
int eval; /* eval (unused) */
|
||||
int prof; /* max left/right profs */
|
||||
int left_prof;
|
||||
struct node *left;
|
||||
int right_prof;
|
||||
struct node *right;
|
||||
struct node *next; /* for transversal walk and free nodes */
|
||||
struct node *next; /* for transv walk and free nodes */
|
||||
} NODE;
|
||||
|
||||
typedef struct tree {
|
||||
char name[80];
|
||||
NODE *head;
|
||||
struct tree *next;
|
||||
int nodes; /* number of nodes */
|
||||
int leaves; /* number of leaves */
|
||||
int depth; /* max depth */
|
||||
int nodes; /* number of nodes */
|
||||
int leaves; /* number of leaves */
|
||||
int depth; /* max depth */
|
||||
} TREE;
|
||||
|
||||
typedef struct best {
|
||||
@@ -67,8 +73,11 @@ extern void print_tree(TREE *tree, int details);
|
||||
extern void print_trees(int details);
|
||||
extern TREE *new_tree(char *name);
|
||||
extern NODE *dup_node(NODE *src);
|
||||
extern NODE *build_tree(int *desc, int size);
|
||||
extern void gen_tree(int *seq, int n, int nb1, int nb0);
|
||||
//extern NODE *build_tree(int *desc, int size);
|
||||
extern NODE *build_tree(char *desc, int size);
|
||||
//extern void gen_tree(int *seq, int n, int nb1, int nb0);
|
||||
extern void gen_reduced_trees(int n);
|
||||
extern void gen_tree(char *seq, int n, int nb1, int nb0);
|
||||
extern TREE *nth_tree(int n);
|
||||
extern int n_trees();
|
||||
|
||||
|
Reference in New Issue
Block a user