Re: [algogeeks] Re: binary nos

2010-06-09 Thread jaladhi dave
hmmm ... Atleast I was of the opinion that such nos. were required and hence
was thinking fib is not the thing. Thanks for clarifying.

On Wed, Jun 9, 2010 at 8:02 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote:

 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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] hashing

2010-06-09 Thread sharad
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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: binary nos

2010-06-09 Thread Sundeep Singh
Whats the logic behind using Fibonacci in determining the number of such
sequences?

-Sundeep.


On Wed, Jun 9, 2010 at 8:02 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote:

 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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] level order traversal

2010-06-09 Thread sharad
can any one tell me how to code for vertical level traversal of a
binary tree?


  1
/\
   2  3
 /   \/  \
45  67


print

4   2156   37

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

2010-06-09 Thread Jitendra Kushwaha
here is a sel explainatory algo

given:

abcd1234
abc1d234
ab1c2d34
a1b2c3d4

here is the link for the code : http://codepad.org/SZnufGc6

-- 
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] Re: constraints satisfied?

2010-06-09 Thread jaladhi dave
Using an n*n array, am afraid, will not solve the problem, since its not
capable to capture transitivity.

Consider the case:

v1=v2
v3=v2
v3!=v1

we will place 0 in arr(1,2) arr(2,1) for v1=v2
we will place 0 in arr(2,3) arr(3,2) for v3=v2
and place 1 in arr(1,3) and arr(3,1) for v3!=v1.

no overwrite :( and still the constraints cannot be satisfied.

-jkd



On Tue, Jun 8, 2010 at 10:07 PM, Minotauraus anike...@gmail.com wrote:

 Use a n x n array.
 initialize with -1 (don't care = no constraints). If there is an
 equality constraint, set to 1, if
 explicity non-equality constraint is expected, replace with 0. While
 doing either of these if
 you come across a situation where 0 has to be overwritten by 1 or 1
 has to be overwritten by 0,
 the system constraints cannot be satisfied, else all is well. Space
 required = n^2 bytes.
 Time complexity = O(c) where c= number of constraints for the system.
 Therefore, independent of the number of variables.


 You can do this with hash tables too and probably save memory. Here
 you'll use not store = -1 = don't care.

 -Minotauraus.

 On Jun 7, 12:16 pm, divya sweetdivya@gmail.com wrote:
  Here's a problem that occurs in automatic program analysis. For a set
  of variables x1; .. ; xn, you are given some equality constraints,
  of the form xi = xj and some dis equality constraints, of the form
  xi != xj Is it possible to satisfy all of them? Give an efficient
  algorithm that takes as input m constraints over n variables and
  decides whether the constraints can be satisfied.

 --
 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] Single ordered list

2010-06-09 Thread Raj N
But what if the same same problem is extended for multiple lists. As the
individual lists have already been sorted, is there any efficient way or any
other sorting algo which exploits this fact.

On Tue, Jun 8, 2010 at 10:56 PM, divya jain sweetdivya@gmail.comwrote:

 merging as in merge sort.

 On 8 June 2010 19:59, Raj N rajn...@gmail.com wrote:

 What is the most efficient way of combining 2 separate ordered list
 into a single ordered list ?

 --
 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: binary nos

2010-06-09 Thread Debajyoti Sarma
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.comwrote:

 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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: binary nos

2010-06-09 Thread Rohit Saraf
@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/~rohitfeb14


On Wed, Jun 9, 2010 at 2:37 PM, Debajyoti Sarma
sarma.debajy...@gmail.comwrote:

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

 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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Single ordered list

2010-06-09 Thread Rohit Saraf
I had answered this question(of multiple lists) 2 or three days back.
Go into the archive if u wanna see :P
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Wed, Jun 9, 2010 at 6:52 PM, Raj N rajn...@gmail.com wrote:

 But what if the same same problem is extended for multiple lists. As the
 individual lists have already been sorted, is there any efficient way or any
 other sorting algo which exploits this fact.


 On Tue, Jun 8, 2010 at 10:56 PM, divya jain sweetdivya@gmail.comwrote:

 merging as in merge sort.

 On 8 June 2010 19:59, Raj N rajn...@gmail.com wrote:

 What is the most efficient way of combining 2 separate ordered list
 into a single ordered list ?

 --
 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: binary nos

2010-06-09 Thread Rohit Saraf
@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/~rohitfeb14


On Wed, Jun 9, 2010 at 9:13 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote:

 @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/~rohitfeb14


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

 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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] identify the recurring part for a given decimal no

2010-06-09 Thread divya jain
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
 .
 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] Tower of Hanoi Iterative Solution

2010-06-09 Thread Jitendra Kushwaha
Below iterative solution of the tower of hanoi problem...

#include stdio.h
#include stdlib.h

int main()
{
   int n, x;
   printf( How many disks?  );
   scanf( %d, n );
   printf(\n);
   for (x=1; x  (1  n); x++)
  printf( move from tower %i to tower %i.\n,
 (xx-1)%3, ((x|x-1)+1)%3 );
return 0;
}


i am not able to get how(xx-1)%3, ((x|x-1)+1)%3is able to
produce the output.What is the logic behind.

Can anybody explain it???

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

2010-06-09 Thread divya jain
@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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: ds

2010-06-09 Thread Anurag Sharma
Its not O(n) time.

Anurag Sharma


On Wed, Jun 9, 2010 at 5:46 PM, Jitendra Kushwaha
jitendra.th...@gmail.comwrote:

 here is a sel explainatory algo

 given:

 abcd1234
 abc1d234
 ab1c2d34
 a1b2c3d4

 here is the link for the code : http://codepad.org/SZnufGc6

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

2010-06-09 Thread Dave
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, sharad sharad20073...@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.



[algogeeks] Re: Tower of Hanoi Iterative Solution

2010-06-09 Thread Dave
See http://en.wikipedia.org/wiki/Tower_of_Hanoi#Binary_solutions

Dave

On Jun 9, 10:37 am, Jitendra Kushwaha jitendra.th...@gmail.com
wrote:
 Below iterative solution of the tower of hanoi problem...

 #include stdio.h
 #include stdlib.h

 int main()
 {
    int n, x;
    printf( How many disks?  );
    scanf( %d, n );
    printf(\n);
    for (x=1; x  (1  n); x++)
       printf( move from tower %i to tower %i.\n,
                  (xx-1)%3, ((x|x-1)+1)%3 );
 return 0;

 }

 i am not able to get how    (xx-1)%3, ((x|x-1)+1)%3    is able to
 produce the output.What is the logic behind.

 Can anybody explain it???

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

2010-06-09 Thread Algoose Chase
The Definition of isomorphic trees given in the first post is incomplete
We say two rooted unordered trees are isomorphic if
1. a tree with a single node (the root) is only isomorphic to a tree with a
single node;
2. two trees with roots A and B, none of which is a single-node tree, are
isomorphic if and only if there is a 1-1 correspondence between the subtrees
of A and the subtrees of B such that corresponding subtrees are isomorphic.

Lets say each node has an additional field that says the number of children
it has.
bool IsIsomorphic(Node* T1,Node* T2)
{
 if( T1 == null  T2 == null ) return true;

 if( T1-numChilderen == T2-numChilderen)
 {
if(IsIsomorphic(( T1-left,T2-left) 
IsIsoMorphic(T1-right,T2-right)) || (IsIsoMorphic(T1-right,T2-left) 
IsIsomorphic(T1-left,T2-Right));
 }
 else return false;
}

Correct me if needed !

On Wed, Jun 9, 2010 at 8:29 PM, divya jain sweetdivya@gmail.com wrote:

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


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

2010-06-09 Thread sharad kumar
@ anurag we can do operation only at bit level sowe will need o(32n)
although it is also O(n) bt if word size is more then its quite inefficient
so suggest 4 that

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

2010-06-09 Thread sharad kumar




  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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: identify the recurring part for a given decimal no

2010-06-09 Thread Veer Sharma
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
  .
  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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] level order traversal

2010-06-09 Thread Anurag Sharma
Do you have 'parent pointers' stored at every node?

Anurag Sharma


On Wed, Jun 9, 2010 at 2:26 PM, sharad sharad20073...@gmail.com wrote:

 can any one tell me how to code for vertical level traversal of a
 binary tree?


  1
/\
   2  3
 /   \/  \
45  67


 print

 4   2156   37

 --
 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] Single ordered list

2010-06-09 Thread Algoose Chase
For multiple ordered lists you can build a single Max heap out of elements
from all this list and Process as its done in heapsort


On Wed, Jun 9, 2010 at 9:14 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote:

 I had answered this question(of multiple lists) 2 or three days back.
 Go into the archive if u wanna see :P
 --
 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 6:52 PM, Raj N rajn...@gmail.com wrote:

 But what if the same same problem is extended for multiple lists. As the
 individual lists have already been sorted, is there any efficient way or any
 other sorting algo which exploits this fact.


 On Tue, Jun 8, 2010 at 10:56 PM, divya jain sweetdivya@gmail.comwrote:

 merging as in merge sort.

 On 8 June 2010 19:59, Raj N rajn...@gmail.com wrote:

 What is the most efficient way of combining 2 separate ordered list
 into a single ordered list ?

 --
 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] isomorphic trees

2010-06-09 Thread saurabh gupta
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.com wrote:

 @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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: constraints satisfied?

2010-06-09 Thread Anurag Sharma
Proceed with the above logic of 2D array and only fill the matrix
considering only the equality constraints ( xi=xj)
Using the Floyd warshall All pair shortest path algorithm, we can know the
all reachable places from every other place.
Now fill the matrix as per the inequality constraints(xi!=xj) and whenever
an overwrite occurs we will know that its not possible to satisfy all
constraints.

Although this will shoot up our time complexity to O(n^3) because of Floyd
Warshal algorithm.

Comments welcome.

Anurag Sharma


On Wed, Jun 9, 2010 at 3:42 PM, jaladhi dave jaladhi.k.d...@gmail.comwrote:

 Using an n*n array, am afraid, will not solve the problem, since its not
 capable to capture transitivity.

 Consider the case:

 v1=v2
 v3=v2
 v3!=v1

 we will place 0 in arr(1,2) arr(2,1) for v1=v2
 we will place 0 in arr(2,3) arr(3,2) for v3=v2
 and place 1 in arr(1,3) and arr(3,1) for v3!=v1.

 no overwrite :( and still the constraints cannot be satisfied.

 -jkd




 On Tue, Jun 8, 2010 at 10:07 PM, Minotauraus anike...@gmail.com wrote:

 Use a n x n array.
 initialize with -1 (don't care = no constraints). If there is an
 equality constraint, set to 1, if
 explicity non-equality constraint is expected, replace with 0. While
 doing either of these if
 you come across a situation where 0 has to be overwritten by 1 or 1
 has to be overwritten by 0,
 the system constraints cannot be satisfied, else all is well. Space
 required = n^2 bytes.
 Time complexity = O(c) where c= number of constraints for the system.
 Therefore, independent of the number of variables.


 You can do this with hash tables too and probably save memory. Here
 you'll use not store = -1 = don't care.

 -Minotauraus.

 On Jun 7, 12:16 pm, divya sweetdivya@gmail.com wrote:
  Here's a problem that occurs in automatic program analysis. For a set
  of variables x1; .. ; xn, you are given some equality constraints,
  of the form xi = xj and some dis equality constraints, of the form
  xi != xj Is it possible to satisfy all of them? Give an efficient
  algorithm that takes as input m constraints over n variables and
  decides whether the constraints can be satisfied.

 --
 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] Re: ds

2010-06-09 Thread souravsain
Guys

We can solve this in O(n) time like this:
Let me say total elements in array is 2N such that 1 to N are a's and N
+1 to 2N (which I will again refer to as 1 to N) are b's

Observation:
If an element is on first 1 to N (an 'a') and has index i then in the
final array its position index (in the final 2N array) will be i+(i-1)
[current index + no. of positions lying to the left].
If an element is on the second 1 to N (the b's series) and has index j
then in the final array of 2N, its index will be 2j.

With this observation we start with the last element of first series,
the a's and find its final position in result array. Place the element
in final position. Take the element which is lying there and find this
elements new position and go on.
Example: start with temp=a6 (the last element of furst series)
a1,a2,a3,a4,a5,a6,b1,b2,b3,b4,b5,b6
temp=a6, final position of a6 = 6+(6-1) = 11. Put a6 in eleventh
position and take the element at 11th position into temp: So now
a1,a2,a3,a4,a5,a6,b1,b2,b3,b4,a6,b6 and temp = b5. Final position of
b5 = 2*5 = 10. Put b5 at 10th position and take previous element in
temp. So now
a1,a2,a3,a4,a5,a6,b1,b2,b3,b5,a6,b6 and temp = b4. Final position of
b4 = 2*4 = 8. Put b4 at 8th position and take previous element at 8th
in temp. So now
a1,a2,a3,a4,a5,a6,b1,b4,b3,b5,a6,b6 and temp = b2, going this way we
will have next position of b2 = 2*2=4
a1,a2,a3,b2,a5,a6,b1,b4,b3,b5,a6,b6 and temp = a4: next position of a4
= 4 + (4-1) = 7
a1,a2,a3,b2,a5,a6,b4,b4,b3,b5,a6,b6 and temp=b1: next position of b1 =
1*2=2
a1,b1,a3,b2,a5,a6,b4,b4,b3,b5,a6,b6 and temp=a2:next position of a2 =
2+(2-1)=3
a1,b1,a2,b2,a5,a6,b4,b4,b3,b5,a6,b6 and temp=a3:next position of a3 =
3+(3-1)=5
a1,b1,a2,b2,a3,a6,b4,b4,b3,b5,a6,b6 and temp=a5:next position of a5 =
5+(5-1)=9
a1,b1,a2,b2,a3,a6,b4,b4,a5,b5,a6,b6 and temp=b3:next position of b3 =
3*2=6
a1,b1,a2,b2,a3,b3,b4,b4,a5,b5,a6,b6 and temp=a6:next position of a6 =
6 + (6-1)=11
But now we find a6 already present at 11. Hence arranged in O(n) time
and constant space of 1 temp variable

Thanks,
Sourav Sain

On Jun 9, 8:54 pm, Anurag Sharma anuragvic...@gmail.com wrote:
 Its not O(n) time.

 Anurag Sharma

 On Wed, Jun 9, 2010 at 5:46 PM, Jitendra Kushwaha
 jitendra.th...@gmail.comwrote:



  here is a sel explainatory algo

  given:

  abcd1234
  abc1d234
  ab1c2d34
  a1b2c3d4

  here is the link for the code :http://codepad.org/SZnufGc6

  --
  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.comalgogeeks%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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] level order traversal

2010-06-09 Thread Anurag Sharma
In case of array representation of this binary tree where we can traverse
through all the leaf nodes and move to their parents, this problem becomes
quite easy.
for the example stated consider its array representation
arr[]={1,2,3,4,5,6,7} and take another array marked[7]={false} indicating
whether the current node has been printed

Now for every non leaf node, index i in (n/2) to (n-1)
  print the leaf node and mark its marked[i]=true
  change j= floor(i-1)/2
  while marked[j] = false:
  print arr[j]
  marked[j]=true
  change j=floor(j-1)/2


a C++ implementation for the above:-
int main(int argc, char **argv) {
int arr[] = { 1, 2, 3, 4, 5, 6, 7 }, N = 7;
bool marked[7];

for (int i = 0; i  N; i++)
marked[i] = false;

for (int i = N / 2; i  N; i++) {
printf([%d], arr[i]);
marked[i] = true;
for (int j = (i - 1) / 2; j=0  !marked[j]; j = (j - 1) / 2) {
printf([%d], arr[j]);
marked[j] = true;
}
}

}


Anurag Sharma


On Wed, Jun 9, 2010 at 9:31 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.


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

2010-06-09 Thread Anurag Sharma
but you have already given the range of numbers from 1 to 1 for which I
think it should work pretty fine.
We can just keep a count of every number arriving in an array since we know
its in the range 1..1 and later get the sorted array accordingly
repeating the elements that many times. Its almost trivial this way.
I did not get your statement completely if word size is more then its quite
inefficient. Any algorithm you choose for this you may mostly need to work
on such arithmetic(addition in this case). Do you want some algo with some
bit level operations?
Correct me if I am wrong.

Anurag Sharma

On Wed, Jun 9, 2010 at 9:29 PM, sharad kumar sharad20073...@gmail.comwrote:

 @ anurag we can do operation only at bit level sowe will need o(32n)
 although it is also O(n) bt if word size is more then its quite inefficient
 so suggest 4 that

 --
 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: isomorphic trees

2010-06-09 Thread souravsain

As per @Algoose's explanation, this can be found using the algorithm
to comapre if 2 binary trees are equal (quite often asked and found in
net). In this we generally go recursive and say
T1 is equal to T2
if T1=T2
and same holds for T1-Left, T2-Left (recursive call on left tree)
and same holds for T1-Right, T2-Right (recursive call on right tree).

We can use the same and change the calls as
if T1=T2
and same holds for T1-Left, T2-Right (recursive call on left tree)
and same holds for T1-Right, T2-Left (recursive call on right tree).


Sain

On Jun 9, 10:45 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.com wrote:
  @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.- 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.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

2010-06-09 Thread Anurag Sharma
multiply the original number x=23.34563456

Anurag Sharma

On Wed, Jun 9, 2010 at 10:36 PM, Veer Sharma thisisv...@rediffmail.comwrote:

 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
   .
   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] level order traversal

2010-06-09 Thread Antony Vincent Pandian.S.
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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] hashing

2010-06-09 Thread sharad kumar
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
 .
 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.