AVL Tree Deletion | (Theory + Dry Run + Code Implementation)

  Рет қаралды 11,611

Coder Army

Coder Army

Күн бұрын

Пікірлер: 110
@CoderArmy9
@CoderArmy9 9 ай бұрын
AVL Tree ko ratna nahi hai, Logic samj jaao achee se, baaki Khud implement kar loge....
@zafrul_islam
@zafrul_islam 9 ай бұрын
Yes, I want to learn about segment trees, Fenwick trees, and tries.
@ayushmaanyadav722
@ayushmaanyadav722 9 ай бұрын
Bhaiya c language ke baad c++ chalu karu ke sidhe 180 days hard me ghus jau .please reply
@GopalMaheshwari-ApkaDost
@GopalMaheshwari-ApkaDost 9 ай бұрын
sir ye koi puchne vali bat thodina hai sab pahaiyeiye😅
@Sanataniblood-mb5pu
@Sanataniblood-mb5pu 6 ай бұрын
Awesome bhaiya ❤
@RishabhChatterjee-fg2gz
@RishabhChatterjee-fg2gz 5 ай бұрын
Bhaiya Trie, Segment trees bhi parna hai aap se AVL tree ko jab college mein para tha tab implementation nehi kar paunga esa felling hota tha, par ye to bahut easy hai
@mohit6215
@mohit6215 9 ай бұрын
Bhaiya this is the G.O.A.T of all DSA trees ,please pickup fenwick trees and tries because google asks many QUESTIONS in the interview
@Sanataniblood-mb5pu
@Sanataniblood-mb5pu 6 ай бұрын
Etana koi nhi samajhta bhaiya your efforts are incredible 🙏🏻
@gurtegsinghsohi411
@gurtegsinghsohi411 4 ай бұрын
Hi , can someone please find logical error in my code .. i even tried to debug with chatgpt and also dry run many times but still error is coming For Input: 54 44 86 43 46 78 88 N N N 50 61 83 N 89 8 46 86 88 61 89 78 54 83 Your Code's output is: Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 It's Correct output is: 43 44 50 Output Difference Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 CODE ----------------------- int getheight(Node* root){ if(root==NULL){ return 0; } return root->height; } int check(Node* root){ return getheight(root->left) - getheight(root->right); } Node* rrotate(Node* root){ Node* child = root->left; Node* cr = child->right; child->right = root; root->left = cr; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* lrotate(Node* root){ Node* child = root->right; Node* cl = child->left; child->left = root; root->right = cl; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* deleteNode(Node* root, int k) { if(!root){ return NULL; } if(root->data > k){ root->left = deleteNode(root->left,k); }else if(root->data < k){ root->right = deleteNode(root->right,k); }else{ if(root->left == NULL && root->right == NULL){ delete root; return NULL; } else if(!root->left && root->right){ Node* temp = root->right; delete root; return temp; }else if(!root->right && root->left){ Node* temp =root->left; delete root; return temp; }else{ Node* temp = root->right; while(temp->left){ temp = temp ->left; } root->data = temp->data; root->right = deleteNode(root->right,temp->data); } root->height = 1 + max(getheight(root->left),getheight(root->right)); int b = check(root); if(b>1){ if(check(root->left)>=0){ return rrotate(root); }else{ root->left = lrotate(root->left); return rrotate(root); } }else if(b < -1){ if(check(root->right)right = rrotate(root->right); return lrotate(root); } }else{ return root; } }
@sunandachakraborty7844
@sunandachakraborty7844 5 ай бұрын
This is the most underrated yt channel !! :) Thanks sir for such efforts ❤
@motivationvideo-be6hv
@motivationvideo-be6hv 9 ай бұрын
Bhiya ek baat hai jindgi me koi teacher student ke liye kitni mehnat karta hai❤❤
@sumitvishwakarma1075
@sumitvishwakarma1075 9 ай бұрын
6 days more and the challenge of 180 days will be completed. Thankyou bhaiya I learned many things because of you #coderarmy ❤
@vaishalichoudhary5
@vaishalichoudhary5 9 ай бұрын
Yes ..I want to learn about segment trees, Fenwick trees, and tries...:)
@MaheshwariLakde
@MaheshwariLakde 6 ай бұрын
sabhi topics padhne hai bhaiya trie bhi segment tree bhi sabhi..!! Thanks for such quality content..!!
@manish_kumar_iitg
@manish_kumar_iitg 3 ай бұрын
Final code:- int getheight(Node *root){ if(!root) return 0; return root->height; } int getbalance(Node *root){ if(!root){ return 0; } return getheight(root->left) - getheight(root->right); } Node *leftRotation(Node *root){ Node *child = root->right; Node *childLeft = child->left; child->left = root; root->right = childLeft; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node *rightRotation(Node *root){ Node *child = root->left; Node *childRight = child->right; child->right = root; root->left = childRight; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* deleteNode(Node* root, int data) { //add code here, if(!root) return NULL; if(data < root->data){ root->left = deleteNode(root->left,data); } else if(data > root->data){ root->right = deleteNode(root->right,data); } else{ //Leaf Node if(!root->left && !root->right){ delete root; return NULL; } else if(!root->left && root->right){ Node *temp = root->right; delete root; return temp; } else if(root->left && !root->right){ Node *temp = root->left; delete root; return temp; } // both child exist else{ Node *curr = root->right; while(curr->left){ curr = curr->left; } root->data = curr->data; root->right = deleteNode(root->right,curr->data); } } // update heioght root->height = 1 + max(getheight(root->left),getheight(root->right)); // check balancing int balance = getbalance(root); if(balance > 1){ //LL if(getbalance(root->left) >= 0){ return rightRotation(root); }else{ root->left = leftRotation(root->left); return rightRotation(root); } }else if(balance < -1){ //RR if(getbalance(root->right) right = rightRotation(root->right); return leftRotation(root); } } return root; }
@ManojSinghRawat-x2w
@ManojSinghRawat-x2w 9 ай бұрын
Ji bhaiya ..we want to learn about segment trees, Fenwick trees, tries and further advance topics, just a request that please don't hold this series👍👍❤❤
@jaivikpatel2882
@jaivikpatel2882 4 ай бұрын
best video and detailed video for avl tree
@SK__EDITZ45
@SK__EDITZ45 3 ай бұрын
sir you are the best teacher i have ever seen the concept clarity in your lectures are just incredible...its my humble request to you to please make thw videos on k-tree,b-tree,b+-tree and red-black tree please sir.... and i am from uttarakhand too sir....love you from the bottom of my heart..and i always suggest to my friend circle to study from you as you are the best teacher🥰🥰🥰
@jamitkumar7251
@jamitkumar7251 Ай бұрын
thanks a lot sir..., uh made this topic super easy
@amankumbhalwar
@amankumbhalwar 9 ай бұрын
kisi ne bhi ye puri playlist follow ki hai ya aage karne wale hai please 1st video me comment kar do ki ye playlist aachi hai aur kyu follow karni chahiye :)
@puneetsetia6800
@puneetsetia6800 9 ай бұрын
Bhaut bdiya complete sir you made my interest in it
@Codes_king
@Codes_king 9 ай бұрын
Such me two times dekha video aur sb automatic clear ho gaya aur bahut acche se implement bhi kar liya, maza aa gaya , Baap level AVL Tree on KZbin 🙏🙏
@gurtegsinghsohi411
@gurtegsinghsohi411 4 ай бұрын
Hi , can someone please find logical error in my code .. i even tried to debug with chatgpt and also dry run many times but still error is coming For Input: 54 44 86 43 46 78 88 N N N 50 61 83 N 89 8 46 86 88 61 89 78 54 83 Your Code's output is: Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 It's Correct output is: 43 44 50 Output Difference Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 CODE ----------------------- int getheight(Node* root){ if(root==NULL){ return 0; } return root->height; } int check(Node* root){ return getheight(root->left) - getheight(root->right); } Node* rrotate(Node* root){ Node* child = root->left; Node* cr = child->right; child->right = root; root->left = cr; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* lrotate(Node* root){ Node* child = root->right; Node* cl = child->left; child->left = root; root->right = cl; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* deleteNode(Node* root, int k) { if(!root){ return NULL; } if(root->data > k){ root->left = deleteNode(root->left,k); }else if(root->data < k){ root->right = deleteNode(root->right,k); }else{ if(root->left == NULL && root->right == NULL){ delete root; return NULL; } else if(!root->left && root->right){ Node* temp = root->right; delete root; return temp; }else if(!root->right && root->left){ Node* temp =root->left; delete root; return temp; }else{ Node* temp = root->right; while(temp->left){ temp = temp ->left; } root->data = temp->data; root->right = deleteNode(root->right,temp->data); } root->height = 1 + max(getheight(root->left),getheight(root->right)); int b = check(root); if(b>1){ if(check(root->left)>=0){ return rrotate(root); }else{ root->left = lrotate(root->left); return rrotate(root); } }else if(b < -1){ if(check(root->right)right = rrotate(root->right); return lrotate(root); } }else{ return root; } }
@heetpatel3037
@heetpatel3037 7 ай бұрын
Jai shree Ram ❤️ Bohot bohot shukriya Dil se dhanyawad
@alihaider-ik5ie
@alihaider-ik5ie 3 ай бұрын
class Solution { public: /* You are required to complete this method */ int Hight(Node* root) { if (!root) { return 0; } return root->height; } Node* leftrotation(Node* root) { Node* child = root->right; // Fix this to rotate the right child Node* childleft = child->left; // Perform rotation child->left = root; root->right = childleft; // Update heights root->height = 1 + max(Hight(root->left), Hight(root->right)); child->height = 1 + max(Hight(child->left), Hight(child->right)); // Return new root return child; } Node* rightrotation(Node* root) { Node* child = root->left; // Fix this to rotate the left child Node* childright = child->right; // Perform rotation child->right = root; root->left = childright; // Update heights root->height = 1 + max(Hight(root->left), Hight(root->right)); child->height = 1 + max(Hight(child->left), Hight(child->right)); // Return new root return child; } int getbalance(Node* root) { return Hight(root->left) - Hight(root->right); } Node* insertToAVL(Node* root, int data) { // Your code here if (!root) { return new Node(data); } if (data < root->data) { root->left = insertToAVL(root->left, data); } else if (data > root->data) { root->right = insertToAVL(root->right, data); } else { return root; } // Update height of this ancestor node root->height = 1 + max(Hight(root->left), Hight(root->right)); // Get the balance factor int balance = getbalance(root); // Left Left Case if (balance > 1 && data < root->left->data) { return rightrotation(root); } // Right Right Case if (balance < -1 && data > root->right->data) { return leftrotation(root); } // Left Right Case if (balance > 1 && data > root->left->data) { root->left = leftrotation(root->left); return rightrotation(root); } // Right Left Case if (balance < -1 && data < root->right->data) { root->right = rightrotation(root->right); return leftrotation(root); } // Return the unchanged root pointer return root; } };
@itshirdeshk
@itshirdeshk 9 ай бұрын
Day 174 ✅🔥 Hn bhaiya hume sare type of trees chaiye 🎄🌴🌳🌲😁✨
@shubhamkumarjha9192
@shubhamkumarjha9192 9 ай бұрын
Good morning bhaiya ji. 💖
@tarunbansal6081
@tarunbansal6081 9 ай бұрын
yes want to lear n fenwick, segment and tries
@aakashy_07
@aakashy_07 4 ай бұрын
Thank you bhaiya for ur incredible efforts..😊
@ujjawalgupta3319
@ujjawalgupta3319 26 күн бұрын
My Solution for Problem Deletion in AVL tree : int getHeight(Node* root) { if(!root) return 0; return root->height; } Node* rightRotation(Node* root) { Node* leftChild = root->left; Node* temp = leftChild->right; leftChild->right = root; root->left = temp; root->height = max(getHeight(root->left), getHeight(root->right)) + 1; leftChild->height = max(getHeight(leftChild->left) , getHeight(leftChild->right)) + 1; return leftChild; } Node* leftRotation(Node* root) { Node* rightChild = root->right; Node* temp = rightChild->left; rightChild->left = root; root->right = temp; root->height = max(getHeight(root->left), getHeight(root->right)) + 1; rightChild->height = max(getHeight(rightChild->left) , getHeight(rightChild->right)) + 1; return rightChild; } Node* deleteNode(Node* root, int x) { // tree is empty if(!root) return NULL; // move to left if(root->data > x) { root->left = deleteNode(root->left, x); } // move to right else if(root->data < x) { root->right = deleteNode(root->right, x); } // current node has to delete else { // current node is leaf node if(!root->left && !root->right) { delete root; return NULL; } // current node has only left subtree else if(root->left && !root->right) { Node* temp = root->left; delete root; return temp; } // current node has only right subtree else if(!root->left && root->right) { Node* temp = root->right; delete root; return temp; } // Both left and right subtree exits else { Node* temp = root->left; while(temp->right) temp = temp->right; root->data = temp->data; temp->data = x; root->left = deleteNode(root->left, x); } } // Check for balance int balance = getHeight(root->left) - getHeight(root->right); // Unbalance fix if(balance > 1) { // case L if(getHeight(root->left->right) > getHeight(root->left->left)) { // case LR root->left = leftRotation(root->left); root = rightRotation(root); } else { //case LL root = rightRotation(root); } } else if(balance < -1) { // case R if(getHeight(root->right->right) >= getHeight(root->right->left)) { // case RR root = leftRotation(root); } else { // case RL root->right = rightRotation(root->right); root = leftRotation(root); } } // update height root->height = max(getHeight(root->left), getHeight(root->right)) + 1; // balance tree return return root; }
@ybyewhy9409
@ybyewhy9409 8 ай бұрын
yes teach also the remaining advance topic
@tripurarisen4362
@tripurarisen4362 13 күн бұрын
Chamak gaya sir ji
@chanchalsoni7535
@chanchalsoni7535 6 ай бұрын
ek hi dil h dost...kitni baar jeetoge☺
@nonstopcodingcodewithadity8238
@nonstopcodingcodewithadity8238 9 ай бұрын
Good morning bro 😅aaj maths exam hai but apka lecture dhak raha fail huga aaj tho padhne ka fayada nhi maths tho dsa kar raha
@SurajGupta-ux2se
@SurajGupta-ux2se 7 ай бұрын
yes bhaiya please make videos on tries, segment trees as well
@ankushladani496
@ankushladani496 9 ай бұрын
Tries padhao Segment tree Fenwick tree Padhao....🎉🎉
@AyushSingh-le1co
@AyushSingh-le1co 9 ай бұрын
Ha bhaiya tries bhi padhaiyega
@NitinSingh-zy8io
@NitinSingh-zy8io 7 ай бұрын
please teach more advance topic like segment tree, trie, red and black tree and more topics like this
@Aniruddha_Mukherjee
@Aniruddha_Mukherjee 9 ай бұрын
Good morning bhaiya ji😍
@CoderArmy9
@CoderArmy9 9 ай бұрын
Good Morning bhai
@rocketgamerzz.7577
@rocketgamerzz.7577 6 ай бұрын
Like button for bhaiyya to teach red black tree also :)
@ankushladani496
@ankushladani496 9 ай бұрын
Thanks Bhaiya...❤🎉
@sabiruddinkhan496
@sabiruddinkhan496 17 күн бұрын
Haa bhaiya padhna hai segment tree,dp and all
@Piyush_sahu.1
@Piyush_sahu.1 9 ай бұрын
Bhaiya love so much Views kam hogaye as compared to 1st video compitition kam hogaya apne appp
@dhruv12151
@dhruv12151 2 ай бұрын
Mza aa gya
@AMITKUMAR-ds4hp
@AMITKUMAR-ds4hp 9 ай бұрын
Good morning boss ❤
@VINAYKUMAR-zo4pb
@VINAYKUMAR-zo4pb 9 ай бұрын
Bhaiya Graph and DP kab start hoga174 days ho gaye waise extra time bhi lage toh please kara dena 🤗
@LuckyPanwar_0001
@LuckyPanwar_0001 9 ай бұрын
Sir lectures kb tk nhi aayenge??
@ankushladani496
@ankushladani496 9 ай бұрын
Done Bhaiya... Day 174/180 ✅
@laganmittal7442
@laganmittal7442 5 ай бұрын
we need tries , segment tree and primary video too
@anupammishra6514
@anupammishra6514 9 ай бұрын
Good morning brother 🌞❤
@CoderArmy9
@CoderArmy9 9 ай бұрын
Good Morning
@nonstopcodingcodewithadity8238
@nonstopcodingcodewithadity8238 9 ай бұрын
Kha se ho aap?
@gurtegsinghsohi411
@gurtegsinghsohi411 4 ай бұрын
@@CoderArmy9 Hi , can someone please find logical error in my code .. i even tried to debug with chatgpt and also dry run many times but still error is coming For Input: 54 44 86 43 46 78 88 N N N 50 61 83 N 89 8 46 86 88 61 89 78 54 83 Your Code's output is: Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 It's Correct output is: 43 44 50 Output Difference Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 CODE ----------------------- int getheight(Node* root){ if(root==NULL){ return 0; } return root->height; } int check(Node* root){ return getheight(root->left) - getheight(root->right); } Node* rrotate(Node* root){ Node* child = root->left; Node* cr = child->right; child->right = root; root->left = cr; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* lrotate(Node* root){ Node* child = root->right; Node* cl = child->left; child->left = root; root->right = cl; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* deleteNode(Node* root, int k) { if(!root){ return NULL; } if(root->data > k){ root->left = deleteNode(root->left,k); }else if(root->data < k){ root->right = deleteNode(root->right,k); }else{ if(root->left == NULL && root->right == NULL){ delete root; return NULL; } else if(!root->left && root->right){ Node* temp = root->right; delete root; return temp; }else if(!root->right && root->left){ Node* temp =root->left; delete root; return temp; }else{ Node* temp = root->right; while(temp->left){ temp = temp ->left; } root->data = temp->data; root->right = deleteNode(root->right,temp->data); } root->height = 1 + max(getheight(root->left),getheight(root->right)); int b = check(root); if(b>1){ if(check(root->left)>=0){ return rrotate(root); }else{ root->left = lrotate(root->left); return rrotate(root); } }else if(b < -1){ if(check(root->right)right = rrotate(root->right); return lrotate(root); } }else{ return root; } }
@Aniruddha_Mukherjee
@Aniruddha_Mukherjee 9 ай бұрын
Ji bhaiya ji Hume advanced topics sikhna hain. Aap wo bhi hum logo ko sikha dijiye.
@yadiencollection5073
@yadiencollection5073 9 ай бұрын
Ram ram bhaiya ❤
@CoderArmy9
@CoderArmy9 9 ай бұрын
Ram Ram Bhai
@kartikverma6988
@kartikverma6988 9 ай бұрын
Yes bhaiya ❤❤
@ayushmaanyadav722
@ayushmaanyadav722 9 ай бұрын
Bhaiya c language ke baad c++ chalu kare ya fir sidhe 180 days hard me ghus jai .please reply
@enghimanshu
@enghimanshu 9 ай бұрын
direct 180 karo c++ coverd hai esme
@ayushmaanyadav722
@ayushmaanyadav722 9 ай бұрын
@@enghimanshu nahi mai puch raha hu pehle c karne chaie ke usko chodke sidhe c++ kare
@enghimanshu
@enghimanshu 9 ай бұрын
@@ayushmaanyadav722 direct jump to the playlist sab kuch covered h...c ki koi need nahi h
@Ankitakumari-t5q
@Ankitakumari-t5q 9 ай бұрын
good morning Bhaiya
@CoderArmy9
@CoderArmy9 9 ай бұрын
Good Morning
@binauralbeats-relaxingmusi4336
@binauralbeats-relaxingmusi4336 9 ай бұрын
Dsa notes me page no 35 me. Num=0; Cout
@adarsh_kumar_sharma_8638
@adarsh_kumar_sharma_8638 9 ай бұрын
whose notes is this from where you get it
@allinonemoviesyt
@allinonemoviesyt 9 ай бұрын
good morning bhaiya ji
@asad_iliyas
@asad_iliyas 9 ай бұрын
Bhaiya DSA series kab tak complete ho jayegi?
@kartikverma6988
@kartikverma6988 9 ай бұрын
Thank you 🎉🎉🎉
@ManmohanTiwari-tm5tt
@ManmohanTiwari-tm5tt 9 ай бұрын
bhaiya ye playlist kab tak khatam hoga please bata dijiye
@SmritiSharma-vv7ib
@SmritiSharma-vv7ib 3 ай бұрын
we want tries segment tree pleaseeeee
@rajeshpatel8082
@rajeshpatel8082 9 ай бұрын
Bhaiya aur konse konse topic bache hai Love you ❤
@ankushladani496
@ankushladani496 9 ай бұрын
Bhaiya mene try Kiya and I think Mera logic sahi hoga. Let's see in video. 😅
@gurtegsinghsohi411
@gurtegsinghsohi411 4 ай бұрын
Hi , can someone please find logical error in my code .. i even tried to debug with chatgpt and also dry run many times but still error is coming For Input: 54 44 86 43 46 78 88 N N N 50 61 83 N 89 8 46 86 88 61 89 78 54 83 Your Code's output is: Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 It's Correct output is: 43 44 50 Output Difference Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 CODE ----------------------- int getheight(Node* root){ if(root==NULL){ return 0; } return root->height; } int check(Node* root){ return getheight(root->left) - getheight(root->right); } Node* rrotate(Node* root){ Node* child = root->left; Node* cr = child->right; child->right = root; root->left = cr; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* lrotate(Node* root){ Node* child = root->right; Node* cl = child->left; child->left = root; root->right = cl; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* deleteNode(Node* root, int k) { if(!root){ return NULL; } if(root->data > k){ root->left = deleteNode(root->left,k); }else if(root->data < k){ root->right = deleteNode(root->right,k); }else{ if(root->left == NULL && root->right == NULL){ delete root; return NULL; } else if(!root->left && root->right){ Node* temp = root->right; delete root; return temp; }else if(!root->right && root->left){ Node* temp =root->left; delete root; return temp; }else{ Node* temp = root->right; while(temp->left){ temp = temp ->left; } root->data = temp->data; root->right = deleteNode(root->right,temp->data); } root->height = 1 + max(getheight(root->left),getheight(root->right)); int b = check(root); if(b>1){ if(check(root->left)>=0){ return rrotate(root); }else{ root->left = lrotate(root->left); return rrotate(root); } }else if(b < -1){ if(check(root->right)right = rrotate(root->right); return lrotate(root); } }else{ return root; } }
@Manav00121
@Manav00121 9 ай бұрын
bhaiya logic toh samagh aa gaya hai but code thodi si bda hone ke karan problem aa rhi hai apne se implement karne me
@MdShoaib-nk2im
@MdShoaib-nk2im 9 ай бұрын
hello bhaiya, after dsa which cource you start
@codewithlarry3558
@codewithlarry3558 9 ай бұрын
Bhaiya web development course KZbin mai ayey ga kya?
@aryachauhan6118
@aryachauhan6118 9 ай бұрын
bhaiya trie aur sliding window bhi pdha dena
@YashSaini007
@YashSaini007 9 ай бұрын
Bhaiya Radhe Radhe 🙏
@CoderArmy9
@CoderArmy9 9 ай бұрын
Radhe Radhe bhai
@soumilkhanna9177
@soumilkhanna9177 9 ай бұрын
bhaiya please teach tries also
@deep_singh01
@deep_singh01 9 ай бұрын
Day 174/180 👍👍
@suplexshivam
@suplexshivam 9 ай бұрын
Bhaiya agr thoda aur pehle aa jata ye video to mera exam hogya hota acha😅
@susmoy4385
@susmoy4385 9 ай бұрын
148 k bad k assignment kaha hai ???
@saumyachauhan174
@saumyachauhan174 7 ай бұрын
🔥🔥
@ysh___88
@ysh___88 8 ай бұрын
Bhai I'm starting my coding journey.i have never done this before will it ok if start directly from this or do i need to learn full concept of c++ first
@CoderArmy9
@CoderArmy9 8 ай бұрын
DSA in C++ wali playlist ko follow karo, Udhr sab starting se hai, C++ bhi basic se padaya hai
@ysh___88
@ysh___88 8 ай бұрын
@@CoderArmy9 thanks bhaiya
@vishalboudhh
@vishalboudhh 9 ай бұрын
Bhaiya DSA ki series m aur kitne videos bache hai
@gurtegsinghsohi411
@gurtegsinghsohi411 4 ай бұрын
Hi , can someone please find logical error in my code .. i even tried to debug with chatgpt and also dry run many times but still error is coming For Input: 54 44 86 43 46 78 88 N N N 50 61 83 N 89 8 46 86 88 61 89 78 54 83 Your Code's output is: Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 It's Correct output is: 43 44 50 Output Difference Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 CODE ----------------------- int getheight(Node* root){ if(root==NULL){ return 0; } return root->height; } int check(Node* root){ return getheight(root->left) - getheight(root->right); } Node* rrotate(Node* root){ Node* child = root->left; Node* cr = child->right; child->right = root; root->left = cr; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* lrotate(Node* root){ Node* child = root->right; Node* cl = child->left; child->left = root; root->right = cl; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* deleteNode(Node* root, int k) { if(!root){ return NULL; } if(root->data > k){ root->left = deleteNode(root->left,k); }else if(root->data < k){ root->right = deleteNode(root->right,k); }else{ if(root->left == NULL && root->right == NULL){ delete root; return NULL; } else if(!root->left && root->right){ Node* temp = root->right; delete root; return temp; }else if(!root->right && root->left){ Node* temp =root->left; delete root; return temp; }else{ Node* temp = root->right; while(temp->left){ temp = temp ->left; } root->data = temp->data; root->right = deleteNode(root->right,temp->data); } root->height = 1 + max(getheight(root->left),getheight(root->right)); int b = check(root); if(b>1){ if(check(root->left)>=0){ return rrotate(root); }else{ root->left = lrotate(root->left); return rrotate(root); } }else if(b < -1){ if(check(root->right)right = rrotate(root->right); return lrotate(root); } }else{ return root; } }
@aaryan5179
@aaryan5179 9 ай бұрын
Bhaiya mere ek question hai aapse ki ye DSA course kb tk completre hoga, aap koi approx date bta skte ho kya???
@AkashDeep1271-f9w
@AkashDeep1271-f9w 9 ай бұрын
Maan kr chalo next 2 month Mai complete ho Jaye ga
@AbdurRahimIIITK
@AbdurRahimIIITK 9 ай бұрын
Hii. Mai C se basic DSA kr rha hu. Mai vacation me C++ se krna cha rha hu.Rohit Bhaiya ka ya babbar bhaiya ka sahi rahega kya ? Anyone plz...
@gopalmalpani1947
@gopalmalpani1947 9 ай бұрын
rohit negi is best from all paid courses
@AbdurRahimIIITK
@AbdurRahimIIITK 9 ай бұрын
@@gopalmalpani1947 which one is best Love babbar Or Rohit bhaiya
@SmritiSharma-vv7ib
@SmritiSharma-vv7ib 3 ай бұрын
@@AbdurRahimIIITK depends on your grasping skills try one topic of both then accordingly choose one which suits u more. Its rohit bhaiya for me coz m babbar sir ka course chd k inse pdhne ai thi
@alishagoel184
@alishagoel184 9 ай бұрын
Bhayia logics nahi lag rahi
@kartikverma6988
@kartikverma6988 9 ай бұрын
🎉🎉🎉
@positivevibes-f2j
@positivevibes-f2j 8 ай бұрын
We need advance dsa
@fire7874
@fire7874 9 ай бұрын
❤❤
@YashSaini007
@YashSaini007 9 ай бұрын
Day 174/180 #180DaysOfCode
@hiteshsharma5034
@hiteshsharma5034 7 ай бұрын
Anyone Who can find my error and inform me...😐😐😐 only 13 Testcases passed.. int get_height(Node* root){ if(!root){ return 0; } return root->height; } //Right Rotation Node* rightRotation(Node* &root){ Node* child=root->left; Node* childRight=child->right; child->right=root; root->left=childRight;//adding right child of middle to updated top left(edge case) root->height=1+max(get_height(root->left),get_height(root->right)); child->height=1+max(get_height(child->left),get_height(child->right)); return child; } //Left Noation Node* leftRotation(Node* &root){ Node* child=root->right; Node* childLeft=child->left; child->left=root; root->right=childLeft; child->height=1+max(get_height(child->left),get_height(child->right)); root->height=1+max(get_height(root->left),get_height(root->right)); return child; } int get_bal(Node* root){ return get_height(root->left)-get_height(root->right); } Node* deleteNode(Node* root, int key) { if(!root) return NULL; //exists if(root->data > key){ root->left=deleteNode(root->left,key); } else if(root->data < key){ root->right=deleteNode(root->right, key); } else{ //when key is equal to root->data, hence we have to delete the node //leaf Node; if(!root->left && !root->right){ delete (root); return NULL; } //only one child else if(!root->left && root->right){ //only right exists Node* temp=root->right; delete (root); return temp; } else if(!root->right && root->left){ //only left exists Node* temp=root->left; delete(root); return temp; } //both childs exits else{ //right se smallest leke aoo Node* temp=root->right; while(temp->left){ temp=temp->left; } root->data=temp->data; root->right=deleteNode(root->right,temp->data); //mine confusion point } } //end of else root->height=1+max(get_height(root->left),get_height(root->right)); int balance=get_bal(root); if(balance>1){ //left side me dikkat hai //LL if(get_bal(root->left)>=0){ return rightRotation(root); } //LR else{ root->left=leftRotation(root->left); return rightRotation(root); } } else if(balanceright)right=rightRotation(root->right); return leftRotation(root); } } else{ return root; } }
@harshitpatil6138
@harshitpatil6138 7 ай бұрын
In left Rotation part try to first update root height then child height and passed root without reference
@hiteshsharma5034
@hiteshsharma5034 7 ай бұрын
@@harshitpatil6138 ok Bro thankyou, Let me this Updated solution
@gurtegsinghsohi411
@gurtegsinghsohi411 4 ай бұрын
@@harshitpatil6138 Hi , can someone please find logical error in my code .. i even tried to debug with chatgpt and also dry run many times but still error is coming For Input: 54 44 86 43 46 78 88 N N N 50 61 83 N 89 8 46 86 88 61 89 78 54 83 Your Code's output is: Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 It's Correct output is: 43 44 50 Output Difference Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 CODE ----------------------- int getheight(Node* root){ if(root==NULL){ return 0; } return root->height; } int check(Node* root){ return getheight(root->left) - getheight(root->right); } Node* rrotate(Node* root){ Node* child = root->left; Node* cr = child->right; child->right = root; root->left = cr; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* lrotate(Node* root){ Node* child = root->right; Node* cl = child->left; child->left = root; root->right = cl; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* deleteNode(Node* root, int k) { if(!root){ return NULL; } if(root->data > k){ root->left = deleteNode(root->left,k); }else if(root->data < k){ root->right = deleteNode(root->right,k); }else{ if(root->left == NULL && root->right == NULL){ delete root; return NULL; } else if(!root->left && root->right){ Node* temp = root->right; delete root; return temp; }else if(!root->right && root->left){ Node* temp =root->left; delete root; return temp; }else{ Node* temp = root->right; while(temp->left){ temp = temp ->left; } root->data = temp->data; root->right = deleteNode(root->right,temp->data); } root->height = 1 + max(getheight(root->left),getheight(root->right)); int b = check(root); if(b>1){ if(check(root->left)>=0){ return rrotate(root); }else{ root->left = lrotate(root->left); return rrotate(root); } }else if(b < -1){ if(check(root->right)right = rrotate(root->right); return lrotate(root); } }else{ return root; } }
@gurtegsinghsohi411
@gurtegsinghsohi411 4 ай бұрын
Hi , can someone please find logical error in my code .. i even tried to debug with chatgpt and also dry run many times but still error is coming For Input: 54 44 86 43 46 78 88 N N N 50 61 83 N 89 8 46 86 88 61 89 78 54 83 Your Code's output is: Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 It's Correct output is: 43 44 50 Output Difference Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 CODE ----------------------- int getheight(Node* root){ if(root==NULL){ return 0; } return root->height; } int check(Node* root){ return getheight(root->left) - getheight(root->right); } Node* rrotate(Node* root){ Node* child = root->left; Node* cr = child->right; child->right = root; root->left = cr; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* lrotate(Node* root){ Node* child = root->right; Node* cl = child->left; child->left = root; root->right = cl; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* deleteNode(Node* root, int k) { if(!root){ return NULL; } if(root->data > k){ root->left = deleteNode(root->left,k); }else if(root->data < k){ root->right = deleteNode(root->right,k); }else{ if(root->left == NULL && root->right == NULL){ delete root; return NULL; } else if(!root->left && root->right){ Node* temp = root->right; delete root; return temp; }else if(!root->right && root->left){ Node* temp =root->left; delete root; return temp; }else{ Node* temp = root->right; while(temp->left){ temp = temp ->left; } root->data = temp->data; root->right = deleteNode(root->right,temp->data); } root->height = 1 + max(getheight(root->left),getheight(root->right)); int b = check(root); if(b>1){ if(check(root->left)>=0){ return rrotate(root); }else{ root->left = lrotate(root->left); return rrotate(root); } }else if(b < -1){ if(check(root->right)right = rrotate(root->right); return lrotate(root); } }else{ return root; } }
@gurtegsinghsohi411
@gurtegsinghsohi411 4 ай бұрын
Hi , can someone please find logical error in my code .. i even tried to debug with chatgpt and also dry run many times but still error is coming For Input: 54 44 86 43 46 78 88 N N N 50 61 83 N 89 8 46 86 88 61 89 78 54 83 Your Code's output is: Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 It's Correct output is: 43 44 50 Output Difference Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 CODE ----------------------- int getheight(Node* root){ if(root==NULL){ return 0; } return root->height; } int check(Node* root){ return getheight(root->left) - getheight(root->right); } Node* rrotate(Node* root){ Node* child = root->left; Node* cr = child->right; child->right = root; root->left = cr; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* lrotate(Node* root){ Node* child = root->right; Node* cl = child->left; child->left = root; root->right = cl; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* deleteNode(Node* root, int k) { if(!root){ return NULL; } if(root->data > k){ root->left = deleteNode(root->left,k); }else if(root->data < k){ root->right = deleteNode(root->right,k); }else{ if(root->left == NULL && root->right == NULL){ delete root; return NULL; } else if(!root->left && root->right){ Node* temp = root->right; delete root; return temp; }else if(!root->right && root->left){ Node* temp =root->left; delete root; return temp; }else{ Node* temp = root->right; while(temp->left){ temp = temp ->left; } root->data = temp->data; root->right = deleteNode(root->right,temp->data); } root->height = 1 + max(getheight(root->left),getheight(root->right)); int b = check(root); if(b>1){ if(check(root->left)>=0){ return rrotate(root); }else{ root->left = lrotate(root->left); return rrotate(root); } }else if(b < -1){ if(check(root->right)right = rrotate(root->right); return lrotate(root); } }else{ return root; } }
@4minix643
@4minix643 3 ай бұрын
Bro u haven't closed your first else block ... close that first before updating height and rotations
@gurtegsinghsohi411
@gurtegsinghsohi411 4 ай бұрын
Hi , can someone please find logical error in my code .. i even tried to debug with chatgpt and also dry run many times but still error is coming For Input: 54 44 86 43 46 78 88 N N N 50 61 83 N 89 8 46 86 88 61 89 78 54 83 Your Code's output is: Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 It's Correct output is: 43 44 50 Output Difference Unbalanced BST, inorder traversal : 43 44 50 54 78 83 89 CODE ----------------------- int getheight(Node* root){ if(root==NULL){ return 0; } return root->height; } int check(Node* root){ return getheight(root->left) - getheight(root->right); } Node* rrotate(Node* root){ Node* child = root->left; Node* cr = child->right; child->right = root; root->left = cr; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* lrotate(Node* root){ Node* child = root->right; Node* cl = child->left; child->left = root; root->right = cl; root->height = 1 + max(getheight(root->left),getheight(root->right)); child->height = 1 + max(getheight(child->left),getheight(child->right)); return child; } Node* deleteNode(Node* root, int k) { if(!root){ return NULL; } if(root->data > k){ root->left = deleteNode(root->left,k); }else if(root->data < k){ root->right = deleteNode(root->right,k); }else{ if(root->left == NULL && root->right == NULL){ delete root; return NULL; } else if(!root->left && root->right){ Node* temp = root->right; delete root; return temp; }else if(!root->right && root->left){ Node* temp =root->left; delete root; return temp; }else{ Node* temp = root->right; while(temp->left){ temp = temp ->left; } root->data = temp->data; root->right = deleteNode(root->right,temp->data); } root->height = 1 + max(getheight(root->left),getheight(root->right)); int b = check(root); if(b>1){ if(check(root->left)>=0){ return rrotate(root); }else{ root->left = lrotate(root->left); return rrotate(root); } }else if(b < -1){ if(check(root->right)right = rrotate(root->right); return lrotate(root); } }else{ return root; } }
Heaps, heapsort, and priority queues - Inside code
19:01
Inside code
Рет қаралды 106 М.
УЛИЧНЫЕ МУЗЫКАНТЫ В СОЧИ 🤘🏻
0:33
РОК ЗАВОД
Рет қаралды 7 МЛН
I Sent a Subscriber to Disneyland
0:27
MrBeast
Рет қаралды 104 МЛН
STL in C++
1:52:30
Coder Army
Рет қаралды 32 М.
AVL Trees & Rotations (Self-Balancing Binary Search Trees)
20:38
Back To Back SWE
Рет қаралды 363 М.
I Helped 2,000 People Walk Again
15:31
MrBeast
Рет қаралды 27 МЛН
Burning Tree || Maximum Path Sum between 2 Special Nodes
1:27:12
Coder Army
Рет қаралды 10 М.
2.6.3 Heap - Heap Sort - Heapify - Priority Queues
51:08
Abdul Bari
Рет қаралды 2,3 МЛН
Data Structure | L-35 | AVL Tree|  Deletion & Questions | Vishvadeep Gothi
1:12:59
Unacademy Computer Science
Рет қаралды 10 М.
10.1 AVL Tree - Insertion and Rotations
43:08
Abdul Bari
Рет қаралды 1,3 МЛН
Lecture 60: Quick Sort Algorithm
59:48
Coder Army
Рет қаралды 27 М.