what is vertical sum in binayr tree...i dnt need the algo for this..just
need the concept...that what is vertical sum???
Given a Binary Tree, find vertical sum of the nodes that are in same
vertical line. Print all sums through different vertical lines.
Examples:
1
/ \
2 3
Vertical sum is sum of all the nodes that are present in same horizontal
distance from the root.
In the example quoted by you
the root 1 is at 0 Horizontal distance from root, while its children are
both -1 and +1 distance from root.
Now take the case of 1,5 and 6, 1 being the root is at 0
First , Do recursive traverse from root node and assign vertical level for
each node. like this,
for root node level = 0 , root-left level = -1 , root-left-right = 0 ,
root-left-left = -2, like this
so below tree becomes,
1(0)
/\
2(-1)3(1)
/ \ /
Hello!
I got to know that Google visited several colleges in last week. They will
be visiting my campus on 20th. Please let us know pattern questions if
you know.
Thanks,
- RD
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
20 multiple choice questions out of which around 10 were from the GATE '12
paper.
1 coding question: Represent a no in its Fibonacci representation.
Ex- 15 can be represented as 100010 (1*13+0*8+0*5+0*3+1*2+0*1)
On Sat, Mar 17, 2012 at 6:39 PM, Ronit Douglas ronit.doug...@gmail.comwrote:
guys do we have algo to remove duplicates in o(n) time and in spce
comepexity 0(1)...in unsorted...array or string.???
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To
i earlier post same question and got the satifactory response from dave
..but now i got new explanation from carcking the coding interview..
plz explain this with examplethnx in advance,
If we move two pointers, one with speed 1 and another with speed 2, they
will end up meeting if the
in binary tree..
suppose c is parent of dnow if i want to find least common ancesor of c
and dwhther it is parent of c or c itself
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
C itself
On Sat, Mar 17, 2012 at 8:39 PM, rahul sharma rahul23111...@gmail.comwrote:
in binary tree..
suppose c is parent of dnow if i want to find least common ancesor of
c and dwhther it is parent of c or c itself
--
You received this message because you are subscribed to the
thnx buddy...according to algo c is the answer.
On Sat, Mar 17, 2012 at 8:42 PM, sunny agrawal sunny816.i...@gmail.comwrote:
C itself
On Sat, Mar 17, 2012 at 8:39 PM, rahul sharma rahul23111...@gmail.comwrote:
in binary tree..
suppose c is parent of dnow if i want to find least common
how come 2,3,7 in vertical sum?
On Sat, Mar 17, 2012 at 3:48 PM, prashant thorat
prashantnit...@gmail.comwrote:
First , Do recursive traverse from root node and assign vertical level for
each node. like this,
for root node level = 0 , root-left level = -1 , root-left-right = 0 ,
plz explain...i m nt able to get the concept.
On Sat, Mar 17, 2012 at 8:50 PM, rahul sharma rahul23111...@gmail.comwrote:
how come 2,3,7 in vertical sum?
On Sat, Mar 17, 2012 at 3:48 PM, prashant thorat prashantnit...@gmail.com
wrote:
First , Do recursive traverse from root node and
@ if for a given number more than 1 answer exist then whats the answer???
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
You are given a dynamic stream of numbers and numbers are coming one
by one. At a time you can store at max k numbers(coz you have only
that much memory available). Task is that we have to select the random
subset of size k from the numbers we have got so far with equal
probability.
--
You
Hi
I think its the sum of all the right children of the left subtree and left
children of the right subtree. (Note: this does NOT apply recursively)
Thanks
On Sat, Mar 17, 2012 at 9:31 AM, rahul sharma rahul23111...@gmail.comwrote:
plz explain...i m nt able to get the concept.
On Sat, Mar
@anna..plz elaborate more...
On Sun, Mar 18, 2012 at 12:26 AM, Supraja Jayakumar
suprajasank...@gmail.com wrote:
Hi
I think its the sum of all the right children of the left subtree and left
children of the right subtree. (Note: this does NOT apply recursively)
Thanks
On Sat, Mar 17,
It looks from the example like you pick the largest (as if the digits
were a binary number). Here's what I get:
#include stdio.h
unsigned f(unsigned n, unsigned fi, unsigned fim1)
{
if (fi n) return n;
unsigned r = f(n, fi + fim1, fi);
if (r = fi) {
putchar('1');
return r - fi;
It looks from the example like you pick the largest (as if the digits
were a binary number). Here's what I get:
#include stdio.h
unsigned f(unsigned n, unsigned fi, unsigned fim1)
{
if (fi n) return n;
unsigned r = f(n, fi + fim1, fi);
if (r = fi) {
putchar('1');
return r - fi;
When the n'th number (nk) is received, apply the following algorithm:
1. Generate random real r uniformly distributed in [0..1].
2. If r k/n, throw away the new number,
3. else generate random integer i in [1..k] and replace the number in
the i'th storage location with the new one.
This is
@Ravi... there should be only one answer as for fibonacci representation
of a number we have to include the part of the fibonacci number just less
than the number then remaining part of the sum is filled by fibonacci
numbers starting from 1
suppose we have to convert 6 into fibonacci
20 matches
Mail list logo