Re: [algogeeks] Needed recursive sol

2011-10-01 Thread Shuaib Khan
I am I not wrong, the problem asks for fib numbers which are even, not fib
numbers with even index...?

On Sat, Oct 1, 2011 at 10:16 PM, Wladimir Tavares wrote:

> F(0)+F(2)+...+F(2n) = F(2n+1) - 1
>
>
> Wladimir Araujo Tavares
> *Federal University of CearĂ¡ 
> Homepage  | 
> Maratona|
> *
>
>
>
>
>
> On Sat, Oct 1, 2011 at 1:40 PM, rahul sharma wrote:
>
>> nyone provide me with recursive sol of the following prob.
>>
>>
>> find the sum of all even nos. in the fibbonacci series upto 1000thnx
>> in davance
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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.
>



-- 
Shuaib

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Maximum possible edges in a graph

2011-09-06 Thread Shuaib Khan
I don't have a formal proof yet, but can anyone give a counter test case to
following:

Let f(n) be our function:
if n is even: f(n) = (n^2)/4
else: f(n) = ((n-1)^2)/4 + (n-1)/2

On Wed, Sep 7, 2011 at 5:36 AM, Shuaib Khan  wrote:

> What is the maximum number of edges possible in a graph with N nodes, and
> where any three nodes can have at most two edges between them. 1<=N<=10.
>
>
> --
> Shuaib
>
>


-- 
Shuaib

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Maximum possible edges in a graph

2011-09-06 Thread Shuaib Khan
What is the maximum number of edges possible in a graph with N nodes, and
where any three nodes can have at most two edges between them. 1<=N<=10.


-- 
Shuaib

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] math puzzle

2011-08-28 Thread Shuaib Khan
You don't need trial and error. Start by setting x = 1, 2, 3... and find
values for y. If the y you get is a positive integer, you have a solution.

On Sun, Aug 28, 2011 at 5:46 PM, sivaviknesh s wrote:

> *Find the number of solutions for 3x+4y=60, if x and y are positive
> integers.*
>
> Is there any standard method for solving these type of ques ..or only trial
> and error ???
>
> --
> Regards,
> $iva
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Shuaib
http://www.bytehood.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] Re: find numbers whose difference is min

2011-08-16 Thread Shuaib Khan
Dave, I agree. :)

On Tue, Aug 16, 2011 at 6:33 PM, Dave  wrote:

> @Shuaib: We are talking about an array of numbers, arent't we? It is
> natural to assume that the numbers fall into one of the defined data
> types.
>
> Dave
>
> On Aug 16, 4:23 am, Shuaib  wrote:
> > Yes it will work in this specific case. What I meant was that Radix sort
> isn't always applicable in general to achieve linear time sorting. Its
> complexity isn't exactly O(N) rather O(d*N) where d is the number of bytes
> each of our item consumes. So if the elements in array aren't from a finite
> range, that would be an issue.
> >
> > Correct me if I am wrong.
> >
> > --
> > Shuaibhttp://twitter.com/ShuaibKhanhttp://www.bytehood.com/
> >
> > On 16-Aug-2011, at 11:05 AM, Dave  wrote:
> >
> >
> >
> > > @Shuaib: It will work in all cases. If you don't think so, give a
> > > counterexample.
> >
> > > Dave
> >
> > > On Aug 16, 12:50 am, Shuaib  wrote:
> > >> That will work but not in all cases as radix sort isn't a generalized
> sorting algorithm, is it? :)
> >
> > >> --
> > >> Shuaibhttp://twitter.com/ShuaibKhanhttp://www.bytehood.com/
> >
> > >> On 16-Aug-2011, at 10:10 AM, Dave  wrote:
> >
> > >>> @Shuaib: You could sort the numbers in O(n) with a radix sort, and
> > >>> then finding the min is easy. Mind you, the radix sort might be
> slower
> > >>> than an O(n log n) sort, but still it satisfies the O(n) constraint.
> >
> > >>> Dave
> >
> > >>> On Aug 15, 8:41 pm, Shuaib  wrote:
> >  That won't work. And I don't think an O(n) solution is possible.
> >
> >  --
> >  Shuaibhttp://twitter.com/ShuaibKhanhttp://www.bytehood.com/
> >
> >  On 16-Aug-2011, at 6:25 AM, sukran dhawan 
> wrote:
> >
> > > find the minimum of two numbers in a loop o(n) and subtract the two
> >
> > > On Tue, Aug 16, 2011 at 6:13 AM, Brijesh Upadhyay <
> brijeshupadhyay...@gmail.com> wrote:
> > > Algorithm to find the two numbers whose difference is minimum among
> the set of numbers. For example the sequence is 5, 13, 7, 0, 10, 20, 1, 15,
> 4, 19 The algorithm should return min diff = 20-19 = 1. Constraint - Time
> Complexity O(N)
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> > > To view this discussion on the web visithttps://
> groups.google.com/d/msg/algogeeks/-/U8gTWUISJn8J.
> > > To post to this group, send email to algogeeks@googlegroups.com.
> > > To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> > > For more options, visit this group athttp://
> 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 athttp://
> 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 athttp://
> 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 athttp://
> 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.
>
>


-- 
Shuaib
http://www.bytehood.com
http://twitter.com/ShuaibKhan

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Probability question.. help

2011-08-09 Thread Shuaib Khan
On Wed, Aug 10, 2011 at 1:45 AM, Brijesh Upadhyay <
brijeshupadhyay...@gmail.com> wrote:

> No thers is not.. someone has asked me this., dont know anything else about
> the question  :|


Seems like you got half of the question there.


>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/mqMvDgb6TqUJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Shuaib
http://www.bytehood.com
http://twitter.com/ShuaibKhan

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Probability Puzzle

2011-08-08 Thread Shuaib Khan
Man, I feel so stupid. Yes, it is a case of conditional probability. We have
to calculate the probability of six heads, "given" that 5 heads have
occured. So answer is 17/18.

On Tue, Aug 9, 2011 at 1:47 AM, Arun Vishwanathan wrote:

> @shady: 3/5 can be the answer to such a question: what is prob of getting
> head on nth toss if we have 4 coins fair and one biased...then at nth toss u
> choose 4/5 1/5 prob and then u get 3/5
>
> @shady , don: i did this: P( 6th head | 5 heads occured)= P( 6 heads )/ P(
> 5 heads)
>
> answr u get is 17/18..i cud be wrong please correct if so
>
>
> On Mon, Aug 8, 2011 at 10:45 PM, shady  wrote:
>
>> answer is 3/5. 17/80 is the answer for 6 consecutive heads.
>>
>>
>> On Tue, Aug 9, 2011 at 2:07 AM, Don  wrote:
>>
>>> Consider the 5 * 64 possible outcomes for the selection of coin and
>>> six flips, each one happening with equal probability. Of those 320
>>> possible outcomes, 4*62 are excluded by knowing that the first 5 flips
>>> are heads. That leaves 64 outcomes with the rigged coin and 2 outcomes
>>> with each of the fair coins, for a total of 72 outcomes. 68 of those
>>> are heads, so the answer to the puzzle is 68 of 72, or 17 of 18.
>>> Don
>>>
>>> On Aug 8, 2:36 am, Shachindra A C  wrote:
>>> > @brijesh
>>> >
>>> > *first five times* is mentioned intentionally to mislead i think. I
>>> vote for
>>> > 3/5. Moreover, 17/80 doesn't make sense also. Plz correct me if I am
>>> wrong.
>>> >
>>> >
>>> >
>>> > On Mon, Aug 8, 2011 at 12:06 PM, sumit gaur 
>>> wrote:
>>> > > (3/5)
>>> >
>>> > > On Aug 7, 10:34 pm, Algo Lover  wrote:
>>> > > > A bag contains 5 coins. Four of them are fair and one has heads on
>>> > > > both sides. You randomly pulled one coin from the bag and tossed it
>>> 5
>>> > > > times, heads turned up all five times. What is the probability that
>>> > > > you toss next time, heads turns up. (All this time you don't know
>>> you
>>> > > > were tossing a fair coin or not).
>>> >
>>> > > --
>>> > > You received this message because you are subscribed to the Google
>>> Groups
>>> > > "Algorithm Geeks" group.
>>> > > To post to this group, send email to algogeeks@googlegroups.com.
>>> > > To unsubscribe from 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,
>>> > Shachindra A C
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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.
>



-- 
Shuaib
http://www.bytehood.com
http://twitter.com/ShuaibKhan

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] A Nice Programming Challenge Question

2011-08-07 Thread Shuaib Khan
On Mon, Aug 8, 2011 at 1:07 AM, Yasir Imteyaz  wrote:

> @Shuaib,
> You are right, this approach will work! :)
> But for each element 'e'
> instead of checking whether *|K-e| *exists, *you should check for either
> (e+K) or (e-K).*
>

You are right. Mistake. ;)


>
> But here the question is, will the hash map really give o(1) access for
> such a large record?
> ..and is it a good practice to create such large map while solving these
> kinda problem?
>

This is something to ponder over.


>  --
> 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/-/bHxWTp3DLQgJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Shuaib
http://www.bytehood.com
http://twitter.com/ShuaibKhan

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] A Nice Programming Challenge Question

2011-08-07 Thread Shuaib Khan
How about iterating over all the values and hashing them to a dict/map. And
then iterate once more, checking that for each element 'e', |K-e| exists in
the map or not. O(N)?

On Sun, Aug 7, 2011 at 10:53 PM, Yasir  wrote:

> Guys,
> Let's try to find out an efficient solution for the following prob:
>
> Given N numbers , [N<=10^5] we need to count the total pairs of
> numbers that have a difference of K. [K>0 and K<1e9]
>
> Input Format:
> 1st line contains N & K.
> 2nd line contains N numbers of the set. All the N numbers are assured
> to be distinct.
>
> Output Format:
> One integer saying the no of pairs of numbers that have a diff K.
>
>
> PS: Note that n is very large, so try to come up with an efficient
> solution. :)
>
>
> Source: http://www.interviewstreet.com/recruit/challenges/dashboard/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Shuaib
http://www.bytehood.com
http://twitter.com/ShuaibKhan

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Probability Puzzle

2011-08-07 Thread Shuaib Khan
On Mon, Aug 8, 2011 at 12:51 AM, aseem garg  wrote:

> @Shuaib:  **What is the probability that you toss *next time, heads turns
> up***.


Well if you interpret it your way, then you are right. Otherwise, not.

>
> Aseem
>
>
>
> On Mon, Aug 8, 2011 at 1:19 AM, Shuaib Khan wrote:
>
>>
>>
>> On Mon, Aug 8, 2011 at 12:47 AM, aseem garg  wrote:
>>
>>> Think it like this. I have tossed a coin 5 times and it showed heads all
>>> the times. What is the probabilty of it shoing a HEADS now?
>>> Aseem
>>>
>>
>> Well you are thinking about it the wrong way. Question asks that what is
>> the probability that heads will show up the first five times, plus a sixth
>> time. Not just the sixth time. The first five times head showing up is part
>> of the question.
>>
>>
>>
>>>
>>>
>>>
>>> On Mon, Aug 8, 2011 at 1:12 AM, Shuaib Khan wrote:
>>>
>>>>
>>>>
>>>> On Mon, Aug 8, 2011 at 12:40 AM, Puneet Gautam >>> > wrote:
>>>>
>>>>> Sixth toss is independent of previous tosses and dependent only on
>>>>> coin selection...!
>>>>>
>>>>> 1/5 + 4/5(1/2)= 3/5
>>>>>
>>>>> is the correct answer
>>>>>
>>>>> we want to calc. probability of getting heads the sixth time only
>>>>> even if it would have been 100 th time...3/5 would be the answer
>>>>> only..
>>>>>
>>>>>
>>>> It is not independent. Re read the question. The first five times, it
>>>> HAS to be heads.
>>>>
>>>>>
>>>>> On 8/8/11, Prakash D  wrote:
>>>>> > 1.) coin is fair
>>>>> > 2.) coin is unfair
>>>>> >
>>>>> > P(head) for unfair coin= 1/5 * 1= 1/5
>>>>> > P(head) for fair coin= 4/5* 1/2 = 2/5
>>>>> >
>>>>> >
>>>>> > the probability at any instant that the tossed coin is a head is 3/5
>>>>> >
>>>>> > 17/80 is the probability to get head at all the six times.
>>>>> >
>>>>> > the soln. for this problem will be 3/5
>>>>> >
>>>>> > On Mon, Aug 8, 2011 at 12:45 AM, aseem garg 
>>>>> wrote:
>>>>> >
>>>>> >> If the coin is unbiased then probability of heads: 1/2 irrespective
>>>>> of
>>>>> >> whether it is first time or nth time. So answer should be 3/5.
>>>>> >> Aseem
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >> On Mon, Aug 8, 2011 at 12:39 AM, saurabh chhabra
>>>>> >> wrote:
>>>>> >>
>>>>> >>> Even u dont get why u people are gettin 17/80...the probability
>>>>> that
>>>>> >>> it will be a head 6th time will be same as the frst time...so it
>>>>> shud
>>>>> >>> be 3/5...
>>>>> >>>
>>>>> >>> On Aug 7, 11:05 pm, Kunal Yadav  wrote:
>>>>> >>> > @algo: We can get head in two cases:-
>>>>> >>> >
>>>>> >>> > 1.) coin is biases
>>>>> >>> > 2.) coin is not biased
>>>>> >>> >
>>>>> >>> > P(head) for biased= 1/5 *1*1*1*1*1*1= 1/5
>>>>> >>> > P(head) for unbiased= 4/5*(1/2)^6
>>>>> >>> > hence combined probability is what nitish has already mentioned.
>>>>> Hope
>>>>> >>> you
>>>>> >>> > get the point.
>>>>> >>> >
>>>>> >>> >
>>>>> >>> >
>>>>> >>> >
>>>>> >>> >
>>>>> >>> >
>>>>> >>> >
>>>>> >>> >
>>>>> >>> >
>>>>> >>> > On Sun, Aug 7, 2011 at 11:29 PM, Algo Lover <
>>>>> algolear...@gmail.com>
>>>>> >>> wrote:
>>>>> >>> > > Can anyone explain the approach how to solve this .
>>>>> >>> > > I think all tosses are independent so it should be 3/5. why is
>>>>> this
>>>>> >>> in-
>>>

Re: [algogeeks] Re: Probability Puzzle

2011-08-07 Thread Shuaib Khan
On Mon, Aug 8, 2011 at 12:47 AM, aseem garg  wrote:

> Think it like this. I have tossed a coin 5 times and it showed heads all
> the times. What is the probabilty of it shoing a HEADS now?
> Aseem
>

Well you are thinking about it the wrong way. Question asks that what is the
probability that heads will show up the first five times, plus a sixth time.
Not just the sixth time. The first five times head showing up is part of the
question.



>
>
>
> On Mon, Aug 8, 2011 at 1:12 AM, Shuaib Khan wrote:
>
>>
>>
>> On Mon, Aug 8, 2011 at 12:40 AM, Puneet Gautam 
>> wrote:
>>
>>> Sixth toss is independent of previous tosses and dependent only on
>>> coin selection...!
>>>
>>> 1/5 + 4/5(1/2)= 3/5
>>>
>>> is the correct answer
>>>
>>> we want to calc. probability of getting heads the sixth time only
>>> even if it would have been 100 th time...3/5 would be the answer
>>> only..
>>>
>>>
>> It is not independent. Re read the question. The first five times, it HAS
>> to be heads.
>>
>>>
>>> On 8/8/11, Prakash D  wrote:
>>> > 1.) coin is fair
>>> > 2.) coin is unfair
>>> >
>>> > P(head) for unfair coin= 1/5 * 1= 1/5
>>> > P(head) for fair coin= 4/5* 1/2 = 2/5
>>> >
>>> >
>>> > the probability at any instant that the tossed coin is a head is 3/5
>>> >
>>> > 17/80 is the probability to get head at all the six times.
>>> >
>>> > the soln. for this problem will be 3/5
>>> >
>>> > On Mon, Aug 8, 2011 at 12:45 AM, aseem garg 
>>> wrote:
>>> >
>>> >> If the coin is unbiased then probability of heads: 1/2 irrespective of
>>> >> whether it is first time or nth time. So answer should be 3/5.
>>> >> Aseem
>>> >>
>>> >>
>>> >>
>>> >> On Mon, Aug 8, 2011 at 12:39 AM, saurabh chhabra
>>> >> wrote:
>>> >>
>>> >>> Even u dont get why u people are gettin 17/80...the probability that
>>> >>> it will be a head 6th time will be same as the frst time...so it shud
>>> >>> be 3/5...
>>> >>>
>>> >>> On Aug 7, 11:05 pm, Kunal Yadav  wrote:
>>> >>> > @algo: We can get head in two cases:-
>>> >>> >
>>> >>> > 1.) coin is biases
>>> >>> > 2.) coin is not biased
>>> >>> >
>>> >>> > P(head) for biased= 1/5 *1*1*1*1*1*1= 1/5
>>> >>> > P(head) for unbiased= 4/5*(1/2)^6
>>> >>> > hence combined probability is what nitish has already mentioned.
>>> Hope
>>> >>> you
>>> >>> > get the point.
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> > On Sun, Aug 7, 2011 at 11:29 PM, Algo Lover >> >
>>> >>> wrote:
>>> >>> > > Can anyone explain the approach how to solve this .
>>> >>> > > I think all tosses are independent so it should be 3/5. why is
>>> this
>>> >>> in-
>>> >>> > > correct
>>> >>> >
>>> >>> > > On Aug 7, 10:55 pm, saurabh chhabra 
>>> wrote:
>>> >>> > > > sry...its wrong
>>> >>> >
>>> >>> > > > On Aug 7, 10:34 pm, Algo Lover  wrote:
>>> >>> >
>>> >>> > > > > A bag contains 5 coins. Four of them are fair and one has
>>> heads
>>> >>> > > > > on
>>> >>> > > > > both sides. You randomly pulled one coin from the bag and
>>> tossed
>>> >>> it 5
>>> >>> > > > > times, heads turned up all five times. What is the
>>> probability
>>> >>> that
>>> >>> > > > > you toss next time, heads turns up. (All this time you don't
>>> know
>>> >>> you
>>> >>> > > > > were tossing a fair coin or not).
>>> >>> >
>>> >>> > > --
>>> >>> > > You received this message because you are subs

Re: [algogeeks] Re: Probability Puzzle

2011-08-07 Thread Shuaib Khan
On Mon, Aug 8, 2011 at 12:40 AM, Puneet Gautam wrote:

> Sixth toss is independent of previous tosses and dependent only on
> coin selection...!
>
> 1/5 + 4/5(1/2)= 3/5
>
> is the correct answer
>
> we want to calc. probability of getting heads the sixth time only
> even if it would have been 100 th time...3/5 would be the answer
> only..
>
>
It is not independent. Re read the question. The first five times, it HAS to
be heads.

>
> On 8/8/11, Prakash D  wrote:
> > 1.) coin is fair
> > 2.) coin is unfair
> >
> > P(head) for unfair coin= 1/5 * 1= 1/5
> > P(head) for fair coin= 4/5* 1/2 = 2/5
> >
> >
> > the probability at any instant that the tossed coin is a head is 3/5
> >
> > 17/80 is the probability to get head at all the six times.
> >
> > the soln. for this problem will be 3/5
> >
> > On Mon, Aug 8, 2011 at 12:45 AM, aseem garg  wrote:
> >
> >> If the coin is unbiased then probability of heads: 1/2 irrespective of
> >> whether it is first time or nth time. So answer should be 3/5.
> >> Aseem
> >>
> >>
> >>
> >> On Mon, Aug 8, 2011 at 12:39 AM, saurabh chhabra
> >> wrote:
> >>
> >>> Even u dont get why u people are gettin 17/80...the probability that
> >>> it will be a head 6th time will be same as the frst time...so it shud
> >>> be 3/5...
> >>>
> >>> On Aug 7, 11:05 pm, Kunal Yadav  wrote:
> >>> > @algo: We can get head in two cases:-
> >>> >
> >>> > 1.) coin is biases
> >>> > 2.) coin is not biased
> >>> >
> >>> > P(head) for biased= 1/5 *1*1*1*1*1*1= 1/5
> >>> > P(head) for unbiased= 4/5*(1/2)^6
> >>> > hence combined probability is what nitish has already mentioned. Hope
> >>> you
> >>> > get the point.
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > On Sun, Aug 7, 2011 at 11:29 PM, Algo Lover 
> >>> wrote:
> >>> > > Can anyone explain the approach how to solve this .
> >>> > > I think all tosses are independent so it should be 3/5. why is this
> >>> in-
> >>> > > correct
> >>> >
> >>> > > On Aug 7, 10:55 pm, saurabh chhabra 
> wrote:
> >>> > > > sry...its wrong
> >>> >
> >>> > > > On Aug 7, 10:34 pm, Algo Lover  wrote:
> >>> >
> >>> > > > > A bag contains 5 coins. Four of them are fair and one has heads
> >>> > > > > on
> >>> > > > > both sides. You randomly pulled one coin from the bag and
> tossed
> >>> it 5
> >>> > > > > times, heads turned up all five times. What is the probability
> >>> that
> >>> > > > > you toss next time, heads turns up. (All this time you don't
> know
> >>> you
> >>> > > > > were tossing a fair coin or not).
> >>> >
> >>> > > --
> >>> > > You received this message because you are subscribed to the Google
> >>> Groups
> >>> > > "Algorithm Geeks" group.
> >>> > > To post to this group, send email to algogeeks@googlegroups.com.
> >>> > > To unsubscribe from 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
> >>> > Kunal Yadav
> >>> > (http://algoritmus.in/)
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Algorithm Geeks" group.
> >>> To post to this group, send email to algogeeks@googlegroups.com.
> >>> To unsubscribe from 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.
>
>


-- 
Shuaib
http://www.bytehood.com
http://twitter.com/ShuaibKhan

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: A Nice Programming Challenge Question

2011-08-07 Thread Shuaib Khan
On Sun, Aug 7, 2011 at 11:06 PM, Dave  wrote:

> @Yasir: Sort the numbers. Then
>
> int i = 0, j = 1, m, p = 0;
> while( j < N )
> {
>m = a[j] - a[i];
>if( m = K )
>++p;
>else if( m < K )
>++j;
>else
>++i;
> }
> // answer = p
>

Looks like an infinite loop in there to me...



>
> Complexity = O(n log n).
>
> Dave
>
> On Aug 7, 12:53 pm, Yasir  wrote:
> > Guys,
> > Let's try to find out an efficient solution for the following prob:
> >
> > Given N numbers , [N<=10^5] we need to count the total pairs of
> > numbers that have a difference of K. [K>0 and K<1e9]
> >
> > Input Format:
> > 1st line contains N & K.
> > 2nd line contains N numbers of the set. All the N numbers are assured
> > to be distinct.
> >
> > Output Format:
> > One integer saying the no of pairs of numbers that have a diff K.
> >
> > PS: Note that n is very large, so try to come up with an efficient
> > solution. :)
> >
> > Source:http://www.interviewstreet.com/recruit/challenges/dashboard/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Shuaib
http://www.bytehood.com
http://twitter.com/ShuaibKhan

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.