[algogeeks] Probability

2011-08-29 Thread Naman Mahor
An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- You received this

Re: [algogeeks] Probability

2011-08-29 Thread Naman Mahor
...@gmail.comwrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second

Re: [algogeeks] Probability

2011-08-29 Thread Naman Mahor
wrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third

Re: [algogeeks] Probability

2011-08-29 Thread Naman Mahor
abhishek's answer. plz clear my confusion that i hv mentioned above. On Mon, Aug 29, 2011 at 6:04 PM, vishwa vishwavam...@gmail.com wrote: @naman: whose answer man On Mon, Aug 29, 2011 at 5:56 PM, Naman Mahor naman.ma...@gmail.comwrote: ur answer is correct but i hv a confusion that all

Re: [algogeeks]

2011-08-21 Thread Naman Mahor
because the pointer of base class will move by 2 bytes every time but the size of derived class is 4 byte. On Sun, Aug 21, 2011 at 12:31 PM, Puneet Chawla puneetchawla...@gmail.comwrote: class base { public: int bval; base(){bval=0;} }; class

Re: [algogeeks]

2011-08-21 Thread Naman Mahor
...@gmail.comwrote: Wil u please explain in context of o/p.means how 1 whn SomeFunc(DeriArr,5); stmt is executed how 0 and 1 will come..??? On Sun, Aug 21, 2011 at 12:40 PM, Naman Mahor naman.ma...@gmail.comwrote: because the pointer of base class will move by 2 bytes every time but the size

Re: [algogeeks] why the output 16

2011-08-21 Thread Naman Mahor
8==0?1:8* (8-1*(8-1-1)) this will execute as 8*(8-1(8-2)) = 8*(8-1*6)8*(8-6)===8*2===16 On Sat, Aug 20, 2011 at 7:02 PM, SuDhir mIsHra sudhir08.mis...@gmail.comwrote: #includestdio.h #define FUNC1(i) (i*(i-1)) #define FUNC2(i) (i==0?1:i*FUNC1(i-1)) main() { int i=8;

Re: [algogeeks] c programe explain

2011-08-21 Thread Naman Mahor
const char* into char * is error not warning i hv run it on DEV c++; On Sun, Aug 21, 2011 at 11:01 PM, Sanjay Rajpal srn...@gmail.com wrote: i didnt run it, this concept is given in J.K.Chhabra book. Sanju :) On Sun, Aug 21, 2011 at 10:29 AM, Puneet Chawla puneetchawla...@gmail.com

[algogeeks] probability

2011-08-20 Thread Naman Mahor
let's say A keep tossing a fair coin, until he get 2 consecutive heads, define X to be the number of tosses for this process; B keep tossing another fair coin, until he get 3 consecutive heads, define Y to be the number of the tosses for this process.Calculate P{XY} -- You received this message

Re: [algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-20 Thread Naman Mahor
i think there will be three candidate.. 1. TreeSuccessor(nd) 2. TreePredecessor(nd) 3. nd it self. On Sat, Aug 20, 2011 at 12:56 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: Hey i tried it now and got to another solution O(log n) solution: 1. try searching for the number , if

Re: [algogeeks] Challenge

2011-08-20 Thread Naman Mahor
it is O(m+n). sure?? On Sat, Aug 20, 2011 at 2:52 PM, Sanjay Rajpal srn...@gmail.com wrote: We are given a 2-D array of 0s and 1s. We have to determine which row contains maximum no. of 1s in the array in O(m+n); where m - no. of rows and n - no. of columns. Sanju :) -- You received

Re: [algogeeks] Puzzle

2011-08-20 Thread Naman Mahor
21 On Sat, Aug 20, 2011 at 5:16 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: Each side of a given polygon is parallel to either the X or the Y axis. A corner of such a polygon is said to be convex if the internal angle is 90o or concave if the internal angle is 270o. If the number of

Re: [algogeeks] sol

2011-08-20 Thread Naman Mahor
@sanjay assume that the value of a=0,b=0; so a^b=0 and (ab)1 =0 so answer will zero. so the result will not always 1. it can be 0 or 1 depends on the value of a n b. On Sun, Aug 21, 2011 at 12:12 AM, Sanjay Rajpal srn...@gmail.com wrote: || is a short-circuit operator(LOGICAL OR). if first

Re: [algogeeks] Re: Number of nodes at each level in binary tree

2011-08-20 Thread Naman Mahor
it can be done by bfs with slight modification. so in bfs we use queue we have to add a dummy node in queue. So this node will tell us that end of level has come.so we can find out the no of node at any level using bfs. On Sun, Aug 21, 2011 at 1:34 AM, Dave dave_and_da...@juno.com wrote: