00:00Next, just reversal की बात करेंगे,
00:01इसको हम कहते है, post audit reversal.
00:04Pre होता था, पहले, in होता था,
00:06in between, post का मतलब होता है,
00:08बाद में, English में इसका मतलब होता है,
00:09कि बाद में, post something.
00:11तो यहाँ पर हमारी जो root है,
00:13वो सबसे बाद में आ जाती है.
00:15तो वही तीन rules, same रहेंगे.
00:17पहले left subtree को print करवा दो,
00:19यह है पहला rule.
00:20दूसरा rule है right subtree को print करवा दो.
00:22अब यहाँ पर जो root है,
00:23उसको हमें आखिर में print करवाना है.
00:25यह है तीसरा rule.
00:26इसको एक एक्जाम्पल से समझ लेते हैं.
00:28सबसे पहले हम अपनी root पर हैं, one पर,
00:30पर अभी root को print नहीं करवाना.
00:32पहले root के left subtree को print करवाएंगे.
00:34फिर उसके right subtree को print करवाएंगे.
00:37फिर root को print करवाएंगे.
00:38तो one से आए left subtree में two की तरफ,
00:40two को भी अभी print नहीं करवाना.
00:42फिर आएंगे फिर चार की तरफ.
00:44अब four का left subtree वो तो खाली है,
00:46right subtree notification
00:48right subtree void
00:585
00:595
01:00left tid
01:03right subtree
01:10right subtree
01:11here
01:11to date
01:122
01:13Sprint
01:15करवा देंगे अब 2 से वापस जाएंगे हम 1 की तरफ 1 का left
01:19sub tree cover हो गया है पर 1 का right sub tree बाकी है तो 1 के right
01:22sub tree में 3 पर जाएंगे 3 को print करवाने से पहले उसके left
01:26और right sub tree को print करवाना पड़ेगा 3 के left sub tree में कुछ
01:30भी नहीं है null values है 3 के right sub tree में क्या है 6 है 6
01:34को RICH को प्रिंट करवाने से पहले उसका left और right
01:36analyze करते हैं left child null right child null यानि 6 को
01:39print करवा सकते है 6 को हमने print करवा लिया 6 को जैसे
01:43ही print करवा कर वापस 3 पर गए 3 का left sub tree भी
01:59So in last we have our root node, or our one, printed it.
02:04This sequence of 4, 5, 2, 6, 3, 1 is called a post order sequence
02:10because the root is in last.
02:13And the time complexity of this is our big of n
02:16because the linear time will go to one node.
02:20Now write the function of our tree for post order traversal
02:23so it will be public static void post order node root
02:31We have to convert those 3 rules in which we have to convert in code
02:33so first the rule was that we have to print the root node
02:36the left subtree.
02:39So what do we do?
02:40We will call the post order root left
02:44We are using that recursion property
02:47which we thought intuitively that recursive function
02:50we will do everything we have to do
02:51so we will print the post order
02:53to the root left subtree
02:57Now the second rule was to print the root right subtree
03:01so we will call the root right
03:06Now we have to print the root data
03:10Now we have to print the root data
03:11here we will write the output statement
03:15root data
03:18which we have to do
03:19If our root node is null to equal
03:23we have to reach the leaf
03:25or our tree is left
03:26then we can simply print it
03:28so we will do return return
03:30so we will do it
03:31and save it
03:32so this is our post order function
03:34here we will call the post order
03:37and save it
03:41and run it
03:41after this
03:43output
03:43we have to do that
03:43which we have analyzed
03:444, 5, 2, 6, 3, 1
03:47In this way
03:48we will use the post order
03:49reversal
03:50in binary trees
03:51Next
03:52we are going to talk about
03:54this
03:54level order
03:55reversal
03:56In level order reversal
03:57we have to print data
03:59level wise
04:00like
04:01in binary tree
04:02level 1
04:03is 1
04:04then level 2
04:05is 2
04:06and 3
04:07and level 3
04:08is 4
04:105
04:10and 6
04:11so our data
04:12should print in this form
04:141
04:142
04:153
04:154
04:155
04:166
04:16where after 1
04:17we have a next line
04:18and after 2
04:193
04:19we will see that
04:23the first level data
04:24is printed
04:24and then the second level data
04:26and then the third level data
04:28Now
04:29to do this
04:29level order reversal
04:32we use another
04:32data structure
04:33name
04:34that data structure
04:36name