-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Closed
Labels
enhancementNew feature or requestNew feature or requeststaleAuthor has not responded to the comments for over 2 weeksAuthor has not responded to the comments for over 2 weeks
Description
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
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requeststaleAuthor has not responded to the comments for over 2 weeksAuthor has not responded to the comments for over 2 weeks