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(imax1)
max1 =j-i;
}
i++;
}
return(max1>max2?max1:max2);
}
*
On Mon, May 16, 2011 at 11:36 AM, anuj agarwal wrote:
> How about create a BST and then, fo
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 11:
@amit ur code is wrong. just check it for this {5, 4, 1, 8, 4, 4};
--
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+unsub
@amit jaspal
I have doubt with your question...in the maximum window found i.e.
A[i..j]...the elements should be in increasing order or only the end
elements should have the relation of A[i] wrote:
> Given an array A[i..j] find out maximum j-i such that A[i] O(n) time.
>
> --
> You received t
@Anand:
if the stream is let 1,2,3,4,6,7,9
and let we choose k=3
then your algo is giving 7 as the median.
On Mon, May 16, 2011 at 4:39 AM, Anand wrote:
> Complexity will be O(logK) to insert, delete and finding the predecessor or
> successor of current median value in the BST.
>
>
> On Sun, M
Complexity will be O(logK) to insert, delete and finding the predecessor or
successor of current median value in the BST.
On Sun, May 15, 2011 at 4:08 PM, Anand wrote:
> 1. Create a BST for first K elements of the running stream.
> 2. Find the median of first K elements.
> 3. With every new elem
1. Create a BST for first K elements of the running stream.
2. Find the median of first K elements.
3. With every new element from the stream, Insert the new element in Binary
search Tree.
4. Delete the first element from BST.
5. if the new element is greater than the current median value, find the
Hi, this should be working, where is the problem?
const int INF=99;
int n=6;
int weights[6][6];
int parent[6];
int idistance[6];
int rec[6];
struct lesst{
bool operator()(const int&a,const int&b){
return (idistance[a]>idistance[b]);
}
};
int prim(int s){
@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 O(n)
solution. I take it that in-place means with only O(1) extra space.
That is the question to which I was responding. Your suggestion of
using a hashmap is non-responsi
hash all the elements. Keys are stored in hashmap in sorted order based on
values. just iterate thru the hashmap extracting the first k keys.
m I missing something?
On Thu, May 12, 2011 at 2:50 AM, Dave wrote:
> @Apoorve: I don't believe that you can determine the frequency counts
> in-place in
perfect.
Thanks for the effort in explanation.
On Sun, May 15, 2011 at 12:20 AM, Dave wrote:
> @Pacific: A balanced binary tree is commonly defined as a binary tree
> in which the height of the two subtrees of every node never differ by
> more than 1. Thus, there could be more nodes in one subt
@Dave:
without using comparison operator,
int sign = (a >> (sizeof(int) * CHAR_BIT - 1));
sign=0 if a is +ive or 0
else sign=-1;
int mult(int x, int y)
{
int p = 0, s = y;
int sign = (y >> (sizeof(int) * CHAR_BIT - 1));
if(sign) y = add(~y,1);
while(y)
{
if(y & 1) p = add(x
*Hi,*
*
*
*Based on most comments, The popular puzzle of the last week is*
*
http://dailybrainteaser.blogspot.com/2011/05/maths-trick-teaser-9-may.html?lavesh=lavesh
*
*Please subscribe and follow this blog to show your liking to the blog.*
*
*
--
"Never explain yourself.
13 matches
Mail list logo