#include <iostream>
using namespace std;
template <typename T> class RedBlackNode{
protected:
union RedBlackPointer{
RedBlackPointer() : node(0) { } // <==== default constructor
RedBlackNode *node;
struct{
unsigned value:1; // for color / other info
}flag;
}left, right, parent;
T key;
public:
void initialize(T key, RedBlackPointer left = RedBlackPointer(), //refer to default ctor
RedBlackPointer right = RedBlackPointer(),
RedBlackPointer parent = RedBlackPointer()){
this->key = key;
this->left = left; this->right = right;
this->parent = parent;
}
void show() {
cout<<left.node<<","<<right.node<<","<<parent.node<<","<<key<<endl;
}
};
int main() {
RedBlackNode<int> N;
N.initialize(5);
N.show();
// your code goes here
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+IGNsYXNzIFJlZEJsYWNrTm9kZXsKcHJvdGVjdGVkOgogICAgdW5pb24gUmVkQmxhY2tQb2ludGVyewogICAgICAgIFJlZEJsYWNrUG9pbnRlcigpIDogbm9kZSgwKSB7IH0gIC8vIDw9PT09IGRlZmF1bHQgY29uc3RydWN0b3IKICAgICAgICBSZWRCbGFja05vZGUgKm5vZGU7CiAgICAgICAgc3RydWN0ewogICAgICAgICAgICB1bnNpZ25lZCB2YWx1ZToxOyAgIC8vIGZvciBjb2xvciAvIG90aGVyIGluZm8KICAgICAgICB9ZmxhZzsKICAgIH1sZWZ0LCByaWdodCwgcGFyZW50OwogICAgVCBrZXk7CnB1YmxpYzoKICAgIHZvaWQgaW5pdGlhbGl6ZShUIGtleSwgUmVkQmxhY2tQb2ludGVyIGxlZnQgPSBSZWRCbGFja1BvaW50ZXIoKSwgLy9yZWZlciB0byBkZWZhdWx0IGN0b3IKICAgICAgICAgICAgUmVkQmxhY2tQb2ludGVyIHJpZ2h0ID0gUmVkQmxhY2tQb2ludGVyKCksCiAgICAgICAgICAgIFJlZEJsYWNrUG9pbnRlciBwYXJlbnQgPSBSZWRCbGFja1BvaW50ZXIoKSl7CiAgICAgICA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