Re: [algogeeks] probablity

2011-08-05 Thread nishaanth
Bayes theorem...

Approach :

P(pen from packet 1 | Blue) =2/3 (from Bayes rule)

P(pen from packet 2 | Blue) =1/3

Req prob = 2/3 + 1/3 . 1/2
   =5/6

On Fri, Aug 5, 2011 at 6:02 PM, abhishek iyer wrote:

> @Nishant.. Can u please explain ur approach.. I think its as per mentioned
> above 1/2...
> On 5 Aug 2011 21:30, "nishaanth"  wrote:
> > 5/6
> >
> > On Fri, Aug 5, 2011 at 5:55 PM, Rahul Jain 
> wrote:
> >
> >> i agree with puneet. 1/2
> >>
> >>
> >> On Fri, Aug 5, 2011 at 9:18 PM, Puneet Goyal  >wrote:
> >>
> >>> 1/2
> >>>
> >>> you got the blue pen so it is for sure that is one of the first two
> >>> packets, so you are left with a black pen and a blue pen and you have
> to
> >>> find the probability of finding a blue pen among them
> >>>
> >>> On Fri, Aug 5, 2011 at 9:14 PM, Kamakshii Aggarwal <
> >>> kamakshi...@gmail.com> wrote:
> >>>
>  I was given 3 packets, with 2 pens each.
> 
>  1st Packet has 2 blue pens.
> 
>  2nd Packet has 1 blue pen,1 black pen.
> 
>  3rd Packet has 2 black pens.
> 
> 
> 
>  I took any one packet and pulled out one pen. It turned out to be a
> blue
>  one.
> 
>  What is the probability that the next pen from the same packet will
> 
>  also be a blue one?
> 
>  --
>  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.
> 
> >>>
> >>>
> >>>
> >>> --
> >>> ---
> >>> Puneet Goyal
> >>> Student of B. Tech. III Year (Software Engineering)
> >>> Delhi Technological University, 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.
> >>>
> >>
> >> --
> >> 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.
> >>
> >
> >
> >
> > --
> > S.Nishaanth,
> > Computer Science and engineering,
> > IIT Madras.
> >
> > --
> > 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.
>



-- 
S.Nishaanth,
Computer Science and engineering,
IIT Madras.

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

2011-08-05 Thread abhishek iyer
@Nishant.. Can u please explain ur approach.. I think its as per mentioned
above 1/2...
On 5 Aug 2011 21:30, "nishaanth"  wrote:
> 5/6
>
> On Fri, Aug 5, 2011 at 5:55 PM, Rahul Jain  wrote:
>
>> i agree with puneet. 1/2
>>
>>
>> On Fri, Aug 5, 2011 at 9:18 PM, Puneet Goyal wrote:
>>
>>> 1/2
>>>
>>> you got the blue pen so it is for sure that is one of the first two
>>> packets, so you are left with a black pen and a blue pen and you have to
>>> find the probability of finding a blue pen among them
>>>
>>> On Fri, Aug 5, 2011 at 9:14 PM, Kamakshii Aggarwal <
>>> kamakshi...@gmail.com> wrote:
>>>
 I was given 3 packets, with 2 pens each.

 1st Packet has 2 blue pens.

 2nd Packet has 1 blue pen,1 black pen.

 3rd Packet has 2 black pens.



 I took any one packet and pulled out one pen. It turned out to be a
blue
 one.

 What is the probability that the next pen from the same packet will

 also be a blue one?

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

>>>
>>>
>>>
>>> --
>>> ---
>>> Puneet Goyal
>>> Student of B. Tech. III Year (Software Engineering)
>>> Delhi Technological University, 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.
>>>
>>
>> --
>> 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.
>>
>
>
>
> --
> S.Nishaanth,
> Computer Science and engineering,
> IIT Madras.
>
> --
> 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: Printf

2011-08-05 Thread SAMMM
Logical Address ... as Physical address is not accessable tht's wht OS
does , it maps the physical address to the logical address .

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

2011-08-05 Thread nishaanth
5/6

On Fri, Aug 5, 2011 at 5:55 PM, Rahul Jain  wrote:

> i agree with puneet. 1/2
>
>
> On Fri, Aug 5, 2011 at 9:18 PM, Puneet Goyal wrote:
>
>> 1/2
>>
>> you got the blue pen so it is for sure that is one of the first two
>> packets, so you are left with a black pen and a blue pen and you have to
>> find the probability of finding a blue pen among them
>>
>>  On Fri, Aug 5, 2011 at 9:14 PM, Kamakshii Aggarwal <
>> kamakshi...@gmail.com> wrote:
>>
>>>  I was given 3 packets, with 2 pens each.
>>>
>>> 1st Packet has 2 blue pens.
>>>
>>> 2nd Packet has 1 blue pen,1 black pen.
>>>
>>> 3rd Packet has 2 black pens.
>>>
>>>
>>>
>>> I took any one packet and pulled out one pen. It turned out to be a blue
>>> one.
>>>
>>> What is the probability that the next pen from the same packet will
>>>
>>> also be a blue one?
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> ---
>> Puneet Goyal
>> Student of B. Tech. III Year (Software Engineering)
>> Delhi Technological University, 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.
>>
>
>  --
> 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.
>



-- 
S.Nishaanth,
Computer Science and engineering,
IIT Madras.

-- 
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: Duplicates in a string

2011-08-05 Thread kartik sachan
@priya its some thing like this
for(i=0;a[i]!='\0';i++)
count['a[i]']++;

so its O(n) only

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

2011-08-05 Thread Rahul Jain
i agree with puneet. 1/2

On Fri, Aug 5, 2011 at 9:18 PM, Puneet Goyal wrote:

> 1/2
>
> you got the blue pen so it is for sure that is one of the first two
> packets, so you are left with a black pen and a blue pen and you have to
> find the probability of finding a blue pen among them
>
>  On Fri, Aug 5, 2011 at 9:14 PM, Kamakshii Aggarwal  > wrote:
>
>>  I was given 3 packets, with 2 pens each.
>>
>> 1st Packet has 2 blue pens.
>>
>> 2nd Packet has 1 blue pen,1 black pen.
>>
>> 3rd Packet has 2 black pens.
>>
>>
>>
>> I took any one packet and pulled out one pen. It turned out to be a blue
>> one.
>>
>> What is the probability that the next pen from the same packet will
>>
>> also be a blue one?
>>
>> --
>> 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.
>>
>
>
>
> --
> ---
> Puneet Goyal
> Student of B. Tech. III Year (Software Engineering)
> Delhi Technological University, 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.
>

-- 
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] output???

2011-08-05 Thread Rajesh Kumar
Thanks to all

On Fri, Aug 5, 2011 at 8:53 PM, sukran dhawan wrote:

> coz by default all real values are converted to double and it is larger
> than float.ie real nos are not stored accurately inside computer memory.so
> since double occupies more memory it prints hi
>
>
> On Fri, Aug 5, 2011 at 8:24 PM, Kamakshii Aggarwal 
> wrote:
>
>> the reason is dat 0.7 is treated as double..therefore double(0.7)
>> >float(0.7)
>>
>> On Fri, Aug 5, 2011 at 8:20 PM, kartik sachan wrote:
>>
>>> the output will be hi
>>>
>>> even if u have putted equal to sign there this is becoz 0.7 do not
>>> exactly stored like 0.7 in a but some thing lesser as describe in ASCII
>>> format
>>> that's why it is awlays lesser than 0.7
>>>
>>>  --
>>> 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,
>> 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.
>>
>
>  --
> 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
Rajesh 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.



Re: [algogeeks] Re: Duplicates in a string

2011-08-05 Thread nishaanth
@deepikayour solution is not O(n) i guess...
@Sachinthe question says compress the *same* string. By 'printing' i
dont know what you mean

On Fri, Aug 5, 2011 at 5:17 PM, deepikaanand wrote:

> static int array[256];
> removedupli(char s[],int n)
> {
> array[s[0]]=1;
> for(i=1;i {
> if(array[s[i]]==0)
> array[s[i]]=1;
> else
> {
> for(pos=i;i s[pos]=s[pos+1];
> i--;
>
> --
> 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.
>
>


-- 
S.Nishaanth,
Computer Science and engineering,
IIT Madras.

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

2011-08-05 Thread Puneet Goyal
1/2

you got the blue pen so it is for sure that is one of the first two packets,
so you are left with a black pen and a blue pen and you have to find the
probability of finding a blue pen among them

On Fri, Aug 5, 2011 at 9:14 PM, Kamakshii Aggarwal wrote:

> I was given 3 packets, with 2 pens each.
>
> 1st Packet has 2 blue pens.
>
> 2nd Packet has 1 blue pen,1 black pen.
>
> 3rd Packet has 2 black pens.
>
>
>
> I took any one packet and pulled out one pen. It turned out to be a blue
> one.
>
> What is the probability that the next pen from the same packet will
>
> also be a blue one?
>
> --
> 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.
>



-- 
---
Puneet Goyal
Student of B. Tech. III Year (Software Engineering)
Delhi Technological University, 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.



Re: [algogeeks] array pointer

2011-08-05 Thread mohit goyal
n=x, is correct
or n = &x[0][0] is correct

On 8/5/11, Arshad Alam  wrote:
> we can equate base address of double dimension array to a pointer variable,
> tell me which one is correct. if "n" is a pointer variable and x[5][5] is
> double dimension array
>
>1. n=x;
>2. n=x[0][0];
>3. both
>
> --
> 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.
>
>


-- 
Laugh as much as you breathe and love as long as you live.

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

2011-08-05 Thread arvind kumar
Jus use Baye's theorem.its a direct n simple app of dat:)

On Fri, Aug 5, 2011 at 9:14 PM, Kamakshii Aggarwal wrote:

> I was given 3 packets, with 2 pens each.
>
> 1st Packet has 2 blue pens.
>
> 2nd Packet has 1 blue pen,1 black pen.
>
> 3rd Packet has 2 black pens.
>
>
>
> I took any one packet and pulled out one pen. It turned out to be a blue
> one.
>
> What is the probability that the next pen from the same packet will
>
> also be a blue one?
>
> --
> 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.
>

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

2011-08-05 Thread Kamakshii Aggarwal
 I was given 3 packets, with 2 pens each.

1st Packet has 2 blue pens.

2nd Packet has 1 blue pen,1 black pen.

3rd Packet has 2 black pens.



I took any one packet and pulled out one pen. It turned out to be a blue
one.

What is the probability that the next pen from the same packet will

also be a blue one?

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



Re: [algogeeks] MICRSOFT WRITEN TEST

2011-08-05 Thread raj kumar
Ms written test
besides objective test you will get three or four subjective questions which
happened in our case:
so be prepared for UML diagrams:
There's high probability that the questions can repeat
So do these:(don,t remember exactly b'coz i wasn't eligible to sit so
writing the questions which i heard from others)
.algorithm for implementing find and replace utility of notepad.
.how to handel race condition in database.

-- 
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] output???

2011-08-05 Thread sukran dhawan
coz by default all real values are converted to double and it is larger than
float.ie real nos are not stored accurately inside computer memory.so
since double occupies more memory it prints hi

On Fri, Aug 5, 2011 at 8:24 PM, Kamakshii Aggarwal wrote:

> the reason is dat 0.7 is treated as double..therefore double(0.7)
> >float(0.7)
>
> On Fri, Aug 5, 2011 at 8:20 PM, kartik sachan wrote:
>
>> the output will be hi
>>
>> even if u have putted equal to sign there this is becoz 0.7 do not exactly
>> stored like 0.7 in a but some thing lesser as describe in ASCII format
>> that's why it is awlays lesser than 0.7
>>
>>  --
>> 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,
> 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.
>

-- 
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: MICRSOFT WRITEN TEST

2011-08-05 Thread Agyat
Q1> Find shortest distance pair of point among n points in a 2d space.
soln:- CLRS(comp geomentry nlogn soln)


Q2> design  an elevator?
soln:- use semaphores,syn construct etc.

Q3> reverse every k nodes of  a ll?

there will be some o/p questions in c if applied for IDC profle and in
C++ if applied for IT Profile of MS

THEY WANT RUNNING CODE DUDE I MEAN RUNNING NO SINGLE ERROR SHOULD BE
THERE

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

2011-08-05 Thread sukran dhawan
Its logical address !!

On Fri, Aug 5, 2011 at 5:07 PM, Dipankar Patro  wrote:

> +1 to logical address.
> User programs are never given access to physical address.
>
>
> On 5 August 2011 17:00, muthu raj  wrote:
>
>> physical adress is never acessible.Those who claim physical adress pls
>> support ur answers.
>> *Muthuraj R
>> IV th Year , ISE
>> PESIT , Bangalore*
>>
>>
>>
>>
>> On Fri, Aug 5, 2011 at 4:57 PM, Kamakshii Aggarwal > > wrote:
>>
>>> logical address
>>>
>>>
>>> On Fri, Aug 5, 2011 at 2:20 PM, Amol Sharma wrote:
>>>
 physical address i think
 --


 Amol Sharma
 Third Year Student
 Computer Science and Engineering
 MNNIT Allahabad




 On Fri, Aug 5, 2011 at 1:01 AM, amit karmakar <
 amit.codenam...@gmail.com> wrote:

> Some discussions here,
> http://ubuntuforums.org/showthread.php?t=316081
> and some here,
> http://groups.google.com/group/comp.lang.c/msg/21250e8fe083e4f8
>
> On Aug 5, 12:51 pm, Anurag Narain  wrote:
> > i think logical address...physical address is never accessible to
> user
> > program
> >
> > @amit-can u explain why??
>
> --
> 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.

>>>
>>>
>>>
>>> --
>>> 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.
>>>
>>
>>  --
>> 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.
>>
>
>
>
> --
>
> ___
>
> Please do not print this e-mail until urgent requirement. Go Green!!
> Save Papers <=> Save Trees
>
> --
> 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.



Re: [algogeeks] MS

2011-08-05 Thread sukran dhawan
Even adding positive numbers can be done in o(n) ryt !?

On Fri, Aug 5, 2011 at 8:04 PM, muthu raj  wrote:

> Yeah Kadanes algorithm. It can be done in O(n);
>
> *Muthuraj R
> IV th Year , ISE
> PESIT , Bangalore*
>
>
>
>
> On Fri, Aug 5, 2011 at 6:49 PM, Naren s  wrote:
>
>> http://people.csail.mit.edu/bdean/6.046/dp/
>>
>> --
>> 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.
>

-- 
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: Duplicates in a string

2011-08-05 Thread deepikaanand
static int array[256];
removedupli(char s[],int n)
{
array[s[0]]=1;
for(i=1;ihttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Duplicates in a string

2011-08-05 Thread keyan karthi
u can use a bool array size- 26 and do char[i]-'A' = 1 , check it to
decide the first instance of the character. this can be done in O(n).
u can even use bit mask to make ur code look better ( ;) )

On 8/5/11, priya v  wrote:
> If an additional storage is used to store the frequency / marker searching
> the frequency/marker in the array would require an additional nested loop.
> Would it still be O(n)?
>
> On Fri, Aug 5, 2011 at 8:36 PM, kartik sachan
> wrote:
>
>> I think in this case count sort type thing would work better way
>>
>> just take a array of max 26(as 26 CHARACTER ARE THERE)
>>
>> and using index as count['M']=store how many times M  has comes
>>
>> similary store other character
>>
>> now print array whose value >0
>>
>> but IN this case u might lost the ORDER..(but that can
>> be done using binary search using T(log(n))
>>
>>
>> the total time complexcity is O(n)
>>
>>  --
>> 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.
>
>

-- 
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] Duplicates in a string

2011-08-05 Thread priya v
If an additional storage is used to store the frequency / marker searching
the frequency/marker in the array would require an additional nested loop.
Would it still be O(n)?

On Fri, Aug 5, 2011 at 8:36 PM, kartik sachan wrote:

> I think in this case count sort type thing would work better way
>
> just take a array of max 26(as 26 CHARACTER ARE THERE)
>
> and using index as count['M']=store how many times M  has comes
>
> similary store other character
>
> now print array whose value >0
>
> but IN this case u might lost the ORDER..(but that can
> be done using binary search using T(log(n))
>
>
> the total time complexcity is O(n)
>
>  --
> 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.



Re: [algogeeks] Duplicates in a string

2011-08-05 Thread kartik sachan
I think in this case count sort type thing would work better way

just take a array of max 26(as 26 CHARACTER ARE THERE)

and using index as count['M']=store how many times M  has comes

similary store other character

now print array whose value >0

but IN this case u might lost the ORDER..(but that can
be done using binary search using T(log(n))


the total time complexcity is O(n)

-- 
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] Duplicates in a string

2011-08-05 Thread Sachin Jain
We can do it in just one pass.
Start scanning the array and whichever element gets scanned just store some
kind of marker in the additional array that this element has been
vsisted.Next time you get some element if that element (or character) is not
visited earlier than mark it as visited and print it or if it was visited
earlier just skip it.

On Fri, Aug 5, 2011 at 8:30 PM, nishaanth  wrote:

> Store the frequency of all the letters in an array in one scan(like
> counting sort). In the next pass remove the duplicates and appropriately
> shift . takes 2 O(n) passes i guess
>
>
> On Fri, Aug 5, 2011 at 4:50 PM, priya v  wrote:
>
>>
>> Remove duplicate alphabets from a string and compress it in the same
>> string. For
>> example, MISSISSIPPI becomes MISP. O (n2) is not acceptable.
>> For this problem is it a good idea to sort the array using a sorting
>> technique with efficiency O(nlogn)
>> and remove the duplicates?
>>
>> --
>> 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.
>>
>
>
>
> --
> S.Nishaanth,
> Computer Science and engineering,
> IIT Madras.
>
>  --
> 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] Samsung SISO Question

2011-08-05 Thread bagaria.ka...@gmail.com
Given a rope of 10m , numbered at 1m i.e like
0  1  2  3  4  5  6  7  8  9  10
||---|---|---|---|---|---|---|---|---|
|---10m|

One dry out it clothes of various length like 4m from 0-4 then of 2m from
6-8 then 6m from 2-8 and so on ,one on top of another , then u need to
construct a data structure such that
when seeing from the top u have to give the number of clothes drying , at
one particular instance.
-- 
Thanks and Regards

*Karan Bagaria*
*MCA Final Year*
Training and Placement Representative

-- 
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] array pointer

2011-08-05 Thread Arshad Alam
we can equate base address of double dimension array to a pointer variable,
tell me which one is correct. if "n" is a pointer variable and x[5][5] is
double dimension array

   1. n=x;
   2. n=x[0][0];
   3. both

-- 
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] Duplicates in a string

2011-08-05 Thread nishaanth
Store the frequency of all the letters in an array in one scan(like counting
sort). In the next pass remove the duplicates and appropriately shift .
takes 2 O(n) passes i guess

On Fri, Aug 5, 2011 at 4:50 PM, priya v  wrote:

>
> Remove duplicate alphabets from a string and compress it in the same
> string. For
> example, MISSISSIPPI becomes MISP. O (n2) is not acceptable.
> For this problem is it a good idea to sort the array using a sorting
> technique with efficiency O(nlogn)
> and remove the duplicates?
>
> --
> 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.
>



-- 
S.Nishaanth,
Computer Science and engineering,
IIT Madras.

-- 
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] output???

2011-08-05 Thread Kamakshii Aggarwal
the reason is dat 0.7 is treated as double..therefore double(0.7)
>float(0.7)

On Fri, Aug 5, 2011 at 8:20 PM, kartik sachan wrote:

> the output will be hi
>
> even if u have putted equal to sign there this is becoz 0.7 do not exactly
> stored like 0.7 in a but some thing lesser as describe in ASCII format
> that's why it is awlays lesser than 0.7
>
>  --
> 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,
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.



Re: [algogeeks] output???

2011-08-05 Thread bagaria.ka...@gmail.com
.7 in float is taken like .699 i blv ?

On Fri, Aug 5, 2011 at 8:20 PM, kartik sachan wrote:

> the output will be hi
>
> even if u have putted equal to sign there this is becoz 0.7 do not exactly
> stored like 0.7 in a but some thing lesser as describe in ASCII format
> that's why it is awlays lesser than 0.7
>
>  --
> 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.
>



-- 
Thanks and Regards

*Karan Bagaria*
*MCA Final Year*
Training and Placement Representative
*NIT Durgapur*

-- 
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] MICRSOFT WRITEN TEST

2011-08-05 Thread Tushar Bindal
they always repeat questions.
go through lined list and trees questions on geeksforgeeks like finding loop
in LL, path in a binary tree (not BST) for a given sum, addition of numbers
stored digitwise in a linked list.
Printing 2d matrix in spiral order, KMP algorithm - these are some questions
they asked in interviews.

this one was asked to several candidates:
given: ddbbccae
output: 2d4a2b2c1a1e
isn't that easy?

On Fri, Aug 5, 2011 at 11:03 AM, siddharam suresh
wrote:

> thank you
> Thank you,
> Siddharam
>
>
>
> On Fri, Aug 5, 2011 at 10:51 AM, Poised~  wrote:
>
>> try this:
>> https://groups.google.com/forum/?hl=en#!topic/algogeeks/Mbah1QXrJB4
>>
>> --
>> 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/-/pB2VUcnr9igJ.
>>
>> 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.
>



-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.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.



Re: [algogeeks] output???

2011-08-05 Thread kartik sachan
the output will be hi

even if u have putted equal to sign there this is becoz 0.7 do not exactly
stored like 0.7 in a but some thing lesser as describe in ASCII format
that's why it is awlays lesser than 0.7

-- 
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] Duplicates in a string

2011-08-05 Thread priya v
Remove duplicate alphabets from a string and compress it in the same string.
For
example, MISSISSIPPI becomes MISP. O (n2) is not acceptable.
For this problem is it a good idea to sort the array using a sorting
technique with efficiency O(nlogn)
and remove the duplicates?

-- 
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] output???

2011-08-05 Thread Rajesh Kumar
program output comes - hi
why??

#include
main()
{
float a=0.7;
if(.7> a)
printf("hi\n");
else
printf("hello\n");
}

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



Re: [algogeeks] Re: Puzzle

2011-08-05 Thread Tushar Bindal
"of this double, half is kept inside the well, and the other half is used as
input to the 2nd well"

half mean 1/2 or 50%
how can we assume it to be 100???
if we take it to be 1/2, the question goes wrong, so ur concept is valid but
then question should have been framed correctly

On Fri, Aug 5, 2011 at 7:55 PM, Lakshmi Prasad
wrote:

> I didn't understand it fully plese explain
>
> On Aug 4, 2:48 pm, sagar pareek  wrote:
> > double 87.5 gives you 175
> > 100 will be used by 1st well and 75 will be used by second
> > now second well will double the 75 and will give you 150
> > 100 will be used by second and remainder 50 will forwarded to third
> > now third one use 50 and will double it to 100
> >
> > no remainder left
> > i think its clear now  :) :)
> >
> > On Fri, Aug 5, 2011 at 12:14 AM, Himanshu Srivastava <
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > himanshusri...@gmail.com> wrote:
> > > i mean @sagar:how did you get 87.5%??
> >
> > > On Fri, Aug 5, 2011 at 12:13 AM, Himanshu Srivastava <
> > > himanshusri...@gmail.com> wrote:
> >
> > >> @nikhil:how did you get 87.5%??
> >
> > >> On Thu, Aug 4, 2011 at 11:59 PM, sagar pareek  >wrote:
> >
> > >>> 87.5 %
> >
> > >>> On Thu, Aug 4, 2011 at 10:39 PM, Nikhil Gupta <
> nikhilgupta2...@gmail.com
> > >>> > wrote:
> >
> >  There are 3 magical wells. Any input quantity of water we provide
> the
> >  1st well is returned double (of this double, half is kept inside the
> well,
> >  and the other half is used as input to the 2nd well).
> >  The 2nd well also returns double the quantity of its input (of which
> >  half is kept inside the well, and the other half is used as input to
> the 3rd
> >  well). Same goes with the 3rd, but its half output is the remainder
> (other
> >  half being kept inside the well). Now what input should we provide
> in the
> >  1st well, so that the remainder at the end comes out to be zero?
> >
> >  (Asked in classroom coaching of T.I.M.E.)
> >  --
> >  Nikhil Gupta
> >  Senior Co-ordinator, Publicity
> >  CSI, NSIT Students' Branch
> >  NSIT, New Delhi, India
> >
> >   --
> >  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
> > >>> SAGAR PAREEK
> > >>> COMPUTER SCIENCE AND ENGINEERING
> > >>> NIT ALLAHABAD
> >
> > >>>  --
> > >>> 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.
> >
> > --
> > **Regards
> > SAGAR PAREEK
> > COMPUTER SCIENCE AND ENGINEERING
> > NIT ALLAHABAD
>
> --
> 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.
>
>


-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tushicom...@gmail.com
Website: www.jugadengg.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.



Re: [algogeeks] MS

2011-08-05 Thread muthu raj
Yeah Kadanes algorithm. It can be done in O(n);

*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Fri, Aug 5, 2011 at 6:49 PM, Naren s  wrote:

> http://people.csail.mit.edu/bdean/6.046/dp/
>
> --
> 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] PTR Q

2011-08-05 Thread Vijay Khandar
Pointers provide a convenient way to represent multidimensional
arrays, allowing a single  array multidimensional array to be replaced
by a lower-dimensional array of pointers.

this statement is true or false...
Plz Explain

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

2011-08-05 Thread Lakshmi Prasad
I didn't understand it fully plese explain

On Aug 4, 2:48 pm, sagar pareek  wrote:
> double 87.5 gives you 175
> 100 will be used by 1st well and 75 will be used by second
> now second well will double the 75 and will give you 150
> 100 will be used by second and remainder 50 will forwarded to third
> now third one use 50 and will double it to 100
>
> no remainder left
> i think its clear now  :) :)
>
> On Fri, Aug 5, 2011 at 12:14 AM, Himanshu Srivastava <
>
>
>
>
>
>
>
>
>
> himanshusri...@gmail.com> wrote:
> > i mean @sagar:how did you get 87.5%??
>
> > On Fri, Aug 5, 2011 at 12:13 AM, Himanshu Srivastava <
> > himanshusri...@gmail.com> wrote:
>
> >> @nikhil:how did you get 87.5%??
>
> >> On Thu, Aug 4, 2011 at 11:59 PM, sagar pareek wrote:
>
> >>> 87.5 %
>
> >>> On Thu, Aug 4, 2011 at 10:39 PM, Nikhil Gupta  >>> > wrote:
>
>  There are 3 magical wells. Any input quantity of water we provide the
>  1st well is returned double (of this double, half is kept inside the 
>  well,
>  and the other half is used as input to the 2nd well).
>  The 2nd well also returns double the quantity of its input (of which
>  half is kept inside the well, and the other half is used as input to the 
>  3rd
>  well). Same goes with the 3rd, but its half output is the remainder 
>  (other
>  half being kept inside the well). Now what input should we provide in the
>  1st well, so that the remainder at the end comes out to be zero?
>
>  (Asked in classroom coaching of T.I.M.E.)
>  --
>  Nikhil Gupta
>  Senior Co-ordinator, Publicity
>  CSI, NSIT Students' Branch
>  NSIT, New Delhi, India
>
>   --
>  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
> >>> SAGAR PAREEK
> >>> COMPUTER SCIENCE AND ENGINEERING
> >>> NIT ALLAHABAD
>
> >>>  --
> >>> 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.
>
> --
> **Regards
> SAGAR PAREEK
> COMPUTER SCIENCE AND ENGINEERING
> NIT ALLAHABAD

-- 
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] simple doubt

2011-08-05 Thread Vijay Khandar
but u initialized **dp means .
ex-dp=&p  and p=&arr then its correct so dp contains addr of p which inturns
contains addrof arr  now **dp is correct initialization.

On Fri, Aug 5, 2011 at 7:45 PM, Arun Vishwanathan wrote:

> i see but is not arr a pointer to first array element and so &arr contain
> address of that pointer ?
>
>
> On Fri, Aug 5, 2011 at 4:06 PM, Vijay Khandar wrote:
>
>> I dont think so dp=&arr;   since **dp; dp contains the addr of another ptr
>> variable...
>>
>>   On Fri, Aug 5, 2011 at 7:27 PM, Arun Vishwanathan <
>> aaron.nar...@gmail.com> wrote:
>>
>>>
>>> I guess someone had posted a link earlier from which I have a basic doubt
>>>
>>> when u have
>>>
>>> int arr[3]={1,0,2};
>>> int **dp;
>>> int (*pa)[3];
>>>
>>> is this the right assingment for instance?
>>>
>>> pa=arr;
>>> dp=&arr;
>>>
>>> or have I flipped the ampersand in assigning?
>>>
>>> Also when I do pa++ will it jump by size of int or the whole array
>>> size it points to?
>>> --
>>>  "People often say that motivation doesn't last. Well, neither does
>>> bathing - that's why we recommend it daily."
>>>
>>> --
>>> 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.
>>
>
>
>
> --
>  "People often say that motivation doesn't last. Well, neither does
> bathing - that's why we recommend it daily."
>
>  --
> 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.



Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
Yes due to this only i m getting proper o/p, but why it is necessary in
Turbo C++ compiler.?

On Fri, Aug 5, 2011 at 7:41 PM, Rohit Srivastava wrote:

> try using dev or any new 32bit compiler it wont give that error!!!
> or try using this
> void linkfloat(void)
> {
>  float a=0,*b=&a;
>  a=*b;
> }
> this code forces the emulator to be linked
> On Fri, Aug 5, 2011 at 7:38 PM, Vijay Khandar wrote:
>
>> Yes correct,  In m using very old compiler Turbo C++
>>
>>
>> On Fri, Aug 5, 2011 at 7:34 PM, Rohit Srivastava 
>> wrote:
>>
>>> you might get error: floating pointing formats not linked!!
>>> but thats obsolete! I don't compiler these days will give such an error
>>> otherwise code written by Dipankar will solve ur problem if u r unable to
>>> take multi-word input
>>> On Fri, Aug 5, 2011 at 7:24 PM, Dipankar Patro wrote:
>>>
 try doing this way and tell if the program is working properly now:
 for (i=0; i<3; i++)
 {
  scanf("%[^\n]", e[i].name);
  scanf("%f", e[i].sal);
 }

 There is always some problem in string input using %s, don't really know
 why though deeply.

 On 5 August 2011 17:48, Vijay Khandar  wrote:

> But program is not working properly...
>
>
> On Fri, Aug 5, 2011 at 5:44 PM, Nikhil Gupta <
> nikhilgupta2...@gmail.com> wrote:
>
>> Couldn't find any error.
>>
>> On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar <
>> vijaykhand...@gmail.com> wrote:
>>
>>> What errors are you likely to get when you run the following program?
>>>
>>> #include
>>> #include
>>> #include
>>> void main()
>>> {
>>> clrscr();
>>> struct emp
>>> {
>>> char name[20];
>>> float sal;
>>> };
>>> struct emp e[10];
>>> int i;
>>> for(i=0;i<=3;i++)
>>> scanf("%s %f",e[i].name,&e[i].sal);
>>> getch();
>>> }
>>>
>>> Plz Explain anyone.
>>>
>>> Vijay..
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>> Nikhil Gupta
>> Senior Co-ordinator, Publicity
>> CSI, NSIT Students' Branch
>> NSIT, New Delhi, India
>>
>>  --
>> 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.
>



 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers <=> Save Trees

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

Re: [algogeeks] simple doubt

2011-08-05 Thread Arun Vishwanathan
i see but is not arr a pointer to first array element and so &arr contain
address of that pointer ?

On Fri, Aug 5, 2011 at 4:06 PM, Vijay Khandar wrote:

> I dont think so dp=&arr;   since **dp; dp contains the addr of another ptr
> variable...
>
>   On Fri, Aug 5, 2011 at 7:27 PM, Arun Vishwanathan <
> aaron.nar...@gmail.com> wrote:
>
>>
>> I guess someone had posted a link earlier from which I have a basic doubt
>>
>> when u have
>>
>> int arr[3]={1,0,2};
>> int **dp;
>> int (*pa)[3];
>>
>> is this the right assingment for instance?
>>
>> pa=arr;
>> dp=&arr;
>>
>> or have I flipped the ampersand in assigning?
>>
>> Also when I do pa++ will it jump by size of int or the whole array size it
>> points to?
>> --
>>  "People often say that motivation doesn't last. Well, neither does
>> bathing - that's why we recommend it daily."
>>
>> --
>> 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.
>



-- 
 "People often say that motivation doesn't last. Well, neither does bathing
- that's why we recommend it daily."

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

2011-08-05 Thread Rohit Srivastava
try using dev or any new 32bit compiler it wont give that error!!!
or try using this
void linkfloat(void)
{
 float a=0,*b=&a;
 a=*b;
}
this code forces the emulator to be linked
On Fri, Aug 5, 2011 at 7:38 PM, Vijay Khandar wrote:

> Yes correct,  In m using very old compiler Turbo C++
>
>
> On Fri, Aug 5, 2011 at 7:34 PM, Rohit Srivastava 
> wrote:
>
>> you might get error: floating pointing formats not linked!!
>> but thats obsolete! I don't compiler these days will give such an error
>> otherwise code written by Dipankar will solve ur problem if u r unable to
>> take multi-word input
>> On Fri, Aug 5, 2011 at 7:24 PM, Dipankar Patro wrote:
>>
>>> try doing this way and tell if the program is working properly now:
>>> for (i=0; i<3; i++)
>>> {
>>>  scanf("%[^\n]", e[i].name);
>>>  scanf("%f", e[i].sal);
>>> }
>>>
>>> There is always some problem in string input using %s, don't really know
>>> why though deeply.
>>>
>>> On 5 August 2011 17:48, Vijay Khandar  wrote:
>>>
 But program is not working properly...


 On Fri, Aug 5, 2011 at 5:44 PM, Nikhil Gupta >>> > wrote:

> Couldn't find any error.
>
> On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar  > wrote:
>
>> What errors are you likely to get when you run the following program?
>>
>> #include
>> #include
>> #include
>> void main()
>> {
>> clrscr();
>> struct emp
>> {
>> char name[20];
>> float sal;
>> };
>> struct emp e[10];
>> int i;
>> for(i=0;i<=3;i++)
>> scanf("%s %f",e[i].name,&e[i].sal);
>> getch();
>> }
>>
>> Plz Explain anyone.
>>
>> Vijay..
>>
>> --
>> 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.
>>
>>
>
>
> --
> Nikhil Gupta
> Senior Co-ordinator, Publicity
> CSI, NSIT Students' Branch
> NSIT, New Delhi, India
>
>  --
> 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.

>>>
>>>
>>>
>>> --
>>>
>>> ___
>>>
>>> Please do not print this e-mail until urgent requirement. Go Green!!
>>> Save Papers <=> Save Trees
>>>
>>> --
>>> 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.
>>
>
>  --
> 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.



Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
Yes correct,  In m using very old compiler Turbo C++

On Fri, Aug 5, 2011 at 7:34 PM, Rohit Srivastava wrote:

> you might get error: floating pointing formats not linked!!
> but thats obsolete! I don't compiler these days will give such an error
> otherwise code written by Dipankar will solve ur problem if u r unable to
> take multi-word input
> On Fri, Aug 5, 2011 at 7:24 PM, Dipankar Patro wrote:
>
>> try doing this way and tell if the program is working properly now:
>> for (i=0; i<3; i++)
>> {
>>  scanf("%[^\n]", e[i].name);
>>  scanf("%f", e[i].sal);
>> }
>>
>> There is always some problem in string input using %s, don't really know
>> why though deeply.
>>
>> On 5 August 2011 17:48, Vijay Khandar  wrote:
>>
>>> But program is not working properly...
>>>
>>>
>>> On Fri, Aug 5, 2011 at 5:44 PM, Nikhil Gupta 
>>> wrote:
>>>
 Couldn't find any error.

 On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar 
 wrote:

> What errors are you likely to get when you run the following program?
>
> #include
> #include
> #include
> void main()
> {
> clrscr();
> struct emp
> {
> char name[20];
> float sal;
> };
> struct emp e[10];
> int i;
> for(i=0;i<=3;i++)
> scanf("%s %f",e[i].name,&e[i].sal);
> getch();
> }
>
> Plz Explain anyone.
>
> Vijay..
>
> --
> 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.
>
>


 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

  --
 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.
>>>
>>
>>
>>
>> --
>>
>> ___
>>
>> Please do not print this e-mail until urgent requirement. Go Green!!
>> Save Papers <=> Save Trees
>>
>> --
>> 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.
>

-- 
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] simple doubt

2011-08-05 Thread Vijay Khandar
I dont think so dp=&arr;   since **dp; dp contains the addr of another ptr
variable...

On Fri, Aug 5, 2011 at 7:27 PM, Arun Vishwanathan wrote:

>
> I guess someone had posted a link earlier from which I have a basic doubt
>
> when u have
>
> int arr[3]={1,0,2};
> int **dp;
> int (*pa)[3];
>
> is this the right assingment for instance?
>
> pa=arr;
> dp=&arr;
>
> or have I flipped the ampersand in assigning?
>
> Also when I do pa++ will it jump by size of int or the whole array size it
> points to?
> --
>  "People often say that motivation doesn't last. Well, neither does
> bathing - that's why we recommend it daily."
>
>  --
> 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.



Re: [algogeeks] Question

2011-08-05 Thread Rohit Srivastava
which compiler are u using
?

On Fri, Aug 5, 2011 at 7:29 PM, Vijay Khandar wrote:

> I include this fn linkfloat(), Now my program working properlybut
> why we have to include this fn externally plz explain.
>
>
> On Fri, Aug 5, 2011 at 6:07 PM, SANDEEP CHUGH wrote:
>
>> INCLUDE THIS FUNCTION
>> linkfloat( )
>> {
>> float a = , *b ;
>> b = &a ;  /* cause emulator to be linked */
>> a = *b ;/* suppress the warning - variable not used */
>> };
>>
>> On Fri, Aug 5, 2011 at 6:04 PM, Vijay Khandar wrote:
>>
>>> But program is not giving the o/p.
>>> I have taken one printf statement same as scanf..and scanf() taking
>>> i/p but prinf() not giving o/p...
>>>
>>>
>>> On Fri, Aug 5, 2011 at 5:53 PM, Nikhil Gupta 
>>> wrote:
>>>
 http://www.ideone.com/ZIibX

 The changes I have done in the program are to make it compatible to gcc
 compiler.
 Check the statement in the bottom of the page.

 On Fri, Aug 5, 2011 at 5:46 PM, Vijay Khandar 
 wrote:

> What errors are you likely to get when you run the following program?
>
> #include
> #include
> #include
> void main()
> {
> clrscr();
> struct emp
> {
> char name[20];
> float sal;
> };
> struct emp e[10];
> int i;
> for(i=0;i<=3;i++)
> scanf("%s %f",e[i].name,&e[i].sal);
> getch();
> }
>
> A)floating point format not linked
> B)Suspicious pointer conversion
> C)Cannot use scanf() for structures
> D)Strings cannot be nested inside structures
>
> Plz Explain anyone.
>
> Vijay.
>
> --
> 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.
>
>


 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

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

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

2011-08-05 Thread Rohit Srivastava
you might get error: floating pointing formats not linked!!
but thats obsolete! I don't compiler these days will give such an error
otherwise code written by Dipankar will solve ur problem if u r unable to
take multi-word input
On Fri, Aug 5, 2011 at 7:24 PM, Dipankar Patro  wrote:

> try doing this way and tell if the program is working properly now:
> for (i=0; i<3; i++)
> {
>  scanf("%[^\n]", e[i].name);
>  scanf("%f", e[i].sal);
> }
>
> There is always some problem in string input using %s, don't really know
> why though deeply.
>
> On 5 August 2011 17:48, Vijay Khandar  wrote:
>
>> But program is not working properly...
>>
>>
>> On Fri, Aug 5, 2011 at 5:44 PM, Nikhil Gupta 
>> wrote:
>>
>>> Couldn't find any error.
>>>
>>> On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar 
>>> wrote:
>>>
 What errors are you likely to get when you run the following program?

 #include
 #include
 #include
 void main()
 {
 clrscr();
 struct emp
 {
 char name[20];
 float sal;
 };
 struct emp e[10];
 int i;
 for(i=0;i<=3;i++)
 scanf("%s %f",e[i].name,&e[i].sal);
 getch();
 }

 Plz Explain anyone.

 Vijay..

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


>>>
>>>
>>> --
>>> Nikhil Gupta
>>> Senior Co-ordinator, Publicity
>>> CSI, NSIT Students' Branch
>>> NSIT, New Delhi, India
>>>
>>>  --
>>> 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.
>>
>
>
>
> --
>
> ___
>
> Please do not print this e-mail until urgent requirement. Go Green!!
> Save Papers <=> Save Trees
>
> --
> 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.



Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
I include this fn linkfloat(), Now my program working properlybut
why we have to include this fn externally plz explain.

On Fri, Aug 5, 2011 at 6:07 PM, SANDEEP CHUGH wrote:

> INCLUDE THIS FUNCTION
> linkfloat( )
> {
> float a = , *b ;
> b = &a ;  /* cause emulator to be linked */
> a = *b ;/* suppress the warning - variable not used */
> };
>
> On Fri, Aug 5, 2011 at 6:04 PM, Vijay Khandar wrote:
>
>> But program is not giving the o/p.
>> I have taken one printf statement same as scanf..and scanf() taking
>> i/p but prinf() not giving o/p...
>>
>>
>> On Fri, Aug 5, 2011 at 5:53 PM, Nikhil Gupta 
>> wrote:
>>
>>> http://www.ideone.com/ZIibX
>>>
>>> The changes I have done in the program are to make it compatible to gcc
>>> compiler.
>>> Check the statement in the bottom of the page.
>>>
>>> On Fri, Aug 5, 2011 at 5:46 PM, Vijay Khandar 
>>> wrote:
>>>
 What errors are you likely to get when you run the following program?

 #include
 #include
 #include
 void main()
 {
 clrscr();
 struct emp
 {
 char name[20];
 float sal;
 };
 struct emp e[10];
 int i;
 for(i=0;i<=3;i++)
 scanf("%s %f",e[i].name,&e[i].sal);
 getch();
 }

 A)floating point format not linked
 B)Suspicious pointer conversion
 C)Cannot use scanf() for structures
 D)Strings cannot be nested inside structures

 Plz Explain anyone.

 Vijay.

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


>>>
>>>
>>> --
>>> Nikhil Gupta
>>> Senior Co-ordinator, Publicity
>>> CSI, NSIT Students' Branch
>>> NSIT, New Delhi, India
>>>
>>>  --
>>> 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.
>>
>
>  --
> 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] simple doubt

2011-08-05 Thread Arun Vishwanathan
I guess someone had posted a link earlier from which I have a basic doubt

when u have

int arr[3]={1,0,2};
int **dp;
int (*pa)[3];

is this the right assingment for instance?

pa=arr;
dp=&arr;

or have I flipped the ampersand in assigning?

Also when I do pa++ will it jump by size of int or the whole array size it
points to?
-- 
 "People often say that motivation doesn't last. Well, neither does bathing
- that's why we recommend it daily."

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

2011-08-05 Thread Dipankar Patro
try doing this way and tell if the program is working properly now:
for (i=0; i<3; i++)
{
 scanf("%[^\n]", e[i].name);
 scanf("%f", e[i].sal);
}

There is always some problem in string input using %s, don't really know why
though deeply.

On 5 August 2011 17:48, Vijay Khandar  wrote:

> But program is not working properly...
>
>
> On Fri, Aug 5, 2011 at 5:44 PM, Nikhil Gupta wrote:
>
>> Couldn't find any error.
>>
>> On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar wrote:
>>
>>> What errors are you likely to get when you run the following program?
>>>
>>> #include
>>> #include
>>> #include
>>> void main()
>>> {
>>> clrscr();
>>> struct emp
>>> {
>>> char name[20];
>>> float sal;
>>> };
>>> struct emp e[10];
>>> int i;
>>> for(i=0;i<=3;i++)
>>> scanf("%s %f",e[i].name,&e[i].sal);
>>> getch();
>>> }
>>>
>>> Plz Explain anyone.
>>>
>>> Vijay..
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>> Nikhil Gupta
>> Senior Co-ordinator, Publicity
>> CSI, NSIT Students' Branch
>> NSIT, New Delhi, India
>>
>>  --
>> 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.
>



-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers <=> Save Trees

-- 
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] Random number

2011-08-05 Thread Gaurav Menghani
1. Get a good seed.
2. Increase the degree of the polynomial.

This is no fixed algorithm, if you find that more than T steps have
passed and a new number has not been generated, you can always change
the polynomial. And, please remember it is a 'pseudo-random number
generator'. You can read the theory about PRNGs and LFSRs, all of them
repeat.

On Fri, Aug 5, 2011 at 7:14 PM, payel roy  wrote:
> How do you guarantee termination of your algorithm if duplication occurs ??
>
> On 5 August 2011 18:25, Gaurav Menghani  wrote:
>>
>> You might want to read the theory on Pseudo-Random Number Generators
>> [0] and Linear Feedback Shift Register [1]
>>
>> The basic way of generating a random number is taking up a polynomial,
>> f(x) = ax^n + bx^(n-1) + .. + yx + z, and finding f(i + seed) % N,
>> where i is the ith random number you want, and seed can be anything
>> random available, for example, you can find the current millisecond
>> using time.h functions.
>>
>> A simple implementation, without the time thing is below:
>>
>> #include
>> using namespace std;
>>
>> int poly[10],pn,N,M;
>> int get(int seed)
>> {
>>        int t=0;
>>        for(int i=0;i>        {
>>                int res=poly[i];
>>                for(int j=1;j<=(i+1);j++) { res = (res*seed); if(res>=N)
>> res%=N; }
>>                t+=res;
>>                if(t>=N) t%=N;
>>        }
>>        t=(t+seed);
>>        t%=N;
>>        return t;
>> }
>>
>> void setup_prng()
>> {
>>        pn=5;
>>        poly[0]=2; poly[1]=3; poly[2]=5; poly[3]=7; poly[4]=11;
>>        N=200; M=100;
>> }
>>
>> int main()
>> {
>>        setup_prng();
>>        for(int i=1;i<=M;i++)
>>                cout<>        return 0;
>> }
>>
>> Whenever there is a collision, you can increment the value passed to
>> the random number generator and continue. However, I am not sure how
>> to check for collisions in O(1) space.
>>
>> [0] http://en.wikipedia.org/wiki/Pseudorandom_number_generator
>> [1] http://en.wikipedia.org/wiki/Linear_feedback_shift_register
>>
>> On Fri, Aug 5, 2011 at 5:19 PM, payel roy  wrote:
>> > Given a range 0-N, generate 'M' random numbers from the range without
>> > any
>> > duplication. The space complexity is O(1).
>> >
>> > --
>> > 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.
>> >
>>
>>
>>
>> --
>> Gaurav Menghani
>>
>> --
>> 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.
>



-- 
Gaurav Menghani

-- 
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] Random number

2011-08-05 Thread payel roy
How do you guarantee termination of your algorithm if duplication occurs ??

On 5 August 2011 18:25, Gaurav Menghani  wrote:

> You might want to read the theory on Pseudo-Random Number Generators
> [0] and Linear Feedback Shift Register [1]
>
> The basic way of generating a random number is taking up a polynomial,
> f(x) = ax^n + bx^(n-1) + .. + yx + z, and finding f(i + seed) % N,
> where i is the ith random number you want, and seed can be anything
> random available, for example, you can find the current millisecond
> using time.h functions.
>
> A simple implementation, without the time thing is below:
>
> #include
> using namespace std;
>
> int poly[10],pn,N,M;
> int get(int seed)
> {
>int t=0;
>for(int i=0;i{
>int res=poly[i];
>for(int j=1;j<=(i+1);j++) { res = (res*seed); if(res>=N)
> res%=N; }
>t+=res;
>if(t>=N) t%=N;
>}
>t=(t+seed);
>t%=N;
>return t;
> }
>
> void setup_prng()
> {
>pn=5;
>poly[0]=2; poly[1]=3; poly[2]=5; poly[3]=7; poly[4]=11;
>N=200; M=100;
> }
>
> int main()
> {
>setup_prng();
>for(int i=1;i<=M;i++)
>cout }
>
> Whenever there is a collision, you can increment the value passed to
> the random number generator and continue. However, I am not sure how
> to check for collisions in O(1) space.
>
> [0] http://en.wikipedia.org/wiki/Pseudorandom_number_generator
> [1] http://en.wikipedia.org/wiki/Linear_feedback_shift_register
>
> On Fri, Aug 5, 2011 at 5:19 PM, payel roy  wrote:
> > Given a range 0-N, generate 'M' random numbers from the range without any
> > duplication. The space complexity is O(1).
> >
> > --
> > 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.
> >
>
>
>
> --
> Gaurav Menghani
>
> --
> 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.



Re: [algogeeks] Circle

2011-08-05 Thread deepika anand
u can use bresenhems algo  or mid point (2nd order algo)

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

2011-08-05 Thread Nitin Nizhawan
I think this will do.
http://en.wikipedia.org/wiki/Midpoint_circle_algorithm

On Fri, Aug 5, 2011 at 7:08 PM, rShetty  wrote:

> Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without
> making use of any floating point
> computations at all.
>
> --
> 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.



Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread Nitin Nizhawan
@deepika this is a different question, your solution is great for removing
duplicate characters. original question is about removing duplicate words.

On Fri, Aug 5, 2011 at 7:06 PM, deepikaanand wrote:

> ya an array of 256 is surely a wastage of space but this was i couls
> think in my microsoft interview as the result should have also been i
> place that is
> i/p : AAA BBB CCC
> o/p:A BC//space should also be removed
> ::explanantion
> s[0] is alwayz unique therfor array[s[0]] = 1 => this char has already
> occured
> if the encountered s[i] has corresponding array[s[i]]==0 =>this char
> has not occured yet
> else
> delete dat particular char at pos 'i' n decrement i
>
> --
> 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] Circle

2011-08-05 Thread rShetty
Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without
making use of any floating point
computations at all.

-- 
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: remove duplicate words in a string

2011-08-05 Thread deepikaanand
ya an array of 256 is surely a wastage of space but this was i couls
think in my microsoft interview as the result should have also been i
place that is
i/p : AAA BBB CCC
o/p:A BC//space should also be removed
::explanantion
s[0] is alwayz unique therfor array[s[0]] = 1 => this char has already
occured
if the encountered s[i] has corresponding array[s[i]]==0 =>this char
has not occured yet
else
delete dat particular char at pos 'i' n decrement i

-- 
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] Makemytrip.com

2011-08-05 Thread snehi jain
NIT kurukshetra people ... could post some information regarding the
procedure followed by makemytrip during their recruitment process ...



On Sat, Jul 30, 2011 at 1:51 AM, sukhmeet singh wrote:

> CTC ???
>
>
> On Thu, Jul 28, 2011 at 10:22 PM, Raman Gugnani <
> ramangugnani@gmail.com> wrote:
>
>> Hi Can anyone please tell me where from and how to prepare for
>> MAKEMYTRIP.COM intern test..It is coming to NIT Kurukshetra campus
>> next week..! Also tell how this company is Good /Bad...??
>>
>> --
>> 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.
>

-- 
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] Reverse Bits

2011-08-05 Thread rajeev bharshetty
@mithun : Thanks

On Fri, Aug 5, 2011 at 6:37 PM, mithun bs  wrote:

> Hi Rajeev,
>
> I follow similar approach. The basic logic is swap bits of a pair, then
> swap nibbles(2 bits) and then swap (4bits), 8bits  and go on.
>
> So for ex. 0110 1101 1100 0101
> In first step, I swap bits of each pair. So this becomes,
>
> Input -  0110 1101 1100 0101
> output- 1001 1110 1100 1010
>
> In second step, I swap 2bits
>
> Input - 1001 1110 1100 1010
> output-0110 1011 0011 1010
>
> I swap 4 bits now
>
> Input - 0110 1011 0011 1010
> output-1011 0110 1010 0011
>
> Now I swap 8bits
> Input - 1011 0110 1010 0011
> output-1010 0011 1011 0110
>
> So, now we have the bits in reverse order.
>
> First step I do this way
> x = ((x | 0x) >> 2) | (x<<2) | 0x;
> Next step similarly
> x = ((x | 0x) >> 4) | (x<<4) | 0x;
>
> This is the logic.
> Your code does the reverse way.
>
> Regards,
> Mithun
>
> On Fri, Aug 5, 2011 at 6:04 PM, rShetty  wrote:
>
>> This is the code to reverse the bits in an unsigned integer .
>> Could anyone please explain the logic of this approach ? Thank You !!
>>
>> #define reverse(x) \
>> (x=x>>16|(0x&x)<<16, \
>> x=(0xff00ff00&x)>>8|(0x00ff00ff&x)<<8, \
>> x=(0xf0f0f0f0&x)>>4|(0x0f0f0f0f&x)<<4, \
>> x=(0x&x)>>2|(0x&x)<<2, \
>> x=(0x&x)>>1|(0x&x)<<1)
>>
>> --
>> 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.
>>
>>
>
>
> --
> Mithun.B.S
> M:9916775380
>
>  --
> 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.



Re: [algogeeks] remove duplicate words in a string

2011-08-05 Thread Anika Jain
@vaibhav : the question was for this input output shall be where there is a
will way

On Fri, Aug 5, 2011 at 1:51 PM, vaibhav shukla wrote:

> Given a string,remove all duplicates words:
>
> input: where there is a will there is a way
>
> o/p : where will way.
>
> --
>   best wishes!!
> Vaibhav
>   MCA
>
>  --
> 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] nlogn, in-place, iterative mergesort?

2011-08-05 Thread Nitin Nizhawan
 does anyone know of any in-place, iterative mergesort algorithm with nlogN
worst case complexity? It would be good if it is stable also.

TIA
Nitin

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

2011-08-05 Thread Naren s
http://people.csail.mit.edu/bdean/6.046/dp/

-- 
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: remove duplicate words in a string

2011-08-05 Thread mithun bs
Can you please explain this?
Is array[256] not extra space?

On Fri, Aug 5, 2011 at 5:14 PM, deepikaanand wrote:

> static int array[256];
> removedupli(char s[],int n)
> {
> array[s[0]]=1;
> for(i=1;i {
> if(array[s[i]]==0)
> array[s[i]]=1;
> else
> {
> for(pos=i;i s[pos]=s[pos+1];
> i--;
> }
> }
>
>
>
> }
>
> --
> 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.
>
>


-- 
Mithun.B.S
M:9916775380

-- 
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] Reverse Bits

2011-08-05 Thread mithun bs
Hi Rajeev,

I follow similar approach. The basic logic is swap bits of a pair, then swap
nibbles(2 bits) and then swap (4bits), 8bits  and go on.

So for ex. 0110 1101 1100 0101
In first step, I swap bits of each pair. So this becomes,

Input -  0110 1101 1100 0101
output- 1001 1110 1100 1010

In second step, I swap 2bits

Input - 1001 1110 1100 1010
output-0110 1011 0011 1010

I swap 4 bits now

Input - 0110 1011 0011 1010
output-1011 0110 1010 0011

Now I swap 8bits
Input - 1011 0110 1010 0011
output-1010 0011 1011 0110

So, now we have the bits in reverse order.

First step I do this way
x = ((x | 0x) >> 2) | (x<<2) | 0x;
Next step similarly
x = ((x | 0x) >> 4) | (x<<4) | 0x;

This is the logic.
Your code does the reverse way.

Regards,
Mithun

On Fri, Aug 5, 2011 at 6:04 PM, rShetty  wrote:

> This is the code to reverse the bits in an unsigned integer .
> Could anyone please explain the logic of this approach ? Thank You !!
>
> #define reverse(x) \
> (x=x>>16|(0x&x)<<16, \
> x=(0xff00ff00&x)>>8|(0x00ff00ff&x)<<8, \
> x=(0xf0f0f0f0&x)>>4|(0x0f0f0f0f&x)<<4, \
> x=(0x&x)>>2|(0x&x)<<2, \
> x=(0x&x)>>1|(0x&x)<<1)
>
> --
> 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.
>
>


-- 
Mithun.B.S
M:9916775380

-- 
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] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package

2011-08-05 Thread Nitin Nizhawan
if input starts with one or more characters from the string "A telephone
girl" then it will give SEG FAULT because it scanf will try to write to CS,
else initial value "junk" will be printed

On Fri, Aug 5, 2011 at 6:28 PM, Lakshmi Prasad
wrote:

> for some inputs its giving "junk" as the answer and for others its giving
> segmentation fault
>
> could u plese explain why
>
> --
> 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/-/E1TOuF3IY2EJ.
>
> 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.



Re: [algogeeks] Reverse Bits

2011-08-05 Thread Nitin Nizhawan
x = x>>16 | (0x&x)<<16
this line exchanges ls 16bits with ms 16bits, i.e. 1 pair of 16bit

this logic of exchanging bits is the used for 2 pairs of 8bits each, then
for 4 pairs of 4bit, then for 8 pairs of 2 bit and finally 16 pairs of 1bit.


On Fri, Aug 5, 2011 at 6:04 PM, rShetty  wrote:

> This is the code to reverse the bits in an unsigned integer .
> Could anyone please explain the logic of this approach ? Thank You !!
>
> #define reverse(x) \
> (x=x>>16|(0x&x)<<16, \
> x=(0xff00ff00&x)>>8|(0x00ff00ff&x)<<8, \
> x=(0xf0f0f0f0&x)>>4|(0x0f0f0f0f&x)<<4, \
> x=(0x&x)>>2|(0x&x)<<2, \
> x=(0x&x)>>1|(0x&x)<<1)
>
> --
> 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.



Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package

2011-08-05 Thread Lakshmi Prasad
for some inputs its giving "junk" as the answer and for others its giving 
segmentation fault 

could u plese explain why  

-- 
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/-/E1TOuF3IY2EJ.
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] Random number

2011-08-05 Thread Gaurav Menghani
You might want to read the theory on Pseudo-Random Number Generators
[0] and Linear Feedback Shift Register [1]

The basic way of generating a random number is taking up a polynomial,
f(x) = ax^n + bx^(n-1) + .. + yx + z, and finding f(i + seed) % N,
where i is the ith random number you want, and seed can be anything
random available, for example, you can find the current millisecond
using time.h functions.

A simple implementation, without the time thing is below:

#include
using namespace std;

int poly[10],pn,N,M;
int get(int seed)
{
int t=0;
for(int i=0;i=N) 
res%=N; }
t+=res;
if(t>=N) t%=N;
}
t=(t+seed);
t%=N;
return t;
}

void setup_prng()
{
pn=5;
poly[0]=2; poly[1]=3; poly[2]=5; poly[3]=7; poly[4]=11;
N=200; M=100;
}

int main()
{
setup_prng();
for(int i=1;i<=M;i++)
cout Given a range 0-N, generate 'M' random numbers from the range without any
> duplication. The space complexity is O(1).
>
> --
> 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.
>



-- 
Gaurav Menghani

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

2011-08-05 Thread SANDEEP CHUGH
INCLUDE THIS FUNCTION
linkfloat( )
{
float a = , *b ;
b = &a ;  /* cause emulator to be linked */
a = *b ;/* suppress the warning - variable not used */
};

On Fri, Aug 5, 2011 at 6:04 PM, Vijay Khandar wrote:

> But program is not giving the o/p.
> I have taken one printf statement same as scanf..and scanf() taking i/p
> but prinf() not giving o/p...
>
>
> On Fri, Aug 5, 2011 at 5:53 PM, Nikhil Gupta wrote:
>
>> http://www.ideone.com/ZIibX
>>
>> The changes I have done in the program are to make it compatible to gcc
>> compiler.
>> Check the statement in the bottom of the page.
>>
>> On Fri, Aug 5, 2011 at 5:46 PM, Vijay Khandar wrote:
>>
>>> What errors are you likely to get when you run the following program?
>>>
>>> #include
>>> #include
>>> #include
>>> void main()
>>> {
>>> clrscr();
>>> struct emp
>>> {
>>> char name[20];
>>> float sal;
>>> };
>>> struct emp e[10];
>>> int i;
>>> for(i=0;i<=3;i++)
>>> scanf("%s %f",e[i].name,&e[i].sal);
>>> getch();
>>> }
>>>
>>> A)floating point format not linked
>>> B)Suspicious pointer conversion
>>> C)Cannot use scanf() for structures
>>> D)Strings cannot be nested inside structures
>>>
>>> Plz Explain anyone.
>>>
>>> Vijay.
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>> Nikhil Gupta
>> Senior Co-ordinator, Publicity
>> CSI, NSIT Students' Branch
>> NSIT, New Delhi, India
>>
>>  --
>> 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.
>

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

2011-08-05 Thread Vijay Khandar
But program is not giving the o/p.
I have taken one printf statement same as scanf..and scanf() taking i/p
but prinf() not giving o/p...

On Fri, Aug 5, 2011 at 5:53 PM, Nikhil Gupta wrote:

> http://www.ideone.com/ZIibX
>
> The changes I have done in the program are to make it compatible to gcc
> compiler.
> Check the statement in the bottom of the page.
>
> On Fri, Aug 5, 2011 at 5:46 PM, Vijay Khandar wrote:
>
>> What errors are you likely to get when you run the following program?
>>
>> #include
>> #include
>> #include
>> void main()
>> {
>> clrscr();
>> struct emp
>> {
>> char name[20];
>> float sal;
>> };
>> struct emp e[10];
>> int i;
>> for(i=0;i<=3;i++)
>> scanf("%s %f",e[i].name,&e[i].sal);
>> getch();
>> }
>>
>> A)floating point format not linked
>> B)Suspicious pointer conversion
>> C)Cannot use scanf() for structures
>> D)Strings cannot be nested inside structures
>>
>> Plz Explain anyone.
>>
>> Vijay.
>>
>> --
>> 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.
>>
>>
>
>
> --
> Nikhil Gupta
> Senior Co-ordinator, Publicity
> CSI, NSIT Students' Branch
> NSIT, New Delhi, India
>
>  --
> 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] Reverse Bits

2011-08-05 Thread rShetty
This is the code to reverse the bits in an unsigned integer .
Could anyone please explain the logic of this approach ? Thank You !!

#define reverse(x) \
(x=x>>16|(0x&x)<<16, \
x=(0xff00ff00&x)>>8|(0x00ff00ff&x)<<8, \
x=(0xf0f0f0f0&x)>>4|(0x0f0f0f0f&x)<<4, \
x=(0x&x)>>2|(0x&x)<<2, \
x=(0x&x)>>1|(0x&x)<<1)

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

2011-08-05 Thread SANDEEP CHUGH
ITS (A). BECAUSE WE HAVE TO LINK THE EMULATOR AS COMPILER SEES A  REFERENCE
TO  FLOATING POINT NUMBER IT SETS ITS FLAG TO HAVE THE LINKER LINK INT THE
EMULATOR.. ITS IN 16 BIT COMPILER BECAUSE THERE IS NO PROVISION FOR FLOATING
POINT OPERATIONS IN 16 BIT MICRO PROCESSOR..SO THEY USE FLOATING POINT
EMULATOR... NOT IN VC++


On Fri, Aug 5, 2011 at 5:46 PM, Vijay Khandar wrote:

> What errors are you likely to get when you run the following program?
>
> #include
> #include
> #include
> void main()
> {
> clrscr();
> struct emp
> {
> char name[20];
> float sal;
> };
> struct emp e[10];
> int i;
> for(i=0;i<=3;i++)
> scanf("%s %f",e[i].name,&e[i].sal);
> getch();
> }
>
> A)floating point format not linked
> B)Suspicious pointer conversion
> C)Cannot use scanf() for structures
> D)Strings cannot be nested inside structures
>
> Plz Explain anyone.
>
> Vijay.
>
> --
> 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.



Re: [algogeeks] Re: Puzzle

2011-08-05 Thread Arun Vishwanathan
I guess anubhav soln seems ok

On Thu, Aug 4, 2011 at 8:50 PM, ankit sambyal wrote:

> @aditi:Thats a non uniform rope. The 1st half may burn faster than 2nd
> half.
> btw Priyanka's solution is correct.
>
> --
>  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.



Re: [algogeeks] Question

2011-08-05 Thread Nikhil Gupta
http://www.ideone.com/ZIibX

The changes I have done in the program are to make it compatible to gcc
compiler.
Check the statement in the bottom of the page.

On Fri, Aug 5, 2011 at 5:46 PM, Vijay Khandar wrote:

> What errors are you likely to get when you run the following program?
>
> #include
> #include
> #include
> void main()
> {
> clrscr();
> struct emp
> {
> char name[20];
> float sal;
> };
> struct emp e[10];
> int i;
> for(i=0;i<=3;i++)
> scanf("%s %f",e[i].name,&e[i].sal);
> getch();
> }
>
> A)floating point format not linked
> B)Suspicious pointer conversion
> C)Cannot use scanf() for structures
> D)Strings cannot be nested inside structures
>
> Plz Explain anyone.
>
> Vijay.
>
> --
> 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.
>
>


-- 
Nikhil Gupta
Senior Co-ordinator, Publicity
CSI, NSIT Students' Branch
NSIT, New Delhi, India

-- 
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] Samsung Written

2011-08-05 Thread parag khanna
Apti 1 hour

-- 
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] Samsung Written

2011-08-05 Thread Nitin
can anybody give details for smasung written and interview ?

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

2011-08-05 Thread Vijay Khandar
But program is not working properly...

On Fri, Aug 5, 2011 at 5:44 PM, Nikhil Gupta wrote:

> Couldn't find any error.
>
> On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar wrote:
>
>> What errors are you likely to get when you run the following program?
>>
>> #include
>> #include
>> #include
>> void main()
>> {
>> clrscr();
>> struct emp
>> {
>> char name[20];
>> float sal;
>> };
>> struct emp e[10];
>> int i;
>> for(i=0;i<=3;i++)
>> scanf("%s %f",e[i].name,&e[i].sal);
>> getch();
>> }
>>
>> Plz Explain anyone.
>>
>> Vijay..
>>
>> --
>> 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.
>>
>>
>
>
> --
> Nikhil Gupta
> Senior Co-ordinator, Publicity
> CSI, NSIT Students' Branch
> NSIT, New Delhi, India
>
>  --
> 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] Question

2011-08-05 Thread Vijay Khandar
What errors are you likely to get when you run the following program?

#include
#include
#include
void main()
{
clrscr();
struct emp
{
char name[20];
float sal;
};
struct emp e[10];
int i;
for(i=0;i<=3;i++)
scanf("%s %f",e[i].name,&e[i].sal);
getch();
}

A)floating point format not linked
B)Suspicious pointer conversion
C)Cannot use scanf() for structures
D)Strings cannot be nested inside structures

Plz Explain anyone.

Vijay.

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

2011-08-05 Thread Nikhil Gupta
Couldn't find any error.

On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar wrote:

> What errors are you likely to get when you run the following program?
>
> #include
> #include
> #include
> void main()
> {
> clrscr();
> struct emp
> {
> char name[20];
> float sal;
> };
> struct emp e[10];
> int i;
> for(i=0;i<=3;i++)
> scanf("%s %f",e[i].name,&e[i].sal);
> getch();
> }
>
> Plz Explain anyone.
>
> Vijay..
>
> --
> 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.
>
>


-- 
Nikhil Gupta
Senior Co-ordinator, Publicity
CSI, NSIT Students' Branch
NSIT, New Delhi, India

-- 
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] Amazon Question

2011-08-05 Thread Arun Vishwanathan
hmm the problem is we need O(1) spacehaving that count wont make it
O(1).

i had an approach in mind of O(n) time and O(1) space..problem is i havent
tested/debugged the code but it is O(1) space i guess and O(n) time.


if total number of zeros(M) and 1s(N) are same print the whole array
else

the logic i used is something like this...
1)traverse the array from 0 to n
2)2 pointers , one pointing to the first 0 and other pointing to the first 1
in the array
3)i and j are 2 variables to keep count of 0 and 1 that we have seen so far
as we keep traversing
4) 2 more varibales are used to maintain count of left over 0s and 1s from
our current position( we know the total number of zeros and ones in O(n))
5)if at any point i is equal to j and either left over 0s or 1s is 0 then
print array from lesser of pointer index(lesser means one of the pointers is
behind the other) till current index we are looking at
the prtining from lesser pointer index till current index is if only none of
the pointers have been changed in the process in between

6) in case i or j becomes greater than N or M repsectively

i do some steps with pointer updation...i am just posting the codemaybe
u can check and see if it is logically ok..it hasnt been tested

M is number of zerso in array
N is number of ones in array
ptri=pointer to array
ptrj=pointer to array
 i and j hold count of 0 and 1 respectively as i move along array

M is number of zeros N is number of ones in the array ..u can find this in
O(n)..if they are equal print whole array

else


chnagei=0;
changej=0;
ptri=null
ptrj=null;
done0=0;
done1=0;
savestart=null
saveend=Null;


for(int index=0;indexN)
   {
   ptri=ptri+(N-i)
changei=1;
i=i-(N-i);
   if(j!=0 && i>N-j)
{
j=0;
  N--;

  }
}


  if(j>M)
  {
  ptrj=ptrj+(M-j);
changej=1;
j=j-(M-j);
   if(i!=0 && j>M-i)
 {
   i=0;
   M--;

 }
  }




}

print from save start to save end..that is answer

On Fri, Aug 5, 2011 at 1:09 PM, surender sanke  wrote:

> Hi,
>
> for 1 do +1
> for 0 do -1
> maintain count at every index of array
> eg:  100110
> array   X 1 0  0  0  0  0  0  1  1  0
> count   0 1 0 -1 -2 -3 -4 -5 -4 -3 -4
> index  -1 0 1  2  3  4  5  6  7  8  9
>
> find count with same value having max index difference.
> -3 is count at index 4 and 8
> max difference is 8-4 = 4
> -4 is count at index 5 and 9
> max difference is 9-5 = 4
> to reduce traverse time after count calculation
> take a map>;
> i - first index of array having same count,
> j - last index of array having same count
> as and when u encounter count create map value with i
> else if already exist update j, and update max with MAX(j-i,max)
>
> Surender
>
>   On Fri, Aug 5, 2011 at 2:25 PM, Arun Vishwanathan <
> aaron.nar...@gmail.com> wrote:
>
>>
>> by the way doesnt it look like an O(n^2) algo?
>>
>> On Fri, Aug 5, 2011 at 10:53 AM, Arun Vishwanathan <
>> aaron.nar...@gmail.com> wrote:
>>
>>>
>>> would u mind giving a short explanation of yr code too if possible?
>>>
>>>
>>> On Thu, Aug 4, 2011 at 5:38 PM, Apoorve Mohan wrote:
>>>
 I think this should worktell me if this works...

 void longest_0_1_substring(char *str)
 {
 int size=0,count=0,max=0,pos=0,prev=0,prev_pos=0,ptr=0,i=0,j=0;

 while(*str++)
 size++;
 str -= (size + 1);

 while(i>>> {
 for(j=i;(j < size) && (str[j]==str[j+1]);++j)
 count++;
 count++;
 if(ptr > 1)
 {
 if(count >= prev)
 {
 if(prev > max)
 {
 max = prev;
 pos = prev_pos;
 }
 }
 else
 {
 if(count > max)
 {
 max = count;
 pos = i - prev;
 }
 }
 }
 prev = count;
 prev_pos = i;
 i += count;
 ++ptr;
 count = 0;
 }

 printf("substring starts at position %d and is of size %d
 .",pos,max);



 }

 On Thu, Aug 4, 2011 at 6:25 PM, himanshu kansal <
 himanshukansal...@gmail.com> wrote:

> okie...can someone do it in O(n) space...bt time shld be linear
> only
>
>
> On Thu, Aug 4, 2011 at 2:13 AM, Prakash D wrote:
>
>> O(1) space is t hard  for this task
>>
>>
>> On Thu, Aug 4, 2011 at 12:55 AM, payel roy wrote:
>>
>>> Is there any solution for the above?
>>>
>>>
>>> On 3 August 2011 21:09, coder coder wrote:
>>>
 ya amazon will be visiting our campus within few days

 --
 You received this message because you are subscribed to the Google
 

[algogeeks] Question

2011-08-05 Thread Vijay Khandar
What errors are you likely to get when you run the following program?

#include
#include
#include
void main()
{
clrscr();
struct emp
{
char name[20];
float sal;
};
struct emp e[10];
int i;
for(i=0;i<=3;i++)
scanf("%s %f",e[i].name,&e[i].sal);
getch();
}

Plz Explain anyone.

Vijay..

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

2011-08-05 Thread payel roy
Kadane algorithm. Google it.


On 5 August 2011 17:35, rShetty  wrote:

> You're given an array containing both positive and negative integers
> and required to find the sub-
> array with the largest sum (O(N) a la KBL). Write a routine in C for
> the above
>
> Is this problem as simple as just adding the positive numbers with the
> subarray with largest sum being the set of positive numbers in the
> array .
> Or is there any complications , please explain
>
> Thankyou
>
> --
> 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] MS

2011-08-05 Thread rShetty
You're given an array containing both positive and negative integers
and required to find the sub-
array with the largest sum (O(N) a la KBL). Write a routine in C for
the above

Is this problem as simple as just adding the positive numbers with the
subarray with largest sum being the set of positive numbers in the
array .
Or is there any complications , please explain

Thankyou

-- 
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] Structure Q

2011-08-05 Thread Vijay Khandar
Thanks.

On Fri, Aug 5, 2011 at 5:26 PM, ankit sambyal wrote:

> error
> because head is a pointer to the structure, hence head.x gives an error
>
> --
> 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.



Re: [algogeeks] Structure Q

2011-08-05 Thread Vijay Khandar
Thanks

On Fri, Aug 5, 2011 at 5:25 PM, SANDEEP CHUGH wrote:

> ERROR
>
> On Fri, Aug 5, 2011 at 5:19 PM, Vijay Khandar wrote:
>
>> struct list
>> {
>> int x;
>> struct list *next;
>> }*head;
>>
>> The statement head.x=100
>> A)assigns 100 to one element of the structure list
>> B)creates a node of type list and assigns a value to x
>> C)creates a head of the list
>> D)error
>>
>> Plz anyone provide correct option 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.
>>
>>
>  --
> 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.



Re: [algogeeks] Structure Q

2011-08-05 Thread ankit sambyal
error
because head is a pointer to the structure, hence head.x gives an error

-- 
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] Structure Q

2011-08-05 Thread SANDEEP CHUGH
ERROR

On Fri, Aug 5, 2011 at 5:19 PM, Vijay Khandar wrote:

> struct list
> {
> int x;
> struct list *next;
> }*head;
>
> The statement head.x=100
> A)assigns 100 to one element of the structure list
> B)creates a node of type list and assigns a value to x
> C)creates a head of the list
> D)error
>
> Plz anyone provide correct option 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.
>
>

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

2011-08-05 Thread Arun Vishwanathan
@nitin: oh yes i dint see that coming...good working

On Fri, Aug 5, 2011 at 1:49 PM, Arun Vishwanathan wrote:

> oops sorry there
>
>
> On Fri, Aug 5, 2011 at 1:13 PM, aditi garg wrote:
>
>> @arun he speaks truth 3/4 times
>>
>>
>> On Fri, Aug 5, 2011 at 4:40 PM, Arun Vishwanathan > > wrote:
>>
>>> he speaks the truth 1/4 time...the probability of 6 is 1/6so isnt it
>>> just 1/4*1/6=1/24??
>>>
>>>
>>>
>>>
>>> On Fri, Aug 5, 2011 at 12:54 PM, Nitin Nizhawan <
>>> nitin.nizha...@gmail.com> wrote:
>>>
 yes it cant be 1/8 I was wrong.


 On Fri, Aug 5, 2011 at 4:23 PM, coder dumca wrote:

> i think it should  be 3/4
>
>
> On Fri, Aug 5, 2011 at 4:20 PM, aditi garg 
> wrote:
>
>> 1/8
>>
>>   On Fri, Aug 5, 2011 at 4:14 PM, coder dumca 
>> wrote:
>>
>>>A man speaks truth 3 out of 4 times. He throws a die and reports
>>> it to be a 6.
>>> What is the probability of it being a 6?
>>>
>>> 1 /2
>>> 3 /4
>>> 5 /8
>>> 1 /8
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> Aditi Garg
>> Undergraduate Student
>> Electronics & Communication Divison
>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>> Sector 3, Dwarka
>> New 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.
>>
>
> --
> 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.

>>>
>>>
>>>
>>>
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> Aditi Garg
>> Undergraduate Student
>> Electronics & Communication Divison
>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>> Sector 3, Dwarka
>> New 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.
>>
>
>
>
>

-- 
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] Random number

2011-08-05 Thread payel roy
Given a range 0-N, generate 'M' random numbers from the range without any
duplication. The space complexity is O(1).

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

2011-08-05 Thread Arun Vishwanathan
oops sorry there

On Fri, Aug 5, 2011 at 1:13 PM, aditi garg wrote:

> @arun he speaks truth 3/4 times
>
>
> On Fri, Aug 5, 2011 at 4:40 PM, Arun Vishwanathan 
> wrote:
>
>> he speaks the truth 1/4 time...the probability of 6 is 1/6so isnt it
>> just 1/4*1/6=1/24??
>>
>>
>>
>>
>> On Fri, Aug 5, 2011 at 12:54 PM, Nitin Nizhawan > > wrote:
>>
>>> yes it cant be 1/8 I was wrong.
>>>
>>>
>>> On Fri, Aug 5, 2011 at 4:23 PM, coder dumca wrote:
>>>
 i think it should  be 3/4


 On Fri, Aug 5, 2011 at 4:20 PM, aditi garg 
 wrote:

> 1/8
>
>   On Fri, Aug 5, 2011 at 4:14 PM, coder dumca 
> wrote:
>
>>A man speaks truth 3 out of 4 times. He throws a die and reports
>> it to be a 6.
>> What is the probability of it being a 6?
>>
>> 1 /2
>> 3 /4
>> 5 /8
>> 1 /8
>>
>> --
>> 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.
>>
>
>
>
> --
> Aditi Garg
> Undergraduate Student
> Electronics & Communication Divison
> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
> Sector 3, Dwarka
> New 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.
>

 --
 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.
>>>
>>
>>
>>
>>
>>
>> --
>> 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.
>>
>
>
>
> --
> Aditi Garg
> Undergraduate Student
> Electronics & Communication Divison
> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
> Sector 3, Dwarka
> New 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.
>

-- 
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] Structure Q

2011-08-05 Thread Vijay Khandar
struct list
{
int x;
struct list *next;
}*head;

The statement head.x=100
A)assigns 100 to one element of the structure list
B)creates a node of type list and assigns a value to x
C)creates a head of the list
D)error

Plz anyone provide correct option 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: remove duplicate words in a string

2011-08-05 Thread deepikaanand
static int array[256];
removedupli(char s[],int n)
{
array[s[0]]=1;
for(i=1;ihttp://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: max product of a subarray

2011-08-05 Thread WgpShashank
So you Might to Interested to Review It 

Algorithm

Lets us take an array = { 2,-25,4,5,-3,-5}

We take 3 variables P , N , Val

P=1 , N=0 , Val=0

first value is 2 , A[0] which is +ve . So we multiply both P & N with A[0] .
P=2 , N=0

now V[1] = -25 -ve .

We multiply P with -V[1] & N with -V[1] .

P=50
N=0

As V[1] is -ve we swap P & N .
P=0 , N=50

if V[i] == 0
We initialise P=1 , N=0

if( P < 1 ) /* analogous to kadane's algo's 
if( sumSoFar < 0 ) */ { P=1; N=0; } \
at every step val = max( val , P ) 
We proceed in the same fashion till the end . 


Detail & Working Code 

http://shashank7s.blogspot.com/2011/08/given-array-of-integers-ive-ive-0-find.html

Do Notify me if it will fail for any testcases 

Best Regards
Shashank Mani
Computer Science
Birla Institute of Technology Mesra 

-- 
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/-/3SO1V_0XkhoJ.
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: Printf

2011-08-05 Thread Dipankar Patro
+1 to logical address.
User programs are never given access to physical address.

On 5 August 2011 17:00, muthu raj  wrote:

> physical adress is never acessible.Those who claim physical adress pls
> support ur answers.
> *Muthuraj R
> IV th Year , ISE
> PESIT , Bangalore*
>
>
>
>
> On Fri, Aug 5, 2011 at 4:57 PM, Kamakshii Aggarwal 
> wrote:
>
>> logical address
>>
>>
>> On Fri, Aug 5, 2011 at 2:20 PM, Amol Sharma wrote:
>>
>>> physical address i think
>>> --
>>>
>>>
>>> Amol Sharma
>>> Third Year Student
>>> Computer Science and Engineering
>>> MNNIT Allahabad
>>>
>>>
>>>
>>>
>>> On Fri, Aug 5, 2011 at 1:01 AM, amit karmakar >> > wrote:
>>>
 Some discussions here,
 http://ubuntuforums.org/showthread.php?t=316081
 and some here,
 http://groups.google.com/group/comp.lang.c/msg/21250e8fe083e4f8

 On Aug 5, 12:51 pm, Anurag Narain  wrote:
 > i think logical address...physical address is never accessible to user
 > program
 >
 > @amit-can u explain why??

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



-- 
___

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers <=> Save Trees

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

2011-08-05 Thread Nitin Nizhawan
A dice is 6
B reports 6


P(A) = 1/6
P(!A) = 5/6
P(B|!A) =(1/4)*(1/5)
P(B|A) =  (3/4)


P(A|B) = P(B|A)*P(A)/( P(B|A)*P(A) + P(B|!A)*P(!A))
 =((3/4)*(1/6))/( (3/4)*(1/6) + (1/4)*(1/5)*(5/6))
 = 3/4

On Fri, Aug 5, 2011 at 4:50 PM, tarang dawer  wrote:

> 1/2
>
>
>
>  --
> 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: adobe

2011-08-05 Thread Manee
ADOBE asks the very basic C/C++ questions

one of their toughest however was :

every number ending in 3 has a multiple of the form "111...111"

e.g 3 has 111
 13 has 11
so on..

find the algo for finding the number for an input number ending in 3.

On Aug 5, 2:33 pm, Agyat  wrote:
> hey, guys adobe is visiting our campus. So those who know questions
> that adobe asked in written or interview, please post here as it will
> be of great help (as adobe has visited some colleges already).
> Thank you in advance.

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

2011-08-05 Thread muthu raj
physical adress is never acessible.Those who claim physical adress pls
support ur answers.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Fri, Aug 5, 2011 at 4:57 PM, Kamakshii Aggarwal wrote:

> logical address
>
>
> On Fri, Aug 5, 2011 at 2:20 PM, Amol Sharma wrote:
>
>> physical address i think
>> --
>>
>>
>> Amol Sharma
>> Third Year Student
>> Computer Science and Engineering
>> MNNIT Allahabad
>>
>>
>>
>>
>> On Fri, Aug 5, 2011 at 1:01 AM, amit karmakar 
>> wrote:
>>
>>> Some discussions here,
>>> http://ubuntuforums.org/showthread.php?t=316081
>>> and some here,
>>> http://groups.google.com/group/comp.lang.c/msg/21250e8fe083e4f8
>>>
>>> On Aug 5, 12:51 pm, Anurag Narain  wrote:
>>> > i think logical address...physical address is never accessible to user
>>> > program
>>> >
>>> > @amit-can u explain why??
>>>
>>> --
>>> 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.
>>
>
>
>
> --
> 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.
>

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

2011-08-05 Thread Kamakshii Aggarwal
logical address

On Fri, Aug 5, 2011 at 2:20 PM, Amol Sharma  wrote:

> physical address i think
> --
>
>
> Amol Sharma
> Third Year Student
> Computer Science and Engineering
> MNNIT Allahabad
>
>
>
>
> On Fri, Aug 5, 2011 at 1:01 AM, amit karmakar 
> wrote:
>
>> Some discussions here,
>> http://ubuntuforums.org/showthread.php?t=316081
>> and some here,
>> http://groups.google.com/group/comp.lang.c/msg/21250e8fe083e4f8
>>
>> On Aug 5, 12:51 pm, Anurag Narain  wrote:
>> > i think logical address...physical address is never accessible to user
>> > program
>> >
>> > @amit-can u explain why??
>>
>> --
>> 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.
>



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



[algogeeks] hash table

2011-08-05 Thread Kamakshii Aggarwal
can we implement random() function on a hash table in O(1) .

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



Re: [algogeeks] probabilty

2011-08-05 Thread tarang dawer
1/2

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

2011-08-05 Thread aditi garg
@arun he speaks truth 3/4 times

On Fri, Aug 5, 2011 at 4:40 PM, Arun Vishwanathan wrote:

> he speaks the truth 1/4 time...the probability of 6 is 1/6so isnt it
> just 1/4*1/6=1/24??
>
>
>
>
> On Fri, Aug 5, 2011 at 12:54 PM, Nitin Nizhawan 
> wrote:
>
>> yes it cant be 1/8 I was wrong.
>>
>>
>> On Fri, Aug 5, 2011 at 4:23 PM, coder dumca wrote:
>>
>>> i think it should  be 3/4
>>>
>>>
>>> On Fri, Aug 5, 2011 at 4:20 PM, aditi garg wrote:
>>>
 1/8

   On Fri, Aug 5, 2011 at 4:14 PM, coder dumca wrote:

>A man speaks truth 3 out of 4 times. He throws a die and reports it
> to be a 6.
> What is the probability of it being a 6?
>
> 1 /2
> 3 /4
> 5 /8
> 1 /8
>
> --
> 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.
>



 --
 Aditi Garg
 Undergraduate Student
 Electronics & Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New 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.

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



-- 
Aditi Garg
Undergraduate Student
Electronics & Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New 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.



Re: [algogeeks] probabilty

2011-08-05 Thread Arun Vishwanathan
he speaks the truth 1/4 time...the probability of 6 is 1/6so isnt it
just 1/4*1/6=1/24??




On Fri, Aug 5, 2011 at 12:54 PM, Nitin Nizhawan wrote:

> yes it cant be 1/8 I was wrong.
>
>
> On Fri, Aug 5, 2011 at 4:23 PM, coder dumca  wrote:
>
>> i think it should  be 3/4
>>
>>
>> On Fri, Aug 5, 2011 at 4:20 PM, aditi garg wrote:
>>
>>> 1/8
>>>
>>>   On Fri, Aug 5, 2011 at 4:14 PM, coder dumca wrote:
>>>
A man speaks truth 3 out of 4 times. He throws a die and reports it
 to be a 6.
 What is the probability of it being a 6?

 1 /2
 3 /4
 5 /8
 1 /8

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

>>>
>>>
>>>
>>> --
>>> Aditi Garg
>>> Undergraduate Student
>>> Electronics & Communication Divison
>>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
>>> Sector 3, Dwarka
>>> New 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.
>>>
>>
>> --
>> 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.
>

-- 
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] Amazon Question

2011-08-05 Thread surender sanke
Hi,

for 1 do +1
for 0 do -1
maintain count at every index of array
eg:  100110
array   X 1 0  0  0  0  0  0  1  1  0
count   0 1 0 -1 -2 -3 -4 -5 -4 -3 -4
index  -1 0 1  2  3  4  5  6  7  8  9

find count with same value having max index difference.
-3 is count at index 4 and 8
max difference is 8-4 = 4
-4 is count at index 5 and 9
max difference is 9-5 = 4
to reduce traverse time after count calculation
take a map>;
i - first index of array having same count,
j - last index of array having same count
as and when u encounter count create map value with i
else if already exist update j, and update max with MAX(j-i,max)

Surender

On Fri, Aug 5, 2011 at 2:25 PM, Arun Vishwanathan wrote:

>
> by the way doesnt it look like an O(n^2) algo?
>
> On Fri, Aug 5, 2011 at 10:53 AM, Arun Vishwanathan  > wrote:
>
>>
>> would u mind giving a short explanation of yr code too if possible?
>>
>>
>> On Thu, Aug 4, 2011 at 5:38 PM, Apoorve Mohan wrote:
>>
>>> I think this should worktell me if this works...
>>>
>>> void longest_0_1_substring(char *str)
>>> {
>>> int size=0,count=0,max=0,pos=0,prev=0,prev_pos=0,ptr=0,i=0,j=0;
>>>
>>> while(*str++)
>>> size++;
>>> str -= (size + 1);
>>>
>>> while(i>> {
>>> for(j=i;(j < size) && (str[j]==str[j+1]);++j)
>>> count++;
>>> count++;
>>> if(ptr > 1)
>>> {
>>> if(count >= prev)
>>> {
>>> if(prev > max)
>>> {
>>> max = prev;
>>> pos = prev_pos;
>>> }
>>> }
>>> else
>>> {
>>> if(count > max)
>>> {
>>> max = count;
>>> pos = i - prev;
>>> }
>>> }
>>> }
>>> prev = count;
>>> prev_pos = i;
>>> i += count;
>>> ++ptr;
>>> count = 0;
>>> }
>>>
>>> printf("substring starts at position %d and is of size %d
>>> .",pos,max);
>>>
>>>
>>>
>>> }
>>>
>>> On Thu, Aug 4, 2011 at 6:25 PM, himanshu kansal <
>>> himanshukansal...@gmail.com> wrote:
>>>
 okie...can someone do it in O(n) space...bt time shld be linear only



 On Thu, Aug 4, 2011 at 2:13 AM, Prakash D  wrote:

> O(1) space is t hard  for this task
>
>
> On Thu, Aug 4, 2011 at 12:55 AM, payel roy wrote:
>
>> Is there any solution for the above?
>>
>>
>> On 3 August 2011 21:09, coder coder wrote:
>>
>>> ya amazon will be visiting our campus within few days
>>>
>>> --
>>> 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.
>>
>
> --
> 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
 Himanshu Kansal
   Msc Comp. sc.
 (University of 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.

>>>
>>>
>>>
>>> --
>>> regards
>>>
>>> Apoorve Mohan
>>>
>>>
>>> --
>>> 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 thi

[algogeeks] Goldman sachs placements

2011-08-05 Thread Jyoti Gupta
please share questions both for written an interview !

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



<    1   2   3   >