Re: [algogeeks] Derivation
Its not a tough question.Basic arithmetics/algebra question. ACB Suppose speed of train from A =x Suppose speed of train from B =y They meet at C 1st train take a sec to reach C from B CB=ax 2nd train take b sec to reach C from A CA=bx Time taken for 2nd train to reach C from B = ax/y Time taken for 1st train to reach C from a = by/x As they meet these 2 time will be same ax/y=by/x =ax^2=by^2 =x:y= √b : √a On Thu, Jun 10, 2010 at 11:35 PM, Raj N rajn...@gmail.com wrote: Can someone help me deriving this ? If 2 trains start at the same time from points A and B towards each other and after crossing they take a and b sec in reaching B and A respectively, then A's speed:B's speed=b^1/2:a^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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: infix
Use stack to push '( initially. if ')' is found remove its pair '('.finally if the stack is empty then the expression is correct! On Jun 10, 9:45 pm, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote: give an algo which reads an paranthesised infix expression and check well-formdness of paranthesis.. eg .. ))a+b(( and (a+b)) ...are not well formed parantheses exp -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c output
@Divya o/p c prints b 1 - prints a 6, 2 --- printf returns no of characters printed. 6=5 (length of a) + 1 (for \n) 2=1 (length of b) + 1 (for \n) Hope it's clear Mohit Ranjan On Fri, Jun 11, 2010 at 12:56 AM, divya sweetdivya@gmail.com wrote: #include stdio.h main() { int a = 1; char b='c'; int i,j; printf(%d,%d,printf(%d\n,a),printf(%c\n,b)); wat shd b the o/p of this..plzz explain y? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: binary nos
clarification to all n=1 0,1 no of sequence =2 n=2 00,01,10 no of sequence =3 n=3 000,100,010,001,101 no of sequence =5 n=4 ,1000,0100,0010,0001,1010,0101,1001 no of sequence =8 n=5 0,1,01000,00100,00010,1,10100,10010,10001,01010,01001,00101,10101 no of sequence =13 so its coming in fibo no. no of sequence =fibo(n+2)if you exclude 0 from fibo no no of sequence =fibo(n+3)if you include 0 in fibo no On Fri, Jun 11, 2010 at 1:55 PM, Debajyoti Sarma sarma.debajy...@gmail.comwrote: @Rohit Saraf i understood the question. Superb solution by u. On Thu, Jun 10, 2010 at 8:59 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: write an efficient algo to compute no. of sequences of n binary digits that do not contain 2 1's in a row. eg 111 is invalid whereas 1001001 is valid. HERE the number of sequences comes to be a fibonacci number , precisely fib(n+2). So this prob is equivalent to finding fibonacci numbers -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Thu, Jun 10, 2010 at 11:47 AM, Sundeep Singh singh.sund...@gmail.comwrote: @rohit: fibonacci sequence may be the answer to the prob, but I am curious why? I haven't come across any such fib sequence property... On Wed, Jun 9, 2010 at 9:16 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @junta : are fibonacci sequence is the answer of the prob, it is not used :D -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Wed, Jun 9, 2010 at 9:13 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @debajyoti: read the prob before posting -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Wed, Jun 9, 2010 at 2:37 PM, Debajyoti Sarma sarma.debajy...@gmail.com wrote: First 20 fibo no as follows with binary form 0 = 0 1 = 1 1 = 1 2 = 10 3 = 11 5 = 101 8 = 1000 13 = 1101 21 = 10101 34 = 100010 55 = 110111 89 = 1011001 144 = 1001 233 = 11101001 377 = 10001 610 = 1001100010 987 = 011011 1597 = 1100001 2584 = 10111000 4181 = 101010101 Now please explain how fibo no is coming under consideration.Both kind of no is mixed here. On Wed, Jun 9, 2010 at 8:02 AM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: Fib comes because she wants the number of such sequences -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at
Re: [algogeeks] c output
printf returns number of successfully printed characters. so printf(1\n) will return 6 and printf(c\n) will return 2 due to the extra '\n' character which is also being printed I hope the output is now clear Anurag Sharma On Fri, Jun 11, 2010 at 12:26 AM, divya sweetdivya@gmail.com wrote: #include stdio.h main() { int a = 1; char b='c'; int i,j; printf(%d,%d,printf(%d\n,a),printf(%c\n,b)); wat shd b the o/p of this..plzz explain y? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: c output
Explanation: The prototype for printf as per ANSI C is: int printf( const char *format,…) the return value is integer and returns the number of characters successfully read by printf. Also,in case of printf(),the evaluation of expressions passed on as arguments is done from right to left on stack and then printed from left to right by popping the stack. So,the output comes as: c :Evaluation of printf(%c\n,b).Note that after execution,they return the number of characters read. 1: Evaluation of printf(%d\n,a) 6,2 :No of characters read printed from left to right as printf now is: printf(%d %d,6,2); Ashish Kumar Jain On Jun 11, 8:56 am, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: c 1 6,2 u might be expecting 5,1 if u are forgetting the newline character :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] level order traversal
@sharad : In which order you will make the tree into doubly linklist ?? another algorithm: 1. keep root value as 0 2. when moving left decrement this value and assign to node 3. when moving right increment the value and assign to node 4. now sort the nodes on this number basis and if this number is same then on level basis eg: 1 /\ 2 3 / \/ \ 45 67 1 - 0 2 - -1 3 - 1 4 - -2 5 - 0 6 - 0 7 - 2 sort : 4 2 1 5 6 3 7 any comments??? -- Regards Jitendra Kushwaha MNNIT, Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c output
The return value of printf is the number of characters it prints successfully. So the rightmost printf is going to return 2 (one for char c and one for new line), similarly second one returning 6. Regards, Chetan. On 11 June 2010 00:56, divya sweetdivya@gmail.com wrote: #include stdio.h main() { int a = 1; char b='c'; int i,j; printf(%d,%d,printf(%d\n,a),printf(%c\n,b)); wat shd b the o/p of this..plzz explain y? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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 algoge...@googlegroups.com. To unsubscribe from 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: identify the recurring part for a given decimal no
One solution that is very simple is: while doing division keep storing the dividend. if any one dividend is repeated stop there and extract the part between first occurrence digit before new occurrence. Example: 7/9 7) 9 (1.*285714*28 7 -- 20 14 --- 60 56 --- 40 35 --- 50 49 --- 10 7 30 28 20 14 60 56 repeats here *285714 is repeating pattern. * On 10 June 2010 08:55, Veer Sharma thisisv...@rediffmail.com wrote: Seems it wont work... x=23.34563456 temp = x*100 -x = 233.4563456 - 23.34563456 = 210.11071104 temp = x*100 -x = 2334.563456 - 23.34563456 = 2311.21782144 temp = x*1000 -x = 23345.63456 - 23.34563456 = 23322.28892544 temp = x*1 -x = 233456.3456 - 23.34563456 = 233432.6544 temp = x*10 -x = 2334563.456 - 23.34563456 = 2334540.11036544 ... On Jun 9, 11:24 pm, Anurag Sharma anuragvic...@gmail.com wrote: multiply the original number x=23.34563456 Anurag Sharma On Wed, Jun 9, 2010 at 10:36 PM, Veer Sharma thisisv...@rediffmail.com wrote: One question: No x = 23.34563456 temp = x X 10 = 233.4563456 temp = temp - x = 210.11071104 decimal part zero? No. Now multiply the no. with 100. Which no? original x (= 23.34563456) or new no. temp (=210.11071104)? On Jun 9, 8:12 pm, divya jain sweetdivya@gmail.com wrote: multiply the no. with 10 nd store in temp. now subtract no from temp. check if the decimal part is zero if yes. then 1st digit after decimal is recurring. if no. multiply the no with 100 and repeat . if this time decimal part is zero then 2 digits after decimal r recurring nd so on.. On 8 June 2010 21:45, Veer Sharma thisisv...@rediffmail.com wrote: You have a Numerator and Denominator. After division you might get a recurring decimal points float as the answer. Problem is: You need to identify the recurring part for a given decimal no? For example 23.34563456 ... return 3456 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards, Ravi.Thati -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: c output
Output will be 1,1 bcoz printf returns number of characters or integers printed On Jun 11, 12:26 am, divya sweetdivya@gmail.com wrote: #include stdio.h main() { int a = 1; char b='c'; int i,j; printf(%d,%d,printf(%d\n,a),printf(%c\n,b)); wat shd b the o/p of this..plzz explain y? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: infix
BALARUKESH, In Rohit's algorithm there was one more condition that sum should never be negative. I think you missed that point. The algorithm seems to be fine at least for correct ordering of paranthesis. didn't check for correctness of expression. :P -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: identify the recurring part for a given decimal no
Please note that the fractional repeating part is recurring. and so that 4th temporary variable assignment will be this way- temp=x*1 - x= 233456.34563456... - 23.34563456 = 233433.0 ( mark the fractional part is 0 now since the infinitely repeating 3456... will get cancelled) In this case you can say that 4 places are repeating. But yes its according to the maths and in any programming language whenever you divide the numerator and denominator you wont get this infinitely recurring decimal places. @divya, also your approach wont work if the recurring fractional digits start after few places from the decimal like in the case of 23.123345634563456 (note here after the decimal place 123 is not repeating while 3456.. after this 123 is repeating.) What I suggest in this case is keep dividing the numerator by denominator and at every step keep inserting the tupple (remainder, quotient) of that division step in a set. and before inserting in the set check whether it already exists. If yes then the all the quotients following from that point (including the point) will be recurring. Regards, Anurag Sharma On Thu, Jun 10, 2010 at 8:25 AM, Veer Sharma thisisv...@rediffmail.comwrote: Seems it wont work... x=23.34563456 temp = x*100 -x = 233.4563456 - 23.34563456 = 210.11071104 temp = x*100 -x = 2334.563456 - 23.34563456 = 2311.21782144 temp = x*1000 -x = 23345.63456 - 23.34563456 = 23322.28892544 temp = x*1 -x = 233456.3456 - 23.34563456 = 233432.6544 temp = x*10 -x = 2334563.456 - 23.34563456 = 2334540.11036544 ... On Jun 9, 11:24 pm, Anurag Sharma anuragvic...@gmail.com wrote: multiply the original number x=23.34563456 Anurag Sharma On Wed, Jun 9, 2010 at 10:36 PM, Veer Sharma thisisv...@rediffmail.com wrote: One question: No x = 23.34563456 temp = x X 10 = 233.4563456 temp = temp - x = 210.11071104 decimal part zero? No. Now multiply the no. with 100. Which no? original x (= 23.34563456) or new no. temp (=210.11071104)? On Jun 9, 8:12 pm, divya jain sweetdivya@gmail.com wrote: multiply the no. with 10 nd store in temp. now subtract no from temp. check if the decimal part is zero if yes. then 1st digit after decimal is recurring. if no. multiply the no with 100 and repeat . if this time decimal part is zero then 2 digits after decimal r recurring nd so on.. On 8 June 2010 21:45, Veer Sharma thisisv...@rediffmail.com wrote: You have a Numerator and Denominator. After division you might get a recurring decimal points float as the answer. Problem is: You need to identify the recurring part for a given decimal no? For example 23.34563456 ... return 3456 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: hashing
Hi All, For if max is 1 then we do not need to read the bits after 14th place. 1(dec) = 1001110001 (bin) that is 14 bits. On Fri, Jun 11, 2010 at 12:08 AM, kirubakaran kirubakaran1...@gmail.comwrote: When it is a stream of data,counting is a best way to go ! On Jun 10, 7:54 am, Anurag Sharma anuragvic...@gmail.com wrote: Even if you use bucket sort, you will have to store the numbers arriving, or atleast 1..1 numbers along with their count. If you reduce the size of the bucket further you will have to make a list associated with the buckets. So asymptotically you will again reach the same space complexity. Anurag Sharma On Thu, Jun 10, 2010 at 5:16 AM, sharad kumar aryansmit3...@gmail.com wrote: can u reduce the size by making use of bucket sort On Wed, Jun 9, 2010 at 5:01 PM, sharad sharad20073...@gmail.com wrote: I have a stream of numbers coming one by one from a computer generated program. I know that these numbers will be between 0 and 1. In minimum time how can I sort them. Space is no constraint. Later we have to try and optimize the space to as minimum as possible -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups .com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- yezhu malai vaasa venkataramana Govinda Govinda -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups .com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. Kirubakaran.S GSoC -2010 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Rishi B. Agrawal http://www.linkedin.com/in/rishibagrawal http://code.google.com/p/fscops/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: infix
As you encounter the opening parentheses (,[,{ push them onto the stack. When you encounter closing parentheses pop the top element if it is not a matching parentheses then the expr is not valid. Finally after the input string is scanned, the stack has to be empty else expr is invalid. On Fri, Jun 11, 2010 at 11:09 AM, BALARUKESH sbalarukesh1...@gmail.comwrote: The increment and decrement method wont work correctly for all cases Ex:- ))a+b(( This is not a well formed parenthesis... But satisfies the algorithm. The better way is to use a stack... When u find a ' ( ' push it into the stack and when u find a ' )' pop off the top element. Finally the stack should be empty. If [stack has one or more ' ( ' ] or [the stack is empty and exp is not empty] then it is not a well formed parenthesis... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: os
So can we say that a mutex is a binary semaphore. On Thu, Jun 10, 2010 at 11:26 PM, souravsain souravs...@gmail.com wrote: Originally semaphore is a concept given by Dijkstra who says it is something that can have two operations P and V both atomic. In an OS (for example Unix) we have kernal objects called semaphore which have the same two atomic oprerations. It is used to control communication between 2 things (it can be 2 thread, 2 processes) as you have rightly mentioned. You can 'wait' for a semaphore. Someone else (thread/process) can broadcast a message that it has freed a semaphore. So emphasis is on communication. Mutex is more for controlling access to some resource. I do not know how many threads will access an object, say a linked list. What I only know is that the linked list should not be manipulated simultaneously by 2 or more threads. So my focus is on makeing sure than the shared object 'linked list' is in good shape. So a Mutex is in itself an object which sort of guards the resoure. So the mutex says If a thread wants to access / change the linked list, first lock me, then do ur changes and unlock me. Having said this, Binary semaphore is one which can change value between 2 states (enerally 1 and 0) and most interestingly, we implement a mutex object by having a binary semaphore inside the Mutex object. class Mutex { private BinSem MySem; lock() { if MySem is 0 then lock or wait } unlock() { if MySem is 1 broadcast all am releasing and release. } } On Jun 10, 8:56 pm, sharad kumar sharad20073...@gmail.com wrote: @sharad but when it is binary semaphore then only one process is accessing the resource,rest all are blockedwhich means that only that process who locked bin. sem will unlock it .plzzz correct me if i m wrong -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Rishi B. Agrawal http://www.linkedin.com/in/rishibagrawal http://code.google.com/p/fscops/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] level order traversal
If a doubly Linked List is made out of this, then there should be kept some mechanism to keep the parent pointer in it and update it while creating and then we can proceed in similar approach as my array solution above. Anurag Sharma On Thu, Jun 10, 2010 at 7:09 PM, sharad kumar sharad20073...@gmail.comwrote: @ anurag we dont hve parent poiner hey can we do this problem by converting this to doubly link list and printing it plzzz comment -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: infix
@Rohit Consider : (a+)b The above is not well formed! :) On 11 June 2010 11:58, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @BALARUKESH : What are you saying !! and Why would this not work As you start you get sum -1 at start itself. Hence you quit. The sum should be 0 always and 0 at last -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Fri, Jun 11, 2010 at 11:09 AM, BALARUKESH sbalarukesh1...@gmail.comwrote: The increment and decrement method wont work correctly for all cases Ex:- ))a+b(( This is not a well formed parenthesis... But satisfies the algorithm. The better way is to use a stack... When u find a ' ( ' push it into the stack and when u find a ' )' pop off the top element. Finally the stack should be empty. If [stack has one or more ' ( ' ] or [the stack is empty and exp is not empty] then it is not a well formed parenthesis... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Reduce, Reuse and Recycle Regards, Vivek.S -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c output
It will be c 1 6 2 6 and 2 because of newline On Fri, Jun 11, 2010 at 9:26 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: c 1 6,2 u might be expecting 5,1 if u are forgetting the newline character :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Print large Fibonacci numbers
How to print very large Fibonacci numbers eg fib(1000). My approach: When any one of fib(i-1) or fib(i-2) has more than 12 or 13 digits, partition them into groups of 4 digits and put them in a linked list. fib(i-1) is put in list1, fib(i-2) in list2. Perform the addition of these long numbers and overwrite in list2. Now to find next fib list1 is taken as fib(i-2) and list2 as fib(i-1) and this repeats until we approach the given number and finally the result is in list2. As the number of digits goes on increasing, the list is constructed dynamically. If anyone has an efficient approach pls tell me. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] isomorphic trees
@Harish, it does. @Divya, r we not on the same page. On Thu, Jun 10, 2010 at 10:20 AM, Harish U harishs...@gmail.com wrote: @Saurabh I believe for Isomorphic trees only the structure counts not the value at each nodes. So i think there is no need to compare the value at the corresponding node positions of the two trees. On Wed, Jun 9, 2010 at 11:15 PM, saurabh gupta sgup...@gmail.com wrote: is-isomorphic(t1, t2) { t1ld = t1-left-data t2ld = t2-left-data //. //base case for null or replace by sentinels and check if( t1ld == t2ld t1rd == t2rd) return is-isomorphic(t1ld, t2ld) return is-isomorphic(t1rd, t2rd) if (t1ld == t2rd t1rd == t2ld) return is-isomorphic(t1ld, t2rd) return is-isomorphic(t1rd, t2ld) return false; } On Wed, Jun 9, 2010 at 8:29 PM, divya jain sweetdivya@gmail.comwrote: @vadivel and anand { 1,2,3 } is *isomorphic* to { 1,3,2 } { 1,2,3,4,5,6,7 } is *isomorphic* to { 1,3,2,7,6,4,5 } { 1,2,3,4,5,6,7 } is NOT *isomorphic* to { 1,3,2,4,5,6,7 } so its nt necessary that right and left will interchange. it may or may not. if all right and left are interchanged then it is mirror tree. i think ur code is for mirror tree and not isomorphic tree.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Man goes to doctor. Says he's depressed. Says life seems harsh and cruel. Says he feels all alone in a threatening world where what lies ahead is vague and uncertain. Doctor says Treatment is simple. Great clown Pagliacci is in town tonight. Go and see him. That should pick you up. Man bursts into tears. Says But, doctor...I am Pagliacci. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Man goes to doctor. Says he's depressed. Says life seems harsh and cruel. Says he feels all alone in a threatening world where what lies ahead is vague and uncertain. Doctor says Treatment is simple. Great clown Pagliacci is in town tonight. Go and see him. That should pick you up. Man bursts into tears. Says But, doctor...I am Pagliacci. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: sleep
@souravsain means that process has slept and asked kernel to wake it only if its resource which it need,it got so at that time can any process interrupt it 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 algoge...@googlegroups.com. To unsubscribe from 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] sum to x
Given a large file, having N (N is very large) positive integers, how will you find a pair of numbers that add up to x (eg. 100). What data structure will you use and give appropriate Algo/code. It should be efficient in time and space. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: identify the recurring part for a given decimal no
it will work as the number after the decimal digit is recurring as in this case 3456 is recurring that is the the number is not just 23.34563456, its 23.3456345634563456.. so after subtraction it will give zero as the decimal part. On Thu, Jun 10, 2010 at 8:55 AM, Veer Sharma thisisv...@rediffmail.comwrote: Seems it wont work... x=23.34563456 temp = x*100 -x = 233.4563456 - 23.34563456 = 210.11071104 temp = x*100 -x = 2334.563456 - 23.34563456 = 2311.21782144 temp = x*1000 -x = 23345.63456 - 23.34563456 = 23322.28892544 temp = x*1 -x = 233456.3456 - 23.34563456 = 233432.6544 temp = x*10 -x = 2334563.456 - 23.34563456 = 2334540.11036544 ... On Jun 9, 11:24 pm, Anurag Sharma anuragvic...@gmail.com wrote: multiply the original number x=23.34563456 Anurag Sharma On Wed, Jun 9, 2010 at 10:36 PM, Veer Sharma thisisv...@rediffmail.com wrote: One question: No x = 23.34563456 temp = x X 10 = 233.4563456 temp = temp - x = 210.11071104 decimal part zero? No. Now multiply the no. with 100. Which no? original x (= 23.34563456) or new no. temp (=210.11071104)? On Jun 9, 8:12 pm, divya jain sweetdivya@gmail.com wrote: multiply the no. with 10 nd store in temp. now subtract no from temp. check if the decimal part is zero if yes. then 1st digit after decimal is recurring. if no. multiply the no with 100 and repeat . if this time decimal part is zero then 2 digits after decimal r recurring nd so on.. On 8 June 2010 21:45, Veer Sharma thisisv...@rediffmail.com wrote: You have a Numerator and Denominator. After division you might get a recurring decimal points float as the answer. Problem is: You need to identify the recurring part for a given decimal no? For example 23.34563456 ... return 3456 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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:
No need to enumerate all possible states. In the final state (2,8,5), each jug is neither full nor empty, while every valid operation has to fill or empty one jug. So it is not possible to get this state from any other state by one valid operation. (As others said, the state before the final one does not exist) On 2010-6-10 0:35, Dave wrote: Assuming that the only moves you can make are to pour the contents of one jug into another until either the source is empty or the destination is full, the following are the only positions possible: 0: initial position (15,0,0) 1: starting from 0, pour 10 from jug 1 to jug 2, getting (5,10,0) 2: starting from 0, pour 6 from jug 1 to jug 3, getting (9,0,6) 3: starting from 1, pour 5 from jug 1 to jug 3, getting (0,10,5) 4: starting from 1, pour 6 from jug 2 to jug 3, getting (5,4,6) 5: starting from 2, pour 9 from jug 1 to jug 2, getting (0,9,6) 6: starting from 2, pour 6 from jug 3 to jug 2, getting (9,6,0) 7: starting from 3, pour 10 from jug 2 to jug 1, getting (10,0,5) 8: starting from 4, pour 6 from jug 3 to jug 1, getting (11,4,0) 9: starting from 5, pour 6 from jug 3 to jug 1, getting (6,9,0) 10: starting from 6, pour 6 from jug 1 to jug 3, getting (3,6,6) 11: starting from 7, pour 5 from jug 3 to jug 2, getting (10,5,0) 12: starting from 8, pour 4 from jug 2 to jug 3, getting (11,0,4) 13: starting from 9, pour 6 from jug 2 to jug 3, getting (6,3,6) 14: starting from 10, pour 4 from jug 3 to jug 2, getting (3,10,2) 15: starting from 11, pour 6 from jug 1 to jug 3, getting (4,5,6) 16: starting from 12, pour 10 from jug 1 to jug 2, getting (1,10,4) 17: starting from 13, pour 6 from jug 3 to jug 1, getting (12,3,0) 18: starting from 14, pour 10 from jug 2 to jug 1, getting (13,0,2) 19: starting from 15, pour 5 from jug 3 to jug 2, getting (4,10,1) 20: starting from 16, pour 2 from jug 2 to jug 3, getting (1,8,6) 21: starting from 17, pour 3 from jug 2 to jug 3, getting (12,0,3) 22: starting from 18, pour 2 from jug 3 to jug 2, getting (13,2,0) 23: starting from 19, pour 10 from jug 2 to jug 1, getting (14,0,1) 24: starting from 20, pour 6 from jug 3 to jug 1, getting (7,8,0) 25: starting from 21, pour 10 from jug 1 to jug 2, getting (2,10,3) 26: starting from 22, pour 6 from jug 1 to jug 3, getting (7,2,6) 27: starting from 23, pour 1 from jug 3 to jug 2, getting (14,1,0) 28: starting from 25, pour 3 from jug 2 to jug 3, getting (2,7,6) 29: starting from 27, pour 6 from jug 1 to jug 3, getting (8,1,6) 30: starting from 28, pour 6 from jug 3 to jug 1, getting (8,7,0) Since {2,8,5) doesn't appear on the list, the puzzle has no solution. Dave On Jun 7, 3:32 am, sharadsharad20073...@gmail.com wrote: : Three containers are of 15,10 and 6 ltrs capacity. Initially its in configuration (15,0,0). Make it to configuration (2,8,5) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c output
Explanation: The prototype for printf as per ANSI C is: *int printf( const char *format,…)* the return value is integer and returns the number of characters successfully read by printf. Also,in case of printf(),the evaluation of expressions passed on as arguments is done from right to left on stack and then printed from left to right by popping the stack. So,the output comes as: c :Evaluation of printf(%c\n,b).Note that after execution,they return the number of characters read. 1: Evaluation of printf(%d\n,a) 6,2 :No of characters read printed from left to right as printf now is: printf(%d %d,6,2); @Divya:Good question for clearing concepts related to printf.May i know the source? On Fri, Jun 11, 2010 at 9:26 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: c 1 6,2 u might be expecting 5,1 if u are forgetting the newline character :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- ASHISH KUMAR JAIN Engineer,P T CIENA,Gurgaon Contacts: Phone:- +919899668402 e-mail: ashish.jain.cs...@itbhu.ac.in akjlucky4...@gmail.com asj...@ciena.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] stack
Give an algorithm to implement n stacks in an array... take care of the empty space too i.e no overflow shld occur if there is eny empty space left . -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: binary nos
@Rohit Saraf i understood the question. Superb solution by u. On Thu, Jun 10, 2010 at 8:59 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: write an efficient algo to compute no. of sequences of n binary digits that do not contain 2 1's in a row. eg 111 is invalid whereas 1001001 is valid. HERE the number of sequences comes to be a fibonacci number , precisely fib(n+2). So this prob is equivalent to finding fibonacci numbers -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Thu, Jun 10, 2010 at 11:47 AM, Sundeep Singh singh.sund...@gmail.comwrote: @rohit: fibonacci sequence may be the answer to the prob, but I am curious why? I haven't come across any such fib sequence property... On Wed, Jun 9, 2010 at 9:16 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: @junta : are fibonacci sequence is the answer of the prob, it is not used :D -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Wed, Jun 9, 2010 at 9:13 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @debajyoti: read the prob before posting -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Wed, Jun 9, 2010 at 2:37 PM, Debajyoti Sarma sarma.debajy...@gmail.com wrote: First 20 fibo no as follows with binary form 0 = 0 1 = 1 1 = 1 2 = 10 3 = 11 5 = 101 8 = 1000 13 = 1101 21 = 10101 34 = 100010 55 = 110111 89 = 1011001 144 = 1001 233 = 11101001 377 = 10001 610 = 1001100010 987 = 011011 1597 = 1100001 2584 = 10111000 4181 = 101010101 Now please explain how fibo no is coming under consideration.Both kind of no is mixed here. On Wed, Jun 9, 2010 at 8:02 AM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: Fib comes because she wants the number of such sequences -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: infix
On 2010-6-11 13:39, BALARUKESH wrote: The increment and decrement method wont work correctly for all cases Ex:- ))a+b(( It works. In this example, the first ')' lead to -1 which indicate the expression is not well formed. This is not a well formed parenthesis... But satisfies the algorithm. The better way is to use a stack... When u find a ' ( ' push it into the stack and when u find a ' )' pop off the top element. Finally the stack should be empty. If [stack has one or more ' ( ' ] or [the stack is empty and exp is not empty] then it is not a well formed parenthesis... The later condition [the stack is empty and exp is not empty] does not necessary lead to ill formed parenthesis. Ex: (a+b)*(c+d). To solve this, you can 1) add an additional pair of parenthesis around the whole expression or 2) change the condition to [the stack is empty and ')' is the next element of the expression] Actually, the increment and decrement method is maintaining the stack size, checking 1) no stack underflow, and 2) stack is empty at the end. So the two method is equivalent. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] Common elements in 2 circular linked lists
Given a circular linked list, what is the most efficient way of constructing a new list which contains the common elements between the 2 given lists. Is it sorting and then comparing ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] concatenation of 2 circular linked lists
Hi, I came across this statement that using circular lists, concatenation can be done without traversing either list. The same case with freeing the entire list. Can someone elaborate on this ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: infix
@balarukesh thanks On Fri, Jun 11, 2010 at 11:58 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: @BALARUKESH : What are you saying !! and Why would this not work As you start you get sum -1 at start itself. Hence you quit. The sum should be 0 always and 0 at last -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Fri, Jun 11, 2010 at 11:09 AM, BALARUKESH sbalarukesh1...@gmail.comwrote: The increment and decrement method wont work correctly for all cases Ex:- ))a+b(( This is not a well formed parenthesis... But satisfies the algorithm. The better way is to use a stack... When u find a ' ( ' push it into the stack and when u find a ' )' pop off the top element. Finally the stack should be empty. If [stack has one or more ' ( ' ] or [the stack is empty and exp is not empty] then it is not a well formed parenthesis... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: ds
excellent soln!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] max sum
Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. Eg. i) 3 2 7 10 should return 13 (sum of 3 and 10) ii) 3 2 5 10 7 should return 15 (sum of 3, 5 and 7) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] level order traversal
from inorder traversal i ll make doubly link list then print it.is it correct approach -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] level order traversal
@jitendra ur approach is good but o(nlogn) where as o(n) is possible -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] Derivation
Yeah got it !! I know, its simple. Dunno what I didn't get it when I posted :-) On Fri, Jun 11, 2010 at 9:26 AM, Anurag Sharma anuragvic...@gmail.comwrote: well the solution is pretty straight forward. let the distance between stations be 'd' and speed of trains starting at A and B (lets call them X and Y) be 'u' and 'v' resp. A-B (X) u- -v(Y)at t=0 (X)|(Y) meet each other at t= d/(u+v) So distance left to cover for X = dv/(u+v) and distance left to cover for Y= du/(u+v) time X will take to cover this distance= dv/(u*(u+v)) = a time Y will take to cover this distance= du/(v*(u+v)) = b = a : b = v^2 : u^2 = u : v = b^1/2 : a^1/2 hope its clear Anurag Sharma On Thu, Jun 10, 2010 at 11:05 PM, Raj N rajn...@gmail.com wrote: Can someone help me deriving this ? If 2 trains start at the same time from points A and B towards each other and after crossing they take a and b sec in reaching B and A respectively, then A's speed:B's speed=b^1/2:a^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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] sum to 0
Given three lists: A, B and C of length n each. Write a function which returns true if any 3 three numbers (1 from each list), sum up to zero. Else return false, if there is no such combination. both o(n2)+o(n)space and o(n2logn)+o(1)space are trivial but can we optimise more -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] Common elements in 2 circular linked lists
Ya that will do.. Anurag Sharma On Fri, Jun 11, 2010 at 7:08 PM, Raj N rajn...@gmail.com wrote: Given a circular linked list, what is the most efficient way of constructing a new list which contains the common elements between the 2 given lists. Is it sorting and then comparing ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: c output
@kirubakaran: How can it be 1,1 ? No of characters read in a is 5+ 1 for '\n' so its 6 and for the next one 1+1=2 On Fri, Jun 11, 2010 at 9:09 AM, kirubakaran kirubakaran1...@gmail.comwrote: Output will be 1,1 bcoz printf returns number of characters or integers printed On Jun 11, 12:26 am, divya sweetdivya@gmail.com wrote: #include stdio.h main() { int a = 1; char b='c'; int i,j; printf(%d,%d,printf(%d\n,a),printf(%c\n,b)); wat shd b the o/p of this..plzz explain y? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] stack
Is it without having the need to shift elements at all? Anurag Sharma On Fri, Jun 11, 2010 at 3:41 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: Give an algorithm to implement n stacks in an array... take care of the empty space too i.e no overflow shld occur if there is eny empty space left . -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] stack
@jalaj: This question has already been discussed for n=2,3 On Fri, Jun 11, 2010 at 4:11 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: Give an algorithm to implement n stacks in an array... take care of the empty space too i.e no overflow shld occur if there is eny empty space left . -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] concatenation of 2 circular linked lists
Concatenation of two lists without traversing even one of the lists completely requires a pointer to the last element of the first list (first, as in the one that is to be attached in front of the other list). This is only possible if either, there's a *last *pointer for the lists, or the list is a double-linked list (besides being a circular list) where each node stores pointers to both the previous and the next nodes. Concatenation in a doubly-linked circular list is a simple exchange of pointers as illustrated below list Concat(list1, list2) { last1 = list1.head.prev last2 = list2.head.prev last1.next = list2.head last2.next = list1.head list1.head.prev = last2 list2.head.prev = last1 return list1 } Depending upon your implementation, there would have to be checks for NULL pointers. Also, one may use pointer swapping to achieve the effect in, for example, a C implementation. Freeing up a list on the other hand requires a full traversal, no matter what kind of list it is. That's because each node was allocated separately (that would be the whole point of having a dynamically created list). thanks, mayur On Fri, Jun 11, 2010 at 1:23 PM, Raj N rajn...@gmail.com wrote: Hi, I came across this statement that using circular lists, concatenation can be done without traversing either list. The same case with freeing the entire list. Can someone elaborate on this ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] sum to x
@sharad: Does it have to return the first pair or all possible pairs ? On Fri, Jun 11, 2010 at 6:56 PM, sharad sharad20073...@gmail.com wrote: Given a large file, having N (N is very large) positive integers, how will you find a pair of numbers that add up to x (eg. 100). What data structure will you use and give appropriate Algo/code. It should be efficient in time and space. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: binary nos
A more theoretical answer to the question can be the following: Let's try to construct a tree for all such possible sequences. Level 0 = 0 or 1 Level 1 = 01 0 Level 2 =0 1 0 01 Level 3 = 0 1 0 0 1 0 10 Simple observation will tell you that for every 0 in a position, the next position can have either 0 or 1, but for a 1 in the position, the next bit *has *to be a 0. -- (1) Let us call the function N0(p) to be the number of 0s at level (position) p in the sequence; N1(p) to be the number of 1s at level p. The total number of nodes at level p is then N(p) = N0(p) + N1(p). It is also clear from statement (1) that N0(p) = N0(p-1) + N1(p-1)--- (2) and N1(p) = N0(p-1)-- (3) i.e. the number of 0s in the next level equal to the number of 0s in the previous level plus the number of 1s in the previous level, whereas the number of 1s is equal to the number of 0s in the previous level. Thus, combining (2) and (3), we have... N(p) = N0(p-1) + N1(p-1) + N0(p-1) --- (4) Now, N0(p-1) + N1(p-1) is really N(p-1) - i.e. the total number of possible sequences of length p. Also, N0(p-1) = N0(p-2) + N1(p-2) = N(p-2) from (2) Therefore, (4) reduces to N(p) = N(p-1) + N(p-2) The above, you would recognize as the generative recursive form of the sequence of fibonacci numbers. thanks, mayur On Fri, Jun 11, 2010 at 2:05 PM, Debajyoti Sarma sarma.debajy...@gmail.comwrote: clarification to all n=1 0,1 no of sequence =2 n=2 00,01,10 no of sequence =3 n=3 000,100,010,001,101 no of sequence =5 n=4 ,1000,0100,0010,0001,1010,0101,1001 no of sequence =8 n=5 0,1,01000,00100,00010,1,10100,10010,10001,01010,01001,00101,10101 no of sequence =13 so its coming in fibo no. no of sequence =fibo(n+2)if you exclude 0 from fibo no no of sequence =fibo(n+3)if you include 0 in fibo no On Fri, Jun 11, 2010 at 1:55 PM, Debajyoti Sarma sarma.debajy...@gmail.com wrote: @Rohit Saraf i understood the question. Superb solution by u. On Thu, Jun 10, 2010 at 8:59 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: write an efficient algo to compute no. of sequences of n binary digits that do not contain 2 1's in a row. eg 111 is invalid whereas 1001001 is valid. HERE the number of sequences comes to be a fibonacci number , precisely fib(n+2). So this prob is equivalent to finding fibonacci numbers -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Thu, Jun 10, 2010 at 11:47 AM, Sundeep Singh singh.sund...@gmail.com wrote: @rohit: fibonacci sequence may be the answer to the prob, but I am curious why? I haven't come across any such fib sequence property... On Wed, Jun 9, 2010 at 9:16 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @junta : are fibonacci sequence is the answer of the prob, it is not used :D -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Wed, Jun 9, 2010 at 9:13 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @debajyoti: read the prob before posting -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Wed, Jun 9, 2010 at 2:37 PM, Debajyoti Sarma sarma.debajy...@gmail.com wrote: First 20 fibo no as follows with binary form 0 = 0 1 = 1 1 = 1 2 = 10 3 = 11 5 = 101 8 = 1000 13 = 1101 21 = 10101 34 = 100010 55 = 110111 89 = 1011001 144 = 1001 233 = 11101001 377 = 10001 610 = 1001100010 987 = 011011 1597 = 1100001 2584 = 10111000 4181 = 101010101 Now please explain how fibo no is coming under consideration.Both kind of no is mixed here. On Wed, Jun 9, 2010 at 8:02 AM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: Fib comes because she wants the number of such sequences -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group
Re: [algogeeks] Re: binary nos
Oh! Forgot to mention that the count of the leaves of the tree, gives the number of possible sequences (as required to be determined by the question) On Fri, Jun 11, 2010 at 10:02 PM, Mayur mayurhem...@gmail.com wrote: A more theoretical answer to the question can be the following: Let's try to construct a tree for all such possible sequences. Level 0 = 0 or 1 Level 1 = 01 0 Level 2 =0 1 0 01 Level 3 = 0 1 0 0 1 0 10 Simple observation will tell you that for every 0 in a position, the next position can have either 0 or 1, but for a 1 in the position, the next bit *has *to be a 0. -- (1) Let us call the function N0(p) to be the number of 0s at level (position) p in the sequence; N1(p) to be the number of 1s at level p. The total number of nodes at level p is then N(p) = N0(p) + N1(p). It is also clear from statement (1) that N0(p) = N0(p-1) + N1(p-1)--- (2) and N1(p) = N0(p-1)-- (3) i.e. the number of 0s in the next level equal to the number of 0s in the previous level plus the number of 1s in the previous level, whereas the number of 1s is equal to the number of 0s in the previous level. Thus, combining (2) and (3), we have... N(p) = N0(p-1) + N1(p-1) + N0(p-1) --- (4) Now, N0(p-1) + N1(p-1) is really N(p-1) - i.e. the total number of possible sequences of length p. Also, N0(p-1) = N0(p-2) + N1(p-2) = N(p-2) from (2) Therefore, (4) reduces to N(p) = N(p-1) + N(p-2) The above, you would recognize as the generative recursive form of the sequence of fibonacci numbers. thanks, mayur On Fri, Jun 11, 2010 at 2:05 PM, Debajyoti Sarma sarma.debajy...@gmail.com wrote: clarification to all n=1 0,1 no of sequence =2 n=2 00,01,10 no of sequence =3 n=3 000,100,010,001,101 no of sequence =5 n=4 ,1000,0100,0010,0001,1010,0101,1001 no of sequence =8 n=5 0,1,01000,00100,00010,1,10100,10010,10001,01010,01001,00101,10101 no of sequence =13 so its coming in fibo no. no of sequence =fibo(n+2)if you exclude 0 from fibo no no of sequence =fibo(n+3)if you include 0 in fibo no On Fri, Jun 11, 2010 at 1:55 PM, Debajyoti Sarma sarma.debajy...@gmail.com wrote: @Rohit Saraf i understood the question. Superb solution by u. On Thu, Jun 10, 2010 at 8:59 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: write an efficient algo to compute no. of sequences of n binary digits that do not contain 2 1's in a row. eg 111 is invalid whereas 1001001 is valid. HERE the number of sequences comes to be a fibonacci number , precisely fib(n+2). So this prob is equivalent to finding fibonacci numbers -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Thu, Jun 10, 2010 at 11:47 AM, Sundeep Singh singh.sund...@gmail.com wrote: @rohit: fibonacci sequence may be the answer to the prob, but I am curious why? I haven't come across any such fib sequence property... On Wed, Jun 9, 2010 at 9:16 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @junta : are fibonacci sequence is the answer of the prob, it is not used :D -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Wed, Jun 9, 2010 at 9:13 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @debajyoti: read the prob before posting -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Wed, Jun 9, 2010 at 2:37 PM, Debajyoti Sarma sarma.debajy...@gmail.com wrote: First 20 fibo no as follows with binary form 0 = 0 1 = 1 1 = 1 2 = 10 3 = 11 5 = 101 8 = 1000 13 = 1101 21 = 10101 34 = 100010 55 = 110111 89 = 1011001 144 = 1001 233 = 11101001 377 = 10001 610 = 1001100010 987 = 011011 1597 = 1100001 2584 = 10111000 4181 = 101010101 Now please explain how fibo no is coming under consideration.Both kind of no is mixed here. On Wed, Jun 9, 2010 at 8:02 AM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: Fib comes because she wants the number of such sequences -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 -- You received this message because you are subscribed to the Google
Re: [algogeeks] Re: infix
@vivek: read again: ) = -1 ( = +1 Keep a sum of all these as u iterate. That should never be negative Plus check for these types (if you need correct arithmetic expressions as well *some operator followed by )* * or / after a ( () -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Fri, Jun 11, 2010 at 12:07 PM, Vivek Sundararajan s.vivek.ra...@gmail.com wrote: @Rohit Consider : (a+)b The above is not well formed! :) On 11 June 2010 11:58, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @BALARUKESH : What are you saying !! and Why would this not work As you start you get sum -1 at start itself. Hence you quit. The sum should be 0 always and 0 at last -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Fri, Jun 11, 2010 at 11:09 AM, BALARUKESH sbalarukesh1...@gmail.comwrote: The increment and decrement method wont work correctly for all cases Ex:- ))a+b(( This is not a well formed parenthesis... But satisfies the algorithm. The better way is to use a stack... When u find a ' ( ' push it into the stack and when u find a ' )' pop off the top element. Finally the stack should be empty. If [stack has one or more ' ( ' ] or [the stack is empty and exp is not empty] then it is not a well formed parenthesis... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Reduce, Reuse and Recycle Regards, Vivek.S -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Print large Fibonacci numbers
Fibonacci numbers can be calculated very efficiently using matrix multiplications. I hope you can think it/google it now.. that is better than me writing so much again :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Fri, Jun 11, 2010 at 8:12 PM, Raj N rajn...@gmail.com wrote: How to print very large Fibonacci numbers eg fib(1000). My approach: When any one of fib(i-1) or fib(i-2) has more than 12 or 13 digits, partition them into groups of 4 digits and put them in a linked list. fib(i-1) is put in list1, fib(i-2) in list2. Perform the addition of these long numbers and overwrite in list2. Now to find next fib list1 is taken as fib(i-2) and list2 as fib(i-1) and this repeats until we approach the given number and finally the result is in list2. As the number of digits goes on increasing, the list is constructed dynamically. If anyone has an efficient approach pls tell me. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: concatenation of 2 circular linked lists
Break the link between the first and second items in each list. Link the first item in the first list to the second item in the second list, and link the first item in the second list to the first item in the first list. The traversal is from the first item of the first list, through the second list, starting with the second item and ending with the first item, and then through the remainder of the first list starting at the second item and ending with the first item (if it is correct to say that you end traversing a circular list). Dave On Jun 11, 2:53 am, Raj N rajn...@gmail.com wrote: Hi, I came across this statement that using circular lists, concatenation can be done without traversing either list. The same case with freeing the entire list. Can someone elaborate on this ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: infix
I missed out the condition that it should never be negative... Sorry for the comment... Thanks for correcting... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: max sum
I hope using a backtracking solution suits the problem well... maxsum( int arr[] , int n,int i,int sum, int last) { if(in) { int s1= 0,s2= 0,s3; if(last ==i-1) { s1=maxsum(arr,n,i+2,sum,last); } else { s2= maxsum(arr,n,i+1,sum+arr[i],i); s3=maxsum(arr,n,i+2,sum,last); s2= s2s3? s2 : s3 ; } s1= s1s2? s1: s2; return s1; } return sum; } invoke the function initially as max= maxsum(arr,n,-2, 0, 0); Hope the program works... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: Common elements in 2 circular linked lists
I hope u can do better... try this.. use a hash table and try inserting all elements of 1st list and then insert the elements of second list. if u find an element already existing when u insert from second list then add it to a new list. the new list has the common elements... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: max sum
int FindMaxSum(int array[],int i) { if(iSize) //Size is array size, considered as global variable in my solution return 0; int Sum1 = FindMaxSum(array,i+2);//cannot chose i+1 as that will make it adjacent int Sum2 = FindMaxSum(array,i+3);//at any place I cannot chose i +1, so I chose i+2 above //But chosing i+2 will mean cannot chose i+3 and I will miss that route. So again call //FindMaxSum with i+3; if(Sum1Sum2) return Sum1+array[i]; else return Sum2+array[i]; } This FindMaxSum must be called by some function like F() { int Sum1 = FindMaxSum(array,0);//0 = first element of array int Sum2 = FindMaxSum(array,1); //Larger of Sum1 and Sum2 will be the answer. } This is a brute force approach and many calculations are done repetedly. Dynamic Programing will improve the performance. On Jun 11, 8:41 pm, divya sweetdivya@gmail.com wrote: Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. Eg. i) 3 2 7 10 should return 13 (sum of 3 and 10) ii) 3 2 5 10 7 should return 15 (sum of 3, 5 and 7) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] level order traversal
@Anurag: Check your approach for non balanced tree alsoeg take 8 nodes and try. -- Regards Jitendra Kushwaha MNNIT, Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] sum to x
trivial solution will be exponential where we check for each selection nC1+nC2...nCn = 2^n we can optimise time by taking some memory. It can be solved by subset sum where we will require extra memory of maximum sum possible. refer this link for subset sum problem: http://en.wikipedia.org/wiki/Subset_sum_problem -- Regards Jitendra Kushwaha MNNIT, Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] stack
@raj n for 2 stacks its fine can you please tell for 3 stacks ...i'll generalize it On Fri, Jun 11, 2010 at 9:32 PM, Anurag Sharma anuragvic...@gmail.comwrote: Is it without having the need to shift elements at all? Anurag Sharma On Fri, Jun 11, 2010 at 3:41 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: Give an algorithm to implement n stacks in an array... take care of the empty space too i.e no overflow shld occur if there is eny empty space left . -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] max sum
this can done by dyanamic programming At every point keep the maximum sum including the current element and excluding the current element At last the maimum will be max of both the maximum pseudo code : max1 = max2 = 0 for i in 1 to n temp = max2 max1 = MAX(max1, max2+array[i]) max2 = MAX(temp,max1) final_max = MAX(max1,max2) -- Regards Jitendra Kushwaha MNNIT, Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] sum to x
I think we can use a Linked List. Sort it and then find numbers adding upto x. On Fri, Jun 11, 2010 at 9:39 PM, Raj N rajn...@gmail.com wrote: @sharad: Does it have to return the first pair or all possible pairs ? On Fri, Jun 11, 2010 at 6:56 PM, sharad sharad20073...@gmail.com wrote: Given a large file, having N (N is very large) positive integers, how will you find a pair of numbers that add up to x (eg. 100). What data structure will you use and give appropriate Algo/code. It should be efficient in time and space. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] sum to x
all possible pairs -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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 Problem
given an array A of n elements. for indexes j , i such that ji maximize( j - i ) such that A[j] - A [ i ] 0 . Any Algorithm less than O(n^2) would do. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: max sum
this can be done easily using dynamic programming: dp[i] = a[i] + max( dp[i+2], dp[i+3], dp[i+4] , ... ) for (i=n-1 ; i=0 ; i--) { max=0; for (j=i+2 ; jn ;j++) if (dp[j]max) max=dp[j]; dp[i]=a[i]+max; } On 6/11/10, BALARUKESH sbalarukesh1...@gmail.com wrote: I hope using a backtracking solution suits the problem well... maxsum( int arr[] , int n,int i,int sum, int last) { if(in) { int s1= 0,s2= 0,s3; if(last ==i-1) { s1=maxsum(arr,n,i+2,sum,last); } else { s2= maxsum(arr,n,i+1,sum+arr[i],i); s3=maxsum(arr,n,i+2,sum,last); s2= s2s3? s2 : s3 ; } s1= s1s2? s1: s2; return s1; } return sum; } invoke the function initially as max= maxsum(arr,n,-2, 0, 0); Hope the program works... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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 algoge...@googlegroups.com. To unsubscribe from 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] max sum
See http://geeksforgeeks.org/?p=3133 for solution. On Fri, Jun 11, 2010 at 8:41 AM, divya sweetdivya@gmail.com wrote: Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. Eg. i) 3 2 7 10 should return 13 (sum of 3 and 10) ii) 3 2 5 10 7 should return 15 (sum of 3, 5 and 7) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: concatenation of 2 circular linked lists
Agree with the above two. I don't think you can free the entire list without traversing it.You can free an element that you have a reference of. How can you free an entire list with reference to just one element? You'll need the other references. And if you get the other references that means you are traversing the list (indirectly, but you are). On Jun 11, 12:53 am, Raj N rajn...@gmail.com wrote: Hi, I came across this statement that using circular lists, concatenation can be done without traversing either list. The same case with freeing the entire list. Can someone elaborate on this ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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 Increment Problem
Array Increment Problem Given an array A consisting of 'n' elements. Do the following both operations in O(log n) time using a data structure. Increment (A,i,j,x) : This should increment elements from A to A[j] by value x . Report(A,j) : This should report A[j] Trivially in an array Increment takes O(j-i) time and report takes O(1) . Now we need to store in a data structure (can be augmented) such that both operations takes O (log n) time. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] Mirroring Binary Tree Pattern Problem
Good Evening to Algo_Geeks, I am a newbie regarding the Algo Analysis. I was asked this question recently in an interview. Please let me know if anyone of you know how to solve this. *Question:* Assume You have a binary Tree (not sorted and not BST) with a specific pattern on a Desktop1. How can this same binary Tree has be to mirrored to another desktop? *My Approach:* 1. Traverse the binary tree and store the elements in an array. Transfer the same to another process present on another desktop through socket communication. But in this case how do i construct the same binary tree at the other end? Do i read in one of the in-order/post-order/pre-order and do it the same way at the other end? 2. Does this involve Virtualization concept? Regards, Vikas J -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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: concatenation of 2 circular linked lists
@Dave: What do you say about freeing the circular list without traversing it. On Fri, Jun 11, 2010 at 10:36 PM, Dave dave_and_da...@juno.com wrote: Break the link between the first and second items in each list. Link the first item in the first list to the second item in the second list, and link the first item in the second list to the first item in the first list. The traversal is from the first item of the first list, through the second list, starting with the second item and ending with the first item, and then through the remainder of the first list starting at the second item and ending with the first item (if it is correct to say that you end traversing a circular list). Dave On Jun 11, 2:53 am, Raj N rajn...@gmail.com wrote: Hi, I came across this statement that using circular lists, concatenation can be done without traversing either list. The same case with freeing the entire list. Can someone elaborate on this ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Common elements in 2 circular linked lists
@Anurag: Any other efficient way you can think of ? On Fri, Jun 11, 2010 at 9:30 PM, Anurag Sharma anuragvic...@gmail.comwrote: Ya that will do.. Anurag Sharma On Fri, Jun 11, 2010 at 7:08 PM, Raj N rajn...@gmail.com wrote: Given a circular linked list, what is the most efficient way of constructing a new list which contains the common elements between the 2 given lists. Is it sorting and then comparing ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] Print large Fibonacci numbers
Ya thanks !! On Fri, Jun 11, 2010 at 10:31 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: Fibonacci numbers can be calculated very efficiently using matrix multiplications. I hope you can think it/google it now.. that is better than me writing so much again :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Fri, Jun 11, 2010 at 8:12 PM, Raj N rajn...@gmail.com wrote: How to print very large Fibonacci numbers eg fib(1000). My approach: When any one of fib(i-1) or fib(i-2) has more than 12 or 13 digits, partition them into groups of 4 digits and put them in a linked list. fib(i-1) is put in list1, fib(i-2) in list2. Perform the addition of these long numbers and overwrite in list2. Now to find next fib list1 is taken as fib(i-2) and list2 as fib(i-1) and this repeats until we approach the given number and finally the result is in list2. As the number of digits goes on increasing, the list is constructed dynamically. If anyone has an efficient approach pls tell me. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] level order traversal
@antony can u do an inverted dfs with bactracking? On Wed, Jun 9, 2010 at 11:45 PM, Antony Vincent Pandian.S. sant...@gmail.com wrote: Thanks Sharad On Wed, Jun 9, 2010 at 10:01 PM, sharad kumar sharad20073...@gmail.comwrote: 1 /\ 2 3 / \/ \ 45 67 print 4 2156 37 a set of vertical line 4m left u draw then on each line whatever no comes write it -- Luv, S.Antony Vincent Pandian -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Luv, S.Antony Vincent Pandian -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- yezhu malai vaasa venkataramana Govinda Govinda -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] sum to x
I guess it can be done in efficiently using a simple divide and conquer scheme almost imitating mergesort. Can you think of it now? :D -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Fri, Jun 11, 2010 at 10:07 PM, sharad kumar sharad20073...@gmail.comwrote: all possible pairs -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.