implementation of zig zag

I am trying to implement the zig zag movement which and splay tree has.
i am kinda having a hard time doing so, all my solutions seems a bit hardcoded, and kinda looking for a universal solution.


Each node is defined by a struct which contains these informations
struct splay_node{
int value;
splay_node* left;
splay_node* right;
splay_node* parent;
};

And the tree itself is a class which is defined as

lass splay_tree{
public:
splay_tree(int);
splay_node *a;
splay_node *root;
void insert(int);
void display(splay_node*);
private:
void insertp(splay_node*, int);
void splayingp(splay_node*);
string path;
};


The zig and zag has to called with an parameter which is the pointer to node which has to be splayed.
Topic archived. No new replies allowed.