AfanasevGad7

This is a task for our favourite professor
git clone git://git.stellar-nexus.ru/AfanasevGad7
Log | Files | Refs | README

tree.h (917B)


      1 #include "util.h"
      2 
      3 #define BLACK   0
      4 #define RED     1
      5 
      6 #define FCOLOR(n)       (((n)->val) & 1)
      7 #define COLOR(n)        ((n) && FCOLOR(n))
      8 #define SET_COLOR(n,c)  ((n)->val = (((n)->val) & ~1) | ((c) & 1))
      9 #define VALUE(n)        ((n)->val >> 1)
     10 #define SET_VALUE(n,v)  ((n)->val = ((v)<<1) | (((n)->val) & 1))
     11 
     12 struct Node {
     13 	int val;
     14 	struct Node *left, *right;
     15 };
     16 struct Fnode {
     17 	struct Fnode *left, *right;
     18 };
     19 
     20 static inline struct Node *init(int);
     21 struct Node *add(struct Node *, int);
     22 struct Node *parse_pre(struct Node *);
     23 struct Node *parse_post(struct Node *);
     24 struct Node *parse_inf(struct Node *);
     25 int get_height(struct Node *);
     26 struct Node *balance(struct Node *);
     27 struct Node *left_turn(struct Node *);
     28 struct Node *right_turn(struct Node *);
     29 struct Node *search(struct Node *, int);
     30 
     31 static inline struct Fnode *finit(void);
     32 struct Fnode *create(unsigned int);
     33 unsigned long int count(struct Fnode *);