Re: [algogeeks] Re: [Amazon] : constructing fully binary tree

2012-08-07 Thread Navin Kumar
@shiv narayan: we are not going to create exact tree as original. You have to build full binary tree where as original tree may / may not be full binary tree. On Wed, Aug 8, 2012 at 2:31 AM, shiv narayan wrote: > Preorder and postorder do not uniquely define a binary tree. > so question is vague

[algogeeks] Re: Elevator system design - Which ( Design Pattern, Class, DS) will be used

2012-08-07 Thread Subhransu
Anyone has any hint ? On Mon, Aug 6, 2012 at 11:32 PM, Subhransu wrote: > As this might be discussed many times in this thread but cant able to > trace back the archived emails, so reiterating > > If i have to design a elevator system(for simplicity let's say 6 elevator), > 1. How will be my *cl

[algogeeks] Re: [Amazon] : constructing fully binary tree

2012-08-07 Thread shiv narayan
Preorder and postorder do not uniquely define a binary tree. so question is vague . On Sunday, 15 July 2012 01:41:15 UTC+5:30, Navin Kumar wrote: > > Given Preorder and postorder traversals of a tree. Device an algorithm to > constuct a fully binary tree from these traversals. -- You received t

[algogeeks] Re: [Amazon] : constructing fully binary tree

2012-08-07 Thread shiv narayan
Preorder and postorder do not uniquely define a binary tree. so question is vague . On Sunday, 15 July 2012 01:41:15 UTC+5:30, Navin Kumar wrote: > > Given Preorder and postorder traversals of a tree. Device an algorithm to > constuct a fully binary tree from these traversals. -- You received t

Re: [algogeeks] converting binary tree to BST

2012-08-07 Thread Navin Kumar
1. Convert your Binary tree into doubly linked list. 2. Sort the linked list using merge sort 3. Build BST using doubly linked list by each time selecting middle node and recursively calling left part of linked list and right part of linked list. On Tue, Aug 7, 2012 at 10:23 PM, vaibhav shukla wro

[algogeeks] Re: [Amazon] : constructing fully binary tree

2012-08-07 Thread harsha
Can u please explain the algorithm. is n't inorder always needed to construct a unique tree? On Sunday, July 15, 2012 1:41:15 AM UTC+5:30, Navin Kumar wrote: > > Given Preorder and postorder traversals of a tree. Device an algorithm to > constuct a fully binary tree from these traversals. -- Y

[algogeeks] converting binary tree to BST

2012-08-07 Thread vaibhav shukla
Hi all The problem is to convert a binary tree into Binary Search Tree My approach was : 1. Store the Inorder traversal of BT in an array. 2. Sort the array in ascending order. 3. Again do inorder traversal and write the Node's data from array one by one. This approach takes O(n) extra space.

Re: [algogeeks] DE Shaw written test

2012-08-07 Thread algo bard
The problem boils down to this: http://www.geeksforgeeks.org/archives/6463 On Tue, Aug 7, 2012 at 1:59 PM, manish patel wrote: > This is maximum sub-array problem. Nice explaination is given in CLRS - > "Introduction to algorithms " Pg 68, ch-4 3rd edition > > > On Tue, Aug 7, 2012 at 11:00 AM,

Re: [algogeeks] Re: Sort 7 numbers of 4 digits each

2012-08-07 Thread SHOBHIT GUPTA
check dis link http://www.1771.in/how-many-comparisons-are-needed-in-worst-case-if-we-have-to-sort-7-numbers-each-of-4-digit.html On Tue, Aug 7, 2012 at 9:38 PM, Sambhavna Singh wrote: > Its radix sort.. > > > On Fri, Aug 3, 2012 at 4:39 PM, Navin Gupta wrote: > >> I think the no. of comparison

Re: [algogeeks] Re: Sort 7 numbers of 4 digits each

2012-08-07 Thread Sambhavna Singh
Its radix sort.. On Fri, Aug 3, 2012 at 4:39 PM, Navin Gupta wrote: > I think the no. of comparisons depend upon the type of sorting used. > Please specify the sorting algorithm used:- > 1:- in case of bubble sort it is - 21 > 2:- in case of radix sort it is - 84 > > > > On Tuesday, 31 July 201

Re: [algogeeks] DE Shaw written test

2012-08-07 Thread manish patel
This is maximum sub-array problem. Nice explaination is given in CLRS - "Introduction to algorithms " Pg 68, ch-4 3rd edition On Tue, Aug 7, 2012 at 11:00 AM, Navin Gupta wrote: > @ashgoel :- Thanx for pointing it out, my earlier approach doesn't work. > Please check if this works. > We can appl

Re: [algogeeks] DE Shaw written test

2012-08-07 Thread Navin Gupta
@ashgoel :- Thanx for pointing it out, my earlier approach doesn't work. Please check if this works. We can apply this:- For every element, find the highest element to the right of it. For e.g: I/P:- 35 4015 35 10 20 Highest to Right:- 40 3535 20