Re: [algogeeks] Fork in c

2012-10-28 Thread Brijesh Kumar
output -text1text2
   text2

explaination-system call fork creates a child process copying the whole
code of parent but the execution of child process will start after the line
where fork is called.thus the two process parent and child will print text2
twice

-- 
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.



Re: [algogeeks] Fork in c

2012-10-28 Thread Brijesh Kumar
output - text1text2

-- 
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.



Re: [algogeeks] Re: kth smallest element

2011-11-11 Thread Brijesh Upadhyay
I guess this approach will work..

-- 
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/-/zeydVF1OqioJ.
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: Operating System

2011-10-07 Thread Brijesh
Yeah...anyone plz tell good book for OS concepts

-- 
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/-/aVShOmMEE_cJ.
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: deep vas shallow

2011-10-01 Thread Brijesh
http://www.learncpp.com/cpp-tutorial/912-shallow-vs-deep-copying

Go through this link..

-- 
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/-/NIWaOsWRCT0J.
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 -> array problem

2011-09-30 Thread Brijesh
int main() 
{ 
   int a[]={4,3,5,2,6};  // 1 4 12 60 120
   const int n=5;
   int temp=1,i;
   int b[5]={0};
   for(i=0;i=0;i--)
   {
 b[i]*=temp;
 temp*=a[i];
   }
   for(i=0;i
> Given an integer array. { 1,2,3,4,5 } 
> Compute array containing elements 
> 120,60,40,30,24 (2*3*4*5,1*3*4*5, 1*2*4*5, 1*2*3*5, 1*2*3*4) 
>
> We shouldn't use division operator( / )
> Time complexity O(n) .. Space complexity O(1) 
>
>
> ~raju
>

-- 
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/-/pnuv-BqiaBUJ.
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] Explain output

2011-09-29 Thread Brijesh
void main()

 {
void *ptr;
char *a='A';
char *b="TAN";
int i=50;
ptr=a;
ptr=(*char)malloc(sizeof(a));
printf("%c",*ptr);
ptr=i;
ptr=(*int)malloc(sizeof(i));
printf("%d",++(*ptr));
ptr=b;
ptr=(*char)malloc(sizeof(b));
printf("%c",++(*ptr));

}
ptr=(*char)malloc(sizeof(a));
Ans: A51AN

Please explain the output..
Doesnt this line   ptr=(* char)malloc(sizeof(i)) 
 
initialize ptr to NULL 

-- 
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/-/QRNgJFXBZawJ.
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] Explain Output

2011-09-29 Thread Brijesh
void main()

 {
void *ptr;
char *a='A';
char *b="TAN";
int i=50;
ptr=a;
ptr=(*char)malloc(sizeof(a));
printf("%c",*ptr);
ptr=i;
ptr=(*int)malloc(sizeof(i));
printf("%d",++(*ptr));
ptr=b;
ptr=(*char)malloc(sizeof(b));
printf("%c",++(*ptr));

}

Ans: A51AN

Please explain the output..
Doesnt this line   ptr=(* char)malloc(sizeof(i)) 
 
initialize ptr to NULL 

-- 
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/-/dhfxcCtf01cJ.
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.



Re: [algogeeks] Find the output

2011-09-16 Thread Brijesh Upadhyay
&array_name always has the size of whole array...so whenever u increase
this, it will get incremented by size of the whole array..as in this case ,
&a+1 points to next set of 5 numbers

On Fri, Sep 16, 2011 at 10:17 PM, Anup Ghatage  wrote:

> What does one mean by 'address of the whole array' ?
>
>
> On Fri, Sep 16, 2011 at 8:11 PM, mohan kumar wrote:
>
>> thank to explain to this problem...
>>
>>
>>
>> On Fri, Sep 16, 2011 at 1:40 PM, Yogesh Yadav  wrote:
>>
>>> a[]= {1,  2,  3,   4,5}
>>> a
>>>&a
>>>  a+1
>>>   &a+1
>>> &a is address of whole array...so &a+1 means next element after array
>>> completion.
>>>
>>> so ptr-1 will point to 5
>>>
>>> ...
>>>
>>>
>>> On Fri, Sep 16, 2011 at 1:25 PM, Anup Ghatage  wrote:
>>>
>>>> #include
>>>> int main()
>>>> {
>>>> int a[5]={1,2,3,4,5};
>>>> int *ptr=(&a + 1);
>>>> printf("%d %d\n",*(a+1),*(ptr-1));
>>>> return 0;
>>>> }
>>>>
>>>> Find the output!
>>>>
>>>> --
>>>> 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.
>>>
>>
>>
>>
>> --
>>
>>- *MOHAN KUMAR*
>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> Anup Ghatage
>
>  --
> 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.
>



-- 
Regards,
Brijesh Upadhyay
CSE , final year.
Thapar University

-- 
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.



Re: [algogeeks] Find the output

2011-09-16 Thread Brijesh

>
>
>
On Friday, 16 September 2011 13:25:38 UTC+5:30, Anup wrote:
>
> #include
> int main()
> {
> int a[5]={1,2,3,4,5};
> int *ptr=(&a + 1);
>
   int *ptr=(int *)(&a + 1);

> printf("%d %d\n",*(a+1),*(ptr-1));
> return 0;
> }
>
> Find the output!
>

Now it will print 2 5 

-- 
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/-/4tXlbiojgm8J.
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: Thoughtworks and Tejas network

2011-09-13 Thread Brijesh
yes..please anyone post questions asked in  thoughtworks interview

-- 
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/-/Rpd5yw77HbMJ.
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: Object Oriented Programming

2011-09-11 Thread Brijesh
If u have pdf file of this book please attach it :)

-- 
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/-/UAtjWdjmTIEJ.
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: Object Oriented Programming

2011-09-11 Thread Brijesh
Yaarr do u have pdf file of this book??

-- 
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/-/J3_X1gBC3-sJ.
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

2011-09-11 Thread Brijesh


This is the fastest way I can think of to do this, and it is linear to the 
number of intervals there are.

Let L be your original list of numbers and A be a hash of empty arrays where 
initially A[0] = [0]

sum = 0
for i in 0..n
  if L[i] == 0:
sum--
A[sum].push(i)
  elif L[i] == 1:
sum++
A[sum].push(i)

Now A is essentially an x y graph of the sum of the sequence (x is the index 
of the list, y is the sum). Every time there are two x values x1 and x2 to 
an y value, you have an interval (x1, x2] where the number of 0s and 1s is 
equal.

There are m(m-1)/2 (arithmetic sum from 1 to m - 1) intervals where the sum 
is 0 in every array M in A where m = M.length

Using your example to calculate A by hand we use this chart

L   #   0  1  0  1  0  0  1  1  1  1  0
A keys  0  -1  0 -1  0 -1 -2 -1  0  1  2  1
L index-1   0  1  2  3  4  5  6  7  8  9  10

(I've added a # to represent the start of the list with an key of -1. Also 
removed all the numbers that are not 0 or 1 since they're just distractions) 
A will look like this:

[-2]->[5]
[-1]->[0, 2, 4, 6]
[0]->[-1, 1, 3, 7]
[1]->[8, 10]
[2]->[9]

For any M = [a1, a2, a3, ...], (ai + 1, aj) where j > i will be an interval 
with the same number of 0s as 1s. For example, in [-1]->[0, 2, 4, 6], the 
intervals are (1, 2), (1, 4), (1, 6), (3, 4), (3, 6), (5, 6).

Building the array A is O(n), but printing these intervals from A must be 
done in linear time to the number of intervals. In fact, that could be your 
proof that it is not quite possible to do this in linear time to n because 
it's possible to have more intervals than n and you need at least the number 
of interval iterations to print them all.

Unless of course you consider building A is enough to find all the intervals 
(since it's obvious from A what the intervals are), then it is linear to n 

THis is the solution..go through it, its very easy to understand... 
PS: copied from   
http://stackoverflow.com/questions/6967853/dynamic-programming-can-interval-of-even-1s-and-0s-be-found-in-linear-time



 

-- 
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/-/wM8Xhc1tUXQJ.
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] Object Oriented Programming

2011-09-10 Thread Brijesh
Guys please suggest me any good book for object oriented programming..which 
have lots of example of good design pattern.

-- 
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/-/0TkuPUliMtgJ.
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: Write a program

2011-09-10 Thread Brijesh
If you are talking about character array then it can be done in space 
O(128)=constant and time O(n),,. as Use Hash table of all 128 characters , 
and then traverse through your array and mark a flag in the hash table..when 
you encounter any duplicate character , which would be marked already in the 
hash table , dont print it..! 

And if its integer array... best would be sort it in O(n logn) and traverse 
through the loop and print those  numbers which are not same as previous 
number..
On Saturday, 10 September 2011 14:51:18 UTC+5:30, Ishan Aggarwal wrote:
>
> Write a program to remove duplicate elements from an array by printing them 
> only once?
>
> What will be the minimum time and space complexity required for this 
> program?
>
> -- 
> Kind Regards
> Ishan Aggarwal
> [image: Aricent Group]
> Presidency Tower-A, M.G.Road,Sector-14
> Gurgaon,Haryana.122015 INDIA
> Phone : +91-9654602663
> ishan2@aricent.com
>
>  

-- 
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/-/TqJhP_DAD2AJ.
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.



Re: [algogeeks] What would be the ans.

2011-09-10 Thread Brijesh
But probability ZERO means , impossible scenario , while this is possible so 
better say very less, near to zero..not zero exactly :P

-- 
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/-/1JeUKFr2b7cJ.
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: What would be the ans.

2011-09-10 Thread Brijesh
let say there are n points on the circumference, 
then for rt angle triangle , 
answer would be nC2..select any two points , u'll always get a point which 
will make rt angle triangle.. but again we can not define no of points on 
circle..so :| 
On Saturday, 10 September 2011 14:47:53 UTC+5:30, Ishan Aggarwal wrote:
>
> three points are randomly chosen on a circle.what the probability that
> 1.triangle formed is right angled triangle.
> 2.triangle formed is acute angled triangle.
> 3.triangle formed is obtuse angled triangle.
>
>
> -- 
> Kind Regards
> Ishan Aggarwal
> Phone : +91-9654602663
>
>
>  

-- 
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/-/-qmHfbqRbKYJ.
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.



Re: [algogeeks] What would be the ans.

2011-09-10 Thread Brijesh
for RT angled triangle , 0 cudnt be the answer , for obvious reason.. 
however it'll very small and close to zero...
and for any two points on the circumference , there will be a point by which 
u can make rt angle triangle..

On Saturday, 10 September 2011 18:19:25 UTC+5:30, Neha Singh wrote:
>
> The correct ans is :
> for right angled triangle :  0
> for acute angled triangle : 1/2
> for obtuse angled triangle : 1/2
>

-- 
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/-/-fOUp84vPjMJ.
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: informatica pattern and question of interview

2011-09-10 Thread Brijesh
Yeah..agree with this... Just find minimum no and increment that..! Any 
counter-example??

On Saturday, 10 September 2011 01:19:41 UTC+5:30, hashd wrote:
>
>  For question 2 I guess finding the minimum element's index should suffice 
> (considering all elements are positive integer). No need to even calculate 
> n! as it might cause overflow in case the arrary is big. 

-- 
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/-/PY1okbjIwNoJ.
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: worst case complexity

2011-09-10 Thread Brijesh
i==>n 
j==>i*i= n*n
k==>j=i*i=n*n   so total i*j*k=n^5

-- 
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/-/jv1X4YzDp_sJ.
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 Interview question

2011-09-08 Thread Brijesh
Please reply with your alog...!

-- 
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/-/OGVCUV_hutUJ.
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.



Re: [algogeeks] Kth largest element

2011-09-08 Thread Brijesh
Better watch this video... 
http://www.youtube.com/watch?v=HjPmZuOXkHQ&feature=player_embedded After 
20th minute! It'll clear all ypur doubts.

-- 
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/-/cyVQmuf06LcJ.
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: Kth largest element

2011-09-08 Thread Brijesh
Thanks for the elaboration! 

-- 
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/-/z2bD7spFbPQJ.
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.



Re: [algogeeks] Kth largest element

2011-09-08 Thread Brijesh
make a max heap of size K , and keep inserting all the elements in it.. and 
at last the root will be the k-th largest element ! O(nlogk)

On Thursday, 8 September 2011 22:32:52 UTC+5:30, Sandeep Chugh wrote:
>
> wat abt creating a max heap?  and then deleting root element k-1 times..
> after then root contains kth largest element
>
> On Thu, Sep 8, 2011 at 10:28 PM, Piyush Kapoor  wrote:
>
>> use max heap ,it will take n + k*logn
>>
>>
>> On Thu, Sep 8, 2011 at 10:25 PM, Rohit jalan  wrote:
>>
>>> How to find out Kth largest element in an array ?
>>>
>>> -- 
>>> Thanks & Regards :
>>> ROHIT JALAN
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algo...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> algogeeks+...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> -- 
>> *Regards,*
>> *Piyush Kapoor,*
>> *2nd year,CSE
>> IT-BHU*
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Algorithm Geeks" group.
>> To post to this group, send email to algo...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> algogeeks+...@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/-/0aRiVof2NjYJ.
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.



Re: [algogeeks] Kth largest element

2011-09-08 Thread Brijesh
make a max heap of size K , and keep inserting all the elements in it.. and 
at last the root will be the k-th largest element ! O(nlonk)

On Thursday, 8 September 2011 22:32:52 UTC+5:30, Sandeep Chugh wrote:
>
> wat abt creating a max heap?  and then deleting root element k-1 times..
> after then root contains kth largest element
>
> On Thu, Sep 8, 2011 at 10:28 PM, Piyush Kapoor  wrote:
>
>> use max heap ,it will take n + k*logn
>>
>>
>> On Thu, Sep 8, 2011 at 10:25 PM, Rohit jalan  wrote:
>>
>>> How to find out Kth largest element in an array ?
>>>
>>> -- 
>>> Thanks & Regards :
>>> ROHIT JALAN
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algo...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> algogeeks+...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> -- 
>> *Regards,*
>> *Piyush Kapoor,*
>> *2nd year,CSE
>> IT-BHU*
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Algorithm Geeks" group.
>> To post to this group, send email to algo...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> algogeeks+...@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/-/XYeQcjZW-isJ.
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 in VJTI mumbai

2011-09-08 Thread Brijesh
+1.. please someone share the procedure and questions, topics and all...

-- 
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/-/pmW5D1vnWbwJ.
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.



Re: [algogeeks] Re: Please provide Code to Find kth Smallest or kth Largest element in unsorted array in liner time ?

2011-09-06 Thread Brijesh


On Wednesday, 7 September 2011 09:41:53 UTC+5:30, Anup wrote:
>
> Here is another one. Pardon me if it goes by some other name.
>
> Divide the array in K parts.
>
> Find the Maximum in each of these parts and store it in an array of size K.
>
> Find the Minimum in K to find the K'th max.
>
> Total Time Complexity = O ( n + k ) where  0 <= k <= n 
>
 

>
> -- 
> Anup Ghatage
>

-- 
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/-/zg3SeePrmzYJ.
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: convert a word into a palindrome with minimum addition of letters to it

2011-09-06 Thread Brijesh
This can be solve by considering following case: 
i) If all the letters in the word are distinct :  Just concatenate,  reverse 
of the string(excluding last letter) to the original word..e.g. ZXKH==>>ZXKH
KXZ

ii)If two letters are same in the word : First ignore all the letters 
between those same words , and make left sub-string and right sub-string of 
those *same letters* equal by adding letters.. e.g rzLkhmLty===>> rzyt
LkhmLtyzr   And then apply rule i) for middle letters. e.g.  rzytLkhmLtyzr 
===>> rzytLkhmhkLtyzr 

iii)If there are more than a *set of same letters* then first consider the 
farthest set and make it palindrome using rule ii) , e.g. 
ilOtPuyPuOer===>>ilreOtPuyPuOerli   and move to next pair of same 
letters i.e. P,P..(use recursion) and ignore last modified position of same 
letters i.e. 
O,O and again apply rule ii) e.g. ilreOtPuyPuOerli===>>>ilreOtuPuyPutOerli 
  And then finally use rule no i) for distinct 
words..e.g.ilreOtuPuyPutOerli===>>ilreOtuPuyuPutOerli  



On Sunday, 4 September 2011 19:54:35 UTC+5:30, learner wrote:
>
> Given a word, convert it into a palindrome with minimum addition of 
> letters to it. letters can be added anywhere in the word. for eg if 
> yahoo is given result shud be yahohay. 
>
>
> Thanks 
>
>

-- 
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/-/Hsd6Tohi95oJ.
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: Let's see if U can find the bug...

2011-08-30 Thread Brijesh
It is problem of loss of data..as pow(x,y) returns double value and adding 
it to int truncate some data... if u write this 
sum+=(float)pow(r,3); it'll work fine!

-- 
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/-/cI4THXWLutYJ.
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: subset with sum

2011-08-29 Thread Brijesh
Sort the array and use dynamic programming.. it will take at most n^2 
complexity.! 
BY dynamic programming , i mean make a 3D type array.. which will give all 
the combination which sums to all the nos.. try it!

-- 
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/-/qyurZAc9r4wJ.
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: Winshuttle Interview Questions

2011-08-29 Thread Brijesh
Yaar second question thoda elaborate kar.. didn't get it !

-- 
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/-/3ClTQN8-GBEJ.
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: Winshuttle Interview Questions

2011-08-29 Thread Brijesh
Thanks for posting :P

-- 
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/-/jdGHjS_UdSQJ.
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] Adding Two no without using any operator...??

2011-08-27 Thread Brijesh
How to add two nos without using any operator...?

-- 
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/-/MpNKzlE3UuwJ.
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: Winshuttle Pattern and Question *Urgent*

2011-08-27 Thread Brijesh
lol.. Tu bhi yahin pe?
yaar samsung me intern he mili hai.. final offer nahi :| and btw
winshuttle us se achhi hai shayad!

On Aug 27, 4:08 pm, SANDEEP CHUGH  wrote:
> @birju : Samsung nhi leni kya??
>
> On Sat, Aug 27, 2011 at 12:45 PM, Brijesh wrote:
>
>
>
>
>
>
>
> > Can anyone please post the pattern and questions asked by winshuttle ,
> > as it is coming to my college tomorrow..??
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.> To post to this group, send email 
> > toalgoge...@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] Winshuttle Pattern and Question *Urgent*

2011-08-27 Thread Brijesh
Can anyone please post the pattern and questions asked by winshuttle ,
as it is coming to my college tomorrow..??

-- 
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: shortest swapping rows

2011-08-17 Thread Brijesh Upadhyay
IT is the question.. 
You are given an N x N matrix with 0 and 1 values. You can swap any two 
adjacent rows of the matrix.

Your goal is to have all the 1 values in the matrix below or on the main 
diagonal. That is, for each X where 1 ≤ X ≤ N, there must be no 1 values in 
row X 

that are to the right of column X.

Return the minimum number of row swaps you need to achieve the goal.

Input

The first line of input gives the number of cases, T. T test cases follow.
The first line of each test case has one integer, N. Each of the next N 
lines contains N characters. Each character is either 0 or 1.

Output

For each test case, output

Case #X: K
where X is the test case number, starting from 1, and K is the minimum 
number of row swaps needed to have all the 1 values in the matrix below or 
on the main 

diagonal.

You are guaranteed that there is a solution for each test case.

Limits

1 ≤ T ≤ 60

1 ≤ N ≤ 8

Input
  
 
3
2
10
11
3
001
100
010
4
1110
1100
1100
1000
Output 
Case #1: 0
Case #2: 2
Case #3: 4

-- 
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/-/aJHYyoc0z5sJ.
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: shortest swapping rows

2011-08-17 Thread Brijesh Upadhyay
Make an array of size n, and fill it with index of last 1 of corresponding 
row in the matrix.. as if row 0 has  1101100 , than arr[0]=4 .
so we end up with an array containing last position of 1 in the respective 
row.. 
lets arr[4] is like 3,2,2,1... we have to make it 1,2,2,3.. so now apply 
following swap rules.
i) if by swapping two element , greater element is goin into greater 
index...do the swapping else move to next as in 2 ,3 ,2 ,1 : dont swap first 
2 and 3..
ii) or by swapping two element , lesser element is goin into lesser index 
...
and when you reach till the end , move back.. it may require many iteration, 
so use recursion.. *first forward traversing , and then backward* and front 
and end of the array will be decremented by 1 in each iteration..
Please let me know if it is wrong..! 


 

-- 
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/-/Nbphh8aWnTkJ.
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.



Re: [algogeeks] Amazon Interview Q

2011-08-17 Thread Brijesh Upadhyay
At the node from where the loop just started.. anyway we could not use that 
logic , coz it isnt circular linked list! 

-- 
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/-/sr4w-kPmnEsJ.
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.



Re: [algogeeks] Amazon Interview Q

2011-08-17 Thread Brijesh Upadhyay
But it is not circular doubly linked list.,..so u could not traverse in 
backward dirction from HEAD node..

-- 
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/-/0KIdBDCY49MJ.
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] Make My Trip *URGENT*

2011-08-17 Thread Brijesh Upadhyay
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.



[algogeeks] Re: Number theory

2011-08-16 Thread Brijesh Upadhyay
Actually it was one of the assignments given to me in lab.. here is the code

#include 

#include 

using namespace std;

int a[20][20][20]; // Global declration to make every cell's default value 
to zero

// 3D matrix to implement the algorithm

void combinations(int number) // function that accepts the number whose 
combination , you

{

int i, j, k, larg, m, n, flag;

for(i=1; i<=number; i++)

a[i][0][0]=i;

i=1;

while(i<=number)

{

// first row of each number is copied by that number

// external loop to access no. whose combination are inserted

flag=1;

j=1;

do{

//position of rows that is being modified

// inner loop that will run through i

for(k=0; a[j][k][0]!=0; k++) // innermost loop that will check for 
largest/last no.

{

for(larg=0; a[j][k][larg]!=0; larg++); //to check last value

larg--;

if(i-j>a[j][k][larg])

{

for(m=0; m<=larg; m++)

a[i][flag][m] = a[j][k][m];

a[i][flag][m] = i-j;

flag++;

}

// comapring last value with difference

// copy all existing values to current number

// insert difference between numbers

//increase the pointer to insert next combination

}

j++;

}while(j<=i);

i++;

}

k=number;

for(i=0; a[k][i][0]!=0; i++) {

cout<>number;

combinations(number);

getch();

return 0;

}

//input the number whose combination you want

-- 
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/-/CsTCslXuC88J.
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] find numbers whose difference is min

2011-08-15 Thread Brijesh Upadhyay
Algorithm to find the two numbers whose difference is minimum among the set 
of numbers. For example the sequence is 5, 13, 7, 0, 10, 20, 1, 15, 4, 19 
The algorithm should return min diff = 20-19 = 1. Constraint - Time 
Complexity O(N) 

-- 
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/-/U8gTWUISJn8J.
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: C Output

2011-08-13 Thread Brijesh Upadhyay
I think i got it...  "STRING" always return address of S , which then get 
summed with 1 and 2.

-- 
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/-/kFrZUxzFTxsJ.
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] C Output

2011-08-13 Thread Brijesh Upadhyay
int main ()
{
  printf("%d",1+2+"5");
  getch();
  return 0;
} 


what should it return and how..??

-- 
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/-/2H3Gg6hLEQ0J.
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: String questions

2011-08-13 Thread Brijesh Upadhyay
Dynamic programming would surely help but i dont know the algo :| :P

-- 
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/-/MD3432cto60J.
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 Written Test Questions

2011-08-10 Thread Brijesh Upadhyay
Yeah...please share questions..it will be of a lot help!

-- 
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/-/cs4XYfgJrooJ.
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.



Re: [algogeeks] Re: Microsoft written!!!

2011-08-10 Thread Brijesh Upadhyay
thank u , i couldnot  have answered this :P

-- 
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/-/Gppo1P-Gr9oJ.
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.



Re: [algogeeks] pls help

2011-08-10 Thread Brijesh Upadhyay
It could have a maximum of 81 leaves with the same '40' no of internal 
nodes so for any value between 28 to 81, it would have only 40 internal 
nodes

-- 
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/-/hb7mifIIe1kJ.
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.



Re: [algogeeks] pls help

2011-08-09 Thread Brijesh Upadhyay
General approach would be , get the no of levels first by log 28 /log 3 , = 
4(use ceiling)...and now 3^0+3^1+3^2+3^3 = 40 will be no of internal nodes..

-- 
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/-/OyhD3tQ5uPgJ.
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.



Re: [algogeeks] pls help

2011-08-09 Thread Brijesh Upadhyay
1 produces 3 nodes , which then 9 nodes,--> 27 nodes , and thses 27 
nodes finally produces <=81 leaves so sum of 27+9+3+1= 40 is the right 
answer... i guess

-- 
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/-/6EblaEKZozcJ.
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.



Re: [algogeeks] pls help

2011-08-09 Thread Brijesh Upadhyay
80???  how can 80 internal nodes just produce only maximum of 81 leaves and 
that too in 3ary tree  
the answer is  1+3+9+27 = 40 internal nodes... think like this 

-- 
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/-/7h9t9fFsVs0J.
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.



Re: [algogeeks] pls help

2011-08-09 Thread Brijesh Upadhyay
I dont think 27 is the right answer,... it should be log 28 /log 3... i mean 
log 28 base 3 shuold be the no. of internal nodes !   and for any no of 
leaves , >27 &&  < 81, the answer would be same... 

-- 
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/-/DN0DIvuwNLQJ.
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 written!!!

2011-08-09 Thread Brijesh Upadhyay
 10
 4  5
   2  7  6 11
   1 39   8 12  13   14   15
let u have to fine leftmost right cousin of 8 . , move up , u get 10 as the 
ancestor , such that its left subtree contains 8 , unlike 7 ,4 (whose right 
subtree contains 8)!   now no of level u moved is 3 .. then traverse in 
the right subtree of 10 , and find left most node , by moving down 3 levels, 
and u get 12 as ur answer...

-- 
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/-/Lftrcml-FS0J.
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 written!!!

2011-08-09 Thread Brijesh Upadhyay
simple algo.. :
let we have to find leftmost right cousin of x!
>>  try to get an ancestor of the node x such that x lies in left subtree of 
that ancestor  , and count no of levels , say L,  u moved to get that 
ancestor..now start from that ancestor to get left most node IN THE RIGHT 
SUBTREE , by going down L levels... that might be ur answer... correct me , 
if i m wrong!

-- 
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/-/agOYaDD33H0J.
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 written!!!

2011-08-09 Thread Brijesh Upadhyay
simple algo.. :
let we have to find leftmost right cousin of x!
>>  try to get an ancestor of the node x such that x lies in left subtree of 
that ancestor  , and count no of levels , say L,  u moved to get that 
ancestor..now start from that ancestor to get left most node , by going down 
L levels... that might be ur answer... correct me , if i m wrong!

-- 
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/-/--VUgL7M18gJ.
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.



Re: [algogeeks] Probability question.. help

2011-08-09 Thread Brijesh Upadhyay
No thers is not.. someone has asked me this., dont know anything else about 
the question  :|

-- 
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/-/mqMvDgb6TqUJ.
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] Probability question.. help

2011-08-09 Thread Brijesh Upadhyay
100 men & women dance with each other. What is the Probability that a
man cannot dance with more than two women?

--
Regards,
Brijesh Upadhyay
CSE
Thapar University

-- 
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.



Re: [algogeeks] Re: Directi interview question

2011-08-08 Thread Brijesh Upadhyay
Yeah..right..!   u have to select continuous 10 petrol pumps , so just 
traverse through every set of 10 pumps with complexity of o(n). e.g. (1,10) 
(2,11) (3,12)(91 ,100)

-- 
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/-/MqV_rqnIbkMJ.
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] sizeof operator C..

2011-08-08 Thread Brijesh Upadhyay
#include
#include

int main()
{
int a[2]={1,2};

cout

Re: [algogeeks] Amazon Question

2011-08-08 Thread Brijesh Upadhyay
Yeah.. 3rd answer is 1:1 , for reference 
http://discuss.fogcreek.com/techInterview/default.asp?cmd=show&ixPost=150

-- 
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/-/jd2b6mmXq0IJ.
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.



Re: [algogeeks] C easy doubt

2011-08-08 Thread Brijesh Upadhyay
Thank you , every 1 . got it...

-- 
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/-/3cPVG1k4kJ4J.
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] C easy doubt

2011-08-08 Thread Brijesh Upadhyay
int main()
{
int a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12};
printf("%u %u %u",a, a+1,&a+1);
getch();
}

how &a+1 is valid..?? please explain

--
Regards,
Brijesh Upadhyay
CSE , final year.
Thapar University

-- 
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.



Re: [algogeeks] Re: Probability Puzzle

2011-08-07 Thread Brijesh Upadhyay
I think 17/80 is right answer.. otherwise no use of mentioning *first five 
times* specifically in the question. ! though m not sure 

-- 
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/-/1aMP_RgRaDYJ.
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

2011-08-07 Thread Brijesh Upadhyay , Computer Science , 4th year , Thapar Universoty
How?? could u please explain..? why not quick sort?

On Aug 7, 10:27 pm, rajeev bharshetty  wrote:
> b:Shell sort
>
> On Sun, Aug 7, 2011 at 10:56 PM, Kamakshii Aggarwal
> wrote:
>
>
>
>
>
>
>
>
>
> > 1.what is the best sorting method for almost sorted array?
> > a.quicksort
> > c.hapsort
> > c.shell sort
> > d.bubble
>
> > --
> > Regards,
> > Kamakshi
> > kamakshi...@gmail.com
>
> > --
> > 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.
>
> --
> Regards
> Rajeev N B 
>
> "*Winners Don't do Different things , they do things Differently"*

-- 
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

2011-08-07 Thread Brijesh Upadhyay , Computer Science , 4th year , Thapar Universoty
Could u please explain how shell sort... why not quick sort??

On Aug 7, 10:42 pm, sourabh jakhar  wrote:
> shell sort is the correct answer
>
> On Sun, Aug 7, 2011 at 11:09 PM, ankit sambyal wrote:
>
> > bubble sort
>
> > --
> > 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.
>
> --
> SOURABH JAKHAR,(CSE)(Final year)
> ROOM NO 167 ,
> TILAK,HOSTEL
> 'MNNIT ALLAHABAD
>
> The Law of Win says, "Let's not do it your way or my way; let's do it the
> best way."

-- 
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] C question.. increment decrement operator..

2011-08-03 Thread brijesh
Please give the output and explain..
main()
{
int i=7;
printf("%d\n",i++*i++);
printf("%d\n",i++*++i);
printf("%d\n",++i*i++);
printf("%d\n",++i*++i);
}

What is the order of execution!?

-- 
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] C question.. sizeof operator

2011-08-03 Thread brijesh
main()
{
int i,j;
i=10;
j=sizeof(++i);
printf("%d",i);
}

please give the output with explanation!

-- 
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 Written test Q-1

2011-08-02 Thread brijesh
We can do it by just having an extra pointer variable which will store
either rightmost 2's *next node* or left most 2's *previous node*(as
it is doubly linked list)..now start traversing through rear end , if
u get 1 , send it to front..if u get 3 send it to rear , and if u get
2 the insert it between last 2 and 3(using  rightmost 2's *next node*)
or last 1 and 2(left most 2's *previous node*)!...
e.g.front -> 1->2->3->1->1->1->2->3->2  <-rear
iteration1 :   front -> 1->2->3->1->1->1->2->3->2  <-rear   // u get 2
its ok.. as its first turn
iteration2 :   front -> 1->2->3->1->1->1->2->2->3  <-rear   // send 3
to rear , save last 2's next node in temporary pointer now carry on..
i hope u got what i meant!?
On Aug 2, 1:27 am, Lokesh  wrote:
> A doubly linked list has only 1,2 and 3 as values in nodes ..sort the
> linked list
>
> Ex.
> Q: 1->2->3->1->1->1->2->3->2
> O/P: 1->1->1->1->2->2->2->3->3
>
> Dont change the original LL.

-- 
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: adobe written round que

2011-07-29 Thread brijesh
@ankur I didnt get this... could u or anyone please elaborate!

On Jul 30, 12:43 am, Ankur Khurana  wrote:
> when you use itoa , what you get is a string. get the sum of all the digits
> , using c-'0' and then use repeated subtraction . . .
>
> On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh wrote:
>
>
>
>
>
>
>
>
>
> > repeated subtraction !!
>
> > On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora <
> > vivaciousnived...@gmail.com> wrote:
>
> >> Without using /,% and * operators. write a function to divide a number
> >> by 3. itoa() function is available.
>
> >> all i cn thnk of is to use shift operator and addition ,  x/3=e^(logx-
> >> log3) or repetitive subtraction
>
> >> but none of them uses itoa() ..ne idea how its done?
> >> thnks !
>
> >> --
> >> 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.
>
> --
> Ankur Khurana
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.

-- 
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.