Re: [algogeeks] Re: storing URL's

2012-05-17 Thread Prakash D
We can still improve this trie idea.. say we have urls like www.google.com www.goodbye.com www.google.com/transliterate www.goodstrain.com/good we can subdivide everything under "www.goo" I mean we can store each character as a node in a trie and call it like a "URL dictionary" On Wed, May 16,

Re: [algogeeks] Sorting in O(n)

2012-05-04 Thread Prakash D
The range 1 to n^2 is already sorted On Sat, May 5, 2012 at 12:17 AM, Algobiz wrote: > How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the

Re: [algogeeks] Amazon Interview Question

2012-04-27 Thread Prakash D
@bharat: +1 On Thu, Apr 26, 2012 at 1:06 PM, bharat b wrote: > create an array of linked lists.. each index in the array represents the > node number and the linked list of that represents edges of that node. -- You received this message because you are subscribed to the Google Groups "Algorit

Re: [algogeeks] ITRIX'12 OPC

2012-03-18 Thread Prakash D
+1 On Fri, Mar 16, 2012 at 11:35 PM, shady wrote: > i wanted to try the questions now, but can't submit, can you provide the > problems, and testdata ? > > > On Mon, Mar 12, 2012 at 10:41 PM, Kashyap Krishnakumar > wrote: >> >> Hi, >>     The online programming contest of ITRIX, the national lev

Re: [algogeeks] Re: Pbm with rand() function

2012-02-27 Thread Prakash D
with equal probability On Tue, Feb 28, 2012 at 5:28 AM, Prakash D wrote: > i've another doubt. what to do when I need to generate a random long long? > > On Mon, Feb 27, 2012 at 9:07 PM, Don wrote: >> For instance, if RANDMAX= 32768, then >> >> x = rand() % 20

Re: [algogeeks] Re: Pbm with rand() function

2012-02-27 Thread Prakash D
i've another doubt. what to do when I need to generate a random long long? On Mon, Feb 27, 2012 at 9:07 PM, Don wrote: > For instance, if RANDMAX= 32768, then > > x = rand() % 2; > > is twice as likely to result in the value 10,000 as the value 15,000. > This is because there are two output v

Re: [algogeeks] Kurukshetra Online Debugging Prelims today

2012-01-26 Thread Prakash D
1) Your algorithm must be efficient 2) Your I/O should be fast enough. Use scanf, printf instead of cin,cout in C++. Use BufferedReader instead of Scanner in case of Java. 3) Ask such doubts in the space provided in the contest. On Thu, Jan 26, 2012 at 11:17 PM, prakash y wrote: > Please don't mi

Re: [algogeeks] Amazon Interview Question

2012-01-19 Thread Prakash D
why can't u simply place it as 1 2 3 4 5 6 7 1 2 3 4 5 6 7? On Thu, Jan 19, 2012 at 2:05 AM, NEERAJ KODDHAN wrote: > int[] a = new int[2*n]; > put(a, n); > > static void put(int[] a,int i){ > if(i>0){ > for(int j=0;j if(a[j]==0 && a[j+i+1]==0){ > a[j]=i; > a[j+i+1]=i; > put(a, i-1); > a[j]=0;

Re: [algogeeks] Amazon Interview Question

2012-01-19 Thread Prakash D
ignore my last comment.. misunderstood On Thu, Jan 19, 2012 at 1:04 PM, Prakash D wrote: > why can't u simply place it as 1 2 3 4 5 6 7 1 2 3 4 5 6 7? > > > On Thu, Jan 19, 2012 at 2:05 AM, NEERAJ KODDHAN wrote: > >> int[] a = new int[2*n]; >> put(a, n); >

Re: [algogeeks] finding all combination

2012-01-03 Thread Prakash D
0-1 knapsack! On Tue, Jan 3, 2012 at 5:14 PM, saurabh singh wrote: > Most probably noThis is the subset sum problem which is proven NP > complete...Even if a better solution than n^2 exists it won't work for all > cases > Saurabh Singh > B.Tech (Computer Science) > MNNIT ALLAHABAD >

Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread Prakash D
only the number of comparisons is log(n) On Mon, Dec 12, 2011 at 11:04 PM, Ankur Garg wrote: > Agree with dave..Its still O(n) > > > On Mon, Dec 12, 2011 at 10:57 PM, Dave wrote: > >> @Sagar: Don is correct. n/2+n/4+n/8+... ~= n. But even the first >> round, involving n/2 comparisons, is O(n).

Re: [algogeeks] Re: How random numbers are generated?

2011-12-06 Thread Prakash D
how those generators will generate? any idea? On Tue, Dec 6, 2011 at 2:14 AM, Don wrote: > The "rand" function is implementation defined, so it doesn't work the > same for every compiler. Most of them use a pseudo-random generating > function such as linear congruential generators, lagged Fibon

Re: [algogeeks] Print all path of the tree that sums up to the given value

2011-10-31 Thread Prakash D
any constraints for path? On Mon, Oct 31, 2011 at 11:19 AM, Ankuj Gupta wrote: > Print all path of the tree that sums up to the given value. The path > may start from any node. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post

Re: [algogeeks] Dp solution for this problem?

2011-10-30 Thread Prakash D
if all possible diagonal movements are allowed i guess we must check all the possibilities On Mon, Oct 31, 2011 at 12:52 AM, mohit verma wrote: > Given a matrix you have to find the shortest path from one point to > another within the matrix. The cost of path is all the matrix entries on > the w

Re: [algogeeks] choosing numbers

2011-10-30 Thread Prakash D
@Piyush kapoor: i don't get it.. could u plz explain a lil more? On Mon, Oct 24, 2011 at 8:19 PM, praveen raj wrote: > for 3 set .. set value stored in array a[3] and p is the sum > > for( i=0;i<=a[0];i++) > { >for(j=0;j<=a[1];j++) > { > for(k=a[2];k>=0;k--) > { >

Re: [algogeeks] Plz Explain the working

2011-10-03 Thread Prakash D
+1 On Mon, Oct 3, 2011 at 6:40 PM, ~*~VICKY~*~ wrote: > @Shauib: cool soln. Thank you. > > > On Mon, Oct 3, 2011 at 6:14 PM, Shuaib wrote: > >> Chk is a macro that gets replaced with an if statement. The else part gets >> attached to the most recent if which is the one from the macro. And since

Re: [algogeeks] string permutation

2011-10-01 Thread Prakash D
if the string is like abcdef then they will be numbered like 012345 and now we represent them in base 5 numbering and also in sorted order the next permutation is 012354 012435 012453 012534 012543 013245 and so on.. On Sat, Oct 1, 2011 at 4:11 PM, rahul sharma wrote: > guys plz xplain logic be

Re: [algogeeks] Re: THANX ALGOGEEKS !!!!!!

2011-09-22 Thread Prakash D
congrats brother!! On Thu, Sep 22, 2011 at 6:42 PM, saurabh wrote: > thanx to all > > I have shared my interview experience at > http://msidcinterview.blogspot.com/ > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this gro

Re: [algogeeks] string problem

2011-09-20 Thread Prakash D
no.. each ans[s] is stored before returning.. so there is no recalculation of any substring On Sun, Sep 18, 2011 at 4:12 AM, Marcelo Amorim Menegali < mmeneg...@gmail.com> wrote: > *ans[s]=find(s+1,len-1);* >> if(s[0]<'3'&&s[1]<'7') >> *ans[s] = ans[s]+find(s+2,len-2);* > >

Re: [algogeeks] is it possible??

2011-09-19 Thread Prakash D
in c/c++ without main function how to write a compilable code? for example printing a string On Tue, Sep 20, 2011 at 12:15 AM, hary rathor wrote: > use #pragma in c . > static block in java . > > by the way which lang you are talking about ? > > -- > You received this message because you are sub

Re: [algogeeks] convert a vector containing octal representation of a number to decimal number

2011-08-21 Thread Prakash D
A[i]<<3*i why is it needed to convert from base 8 to base 10?? On Sun, Aug 21, 2011 at 4:07 PM, Sanjay Rajpal wrote: > Hi your intention was logical OR or BITWISE OR ? > > u did Logical. > Sanju > :) > > > > On Sun, Aug 21, 2011 at 3:30 AM, sarvesh saran > wrote: > >> Hi Nitin, >> >> thanks th

Re: [algogeeks] why the output 16

2011-08-21 Thread Prakash D
:P.. no comments when i saw On Sun, Aug 21, 2011 at 4:07 PM, sagar pareek wrote: > @prakash > before posting u should check what others already posted :D :D > > On Sun, Aug 21, 2011 at 4:03 PM, Prakash D wrote: > >> FUNC2(8) >> >> ==> 8==0? 1: 8 * FUNC1

Re: [algogeeks] why the output 16

2011-08-21 Thread Prakash D
got it 8==0? 1: 8*( 8 -1* 8-1-1) ==> 8*( 8 - {1* 8-1-1}) ==> 8 * (8-6) ==> 16 but why??? On Sun, Aug 21, 2011 at 4:03 PM, Prakash D wrote: > ==> 8==0? 1: 8*( 8-1* 8-1-1) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks&quo

Re: [algogeeks] why the output 16

2011-08-21 Thread Prakash D
FUNC2(8) ==> 8==0? 1: 8 * FUNC1(8-1) ==> 8==0? 1: 8*( 8-1* 8-1-1) ==> 8 * (8-8-2) ==> -16 but why 16?? On Sat, Aug 20, 2011 at 7:02 PM, SuDhir mIsHra wrote: > #include > #define FUNC1(i) (i*(i-1)) > #define FUNC2(i) (i==0?1:i*FUNC1(i-1)) > main() > { > int i=8; > > > printf("\

Re: [algogeeks] Turbo C vs gcc

2011-08-20 Thread Prakash D
dont ever use turboc On Sat, Aug 20, 2011 at 11:36 PM, Saikat Debnath wrote: > Placement questions are not compiler dependent... :P > > > On Sat, Aug 20, 2011 at 11:32 PM, Abhishek > wrote: > >> okay.. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Alg

Re: [algogeeks] Re: shortest swapping rows

2011-08-18 Thread Prakash D
hey, thanks.. but if it needs many iteration, then we've to check each time whether the array is sorted.. is there any better way for swapping On Thu, Aug 18, 2011 at 5:02 AM, Brijesh Upadhyay < brijeshupadhyay...@gmail.com> wrote: > IT is the question.. > You are given an N x N matrix with 0 and

Re: [algogeeks] SPOJ 9199. Circular Track

2011-08-17 Thread Prakash D
any1?? On Sun, Aug 7, 2011 at 7:16 PM, Prakash D wrote: > yeah, i also need to know the approach for this kind of problems asked in > many places > > > On Sun, Aug 7, 2011 at 3:58 PM, arvind kumar wrote: > >> Hi >> Can any1 pls help me in solving this? >> T

[algogeeks] A problem asked in a contest

2011-08-15 Thread Prakash D
given the sum and product of n numbers we have to find those numbers(any one possibility) sum, product and n are inputs... for example if the sum is 10, product is 36 and n is 3 then 3,3,4 is a possible solution... if it is impossible we should print NO i wrote this code.. is there any faster

Re: [algogeeks] Re: shop keeper and the buyer

2011-08-14 Thread Prakash D
@rashmi: there is no confusion for the third item.. so simply u buy all the third item without any offer On Mon, Aug 15, 2011 at 12:52 AM, ritu wrote: > solution is as following if problem is "buy all the n items for > minimum price if there are offers so that item j is free if customer > buys K

Re: [algogeeks] shop keeper and the buyer

2011-08-14 Thread Prakash D
no one to help ?? On Sat, Aug 13, 2011 at 10:48 PM, Prakash D wrote: > k lets assume that there are 10 kinds of item in the shop > price[]={10,20,30,40,50,60,70,80,90,100} > quantity[]={5,5,5,5,5,5,5,5,5,5} > > say no.of items having some free discounts : 5 > > say p,q,r

Re: [algogeeks] shop keeper and the buyer

2011-08-13 Thread Prakash D
k lets assume that there are 10 kinds of item in the shop price[]={10,20,30,40,50,60,70,80,90,100} quantity[]={5,5,5,5,5,5,5,5,5,5} say no.of items having some free discounts : 5 say p,q,r denotes buying q nos. of p we will get one r for free.. let them be 5 4 1 2 5 1 8 2 10 9 1 10 1 5 10 expl

Re: [algogeeks] what is mean by %2.3d in scanf

2011-08-13 Thread Prakash D
i dont think we can set precision during scanf On Sat, Aug 13, 2011 at 9:49 PM, Anika Jain wrote: > @gaurav: nyc one ;) how u made this one well? > > On Sat, Aug 13, 2011 at 6:14 PM, SANDEEP CHUGH wrote: > >> lol >> >> >> On Sat, Aug 13, 2011 at 6:12 PM, Gaurav Menghani < >> gaurav.mengh...@gmai

Re: [algogeeks] shop keeper and the buyer

2011-08-13 Thread Prakash D
anyone? On Fri, Aug 12, 2011 at 3:49 AM, cegprakash wrote: > there are n number of items available in the shop > price[] {size n} gives the cost of each item > and there are quantity[] {size n} means that there are quantity[i] > number of i'th item > > the shop keeper provides some free items >

Re: [algogeeks] reverse

2011-08-12 Thread Prakash D
how does the above code work? On Fri, Aug 12, 2011 at 1:14 PM, Rahul wrote: > I understand. where I find some more tricks like these , I mean I > really. find. bit thinking hacks. difficult to understand. > > > On 8/12/11, Tarun Arya wrote: > > RAHUL@ > > d question was to reverse d 2 numbers.

Re: [algogeeks] amazon help

2011-08-11 Thread Prakash D
www.projecteuler.net On Fri, Aug 12, 2011 at 6:52 AM, Dipankar Patro wrote: > Topcoder will be a good option. > > Amazon mainly makes you write functions in which the parameters and > structure of any user defined data types are clearly mentioned. > Just coding on a normal computer will also hel

Re: [algogeeks] how o/p is coming

2011-08-11 Thread Prakash D
@anuj kumar: try this #include #include int main() { int a=10,b=20; char x=1,y=0; printf("%d\n",a,b,x,y); printf("%d\n",(a,b,x,y)); if(a,b,x,y) { printf("EXAM"); } getchar(); } this will print 10 and 0 because if the outer bracket is not there, onl

Re: [algogeeks] MICROSOFT INTERVIEW QUESTIONS faced by my frenz nd me

2011-08-11 Thread Prakash D
could anyone explain the question 4? On Fri, Aug 12, 2011 at 3:23 AM, Prakash D wrote: > for 3 i think only b is the true statement > > > On Fri, Aug 12, 2011 at 3:20 AM, Prakash D wrote: > >> whats the solution for 3? >> >> >> On Tue, Aug 9,

Re: [algogeeks] MICROSOFT INTERVIEW QUESTIONS faced by my frenz nd me

2011-08-11 Thread Prakash D
for 3 i think only b is the true statement On Fri, Aug 12, 2011 at 3:20 AM, Prakash D wrote: > whats the solution for 3? > > > On Tue, Aug 9, 2011 at 6:13 PM, Akash Mukherjee wrote: > >> @srinivas if any of the characters (i,n,d,a) appear den it is no longer >> read

Re: [algogeeks] MICROSOFT INTERVIEW QUESTIONS faced by my frenz nd me

2011-08-11 Thread Prakash D
whats the solution for 3? On Tue, Aug 9, 2011 at 6:13 PM, Akash Mukherjee wrote: > @srinivas if any of the characters (i,n,d,a) appear den it is no longer > readso gujr > > > On Tue, Aug 9, 2011 at 6:04 PM, Srinivas Varanasi > wrote: > >> Can any one explain question number 8? >> >> >> On T

Re: [algogeeks] Re: Probability

2011-08-11 Thread Prakash D
sorry that was for equal case : for unequal case 1-(73/648)= 575/648 On Fri, Aug 12, 2011 at 2:28 AM, Prakash D wrote: > total possible outcomes= 6*6*6*6 > > possibility of sum gives 2 in both pair --> 1*1*1*1 =1 > possibility of sum gives 3 in both pair --> 2*1*2*1

Re: [algogeeks] Re: Probability

2011-08-11 Thread Prakash D
total possible outcomes= 6*6*6*6 possibility of sum gives 2 in both pair --> 1*1*1*1 =1 possibility of sum gives 3 in both pair --> 2*1*2*1 =4 {because the possibilities are (1,2)(1,2), (1,2)(2,1), (2,1)(1,2), (2,1)(2,1)} possibility of 4 --> 9 { 2,2 1,3 and 3,1} possibility of 5 --> 16 {1,4 2,3

Re: [algogeeks]

2011-08-11 Thread Prakash D
@sagar nice one :D what u specified above is the scenario in gcc and dev c++ right? On Fri, Aug 12, 2011 at 1:55 AM, sagar pareek wrote: > : :)) > > > On Fri, Aug 12, 2011 at 1:54 AM, aditi garg wrote: > >> @sagar.: Now i get it:) >> Thanks a ton :) >> >> On Fri, Aug 12, 2011 at 1:51 AM, sagar

Re: [algogeeks] goldman sachs paper

2011-08-10 Thread Prakash D
+1.. it'll be helpful On Thu, Aug 11, 2011 at 12:12 AM, Prashant Gupta wrote: > +1 to deepika. > > > On Thu, Aug 11, 2011 at 12:10 AM, deepikaanand wrote: > >> can anyone please post the questions asked in goldman sachs this year >> >> -- >> You received this message because you are subscribed to

Re: [algogeeks] Write a program to find the empirical formulae from physical formulae

2011-08-10 Thread Prakash D
i think the given formula's solution should be c1 h33 o20 n10 check the question.. On Wed, Aug 10, 2011 at 9:49 PM, vikas wrote: > Write a program to find the empirical formulae from physical formulae > ex: ch3((oh)2(nh3)2)5 > has empirical formulae > c1 h43 o2 n10 > > -- > You received this

Re: [algogeeks] Probability question.. help

2011-08-09 Thread Prakash D
is there anything like there should be atleast one man and one women should dance together? On Wed, Aug 10, 2011 at 2:26 AM, Shuaib Khan wrote: > > > On Wed, Aug 10, 2011 at 1:45 AM, Brijesh Upadhyay < > brijeshupadhyay...@gmail.com> wrote: > >> No thers is not.. someone has asked me this., don

Re: [algogeeks] Re: Probability Puzzle

2011-08-09 Thread Prakash D
@dave: thank you.. nice explanation :) On Wed, Aug 10, 2011 at 3:24 AM, Dave wrote: > @Ritu: We are flipping one coin five times. Are you saying that you > don't learn anything about the coin by flipping it? Would you learn > something if any one of the five flips turned up tails? After a tails,

Re: [algogeeks] o/p

2011-08-09 Thread Prakash D
@rajkumar: thanks #include #define max(a,b) ((a>b)?a:b) int main() { int m,n; m=3+max(2,3); n=2*max(3,2); printf("%d,%d",m,n); getchar(); return 0; } this gives the correct output as 6,6 On Mon, Aug 8, 2011 at 7:12 PM, Dipankar Patro wrote: > relational operators give 0/1 outp

Re: [algogeeks] Probability question.. help

2011-08-09 Thread Prakash D
is there any constraint for anyone to dance? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.co

Re: [algogeeks] solve this!

2011-08-09 Thread Prakash D
s. Should we multiply by 6! * 6! (1 6! for > each side)?? > > is the answer > 12C6* 6c3 * 6C2 * 6! * 6!?? > > On Tue, Aug 9, 2011 at 9:22 PM, Prakash D wrote: > >> the solution will be 12C6* 6c3 * 6C2 >> >> because if you choose 6 people for the left side, t

Re: [algogeeks] Re: max product!

2011-08-09 Thread Prakash D
cool.. i was lazy to look at your code :P On Tue, Aug 9, 2011 at 9:32 PM, WgpShashank wrote: > @CEG thats what i explained in given link dude isn't it :) > > @punnu & some others we need to find 3 Maxs & 2 Mins in 5 passes over array > we can do it in single pass it self as explained in link time

Re: [algogeeks] solve this!

2011-08-09 Thread Prakash D
the solution will be 12C6* 6c3 * 6C2 because if you choose 6 people for the left side, then there is no option for the right side(i.e. we can select only the remaining 6 people for right side) also this 12C6 will provide all possible combinations for choosing 6 members for left or right and there

Re: [algogeeks] Re: finding triplets

2011-08-09 Thread Prakash D
if the initial array is [9, 2, 3, -4, 8, 5, 6, 10] square all the elements in the array O(n) map all the squares and set as 1 if it is present in array O(n) sort the array.. O(n log n) i=0 to n-1 j=i+1 to n-1 if(map(arr[i]+arr[j])) then there exist a triplet O(nlog n) so totally this algo

Re: [algogeeks] solve this!

2011-08-09 Thread Prakash D
12C6* 6c3 * 6C2 On Tue, Aug 9, 2011 at 2:10 PM, programming love < love.for.programm...@gmail.com> wrote: > members -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscr

Re: [algogeeks] Re: max product!

2011-08-09 Thread Prakash D
yeah, yours is enough :) tried with various combinations.. thanks On Tue, Aug 9, 2011 at 2:20 AM, Dave wrote: > @Prakash: Yeah, but doesn't the max take care of that? > > Dave > > On Aug 8, 3:07 pm, Prakash D wrote: > > yeah.. but the smaller numbers must be negative

Re: [algogeeks] Re: max product!

2011-08-09 Thread Prakash D
so you should use absolute values in second part On Tue, Aug 9, 2011 at 2:20 AM, Dave wrote: > @Prakash: Yeah, but doesn't the max take care of that? > > Dave > > On Aug 8, 3:07 pm, Prakash D wrote: > > yeah.. but the smaller numbers must be negative in first pa

Re: [algogeeks] Re: max product!

2011-08-08 Thread Prakash D
yeah.. but the smaller numbers must be negative in first part and largest numbers should be of same signs in second part On Mon, Aug 8, 2011 at 6:24 PM, Dave wrote: > max(product of two smallest numbers and largest number, product of > three largest numbers). > -- You received this message be

Re: [algogeeks] MS test

2011-08-08 Thread Prakash D
for 5th one loop will terminate only when n=0 which is not possible i think On Mon, Aug 8, 2011 at 10:58 PM, D!leep Gupta wrote: > yup 1st ans is b. > > > On Sat, Aug 6, 2011 at 10:12 PM, sukran dhawan wrote: > >> i think 1st one is b.not sure. can anybody correct me? >> >> >> >> -- >> You rece

Re: [algogeeks] o/p

2011-08-08 Thread Prakash D
how 2,3 any idea?? On Mon, Aug 8, 2011 at 5:09 PM, raj kumar wrote: > I think you forgot to give a space between macro and it's expansion that's > why > max(a,b)(a>b)?a:b > is getting expanded to null > and the above result > > -- > You received this message because you are subscribed to the Go

Re: [algogeeks] help--code

2011-08-08 Thread Prakash D
@gaurav: are u sure? On Mon, Aug 8, 2011 at 3:40 PM, Amir wrote: > Both Will take same time. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/algogeeks/-/

Re: [algogeeks] Re: max product!

2011-08-08 Thread Prakash D
simple soln = max( product of lowest two negative numbers and highest positive number, product of highest three negative numbers, product of highest three positive numbers) On Mon, Aug 8, 2011 at 4:50 PM, Aditya Virmani wrote: > what if we can maintain three arrays: > large_positives[3]: contain

Re: [algogeeks] Re: Probability Puzzle

2011-08-07 Thread Prakash D
us 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 >>>>

Re: [algogeeks] Re: probablity

2011-08-07 Thread Prakash D
@ all: am sorry.. i din't saw the word "same packet".. so the prob of choosing a blue from 2nd possibility is 0 and so totally there are 1/2 possibilities -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to al

Re: [algogeeks] Re: probablity

2011-08-07 Thread Prakash D
gt; On Sun, Aug 7, 2011 at 9:14 PM, Prakash D wrote: > >> The solution is 5/6 for sure >> >> >> the possible outcomes after a blue is chosen are >> >> blue 1 1 0 >> black 0 1 2 >> >> and >> >> blue 2 0 0 >> black 0 1

Re: [algogeeks] Re: Probability Puzzle

2011-08-07 Thread Prakash D
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,

Re: [algogeeks]

2011-08-07 Thread Prakash D
counting sort with hashing On Sun, Aug 7, 2011 at 10:23 AM, rahul rai wrote: > Thats True , Even insertion and merge sorts are too .. > > !!! > > > Rahul > > > On Sun, Aug 7, 2011 at 10:20 AM, Gaurav Menghani < > gaurav.mengh...@gmail.com> wrote: > >> "The Postman's sort is a variant of bucket s

Re: [algogeeks] Sum from array

2011-08-07 Thread Prakash D
is there a faster algo than O(n^2)? On Sun, Aug 7, 2011 at 4:14 PM, raj kumar wrote: > similar to make change dp problem > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.co

Re: [algogeeks] Re: probablity

2011-08-07 Thread Prakash D
The solution is 5/6 for sure the possible outcomes after a blue is chosen are blue 1 1 0 black 0 1 2 and blue 2 0 0 black 0 1 2 prob of choosing a blue from 1st possibility = 1/3+1/6 prob of choosing a blue from 2nd possibility= 1/3 so totally there are 5/6 possibilities On Sun, Au

Re: [algogeeks] Re: MS test

2011-08-07 Thread Prakash D
any idea for 5th one? On Sun, Aug 7, 2011 at 7:50 PM, Prakash D wrote: > @siddharam: for the second one, the series is like this > > the first character will print once. > second one twice > third one four times and so on > > 1,2,4,8,... > > On Sun, Aug 7, 2011 at 4:5

Re: [algogeeks] Re: MS test

2011-08-07 Thread Prakash D
@siddharam: for the second one, the series is like this the first character will print once. second one twice third one four times and so on 1,2,4,8,... On Sun, Aug 7, 2011 at 4:53 PM, Dave wrote: > 6.5 = 2^2 + 2^1 + 2^-1 > Binary representation = 110.1 = 1.101 * 2^2. > > 0.1 = 2^-3 + 2^-4 + 2

Re: [algogeeks] SPOJ 9199. Circular Track

2011-08-07 Thread Prakash D
yeah, i also need to know the approach for this kind of problems asked in many places On Sun, Aug 7, 2011 at 3:58 PM, arvind kumar wrote: > Hi > Can any1 pls help me in solving this? > Two persons are running on a circular track either in the same > direction or in the opposite direction, indefi

Re: [algogeeks] max product!

2011-08-07 Thread Prakash D
, Aug 7, 2011 at 7:04 PM, Prakash D wrote: > >> that won't work.. there may be two negative bigger numbers whose product >> will bcom +ve >> >> >> On Sun, Aug 7, 2011 at 6:49 PM, Puneet Ginoria >> wrote: >> >>> find the first three larg

Re: [algogeeks] max product!

2011-08-07 Thread Prakash D
that won't work.. there may be two negative bigger numbers whose product will bcom +ve On Sun, Aug 7, 2011 at 6:49 PM, Puneet Ginoria wrote: > find the first three largest nos. and 3 smallest number(negatives).. then > easily you can fig. out the solution.. > > O(6n) solution i guess which is O(n

Re: [algogeeks] Amazon Question

2011-08-03 Thread Prakash D
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 sub

Re: [algogeeks] Re: array

2011-08-03 Thread Prakash D
if it is an 2D array of pointers we can :) On Wed, Aug 3, 2011 at 11:32 PM, shiv narayan wrote: > yes we can. > > On Aug 3, 10:08 pm, Arshad Alam wrote: > > can we insert 16 elements of one dimension array in 4*4 of double > dimension > > array? > > -- > You received this message because you are

Re: [algogeeks] Re: Algorithm complexity

2011-08-03 Thread Prakash D
lol.. nice one :D On Thu, Aug 4, 2011 at 12:30 AM, Don wrote: >n = log(log(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 ema

Re: [algogeeks] Re: Amazon Aptitude questions

2011-08-03 Thread Prakash D
no.. it's really easy to find it out there are 12 black and 12 white pieces. let black =1 and white =0 the possible results are 11, 00, 10, 01 number of ways of 11 solutions= 12 * 11 = 132 number of ways of 00 solutions = 12 * 11 = 132 number of ways of 10 solutions = 12 * 12 = 144 number o

Re: [algogeeks] Re: MS [Written Question]

2011-08-03 Thread Prakash D
@Gene: nice one :D On Wed, Aug 3, 2011 at 11:02 PM, sagar pareek wrote: > same questions...not a single diff were asked in NIT allahabad on 17 july > this yr... > > > On Wed, Aug 3, 2011 at 8:21 PM, Vengadanathan wrote: > >> It may not work for all , the parameter input is double what happens >>

Re: [algogeeks] Re: Amazon Aptitude questions

2011-08-03 Thread Prakash D
i din't look at the word pair :P.. sorry -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. F

Re: [algogeeks] Re: Amazon Aptitude questions

2011-08-03 Thread Prakash D
18/33? On Wed, Aug 3, 2011 at 10:42 PM, muthu raj wrote: > 5) > Sample space=24C2= 276 > N(S) = 12 C 2 + 12 C 2 =132 > > Probability= 132/276= 11/23 > > > *Muthuraj R > IV th Year , ISE > PESIT , Bangalore* > > > > On Wed, Aug 3, 2011 at 10:36 PM, Pra

Re: [algogeeks] Re: Amazon Aptitude questions

2011-08-03 Thread Prakash D
assume there are 6 1's and 6 0's if two are selected together randomly the possible outcomes are 00, 11, 01, 10 00- 30 possibilities 11 - 30 possibilities 10 - 36 possibilities 01 - 36 possibilities probability of 10 or 01 = (36+36)/(30+30+36+36) =18/31 is it one of the options? On Wed,

Re: Re: [algogeeks] aptitude

2011-08-03 Thread Prakash D
I dont get this part of your proof.. :(. "Y-X is a fraction so it's not valid assumption." On Wed, Aug 3, 2011 at 9:57 PM, D!leep Gupta wrote: > Y-X is a fraction so it's not valid assumption. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group

Re: [algogeeks] Max subarray of no 2 adjacent elements

2011-08-03 Thread Prakash D
yeah.. it's 15! On Mon, Aug 1, 2011 at 1:24 PM, coder dumca wrote: > i think the answer should be 15 > > > On Mon, Aug 1, 2011 at 12:46 PM, Abhishek Gupta wrote: > >> let the array be A={ 3,5,7,10} then it should give output as 13 (3+10) >> >> In short, we need to find the possible maximum sum s

Re: [algogeeks] Amazon Question

2011-08-03 Thread Prakash D
someone post all the questions asked by amazon pls.. it'll be useful On Wed, Aug 3, 2011 at 3:43 PM, Arun Vishwanathan wrote: > it cud also be 0011 > > > On Wed, Aug 3, 2011 at 6:54 AM, payel roy wrote: > >> It is contiguous ...the answer will be 0110. >> >> >> On 2 August 2011 20:59, ankit samb

Re: [algogeeks] Max subarray of no 2 adjacent elements

2011-08-01 Thread Prakash D
I just thought of an O(n) dp solution let a[]=5,2,1,7,9,11 traverse from i=0 to n-1 we define arr[i]= a[i]+max(arr[i-2],arr[i-3)); first arr[0]= 5 + max( a[-2], a[-3]) = 5 arr[1]= 2 arr[2]=1 + 5 arr[3]= 7 + max(5,2) = 7+ 5 = 12 then arr[4]= 9 + max(2,6) = 15 then arr[5]= 11 + max(6,12) =

Re: [algogeeks] Max subarray of no 2 adjacent elements

2011-08-01 Thread Prakash D
you cannot choose 7 and 10 since they are adjacent On Mon, Aug 1, 2011 at 1:17 PM, Prakash D wrote: > i can write a O(n^2) soln. but i hope there could be a better way > > > On Mon, Aug 1, 2011 at 12:46 PM, Abhishek Gupta wrote: > >> let the array be A={ 3,5,7,10} then it

Re: [algogeeks] Max subarray of no 2 adjacent elements

2011-08-01 Thread Prakash D
i can write a O(n^2) soln. but i hope there could be a better way On Mon, Aug 1, 2011 at 12:46 PM, Abhishek Gupta wrote: > let the array be A={ 3,5,7,10} then it should give output as 13 (3+10) > > In short, we need to find the possible maximum sum such that no 2 elements > in the subarray has 2

Re: [algogeeks] Re: FB intern

2011-07-31 Thread Prakash D
@priyanka : thank you On Sun, Jul 31, 2011 at 3:17 PM, saurabh singh wrote: > yup you are right.prakash try some cases and you will get why its > necessary. > (Yup i agree can be written in an if else way but i like it this way > better) > > > On Sun, Jul 31, 2011 at 2:08 PM, priyanka raju wrote

Re: [algogeeks] Re: FB intern

2011-07-30 Thread Prakash D
what does n mod 2's job here? the only possible return case is when n/2 is 0 or 1 On Sat, Jul 30, 2011 at 2:04 PM, saurabh singh wrote: > And yes the formula is derived by the fact that x^(a+b)=x^a*x^b > and then think top down with respect to a general variable n.(That is how > to split n in

Re: [algogeeks] Re: MICROSOFT!!!!

2011-07-25 Thread Prakash D
* 2 3 5 6 On Mon, Jul 25, 2011 at 6:38 PM, Prakash D wrote: > thank you all for the gcd algo > > 1) is the solution is 2 3 5 2 ? > > 2) it will not work for double values which is beyond integer range!! > > > 3) this will find the number of 1's in binary re

Re: [algogeeks] Re: MICROSOFT!!!!

2011-07-25 Thread Prakash D
thank you all for the gcd algo 1) is the solution is 2 3 5 2 ? 2) it will not work for double values which is beyond integer range!! 3) this will find the number of 1's in binary representation of x^y.. right? someone explain the CFG question plz.. On Sat, Jul 23, 2011 at 5:58 PM, arun kum

Re: [algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread Prakash D
post the 10 questions plz On Fri, Jul 22, 2011 at 8:29 PM, shady wrote: > what was it ? job interview questions or intern ? > > gcd can always be found in O(log(larger number)) , sorry, couldnt > understand the complexity in that ? > > > On Fri, Jul 22, 2011 at 8:22 PM, siva viknesh wrote: > >>

Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Prakash D IT @ CEG
could someone explain the algo with an example? On Sun, May 22, 2011 at 8:21 PM, Puneet Ginoria wrote: > thnxx all.. i got the soln.. > Qdumanshu: i was asking for quotient and remainder when we divide 2 nos. > without actually dividing them... > > >> > -- > You received this message because you

Re: [algogeeks] Reuest for a book

2011-05-08 Thread Prakash D IT @ CEG
@charles: think in his point of view.. everyone's needs are different On Mon, May 9, 2011 at 4:26 AM, Charles Turner wrote: > On 08/05/2011 23:32, ankit sablok wrote: > > Please mail the book "Data Structures and Algorithms in C" by Mark > Allen Weiss to the following Id - ankit4...@gmail.com >

Re: [algogeeks] Re: If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2011-05-08 Thread Prakash D IT @ CEG
mail me too plzz.. cegprak...@gmail.com On Sun, May 8, 2011 at 10:00 PM, UTKARSH SRIVASTAV wrote: > mail me also usrivastav...@gmail.com > > > On Sun, May 8, 2011 at 1:08 AM, ArPiT BhAtNaGaR < > arpitbhatnagarm...@gmail.com> wrote: > >> dere is soln first person mail to first person on list n d

Re: [algogeeks] Re: partitioning the array

2011-05-07 Thread Prakash D IT @ CEG
sorry, i misunderstood the problem statement On Sun, May 8, 2011 at 10:53 AM, Aakash Johari wrote: > @cegprakash: it doesnt ensure that both the arrays will be having same > number of elements > > > On Sat, May 7, 2011 at 10:10 PM, cegprakash wrote: > >> simple.. >> >> sum all the n elements

Re: [algogeeks] please explain the output

2011-04-09 Thread Prakash D IT @ CEG
nice 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 t

Re: [algogeeks] Re: debugging contest

2011-03-26 Thread Prakash D IT @ CEG
is there any use with labels xxx, yyy.. ? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com.