It was a little bit confusing what prateek bhaiya told in this lecture!

Let me ask you something, suppose I am given a pre-order traversal like 5,10,8,12,20,16,25…then we can make tree which will definitely not be a skewed tree. But if I am given a preorder traversal like 1,2,3,4,5,6,8, then this tree will definitely be a skewed tree as its inorder will also be the same. So, can you please guide as per the requirements of this lecture or can you provide me the code?

hey, your query is not quite clear to me, anyway, I ma giving an explanation on how to do it
to make a bst from it’s preorder traversal
First element is the root
now find the last element in the array which is smaller than the first element
that will mark the end of the left subtree and all the nodes beyond will be right subtree
follow the same steps recursively for the right subtree and the left subtree


My question is, suppose of I am having a pre order traversal 1,2,3,4,5,6,8. Now, what kind of tree will be formed by this traversal - skewed tree??

yes this will be a skewed tree