+1 Akshat
On 7/7/12, Akshat Sapra sapraaks...@gmail.com wrote:
There is no need to use any other data structure or sort the array one can
directly construct the BST from a given array by taking one element at a
time from the beginning and inserting into a BST.
--
Akshat Sapra
Under
There is no need to use any other data structure or sort the array one can
directly construct the BST from a given array by taking one element at a
time from the beginning and inserting into a BST.
--
Akshat Sapra
Under Graduation(B.Tech)
IIIT-Allahabad(Amethi Campus)
@Navin : Why r u sorting the array .. BST can be made using the preorder
traversal if null nodes are well defined in the given traversal.. Right??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/HQ_TvoKSLNgJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this
Vindhya - Navin is right because in case of BST, if you sort the preorder
array you will get inorder array. This means you already have information
about the inorder, if you given preorder/postorder/levelorder.
--
You received this message because you are subscribed to the Google Groups
^ Thank you! Mind discussing the algorithm please?
On Wed, Jul 4, 2012 at 7:06 PM, deepikaanand swinyanand...@gmail.comwrote:
code :-
http://ideone.com/O5yuo
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
thanks all
On Wed, Jul 4, 2012 at 10:57 PM, Navin Gupta navin.nit...@gmail.com wrote:
Given a pre-order traversal, we can sort it to get the inorde traversal.
Sorting the preorder is O( NLogN ).
Now as we know the ordering of elements is
Preorder - Root - Left Child - Right Child
@Navin
I dont think der is any need to sort the preorder traversal
given ...it will cost u more
as sorting take O(n log n ) and recursion alone will take O(n^2)
{mentioned in step 4 }
sO the overall complexity will be the sum of two..+ space of O(n) //to
store inorder traversal
--
You received