#include <iostream>
using namespace std;
enum Color {RED, BLACK};
struct Node {
int data;
bool color;
Node *left, *right, *parent;
Node(int data) {
this->data = data;
left = right = parent = nullptr;
this->color = RED;
}
};
class RedBlackTree {
private:
Node *root;
protected:
void rotateLeft(Node *&, Node *&);
void rotateRight(Node *&, Node *&);
void fixViolation(Node *&, Node *&);
public:
RedBlackTree() { root = nullptr; }
void deleteKey(int key);
void inorder();
void levelOrder();
};
void inorderHelper(Node *root) {
if (root == nullptr)
return;
inorderHelper(root->left);
cout << root->data << " ";
inorderHelper(root->right);
}
Node* BSTInsert(Node* root, Node *pt) {
if (root == nullptr)
return pt;
if (pt->data < root->data) {
root->left = BSTInsert(root->left, pt);
root->left->parent = root;
} else if (pt->data > root->data) {
root->right = BSTInsert(root->right, pt);
root->right->parent = root;
}
return root;
}
void levelOrderHelper(Node *root) {
if (root == nullptr)
return;
static int h = height(root);
for (int i = 1; i <= h; i++) {
printGivenLevel(root, i);
cout << endl;
}
}