00:00Next just traversal की बात करेंगे, इसका नाम है in order traversal, यहाँ पर in का मतलब होता है in
00:06between, इसको in order traversal इसलिए का जाता है क्योंकि pre order में root पहले आ रही थी, in order
00:11में root बीच में आती है, यानि in between आती है, इसके भी 3 rules है, इसके 3 rules कहते
00:17हैं कि पहले left subtree को print करवा लो, फिर root को print करवा लो, फिर right subtree को
00:21print करवा लो, तो यहाँ पर, क्या rule में change आया, पहले root होती थी, फिर left होता था, फिर
00:27right होता था, यहाँ पर root बीच में आ गई है, मतलब in between आ गई है, तो पहले left
00:32तो हमारा उपर ही रहेगा, मिशा right से, पर root in between आ गई है, फिर हमारा right subtree आ
00:37गया है, इसको example की form में solve अगर करें, �
00:40तो अपने tree में हम root पर अगर हैं, मतलब one पर हैं, तो पहले one को print नहीं करवाना,
00:45पहले one के पूरे left subtree को print करवाना है, तो one के left subtree में two, four, five आ
00:50जाते हैं, तो आ गई हम two पर, two को भी अभी print नहीं करवाना, पहले two के पूरे left
00:55subtree को print करवाना है, तो two के left subtree में आ जाता है four, तो
00:59So we got 4 to print 4.
01:01If we print 4 is not on the right 4, then we print 4 out.
01:07So now we can print 4 into 4.
01:11After that we print 4 right subtree.
01:14So in 4 right subtree we will not print 2.
01:17Then we will go back to 2.
01:182 and left subtree is now printed where it was just 4.
01:22Now we can print 2 to print.
01:26So the first we will print 5.
01:28now we will come to 5
01:29we will go left subtree
01:30so left child null
01:31so print we will go 5
01:33we will go left
01:345 to right
01:34right child
01:35so we will go 2
01:36now 2
01:38we will go 1
01:40so now 1
01:41left subtree
01:42print
01:43so 1
01:44we will go to right subtree
01:48so 3
01:493
01:493
01:52left subtree
01:54so now 3
01:55we can print 6
01:57now we print 6
01:58right subtree
02:00before we print left subtree
02:02that is null
02:04then we print right subtree
02:06that is null
02:07from 3 to 3 to 1
02:09from this way
02:13this sequence
02:14we call in order sequence
02:16and in order sequence
02:19we have same time complexity
02:21because every node
02:22one time complexity
02:24will come
02:25if we want to write in order traversal
02:29we can make a function
02:31public static void
02:34in order
02:37node
02:41node
02:41root
02:42here we have to follow the same rules
02:44first rule
02:46was to print left subtree
02:48so in order
02:50call
02:51root
02:52then we print
02:56root
02:58data
02:59call
02:59root
03:01root
03:02root
03:03root
03:03root
03:03root
03:10root
03:11root
03:12root
03:12root
03:12root
03:15root
03:16return
03:17this is our in order traversal
03:205 lines
03:21simple code
03:22now
03:22we will call in order
03:28and the output
03:31will be there
03:32which we have analyzed
03:33in order
03:36425136
03:37root
03:37root
03:37root
03:37root