@Darpan can you implement it without using the multimap and with the same
(divide and conquar) approach.
On Mon, Sep 3, 2012 at 6:25 PM, Darpan Baweja wrote:
> hope this might helps
> code:- http://ideone.com/mtHem
> used divide and conquer approach
> and stored all the beaten elements in the mul
@navin and @atul:
inorder traversal without recursion and stack can be done using Morris
traversal in O(1) space.
Refer the following link for Morris traversal
http://www.geeksforgeeks.org/archives/6358
now the problem takes O(n) time and O(1) space.
--
You received this message because you a
i guess i missed this part of bharat post :-
/*
If we don't get the violation for the second time .. means both are
side-by-side elements .. swap them ..
*/
i was saying the same.so it will work.
On 9/4/12, atul anand wrote:
> @rahul : Here are the boundary cases need to be taken care of :-
@rahul : Here are the boundary cases need to be taken care of :-
suppose given BST is the following :-
root=allocate(70);
root->right=allocate(75);
root->left=allocate(50);
root->left->left=allocate(20);
root->left->left->right=allocate(25);
root->left->left->left=allocate(10);
root->left->right=a
@Daemon: Probably no one understands what you've asked. What does it mean
to convert a number n into strigs of 1's? Doesn't that depend on what a
strig is and what operations are allowed? E.g., if one of the operations is
replacing a digit by the strig 1, the algorithm is pretty simple.
Dave
seems no body interested in this.. v bad..
On Sunday, September 2, 2012 11:05:24 PM UTC+5:30, Daemon Dev wrote:
>
> Can somebody suggest me AO* algorithm that convert a number n into strigs
> of 1's
>
> n-> (n-1)+1; n->ceil(n/2)+floor(n/2)
> h(n)=n and h(1)=0
>
> Please help..
>
--
You receiv
similar discussion is going on in this thread..
reply to this thread ( mentioned below) , if you dont understand the solution.
http://groups.google.com/group/algogeeks/browse_thread/thread/74fc4fb182a484eb?hl=en
On 9/3/12, Puneet Gautam wrote:
> @atul: i didnt get your algo fully..
> Can u just
@navin : if O(n) recursive stack is not allowed then i wonder how can
it can be solved.
On 9/3/12, Navin Kumar wrote:
> @all: If we are doing inorder traversal , it will automatically take O(n)
> space for internal stack.
>
> On Mon, Sep 3, 2012 at 5:17 PM, atul anand wrote:
>
>> @ashish : i.e i
Thats ok.. but can u tell me its more implementations in C and OOP..?
On Sun, Sep 2, 2012 at 9:59 AM, rahul wrote:
> i m talking in contest of question, not explaining overall picture of
> static in c,c++,java.
> On Sep 2, 2012 12:07 AM, "Puneet Gautam" wrote:
>
>> @rahul: There is something m
@atul: i didnt get your algo fully..
Can u just tell me how it works on this array.. {-3 2 1 5 -12 6 1 -2}
the aux array would become {-3 -1 0 5 -7 -1 0 -2}
then whats the next step.?
We analyze the aux for the repeated element which sets
subarray start= 2 subarray end=6
then aux contains 0 at tw
hope this might helps
code:- http://ideone.com/mtHem
used divide and conquer approach
and stored all the beaten elements in the multimap with key is the element
which has beaten them
with key as winner return maximum element stored in multimap
On Mon, Sep 3, 2012 at 3:31 PM, sangeeta goyal wrote:
@all: If we are doing inorder traversal , it will automatically take O(n)
space for internal stack.
On Mon, Sep 3, 2012 at 5:17 PM, atul anand wrote:
> @ashish : i.e in decreasing order
>
> inorder(root)
>if not null
> inorder(root->right);
> inorder(root->left);
>
>
> On M
@bharat: +1
i have tried some test cases.. working finely.. @anyone pls verify??
On Mon, Sep 3, 2012 at 11:58 AM, bharat b wrote:
> while doing in-order traversal, we have to check if(prev > current) -->
> then mark prev element for swapping in the first time violation..
> if it happens for the s
Sorry by mistake i write that
Actually I am not getting desired output..
On Mon, Sep 3, 2012 at 11:02 AM, manish untwal wrote:
> if u r getting desired output ? then what is the problem?
>
>
> On Sun, Sep 2, 2012 at 7:24 PM, shubham jain wrote:
>
>> Hi
>> I am trying to convert the BST t
@ashish : i.e in decreasing order
inorder(root)
if not null
inorder(root->right);
inorder(root->left);
On Mon, Sep 3, 2012 at 4:35 PM, Rahul Kumar Patle wrote:
> @dave same doubt as @atul, how we can manage both function parallel
> and to all can we traverse a tree using so
@bharat is it tournament method??
On Mon, Sep 3, 2012 at 2:34 PM, bharat b wrote:
> Construct a max-heap --> O(n)..
> call delete() 2 times .. --> O(logn)..
> ===> O(n) time..
>
>
> On Fri, Aug 31, 2012 at 1:46 AM, Don wrote:
>
>> While the list length is more than one
>>Take 2 elements fr
@dave same doubt as @atul, how we can manage both function parallel
and to all can we traverse a tree using some looping instead of traditional
recursive methods..??
On Mon, Sep 3, 2012 at 1:13 PM, atul anand wrote:
> @Dave : algo seems fine...but it seems to me that it would difficult to
> main
if u r getting desired output ? then what is the problem?
On Sun, Sep 2, 2012 at 7:24 PM, shubham jain wrote:
> Hi
> I am trying to convert the BST to doubly linked list but I am getting
> desired output with this code Plz correct this code.
>
> #include
> #include
> typedef struct tree
what is right to left inorder?
Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652
On Mon, Sep 3, 2012 at 1:13 PM, atul anand wrote:
> @Dave : algo seems fine...but it seems to me that it would difficult to
> maintain both left to right and right to le
Construct a max-heap --> O(n)..
call delete() 2 times .. --> O(logn)..
===> O(n) time..
On Fri, Aug 31, 2012 at 1:46 AM, Don wrote:
> While the list length is more than one
>Take 2 elements from the head
>Select the larger of the two
>If the smaller is greater than the largest beaten
@Dave : algo seems fine...but it seems to me that it would difficult to
maintain both left to right and right to left parallel way :( :( .
it would be gr8 if you can provided little bit of coded algorithm for it.
On Mon, Sep 3, 2012 at 10:36 AM, Dave wrote:
> @Atul007: No need to destroy the BST
why can't we change the question to sum=0 ..
On Mon, Sep 3, 2012 at 12:57 PM, atul anand wrote:
> above link was for reference , extending the logic was obvious :) :)
>
>
> On Mon, Sep 3, 2012 at 11:22 AM, bharat b wrote:
>
>> @atul: question is to find the largest continuous sub array .. not ju
above link was for reference , extending the logic was obvious :) :)
On Mon, Sep 3, 2012 at 11:22 AM, bharat b wrote:
> @atul: question is to find the largest continuous sub array .. not just
> continuous sub array ..
>
> we can do this with same logic as mentioned in the above link.. we have to
23 matches
Mail list logo