<commit_before>#include <stdlib.h>
#define BLACK 0
#define RED 1
#define DOUBLE_BLACK 2

class RBTNode
{
	
	public:
	bool color;
	
	int data;
	
	RBTNode* parent;
	RBTNode* left;
	RBTNode* right;
	
	RBTNode(int data)
	{
		this->data = data;
		parent = left = right = NULL;
	}
	
};

class RBT
{

	RBTNode* root;
	
	RBT(int data)
	{
		root = NULL;
	}
	RBTNode* getMinValueNode(RBTNode *subRoot)
	{
		RBTNode *current = subRoot;
		while(current->left != NULL)
			current = current->left;
	
		return current;

	}

	RBTNode* getInorderSuccessor(RBTNode *node)
	{
		if(node->right != NULL)
			return getMinValueNode(node->right);
	
		RBTNode *parentNode = node->parent;
		while( parentNode!=NULL and node==parentNode->right)
		{
			node=parentNode;
			parentNode=parentNode->parent;
		}
		return parentNode;

	}


	RBTNode* getGrandParent(RBTNode *node)
	{
		if( (node != NULL) and (node->parent != NULL) )
			return node->parent->parent;
		return NULL;

	}

	RBTNode* getUncle(RBTNode *node)
	{
		RBTNode *grandParent = getGrandParent(node);
	
		if(grandParent == NULL)
			return NULL;
		if(node->parent == grandParent->left)
			return grandParent->right;
		if(node->parent == grandParent->right)
			return grandParent->left;

	}

	void rotateLeft(RBTNode *&root, RBTNode *&node)
	{
		RBTNode *rightNode = node->right;
		
		node->right = rightNode->left;
		
		if(node->right != NULL)
			node->right->parent = node;
		
		nodeRight->parent = node->parent;
		
		if(node->parent ==NULL)
			root = nodeRight;
		else if(node == node->parent->left)
			node->parent->left= nodeRight;
		else
			node->parent->right = nodeRight;
			
		nodeRight->left = node;
		node->parent = nodeRight;
	}
	
	void rotateRight(RBTNode *&root, RBTNode *&node)
	{
		RBTNode *nodeLeft = node->left;
		node->left = nodeLeft->right;
		
		if(node->left != NULL)
			node->left->parent = node;
			
		nodeLeft->parent = node->parent;
		
		if(node->parent == NULL)
			root = nodeLeft;
		else if(node == node->parent->left)
			node->parent->left = nodeLeft;
		else
			node->parent->right = nodeLeft;
			
		nodeLeft->right = node;
		node->parent = nodeLeft;
	}
	
	void fixInsertViolation(RBTNode *&root, RBTNode *&node)
	{
		RBTNode *paretnNode = node->parent;
		RBTNode *grandParentNode = getGrandParent(node);
		
		//Case 1 : If node is root
		if(parentNode==NULL)
		{
			root->color = BLACK;
		}
		else
		{
			//Case 2: Parent is black
			if(parentNode->color == RED)
			{
				return ; //Valid tree
			}
			//Case 3 : Parent is Red
			else
			{
			
			}
		
		}
		
	}
	
	void insertNode(RBTNode *root, int data)
	{
		RBTNode newNode = new RBTNode(data);
		
		this->root = BSTInsert(this->root,newNode);
		
		fixInsertViolation(this->root, newNode);
		

	}

};

RBTNode* BSTInsert(RBTNode *root, RBTNode *node)
	{
		if(root ==NULL)
			return node;
		if(root->data > node->data)
		{<commit_msg>Added blackheight and largest element<commit_after>#include <stdlib.h>
#include <algorithm>
#define BLACK 0
#define RED 1
#define DOUBLE_BLACK 2

class RBTNode
{
	
	public:
	int color;
	
	int data;
	
	RBTNode* parent;
	RBTNode* left;
	RBTNode* right;
	
	RBTNode(int data)
	{
		this->data = data;
		parent = left = right = NULL;
	}
	
};

class RBT
{

	RBTNode* root;
	
	RBT(int data)
	{
		root = NULL;
	}
	RBTNode* getMinValueNode(RBTNode *subRoot)
	{
		RBTNode *current = subRoot;
		while(current->left != NULL)
			current = current->left;
	
		return current;

	}

	RBTNode* getInorderSuccessor(RBTNode *node)
	{
		if(node->right != NULL)
			return getMinValueNode(node->right);
	
		RBTNode *parentNode = node->parent;
		while( parentNode!=NULL and node==parentNode->right)
		{
			node=parentNode;
			parentNode=parentNode->parent;
		}
		return parentNode;

	}


	RBTNode* getGrandParent(RBTNode *node)
	{
		if( (node != NULL) and (node->parent != NULL) )
			return node->parent->parent;
		return NULL;

	}

	RBTNode* getUncle(RBTNode *node)
	{
		RBTNode *grandParent = getGrandParent(node);
	
		if(grandParent == NULL)
			return NULL;
		if(node->parent == grandParent->left)
			return grandParent->right;
		if(node->parent == grandParent->right)
			return grandParent->left;

	}

	void rotateLeft(RBTNode *&root, RBTNode *&node)
	{
		RBTNode *rightNode = node->right;
		
		node->right = rightNode->left;
		
		if(node->right != NULL)
			node->right->parent = node;
		
		nodeRight->parent = node->parent;
		
		if(node->parent ==NULL)
			root = nodeRight;
		else if(node == node->parent->left)
			node->parent->left= nodeRight;
		else
			node->parent->right = nodeRight;
			
		nodeRight->left = node;
		node->parent = nodeRight;
	}
	
	void rotateRight(RBTNode *&root, RBTNode *&node)
	{
		RBTNode *nodeLeft = node->left;
		node->left = nodeLeft->right;
		
		if(node->left != NULL)
			node->left->parent = node;
			
		nodeLeft->parent = node->parent;
		
		if(node->parent == NULL)
			root = nodeLeft;
		else if(node == node->parent->left)
			node->parent->left = nodeLeft;
		else
			node->parent->right = nodeLeft;
			
		nodeLeft->right = node;
		node->parent = nodeLeft;
	}
	
	void fixInsertViolation(RBTNode *&root, RBTNode *&node)
	{
		RBTNode *paretnNode = node->parent;
		RBTNode *grandParentNode = getGrandParent(node);
		
		//Case 1 : If node is root
		if(parentNode==NULL)
		{
			root->color = BLACK;
		}
		else
		{
			//Case 2: Parent is black
			if(parentNode->color == RED)
			{
				return ; //Valid tree
			}
			//Case 3 : Parent is Red
			else
			{
			
			}
		
		}
		
	}
	
	void insertNode(RBTNode *root, int data)
	{
		RBTNode newNode = new RBTNode(data);
		
		this->root = BSTInsert(this->root,newNode);
		
		fixInsertViolation(this->root, newNode);
		

	}

	int blackheight(RBTNode *root)
	{
		if(root==NULL)
			return 0;
		if(root->color== BLACK)
		{
			return 1+max(blackheight(root->left),blackheight(root->right));
		}
		else
			return max(blackheight(root->left),blackheight(root->right));
	}

	int greatestElememt(RBTNode *root)
	{
		if(root==NULL)
			return NULL;
		else if (root->right==NULL)
			return root;
		else
			return greatestElememt(root->right);
	}

};

RBTNode* BSTInsert(RBTNode *root, RBTNode *node)
	{
		if(root ==NULL)
			return node;
		if(root->data > node->data)
		{
{'fraction_non_alphanumeric': 0.1449699333658378, 'fraction_numerical': 0.0022753128555176336, 'mean_word_length': 3.1835486063902105, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2079026', 'n_tokens_mistral': 2677, 'n_tokens_neox': 2278, 'n_words': 485}