How about create a BST and then, for each node find the difference between
the node and its child and do this for all except leaf nodes.
If u want i will write the code for the same.
Anuj Agarwal
Engineering is the art of making what you want from things you can get.
On Mon, May 16, 2011 at
how about this??
*int maxinterval(int a[],int i,int j)
{
if(i==j)
return 0;
int max1 = 0,max2;
max2 = maxinterval(a,i+1,j);
while(ij)
{
if(a[i]a[j])
{
if(j-i)max1)
max1 =j-i;
}
i++;
}
return(max1max2?max1:max2);
}
*
On Mon, May 16, 2011 at 11:36 AM, anuj agarwal
*W Riddle
*
*
*
**
*George Washington's wife was sweeping when George Washington's wife slipped
and got wet. How many w's in all?
*
*Update Your Answers at* : Click
Herehttp://dailybrainteaser.blogspot.com/2011/05/w-riddle-16-may.html?lavesh=lavesh
Solution:
Will be updated after 1 day
--
only one
On Mon, May 16, 2011 at 1:03 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote:
*W Riddle
* * ***
*
*
**
*George Washington's wife was sweeping when George Washington's wife
slipped and got wet. How many w's in all?
*
*Update Your Answers at* : Click
10
On Mon, May 16, 2011 at 1:03 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote:
*W Riddle
*
*
*
**
*George Washington's wife was sweeping when George Washington's wife
slipped and got wet. How many w's in all?
*
*Update Your Answers at* : Click
Can't we do this using map library function..mapping the integer with their
frequency count??
On Sun, May 15, 2011 at 10:15 PM, Dave dave_and_da...@juno.com wrote:
@Akshata: Yes. In my response of May 7, I proposed an algorithm using
hashing. On May 9, Apoorve asked if there was an in-place
@vivek...how come only one?? I think its 8...
On Mon, May 16, 2011 at 1:03 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote:
*W Riddle
*
*
*
**
*George Washington's wife was sweeping when George Washington's wife
slipped and got wet. How many w's in all?
*
*Update Your Answers at* :
I‘v no idea, please give detail analysis, thanks!
On Mon, May 16, 2011 at 5:26 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote:
@vivek...how come only one?? I think its 8...
On Mon, May 16, 2011 at 1:03 PM, Lavesh Rawat lavesh.ra...@gmail.com
wrote:
W Riddle
George Washington's wife was
only 1... its w's that we have to count not w :P
On Mon, May 16, 2011 at 11:26 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
@vivek...how come only one?? I think its 8...
On Mon, May 16, 2011 at 1:03 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote:
*W Riddle
*
*
*
**
*George
0, ther are no w's in all :P
--
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
algogeeks+unsubscr...@googlegroups.com.
For more
its DP problem can be solved in O(m*n)
where m is number of elements in array and n is value of the given number.
--
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
^like :P :P :P
ALL :P :P
On Mon, May 16, 2011 at 4:22 PM, Balaji S balaji.ceg...@gmail.com wrote:
0, ther are no w's in all :P
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
we can use BIT or segment trees.
algorithm using segment tree
1. intialize all node wid zeros
2. read the array element according their index update the node value.
void update(int s, int e, int k, int node)
{
if (tree[node] ar[k]) tree[node] = ar[k];
if (s==e) return;
mid = (s+e) 1;
if (k =
No idea. It would help to tell us what it is intended to do and what
it is actually doing, and maybe include the main function so we can
see how it is called and how the global variables are initialized.
On May 15, 1:45 pm, Edu edu.cv...@gmail.com wrote:
Hi, this should be working, where is the
Kunal,
Your solution runs in O(n) time but it is a wrong solution. It will run fine
if the array is sorted.
Anuj Agarwal
Engineering is the art of making what you want from things you can get.
On Mon, May 16, 2011 at 7:17 PM, Kunal Patil kp101...@gmail.com wrote:
@Piyush Sinha: I doubt
Correct. Its a variant of Knapsack problem.
Anuj Agarwal
Engineering is the art of making what you want from things you can get.
On Mon, May 16, 2011 at 4:53 PM, anshu mishra anshumishra6...@gmail.comwrote:
its DP problem can be solved in O(m*n)
where m is number of elements in array and n
Your sliding window should not be small enough to get the median. For a free
running stream, your window should be of size not less than 100.
On Sun, May 15, 2011 at 7:35 PM, Akshata Sharma
akshatasharm...@gmail.comwrote:
@Anand:
if the stream is let 1,2,3,4,6,7,9
and let we choose k=3
@Anuj:
I have a doubt. I am not getting how to update all the nodes up the leaf
node which we found in the query for our value. The biggest capacity bin for
all the above nodes will change once we modify the leaf value. How to
propagate this upwards? After each query, do we again need to run the
sorry, above mail is addressed to Anshu. :P
On Mon, May 16, 2011 at 10:08 PM, Akshata Sharma
akshatasharm...@gmail.comwrote:
@Anuj:
I have a doubt. I am not getting how to update all the nodes up the leaf
node which we found in the query for our value. The biggest capacity bin for
all the
@kunal..
anuj is right..ur code works only for sorted array...and I missed the
part of doing it in O(n) time...I don't think there is way of doing it
in O(n) time...if its there and if amit knows the solution, he should
provide some hints...
On 5/16/11, anuj agarwal coolbuddy...@gmail.com wrote:
@Anuj Piyush:
You didn't get the algo. It works on unsorted array also. You might have
missed the statement
*else // next element is smaller than or equal to current element
reset curr_max to 1;*
Here, the comment itself shows unsorted elements have been taken into
consideration.
If you
@kunal
i think we both understood the problem differently...thats what i
asked from amit..that whether in the window is it neccessary the
elements in between should also be in increasing order or only the end
elements should have the relation of one being greater than the
other...I too
Say you have an array containing information regarding n people. Each person is
described using a string (their name) and a number (their position
along a number
line). Each person has three friends, which are the three people whose number is
nearest their own. Describe an algorithm to identify
hi all,
Does anyone have an algorithm to detect siemens star(s) in an image??
--
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
@Piyush. The simplest algorithm is to sort the array entries by the
number. Then the three friends of each person will be the closest
three of the set comprising the closest three on the left and the
closest three on the right. This algorithm has running time O(n log
n).
Usually, we regard being
can someone please tell me why I am getting this error?
#includeiostream
#includestack
#includeconio.h
using namespace std;
int main()
{
stackpairint,int stk;
stk.push(make_pair(2,1));
stk.push(make_pair(3,2));
pairint,int p = stk.pop(); //at this line I am getting error conversion
from
pop op doesn't return anything...use top.something like that op.
Rahul.
On Tue, May 17, 2011 at 9:29 AM, Akshata Sharma
akshatasharm...@gmail.comwrote:
can someone please tell me why I am getting this error?
#includeiostream
#includestack
#includeconio.h
using namespace std;
int main()
ya.. sorry my mistake!
On Tue, May 17, 2011 at 9:31 AM, rahul rahulr...@gmail.com wrote:
pop op doesn't return anything...use top.something like that op.
Rahul.
On Tue, May 17, 2011 at 9:29 AM, Akshata Sharma akshatasharm...@gmail.com
wrote:
can someone please tell me why I am getting
it happens, v learn by making mistakes...
keep coding.
On Tue, May 17, 2011 at 9:35 AM, Akshata Sharma
akshatasharm...@gmail.comwrote:
ya.. sorry my mistake!
On Tue, May 17, 2011 at 9:31 AM, rahul rahulr...@gmail.com wrote:
pop op doesn't return anything...use top.something like that
void query(int w, int s, int e, int node)
{
if (s==e)
{
tree[node] -= w;
prpogateNewMax(node);
return;
}
mid = (s+e)1;
if (tree[(node1)+1] = w) query(w, s, mid, (node1)+1);
else query(w, mid+1, e, (node1)+2);
}
void prpogateNewMax(int node)
{
if (node == 0) return;
int par = (node-1)1;
int a =
thanks Dave :)
This is a standard Google question
On 5/17/11, Dave dave_and_da...@juno.com wrote:
@Piyush. The simplest algorithm is to sort the array entries by the
number. Then the three friends of each person will be the closest
three of the set comprising the closest three on the
9
--
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
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
32 matches
Mail list logo