LeetCode Problem: 226. Invert Binary Tree | Java Solution

Code for Interview
7 May 202311:19

Summary

TLDRThe video script discusses the concept of an inverted binary tree, explaining the basic structure and properties of binary trees where each node can have at most two children, referred to as left and right. It delves into the process of inverting a binary tree, which involves swapping the left and right children of all nodes. The script provides a step-by-step guide on how to perform the inversion, emphasizing the importance of understanding the tree's depth and structure. It also touches on the coding aspect, suggesting a recursive approach to inverting the tree, and concludes with an example to illustrate the process, aiming to clarify the concept for viewers.

Takeaways

  • 🌟 The video discusses the concept of an Inverted Binary Tree, a task where the tree is flipped.
  • 📚 A binary tree is defined as a type of tree where each node can have at most two children.
  • 🔄 The process of inverting a binary tree involves swapping the left and right children of each node.
  • 👀 The video explains that if a tree has a node with three children, it is not a binary tree.
  • 💡 The concept of 'left' and 'right' does not apply to nodes with more than two children.
  • 🤔 The task is described as being at an 'IQ level difficulty', indicating it is quite challenging.
  • 👶 The video starts with the basics, explaining what a binary tree is and its properties.
  • 🛠️ The video provides a step-by-step guide on how to invert a binary tree, emphasizing the importance of understanding the structure.
  • 👨‍🏫 The script includes a detailed explanation of the algorithm used to invert the tree, including code snippets.
  • 🔧 The video mentions that the root of the tree remains the same during the inversion process.
  • 🎓 The video concludes with a demonstration of the complete inverting process, using a specific example to illustrate the steps.

Q & A

  • What is the main topic of the video script?

    -The main topic of the video script is about inverting a binary tree. It explains the concept of a binary tree, how it works, and provides a step-by-step guide on how to invert it.

  • What is a binary tree as mentioned in the script?

    -A binary tree is a type of tree data structure where each node has at most two children, referred to as the left and right child.

  • Why is the task of inverting a binary tree considered difficult in the script?

    -The task of inverting a binary tree is considered difficult because it involves understanding the structure of the tree and recursively swapping the left and right children of each node, which can be complex for beginners.

  • What does the script mean by 'inverting' a binary tree?

    -In the context of the script, 'inverting' a binary tree means to reverse the tree structure by swapping the left and right children of each node, effectively creating a mirror image of the original tree.

  • How does the script describe the process of inverting a binary tree?

    -The script describes the process of inverting a binary tree by first explaining the basic structure of a binary tree, then it walks through a recursive function that swaps the left and right children of each node in the tree.

  • What is the significance of the 'root' in the context of the binary tree discussed in the script?

    -In the context of the binary tree, the 'root' is the starting point of the tree. The script explains that during the inversion process, the root's left and right children are swapped, and this process is recursively applied to all nodes.

  • What is the role of the 'left' and 'right' children in the inversion process as described in the script?

    -The 'left' and 'right' children of each node in the binary tree are crucial in the inversion process. The script explains that during the inversion, the roles of the left and right children are swapped, which is the core operation of inverting the tree.

  • How does the script handle the case where a node in the binary tree does not have any children?

    -The script mentions that if a node does not have any children (referred to as 'null' or 'nil'), then no action is needed for that node during the inversion process, and it is simply returned as is.

  • What does the script imply by 'swapping' in the context of inverting a binary tree?

    -In the context of inverting a binary tree, 'swapping' refers to the process of exchanging the positions of the left and right children of each node in the tree, which is a key step in inverting the tree structure.

  • What is the final outcome of the inversion process as described in the script?

    -The final outcome of the inversion process, as described in the script, is a new binary tree structure that is the mirror image of the original tree, with all left and right children of the nodes swapped.

  • Does the script provide any tips or tricks to make the inversion process easier?

    -The script suggests understanding the basic structure of a binary tree and following a recursive approach to invert the tree. It also emphasizes the importance of correctly identifying and swapping the left and right children at each node.

Outlines

00:00

😀 Introduction to Inverted Binary Tree

The script starts with a welcome to the Paint You Bill Connect to the Question Series, addressing question number 226 which involves inverting a binary tree. The explanation begins with a basic understanding of what a binary tree is, highlighting that it can have a maximum of two nodes, referred to as children. It emphasizes that a binary tree must not have more than two children per node, and if a tree has more than two, it's not a binary tree. The concept of left and right nodes is introduced, explaining that if a tree node has a left child, it will not have a right one, and vice versa, unless it has no children at all. The script then delves into the complexity of inverting a binary tree, which involves swapping the left and right children of each node, and explains the process of inverting the tree from the root down to the leaves.

05:08

😉 Inversion Process and Algorithm

This paragraph continues the discussion on inverting a binary tree, focusing on the algorithmic approach. It describes the recursive function that is used to invert the tree, starting with the root and moving down to the leaves. The script explains that if the root's left or right child is null, it should return null, and if a node is encountered, it should return the node itself. The function calls are described in detail, showing how the inversion process involves swapping the left and right children at each node level. The paragraph also discusses the return values at each step of the recursion and how the final inverted tree is constructed. It ends with an example of how the swapping is done at the root level and how the final tree looks after the inversion process.

10:08

🎓 Conclusion and Final Tree Structure

The final paragraph wraps up the video script by summarizing the process and showing the final structure of the inverted binary tree. It explains how the root element remains the same throughout the process and how the left and right children are swapped to achieve the inverted tree. The script provides a clear example of how the final tree looks with the root element, and the left and right children swapped. It concludes with an encouragement for viewers to like the video, subscribe to the channel, and stay tuned for more content.

Mindmap

Keywords

💡Binary Tree

A binary tree is a type of tree data structure in which each node has at most two children. In the video, the concept of binary trees is introduced as the foundation for understanding the main topic of the video. The script mentions that a binary tree can have a maximum of two nodes, referred to as 'left' and 'right'.

💡Invert

In the context of the video, 'invert' refers to the process of reversing the structure of a binary tree. This involves swapping the left and right children of each node in the tree. The script explains how to invert a binary tree by recursively calling a function on the left and right subtrees and then swapping the left and right children of the root.

💡Root

The 'root' is the topmost node in a binary tree. It serves as the starting point for traversing and manipulating the tree. The script frequently refers to the root node when explaining how to invert the tree - the root's left and right children are swapped, and the same process is applied recursively to the root's children.

💡Left Child

The 'left child' is the node in a binary tree that is connected to its parent node on the left side. The video discusses how the left child of a node is identified and manipulated during the tree inversion process. For example, the script mentions that if a node has a left child, it will be swapped with the right child when inverting the tree.

💡Right Child

The 'right child' is the node in a binary tree that is connected to its parent node on the right side. Similar to the left child, the right child is also swapped with the left child during the tree inversion process. The script provides examples of how the right child is used and modified when inverting the tree.

💡Depth-First Search (DFS)

Depth-First Search (DFS) is a tree traversal algorithm that explores as far as possible along each branch before backtracking. In the video, the script mentions using a DFS method to traverse the binary tree and invert it node by node. DFS is essential for the recursive approach taken to invert the tree.

💡Null

In the context of binary trees, 'null' refers to the absence of a child node. The script discusses handling null nodes during the tree traversal and inversion process. For example, if a node's left or right child is null, it is not swapped, and the function returns the node as is.

💡Swap

Swapping refers to the process of exchanging the left and right child nodes of a binary tree node. The video's main focus is on how to perform this swap at each node to achieve the overall inversion of the tree. The script provides step-by-step instructions on when and how to swap the children during the DFS traversal.

💡Recursive Function Call

A recursive function call is when a function calls itself in its definition to solve a smaller instance of the problem. The video explains how the tree inversion process involves making recursive calls to invert the left and right subtrees before swapping the children of the current node. Recursive calls are a key technique used in the algorithm presented.

💡Traversal

Traversal refers to the process of visiting each node in a tree data structure in a specific order. The video discusses using depth-first traversal to visit each node of the binary tree and perform the inversion operation. Traversal is a fundamental concept for understanding how the tree inversion algorithm works.

💡Node

A 'node' is the basic unit of a binary tree, consisting of a value and pointers to its left and right children. The script frequently refers to nodes when explaining the structure of the binary tree and how the inversion process modifies the tree by swapping the children of each node.

Highlights

Introduction to the topic of binary trees and the task of inverting a binary tree.

Explanation of what a binary tree is and its properties, specifically the maximum of two nodes.

Description of a binary tree's structure, with examples of valid and invalid configurations.

Clarification on the concepts of left and right nodes in a binary tree.

Discussion on the limitations of a binary tree, such as not having more than two children per node.

Explanation of how to identify the left and right nodes in a binary tree.

Introduction to the process of inverting a binary tree, emphasizing its complexity.

Step-by-step guide on how to invert a binary tree, starting from the root.

Illustration of the inversion process using a visual example.

Details on swapping nodes during the inversion of a binary tree.

Explanation of the recursive approach to inverting a binary tree.

Discussion on the base case of the recursion when dealing with null nodes.

Presentation of a code example that demonstrates the inversion of a binary tree.

Explanation of the code logic and how it handles the inversion process.

Demonstration of the code execution and its outcome.

Summary of the key points covered in the video about binary trees and their inversion.

Encouragement for viewers to like, subscribe, and watch more on the channel.

Transcripts

play00:00

हाय वेलकम को पेंट यू बिल कनेक्ट तू डू

play00:01

क्वेश्चन सीरीज और यहां पर हम अटेंप्ट

play00:03

करने वाले हैं क्वेश्चन नंबर 226 जो की है

play00:06

इनवर्ड बाइनरी ट्वीट आपको एक बाद भी दिया

play00:09

हुआ है और आपको उसको उल्टा करना है ठीक है

play00:12

जैसे आप अगर खुद को मिरर में देखते हो तो

play00:16

आप वहां पे उल्टा पाते हो खुद को तो

play00:18

बिल्कुल से यहां पे मेरे को करना है तो एक

play00:21

इजी लेवल डिफिकल्ट है और कोर्स काफी

play00:24

ज्यादा है क्योंकि क्वेश्चन काफी अच्छा है

play00:26

सबसे पहले बेसिक से स्टार्ट करते हैं

play00:28

बाइनरी ट्री क्या होता है बाइनरी ट्री एक

play00:30

टाइप ऑफ ट्री होता है जिसमें आपके पास जो

play00:32

मैक्सिमम नोड होती है ट्री में वो दो होती

play00:34

हैं मतलब आपके पास दो से ज्यादा नोट नहीं

play00:36

हो शक्ति जैसे आप आप अगर यहां पे बाइनरी

play00:39

ट्री बनाते हो तो या तो उसकी दो नोट होगी

play00:41

या उसमें एक नोट होगी या फिर एक भी नहीं

play00:45

होगी ठीक है जैसे यहां पे इस वाले नोट की

play00:48

एक भी अपलोड नहीं इसका एक भी छल नहीं है

play00:50

तो मैक्सिमम दो चाइल्ड हो सकते हैं दो से

play00:53

ऊपर नहीं हो सकते अगर आपके पास यहां पर एक

play00:55

ट्री है जिसके आगे जैसे यहां पे इसके तीन

play00:58

चाइल्ड है तो ये बाइनरी नहीं है और ये

play01:00

यहां पर

play01:03

क्या होता है

play01:06

जिवन होता है तो आपको एक उसके लेफ्ट में

play01:09

होती है और आपको यहां पर उसकी राइट होती

play01:12

है क्योंकि

play01:13

यहां पे आपके पास दो ही नो है तो लेफ्ट

play01:16

वाली यहां पे नोट होती है राइट वाली यहां

play01:19

पर

play01:22

बाइनरी नहीं होता तो उसमें आपके पास एक

play01:24

आपके पास वहां पे लेफ्ट और राइट का

play01:27

कॉन्सेप्ट नहीं चला क्योंकि वहां

play01:29

पे हो शक्ति है यहां पर मैंने कर नोट बनाई

play01:31

है बट मल्टीपल इससे भी ज्यादा हो शक्ति है

play01:33

तो यहां पर अगर आपको चाइल्ड में कुछ भी

play01:36

यहां पे करना है तो आपको यहां पे फोन लूप

play01:38

का ही उसे करना पड़ता है क्योंकि आपको

play01:39

यहां पे आइडिया नहीं होता की आपके पास

play01:41

यहां पे कितने चाइल्ड है कितनी नोट्स है

play01:44

यहां पर आपको पता है यहां पर आपको पता है

play01:46

दो ही नोट होगी या तो लेफ्ट होगा या राइट

play01:49

होगा जैसे यहां पे एक भी नोट नहीं है तो

play01:51

इसका लेफ्ट भी नल है और इसका राइट भी ना

play01:53

नल है ठीक है यहां पे लेफ्ट में वैल्यू है

play01:56

लेकिन इसका जो राइट है वो यहां पे नल है

play01:58

आपको पता है की दो से ज्यादा होंगे ही

play02:00

नहीं

play02:01

तो जब भी आपको

play02:02

उसके लेफ्ट जिवन होगी और आपको यहां पे

play02:05

उसकी राइट नोट दी हुई होगी आपको यहां पे

play02:06

क्या कम करना है इस नोट को आपको यहां पे

play02:08

जो ट्री है पूरा उसको यहां पे इनवर्ट करना

play02:11

है इनवर्ट कैसे करना है आप अगर यहां पर एक

play02:14

चीज देखोगे कैसे करना है रूट आपका बिल्कुल

play02:18

से रहेगा आप यहां पर देखो जो भी आपको यहां

play02:20

पे मैंने आपको यहां पे जो आर्गुमेंट है

play02:26

रूट कहानी नहीं जाएगा रूट आपका पहले भी से

play02:29

था और उसके बाद भी से है आप अगर यहां पर

play02:32

देखो तो ये जो आपका सब ट्री है

play02:37

ये पूरा सब ट्री आपका इधर आया है ये पूरा

play02:40

सब ट्री आपका यहां पे

play02:43

ठीक है और जो यह वाला सॉफ्टवेयर आपका

play02:47

लेफ्ट में ए चुका है इसके बाद अगर आप यहां

play02:49

पर देखो तो रूट से है इस वाले सब ट्री

play02:51

लेकिन जो नोट है वो भी आपस में सोया है

play03:00

उसको भी स्वैप करना है और उसकी जो नोट्स

play03:03

है उनको भी स्वैप करना है तो हमें यहां पर

play03:06

ये कम करना है ठीक है तो आई होप क्लियर

play03:09

हुआ होगा की आप यहां पर देखो ये जो पूरा

play03:11

जो यहां पे ये वाला सब फ्री है ये उठाके

play03:13

यहां पे इस वाले तरीके राइट हैंड साइड

play03:17

यहां पे ए चुका है और फिर ये वाली जो

play03:19

नोट्स है इनको भी यहां पे स्वाद किया गया

play03:22

ठीक है तो इसका रूट यहां पर

play03:29

देखोगे तो इसका रूट भी यहां पर स्वाइप हुआ

play03:32

है

play03:34

अगर आप इसको

play03:43

लेकिन मोटा मोटा अगर आप देखो तो इस पूरे

play03:46

सब ट्रिक उठा के आपको राइट हैंड साइड मूव

play03:48

करना है

play03:49

क्वेश्चन इजी है ठीक है क्वेश्चन मुश्किल

play03:53

नहीं है अगर आप यहां पर एक चीज देखो की यह

play03:55

क कैसे कर रहा है रिकजन से ये क्वेश्चन

play03:58

बहुत आसन है कुछ भी नहीं करना आपको इसमें

play03:59

तो एक कम करते हैं सबसे पहले यहां पे जो

play04:03

कोड है इसका वो देख लेट हूं उसके बाद फिर

play04:06

इसको समझाऊंगा की यहां पे हो क्या रहा है

play04:08

क्योंकि बिना कोड के इसको समझना बहुत

play04:10

मुश्किल हो जाएगा तो सपोज सबसे पहले रूट

play04:13

अगर आपने यहां पे नल है तो यहां पे कोई

play04:14

नोड को रिटर्न करना है नल को रिटर्न नहीं

play04:17

कर सकता मैं मेरे को एक नोट को भी रिटर्न

play04:19

करना है यहां पे तो मैंने यहां पे रूट को

play04:21

रिटर्न किया उसके बाद मैं यहां पे लगाने

play04:23

वाला हूं डेप्थ पर सर्च डीएफएस मेथड का

play04:26

मैं यहां पे उसे करने वाला हूं और मैं

play04:28

यहां पे इस वाले फंक्शन को यहां पे मैं कल

play04:30

करने वाला हूं ठीक है और विकर्ण ये वाला

play04:33

फंक्शन कल होगा तब तक कल होगा जब तक मैं

play04:35

अपने आखिरी जो लेफ्ट ओवरलोड है मेरा जो और

play04:38

वाला है उसको मैं हिट ना कर जाऊं और यहां

play04:41

पर इसको स्टोर कर लेना है आपके लेफ्ट के

play04:44

अंदर

play04:46

ठीक है

play04:50

जहां पर आपका रूट का राइट है वो होगा उसके

play04:54

बाद अब यहां पर क्या है रूट का मैंने

play04:57

लेफ्ट निकाल लिया रूट का राइट निकाल लिया

play05:07

मेरे पास यहां पे थ्री भी है तो दोनों को

play05:09

मेरे को बस स्टॉप करना है ठीक है बस इतना

play05:12

सा कम कम करना है मतलब की स्वैप कैसे करना

play05:14

है रूट के लेफ्ट में

play05:20

ठीक है और रूट के राइट में

play05:33

हो क्या रहा है ठीक है तो हां एक्सेप्ट हो

play05:37

चुके हैं सबमिट करके देख लेते हैं तो

play05:40

1 मिनट लेकिन लगेगा बस और आप यहां पे देखो

play05:43

बिट्स 100% जीरो मिले सेकंड इसमें लिए हैं

play05:46

यहां पे और ये लेकिन कम कैसे कर रहा है

play05:49

ठीक है ये जो मेरे यहां पे कोड है ये चल

play05:51

कैसे रहे इसी एग्जांपल से तो सबसे पहले

play05:54

क्या है की जो रूट है मेरा उसमें सब कुछ

play05:57

फोर है ये जो रूट है यहां पे इसमें 4 है

play05:59

क्योंकि सबसे पहले मेरे को यहां पे रूट

play06:01

एलिमेंट जिवन है तो रूट में फोर है

play06:04

सबसे पहले ये वाला फंक्शन यहां पे कल होगा

play06:07

यहां पे ये वाला फंक्शन यहां पे कल किया

play06:10

विद फोर ठीक है इसमें मेरा फोर फटा हुआ है

play06:12

इन शब्द फंक्शन आपको कल हुआ रूट

play06:15

के पास इनवर्टर रूट का लेफ्ट कौन होगा

play06:40

तो आप यहां पर

play06:54

कंप्लीट

play06:56

हो गया अब वापस आएंगे वापस आएगा यहां पे

play07:00

इनवर्ट प्रिपेयर्ड रूट का लेफ्ट कल होगा

play07:02

रूट का लेफ्ट जो की यहां पे ना लेने तो ये

play07:05

वापस जाएगा और यहां पे रूट आपका यहां पे

play07:07

नल है ठीक है तो रिटर्न कर देगा यहां पे

play07:10

रूट को वापस आएंगे हम यहां पे इस वाले

play07:11

फंक्शन पे इंवॉल्वड वन पे और अब इसकी

play07:14

नेक्स्ट लाइन यहां पे एग्जीक्यूट होगी जो

play07:16

की अगर रूट का राइट रूट का राइट भी यहां

play07:18

पे नल है तो रूट का राइट भी नल है तो यहां

play07:22

पर आप देखो तो रूट रूट का राइट भी यहां पर

play07:26

रिटर्न हो जाएगा स्वॅपिंग होगी नल और नल

play07:29

में यहां पे स्वॅपिंग होगी रूट का लेफ्ट

play07:40

वापस जाएगा तू के पास तू के पास आया तो

play07:43

रूट में इस टाइम पर तू पड़ा हुआ है रूट

play07:45

में इस टाइम पर यहां पर तू पढ़ा हुआ है तो

play07:47

तू का लेफ्ट क्या था तू कलेक्ट यहां पे वन

play07:49

है तो लेफ्ट में यहां पे वन ए जाएगा तू का

play07:52

राइट यहां पे थ्री है तो राइट में यहां पे

play07:54

थ्री ए जाएगा हम हमारी कल इस टाइम पे यहां

play07:56

पर ठीक है यहां पर है लेफ्ट में वन पड़ा

play08:00

है राइट में यहां पे थ्री पड़ा है लेफ्ट

play08:01

में यहां पे वन ए गया राइट में यहां पे

play08:02

थ्री ए गया रूट में यहां पे तू पड़ा हुआ

play08:04

है रूट का लेफ्ट को आप राइट से असाइन कर

play08:06

रहे हो रूट के लेफ्ट राइट को आपको राइट से

play08:09

साइन कर रहे हो तो इसको आप यहां पे थ्री

play08:11

से साइन कर रहे हो इसको आप यहां पे वन से

play08:13

साइन करें तो इसकी आपने यहां पे शॉपिंग कर

play08:15

दी और रिटर्न कर रहे हो आप रूट को तो वापस

play08:17

जा रहे हो आप यहां पे फोर के पास और

play08:20

ये चला जाएगा ठीक है फोर के पास आप आए हैं

play08:23

यहां पे रूट में आपका फोर बड़ा है रूट के

play08:25

लेफ्ट में आपका क्या है रूट के लेफ्ट में

play08:27

आपको यहां पे तू पड़ा हुआ है और तो यहां

play08:29

पे क्या हुआ की रूट के लेफ्ट में तो आपको

play08:31

यहां पे तू पड़ा हुआ है

play08:33

ये वाली कल आप यहां पे कंप्लीट हो जाएगी

play08:53

सेवन के लेफ्ट को ये यहां पे कल करेगा

play08:56

सेवन के लेफ्ट में क्या है सिक्स है तो

play08:58

इनवर्ट आपका कल हो जाएगा विद सेक्स ठीक है

play09:01

इनवर्टर ये आपका कल हो गया विद्रोह रूट

play09:03

करें रूट आपका यहां पे नल नहीं है तो ये

play09:06

वापस आएगा यहां पे इनवर्ड ट्री में रूट का

play09:08

लेफ्ट कल करेगा जो की यहां पे नल है और

play09:10

व्हाट ट्री में रूट का राइट कल करेगा जो

play09:12

की यहां पे नल है दोनों को स्वाद करेगा नल

play09:13

और न आपस में आप होंगे रिटर्न हो जाएगा

play09:15

रूट जो की यहां पे सिक्स है तो सिक्स यहां

play09:17

से ब्रिटेन हो के वापस ए जाएगा यहां पे 7

play09:19

के पास 7 जब था तो आपने यहां पे रूट का

play09:22

लेफ्ट कल किया था जो की सेक्स था आप यहां

play09:24

पे रूट के राइट को कल करोगे तो ये कल हो

play09:26

जाएगी आपके पास यहां पे रूट की राइट के

play09:28

पास रूट का राइट जो है वो यहां पे आपका 9

play09:31

है तो ये फिर से कल हुआ रूट यहां पे आपका

play09:34

9 है ठीक है इस कैसे में रूट यहां पे आपका

play09:37

नाइन है इनवर्टर में रूट का लेफ्ट

play09:39

दोनों में शॉपिंग

play09:43

तो ये वापस आपके सेवन के पास तो यह दोनों

play09:46

लाइन यहां पे इस कैसे में एग्जीक्यूट हो

play09:48

चुकी हैं दोनों लाइन यहां पे इस कैसे में

play09:50

एग्जीक्यूट हो चुके हैं अब ये स्वैप करेगा

play09:51

रूट में इस कैसे में आपका यहां पे सेवन

play09:53

पड़ा है क्योंकि नाइन आपका ब्रिटेन हो

play09:55

चुका था तो 7 है 7 का लेफ्ट और सेवन का

play09:58

राइट आपस में यहां पे स्वाद करेंगे तो ये

play10:01

जो यहां पे आपका सिक्स है नाइन हो जाएगा

play10:03

और जो नाइन है ये आपका यहां पे सिक्स हो

play10:04

जाएगा ठीक है और ब्रिटेन हो जाएगा यहां से

play10:07

रूट मतलब 7 यहां से इस कैसे में रिटर्न हो

play10:10

जाएगा और वापस पहुंच जाएंगे हम यहां पे

play10:11

फोर के पास तो आप यहां पे देखो जब रूट

play10:14

यहां पे फोर था तो उसे कैसे में हमने

play10:15

लेफ्ट को कल किया था लेफ्ट यहां तक चला

play10:17

गया था नीचे तक लेफ्ट जब ऊपर वापस 4 के

play10:20

पास आया तो हमने इनवर्ड ट्री में रूट के

play10:23

राइट को कल किया जो की यहां से नाइन तक

play10:25

गया था ठीक है अब वापस हम यहां पे फोर तक

play10:27

ए चुके हैं तो फोर के लिए जब रूट एलिमेंट

play10:30

आपका यहां पे फोर है क्योंकि 7 आपके

play10:32

रिटर्न हो चुका है तो स्टॉक मैं आपसे

play10:36

फोर है उसे कैसे में ये रूट का लेफ्ट जो

play10:40

की यहां पे तू है और रूट का राइट जो की

play10:43

यहां पर 7 है अब हम दोनों की शॉपिंग करेगा

play10:46

तो रूट के लेफ्ट में आप यहां पर राइट को

play10:48

साइन कर रहे हो

play10:51

[संगीत]

play10:56

रूट सब नोट आपका ये पूरा इधर ए जाएगा और

play11:00

ये आपका इधर ए जाएगा तो जो आपका फाइनली

play11:02

बनेगा वो ये बनेगा

play11:06

कोई और एग्जांपल भी है क्या इसमें तो

play11:09

सिंपल दिया हुआ है ठीक है तो

play11:13

अगर आपको वीडियो पसंद लाइक करना ठीक है

play11:15

चैनल पर नए हो सब्सक्राइब करना और थैंक यू

play11:17

सो मैच पर वाचिंग बाय

Rate This

5.0 / 5 (0 votes)

Related Tags
Binary TreesData StructuresInversion TutorialProgramming ConceptsAlgorithm ExplanationComputer ScienceEducational ContentCoding TechniquesTechnical LearningSoftware Development