void Insert(TreeNode* root, string insertString) { TreeNode* walk; walk = root; if (insertString <= walk->Value) { walk->AVL--; if (!walk->Left)//base case { TreeNode* newLeaf = new TreeNode(insertString); walk->Left = newLeaf; } else { Insert(walk->Left, insertString); } } else { walk->AVL++; if (!walk->Right)//base case { TreeNode* newLeaf = new TreeNode(insertString); walk->Right = newLeaf; } else { Insert(walk->Right, insertString); } } if (root->AVL == -2 && root->Left && root->Left->AVL == -1)//left-left { //rotate right around parent TreeNode* temp; temp = root; root = root->Left; root->Right = temp; temp->Left = NULL; } else if (walk->AVL == -2 && walk->Left && walk->Left->AVL == 1)//left-right { //rotate left around child then rotate right around parent } else if (walk->AVL == 2 && walk->Right && walk->Right->AVL == 1)//right-right { //rotate left around parent } else if (walk->AVL == 2 && walk->Right && walk->Right->AVL == -1)//right-left { //rotate right around child, then left around parent } }