struct node *bptrif(ptr==nullptr (struct node *malloc(sizeof(struct node))ptr -val dataptr -left_child nullptr -right_child nullptr -balance *ht_inc truereturn (ptr)if(data valptr -left_child insert(dataptr -left_childht_inc)if(*ht_inc==trueswitch(ptr -balancecase - /right heavy *ptr -balance *ht_inc falsebreakcase /balanced *ptr -balance breakcase /left heavy *aptr ptr -left_childif(aptr -balance = printf("left to left rotation\ ")ptr -left_childaptr -right_childaptr -right_child ptrptr -balance aptr -balance= ptr aptrelse printf("left to right rotation\ ")bptr aptr -right_childaptr -right_child bptr -left_childbptr -left_child aptrptr -left_child bptr -right_childbptr -right_child ptrif(bptr -balance = ptr -balance - else ptr -balance if(bptr -balance =- aptr -balance else aptr -balance bptr -balance= ptr bptr*ht_inc falseif(data ptr -val