C-Plus-Plus
C-Plus-Plus copied to clipboard
[FEATURE] Construct Binary Search Tree from Preorder Traversal
Detailed description
Construct Binary Search Tree from Preorder Traversal.
Problem Statement: Given an array of integers preorder, which represents the preorder traversal of a BST (i.e., binary search tree), construct the tree and return its root.
Test Case: Input: preorder = [8,5,1,7,10,12] Output: [8,5,10,1,7,null,12]
Context
This is a very famous and standard problem asked in most of the interviews. This will enhance the logical thinking of the programmer.
Possible implementation
A binary search tree is a binary tree where for every node, any descendant of Node.left has a value strictly less than Node.val, and any descendant of Node.right has a value strictly greater than Node.val.
A preorder traversal of a binary tree displays the value of the node first, then traverses Node.left, then traverses Node.right.
Additional information
No response
I would also like to contribute a solution to this problem.
Hello Maintainer, I want to solve this problem ,please assign this issue to me.
Hello, Can you please assign this issue to me? Thanks in advance :)
Hi sir/mam can you please assign this issue to me , i think i can do it very well
Hello sir! I am already done with this issue please assign me so I can handover you the code
hello sir can you assign this issue to me i want to solve this issue.
I would like to contribute to the algorithm. Please assign this task to me.
This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!