BINARY TREE CONSTRUCTION WITH INORDER AND PREORDER TRAVERSALS - DATA STRUCTURES

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello friends welcome back to our channel so the previous session we have seen the construction of an expression tree so in today's session we'll go with the construction of a tree if with the help of the pre-order traversal and in order traversal yes so here we will be having the in order and the pre-order so with the help of this in order and a pre-order we are supposed to find the thing so let us take an example here the pre-order traversal of the tree is a big see in order traversal of a 3d is me he and she so let us the let us assume these are the inputs we are having and based upon these inputs where we have to construct it tree so we know that pretty order means the pre-order traversal means first we have to visit the root then left then right this is the pre-order traversal so how these nodes will be visited let's do this another time cell first we have supposed to visit the left load and then followed by loop road and followed by right so this this is very good and from this inputs we know that if you are thrille the pre-order there will be the root element the first element will be the root element so here what is the only event obviously yeah will be the root node so let us construct it yeah will be the root and followed by left and right so Billy is I have to change see is a bike chain B is there left to change see is it my chain so with the help of it in order we are supposed to find which is the left child which is a right chain here there is a holy Poochie to knows once I left and however what is the right so if our inorder traversal or preorder traversal is having a more number of elements then with the help of in order we are supposed to find the next root okay so let us take one more example for with the more than three elements and further we will understand clearly right right so let us take this example so in this example we can find a moon of rough notes so with the help of a pre-order running order we are supposed to find the ring now so let us follow the same steps so from the pre-order we'll get the route more from the in order we get the right child and left shape so the same thing we are supposed to find now coming to the first one so let us find the preorder so with the help of the preorder the first movie we will find the route so in the preorder the first element is the moon so here yeah will be them even with them now we have to find the my children and left children so coming to the right children and left children that can be known with the help of in order so coming to the in order a is here so what are the elements left to the truth I left sub-tree and right to the root a right subtree so here these are the elements HD I be II have a means FC j G and there are five elements to the right and I am a left and for reference to the average J so in the five elements first again we have to find the root so to find in the root we have to take the help of pre-order traversal so in the preorder traversal we can find these at the left chain and these are the right change so the root of an of change is B and the root of right chain is C hope you understood this one okay because here in the preorder the first our group role is visited so the first road will be the root B is a root node season again see after B they are making four elements so heads be I and here also yes Jay G so we are we are supposed to find the left and right chains so here we know that B is a loop road so B is a so whatever the elements left to the B are we have to change so h di okay so HD I other left chain next E is energy right next similarly don't do this one series a move move so whatever the elements left to the scene yeah left chain so yeah is the left to chain and followed by J and G both are the right change in the HD I again we are supposed to find the root of this subject so in the HTV I preordered H D I D D is a root these are and from the inorder traversal de the left one is H right one is I and J and g j ng so from the pre-order J and G c2 elements GG so first one will be the root in the pre-order so G will be the who in the pre-order next J left sorry G pre-order G is a root and coming to the inorder see G is a root jay is on the left side yes so just this is a tree for the given in order and the preorder traversal just to follow the tool steps in order to find the route just observe the preorder traversal and you want to find the right subtree or left subtree or on the right chain of left child go with them in order in order traversal so in the previous session we have seen this in order and the preorder traversal is how to find this in order and a pre-order traversal right so I will just post the link in the description section just go through the link and then this process is easily understand so let us wind up here so hope you understood these sessions and if you are having any doubts regarding this construction pre-construction with in order and the preorder traversal so feel free to post your thoughts in the comment section so that definitely I will try to clarify all your dubs and if you really understood my sessions like magicians share my sessions with your friends and don't forget to subscribe to our channel thanks for watching thank you very much
Info
Channel: Sundeep Saradhi Kanthety
Views: 37,884
Rating: undefined out of 5
Keywords: sundeep, saradhi, kanthety, data structures, arrays, lists, stacks, queues, trees, graphs, primitive, non primitive, linear, non linear, linked lists, ds fundamentals, ds basics, nodes, structures, interview, placements, connection, parent, child, leaf node, sub tree, root node, tree terminology, TREES IN DATA STRUCTURES, complete binary, full binary, binary trees, TREE REPRESENTATION, inorder, preorder, postorder, tree traversals, left child, right child, BINARY TREE CONSTRUCTION
Id: S-I71Mtr2I0
Channel Id: undefined
Length: 9min 1sec (541 seconds)
Published: Sun Jul 21 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.