00:00Now, for build3 code, we have already stored our pre-order sequence in the name of this array.
00:07First of all, we have to create a node class.
00:09Static class node
00:15We store our data
00:17A left child node
00:20And a right child node
00:22We create a constructor in which we have our data.
00:27This.data is equal to data
00:30This.left is equal to null
00:34This.right is equal to null
00:37We have created our node class
00:41Next, we are going to create our binary tree class
00:44So, another static class
00:49Binary tree
00:50In this function, we call public static node
00:58Build tree
01:00In the build tree, we will take our nodes in the array
01:05And here, a node will return
01:08This means that we will return our root root
01:11Now, what do we need to do?
01:20We need to create a node
01:21We need to create a node
01:23We need to create a node
01:25We need to create a node
01:25First of all, we need to create an index variable
01:28Static
01:28Int
01:28Index
01:29Is equal to minus 1
01:30This is static
01:32Because in every recursion
01:34We want to create our index every time
01:36If we were 1
01:37If we were 1
01:38Then we were 2
01:38Then we were 3
01:39Then we were 4
01:47If we were 1
01:49Then we need to create a node
01:55We need to create our index
01:55We need to create a node
01:56We need to create a node
02:09we will make a null node
02:10but the left child and the right child
02:12don't need to make null
02:14if there is no null
02:16then we need to make a new node
02:19new node is equal to
02:22new node of
02:25nodes
02:26at index
02:29so
02:30whatever
02:31we will make a new node
02:33we will make a new node
02:35then our process
02:37we will make a node
02:38then we will make a left sub-tree
02:40and then the right sub-tree
02:44we will make a new node
02:47that is going to be equal to
02:50build tree
02:51we will call the nodes
02:53we will assume that
02:55build tree is recursive function
02:56so build tree
02:59we will make a left sub-tree
03:02we will add it
03:02we will add it
03:03this is equal to
03:05it is working
03:07now we will do the same thing
03:08for the right sub-tree
03:10dot right is equal to
03:12build tree nodes
03:14here we will create our right sub-tree
03:17and finally
03:18we will return new node
03:22new node
03:22we have created the new node
03:23we have created the left sub-tree
03:24and finally
03:26we have returned to our function
03:29this way our whole tree is going to be built
03:32in the main function
03:33we will do something
03:34the first thing we will do
03:37the binary tree
03:39tree is equal to new
03:42binary tree
03:45now
03:46we will call the tree
03:48build tree
03:48in which we will pass our nodes
03:51data
03:51here we will return
03:53our tree
03:55root
03:55verify
03:57for us
03:57we will print the tree
03:58root
04:00now
04:01what we will tell
04:02this pre-order sequence
04:04when we send
04:05which tree is going to be
04:07this diagram
04:07we have already
04:08built
04:09in the root
04:10we will know
04:11which data store
04:12is going to be 1
04:13and we will do it
04:14in this recursive function
04:16we will save
04:18and run
04:19in the output
04:20we have 1
04:20because the root
04:21was 1
04:22in the output
04:24we have 1
04:25so we will write code
04:27to build our tree
04:29if we have pre-order sequence
04:30and the whole code
04:32is going to be big of n
04:35more cap
04:35as possible
04:35as possible
04:36as possible
04:36we will touch our gallery
04:37details
04:38we have to fill
04:38we will contact our
04:42mattes
04:42to fill
04:42in the outreach
04:45in the source
04:45we can
04:45use tool