@mohit: your algo will add assurance that the tree is balanced.. otherwise
ankit's approach is sufficient.
On Sat, Nov 5, 2011 at 8:49 PM, mohit verma wrote:
> another way is : convert binary tree to link list , sort the list and
> using divide and conquer approach create the BST.
>
> From link
this is the solution . it also prints all the possible as well as the total
count
int count=0;
void fun(int a[],int index,int n,int i)
{
if(index==n)
{
count++;
cout<<"\n";
for(int k=0;k wrote:
> how ?
> elaborate on the solution part ? how to arrive at that
> formulation ?
>
> On Se
In C you can get close by wrapping malloc() and free() and maintaining
your own total. This will not capture the header within each
malloc()'ed block.
You can also use a tool like valgrind .
The behavior of sbrk() is totally OS dependent, and sbrk() doesn't
exist on e.g. Windows. This method wo
Unfortunately this isn't true. See the example I gave earlier:
1 2 3
2 4 5
3 4 6
Thje median is 3.
1 2 2 3 >3< 4 4 5 6
Niether one of the 3's lies on the diagonal.
When you pick any element P on the diagonal, all you know is that
anything to the right and downward is no less than P and everyth
Hey what was the facebook question at IIT Roorkee?
On Nov 5, 6:04 pm, saket wrote:
> As far as I have googled about the 'game of life' problem, of which
> this question is a variant ; no mathematical pattern/series emerges
> out of it ...
> but in this problem since the moves are defined in a 3*
another way is : convert binary tree to link list , sort the list and using
divide and conquer approach create the BST.
>From link list to BST : find mid of sorted link list , make it root node
and put left of it to recursive(list,start,mid->prev) and
root->right=recursive(list,mid->next,last);
can we know the size of heap memory allocated to our program
i think sbrk(0) will return the address of end of heap.
but how to find the start of heap so that we can calculate the size of
total heap memory allocated to our program
is there any way possible
--
You received this m
As far as I have googled about the 'game of life' problem, of which
this question is a variant ; no mathematical pattern/series emerges
out of it ...
but in this problem since the moves are defined in a 3*3 grids, I
found some test cases where the board configurations do not change
after certain k
I think it's the only way as you need to traverse the entire binary
tree to do it.
On Oct 31, 9:45 pm, Ankuj Gupta wrote:
> How to convert a Binary tree to BST ? Naive way is to create each node
> of Binary tree one by one and keep on creating the BST.
--
You received this message because you
@ Gene : I think your remove() function takes O(n) time in case if all n
numbers hash to same bucket.
Could you please elaborate on unbiased_hash() function?
Can't we do it like this : rand() % TABLE_SIZE coz rand() generates
uniformly distribution of numbers.
On Fri, Nov 4, 2011 at 1:47 AM,
@ myself
Dave's solution works fine. I should have close look at it.
On Sat, Nov 5, 2011 at 12:17 PM, mohit verma wrote:
> @ Dave
>
> I think your solution wont work for the cases like (MAX_INT) C
> (MAX_INT-1).
>
>
> On Thu, Nov 3, 2011 at 10:20 PM, wrote:
>
>> correction: "if P is prime"
>>
@ Dave
I think your solution wont work for the cases like (MAX_INT) C
(MAX_INT-1).
On Thu, Nov 3, 2011 at 10:20 PM, wrote:
> correction: "if P is prime"
>
> VM
> NSIT, Dwarka
>
>
> On , vaibhavmitta...@gmail.com wrote:
> > Use Lucas Theorem is P is prime.
> >
> > VM
> > NSIT, Dwarka
> >
> > O
12 matches
Mail list logo