Re: [algogeeks] Microsoft interview question

2012-05-21 Thread monish001
@mithun: Try 
A = 1, 6
B = 4, 3

A ^ B = 0.

Alone Ex-OR cant solve this in O(n) time.

On Monday, 21 May 2012 21:48:30 UTC+5:30, mithun wrote:
>
> By doing Ex-OR we can find if b is permutation of A
>
> suppose a --  3 5 4
>  b --  4 3 5
> if A ^ B = 0 then both are permutation or else not
>
> shout loud if this has flaws :P
>
> -mithun
>
>
>
> On Sun, May 20, 2012 at 12:59 AM, HARSHIT PAHUJA 
> wrote:
>
>> given 2 unsorted integer arrays a and b of equal size. Determine if b is 
>> a permutation of a. Can this be done in O(n) time and O(1) space ?
>>
>>
>>
>>
>> please help me with my solution
>>
>>
>> suppose a --  3 5 4
>>  b --  4 3 5
>>
>> now we replace a[i] with a[i]..th prime number  and b with b[i] .. th 
>> prime number
>>
>>   now array  a becomes  5 11 7
>>  array  b becomes  7 5 11   
>>
>> now we take product of elements of array a and do the same with array  b 
>> elements  
>> if product is equal  then b is a permutation of a
>>
>> -- 
>> 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 
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/M16KXaNqGnEJ.
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: print vertical sums of a binary tree

2011-10-19 Thread monish001
I think it might done using function of following prototype:
void func(node* root, deque& d, const deque::iterator& it);

I will add left child's value in it-1 if exists else create new...
similarly for right child.
and call the same function for each of the children to explore
further..

Monish

On Oct 15, 11:57 pm, SUMANTH M  wrote:
> Hi,
>
>    A binary tree is given we need to print vertical sums of nodes. for
> example
>
>   1    2      3        4     5
>
>   |      |       5        |     |
>   |      |     / |       \ |     |
>   |      |   /   |        8     |
>   |      | /     |       / |    \|
>   |      4      |    /    |   10
>   |    / |  \    9        |     |
>   |  /   |      \          |     |
>   7     |      6               |
>   |      |      |          |     |
>   |      |      |          |     |
>   ---
>   7     4     20       8   10
>
>      Here we need to print sum 7,4,20,8,10.
>
> -Thanks

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: MICROSOFT

2011-09-04 Thread monish001
ALGO:
1. For each element 1 to k:
   insert in into min-heap
2. for each element k+1 to n
   delete the root of min-heap and insert this item into the min-
heap
3. Finally you have a min-heap of k largest numbers and the root is
your answer

COMPLEXITY: O(n logn)

-Monish

On Sep 3, 3:03 pm, teja bala  wrote:
> //Asked in MS please help me with the coding or Give an algorithm
>
> Write code to return the kth largest element in a tree ...>>> function
> prototype is int fucnkth(node *root,int k)

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: amazon ques :Online round

2011-08-27 Thread monish001
If I correctly understood the question, It says:
1. 0<= x[i] <=1 for all i and for all x of line i.
2. y[i] wrote:
> You are given n no. of lines in form of Ax + By = C, basically you are given
> A[i], b[i] and C[i] for line "i".
> Lines are given in a way such that 0 <= x[i] <= 1 and y[i] < y[i+1] for same
> X.
> Also, one point (x,y) is given too. Find out the two closest lines to the
> point such that the point is between them.
> Given: n - no. of lines
> a[i] b[i] c[i] - i th line.
> X Y - Point
> Output
> A[i] B[i] C[i]
> A[j] B[j] C[j]
> such that the point X,Y is between them.

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Make My Trip *URGENT*

2011-08-18 Thread monish001
What level of questions for each- english, aptitute, coding? Can you
discuss some?

-Monish

On Aug 17, 5:06 pm, Anika Jain  wrote:
> there will be 15 english fill in the blanks, 5 series questn, 10 aptitude
> questions, 10 logical questions..
> then 10 c++ mcqs and 5 coding questions
>
> On Wed, Aug 17, 2011 at 5:28 PM, Brijesh Upadhyay <
>
>
>
>
>
>
>
> brijeshupadhyay...@gmail.com> wrote:
> > has anyone given MMT written test.??  please reply , what is the
> > pattern of the paper?
>
> > --
> > 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
> >http://groups.google.com/group/algogeeks?hl=en.

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Makemytrip.com

2011-08-18 Thread monish001
What level of questions for each- english, aptitute, coding? Can you
discuss some?

-Monish

On Aug 5, 10:22 pm, parag khanna  wrote:
> half an hour Aptitude test , after that half an hour written test , then
> Technical rounds (2-3) and then HR
>
> profile Software dev - 6 lacs
> QA - 5 lacs

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: akamai.....

2011-08-14 Thread monish001
In which college akamai coming?

-Monish

On Aug 11, 11:01 am, naveen ms  wrote:
> hey can any1 help me out...how ll be the akamai recruiment
> procedure...and if u have any akamai papers please upload it
>
> with regards
>
> naveen

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Closest ancestor of two nodes

2011-08-14 Thread monish001
Check the c language implementation:

node* LeastCommonAncestor(const node* root, const int data1, const int
data2, int* const status){
static node* ans = NULL;
int l_st=0, r_st=0;
if(root==NULL) return;
if(root->left != NULL)
LeastCommonAncestor(root->left, data1, data2, &l_st);
if(root->right != NULL)
LeastCommonAncestor(root->right, data1, data2, &r_st);
if(l_st == 3 || r_st == 3)//if both data already found by subtrees
return ans;
if((l_st|r_st)==3){//if one data found in each subtree
*status = 3;
ans=root;
return ans;
}
if( ((l_st|r_st)==2 && root->data == data1) || ((l_st|r_st)==1 &&
root->data == data2) ){
//if one data found in subtree and other is root itself
ans = root;
*status =3;}
else//record if any one data found (case when both data found is
catered above)
*status |= l_st |= r_st;
if(root->data == data1)
*status |= 1;
if(root->data == data2)
*status |= 2;
return ans;
}

Full Program here: 
https://github.com/monish001/CPP-Programs/blob/master/General/LeastCommonAncestor.c
Program tested on Dev-CPP

-
Monish

On Aug 9, 7:56 pm, Raman  wrote:
> Can anyone give me the recursive algo to find closest ancestor of two nodes
> in a tree(not a BST).

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Value of base pointer VS Address of base pointer

2011-08-12 Thread monish001
Program:
int arr[] = {12, 14, 15, 23, 45};
printf("%u %u\n", arr, &arr);

Question: Why arr == &arr ?

Comments:
1. arr is a variable that stores the address of location where arr[0]
resides. Complier shows &arr and arr having same value. Shouldn't &arr
be the address where arr resides?

Thanks
Monish

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: MS question

2011-08-09 Thread monish001
Given : ddbbccae
O/P : 2d4a2b2c1a1e
What is happening? What algo?

Thanks and regards
Monish

On Aug 9, 5:59 pm, ankit sambyal  wrote:
> Given an array of characters, change the array to something as shown in the
> following example.
> Given : ddbbccae
> O/P : 2d4a2b2c1a1e
>
> Do it in the most efficient manner both in terms of time and space ...

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.