[algogeeks] winning strategy for misere game

2012-12-21 Thread amrit harry
http://acm.mipt.ru/judge/problems.pl?problem=103CGISESSID=250a19da059c5576167cb500c62fa49c
i learned how to play normal NIM game but im not able to find the winning 
strategy of misere game please put some light on it. 
Thanks  Regards 
Amritpal singh

-- 




Re: [algogeeks] Adobe Interview Question

2012-12-11 Thread amrit harry
1st:

freopen(filename,r,stdin);

while(scanf(%s,str)!=-1)
{
printf(%s\n,str);
}


On Sun, Dec 9, 2012 at 3:22 PM, manish untwal manishuntw...@gmail.comwrote:

 I gave this interview in August this year, two of the question i was not
 able to answer properly
 1) how to print the content of file in C without using the file pointer.
 2) count the total number of permutation of a number in order O(n)

 --






-- 
Thanks  Regards
Amritpal singh

-- 




[algogeeks] Suggest algo...

2012-08-24 Thread amrit harry
 find the all possible combination of digits ranging 1 to 9 whose sum is 10,
no digit shud be repeated in any combination. 
1234
127
136
145
19
235
28
37
46 

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



[algogeeks] how to print tata from tatapower using only strcat and strcpy???

2012-07-10 Thread amrit harry


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



Re: [algogeeks] balanced tree

2012-07-04 Thread amrit harry
bool checkTree(Tree node)
{
if(node[right]==NULLnode[left]==NULL)
return true;
if(node[right]==NULLnode[left]!=NULL||node[left]==NULLnode[right]!=NULL)
return false;
else
return checkTree(node[right])checkTree(node[left]);
}

i think this algo can solve problem just traverse the node and keep eye on
that either a node have 2 childs or no child

On Wed, Jul 4, 2012 at 3:08 PM, Ashish Goel ashg...@gmail.com wrote:

 i think checking full is easy, find height(0to h) and then check if level
 h has 2^(h+1) nodes

 how to check if it is complete..level order traversal? ensure that every
 node has two children or left for the last one just before first leaf( till
 you find the first leaf). Now on, every node should be a leaf.


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Wed, Jul 4, 2012 at 2:36 PM, Ashish Goel ashg...@gmail.com wrote:

 ok, lets modify the problem to find if the tree is complete binary tree

 The tree is a complete binary tree; that is, all levels of the tree,
 except possibly the last one (deepest) are fully filled, and, if the last
 level of the tree is not complete, the nodes of that level are filled from
 left to right



 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Wed, Jul 4, 2012 at 11:09 AM, atul anand atul.87fri...@gmail.comwrote:

 http://www.geeksforgeeks.org/archives/5230
 modify this to meet the requirnment.

 On 7/4/12, Ashish Goel ashg...@gmail.com wrote:
  WAP to find if a tree is balanced/fully balanced?
 
  Best Regards
  Ashish Goel
  Think positive and find fuel in failure
  +919985813081
  +919966006652
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

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



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




-- 
Thanks  Regards
Amritpal singh

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



Re: [algogeeks] balanced tree

2012-07-04 Thread amrit harry
int treeMaxHeight(int index)
{
if(tree[index]==NULL)
return 0;
 else
{
return 1+max(treeHeight(2*index),treeHeight(2*index+1));
 }
}
int treeMinHeight(int index)
{
if(tree[index]==NULL)
return 0;
 else
{
return 1+min(treeHeight(2*index),treeHeight(2*index+1));
 }
}

if(treeMaxHeight(1)-treeMinHeight(1)1)
then not balanced;
else
Balanced;

On Wed, Jul 4, 2012 at 8:53 AM, Ashish Goel ashg...@gmail.com wrote:

 WAP to find if a tree is balanced/fully balanced?

 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652

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




-- 
Thanks  Regards
Amritpal singh

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



Re: [algogeeks] simple FILE reading problem.

2012-07-04 Thread amrit harry
reading from a file is bottle neck so better to read number of line into a
buffer then read it char by char or word by word depend on algo...

On Wed, Jul 4, 2012 at 10:44 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 Suppose a file.txt contains : 50 40 30 # # 5 # 10 # #

 i want to fetch only integers. How should i fetch it. I tried with fgetc
 and fscanf but it was too complicated.

 My approach: fetched one word at a time and put it into separate string
 and then i converted that string to integer(if each character of that
 string was between '0' to '9').

 Is there any simple way to do this.


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




-- 
Thanks  Regards
Amritpal singh

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



Re: [algogeeks] Question asked in Amazon Online Test

2012-06-29 Thread amrit harry
@bhaskar ur algo fails on this case (5+3)-(2+(3/6))
-+53+2/36
63/2+35-+
showing that 6/3 but actually it is 3/6
so i think it could be done by folowing algo
make a binary tree of given expression in O(n)  then do postorder traversal
take O(n) so problem can be solved in O(n). and take O(2*n+1) space

On Fri, Jun 29, 2012 at 9:13 PM, Bhaskar Kushwaha 
bhaskar.kushwaha2...@gmail.com wrote:

 I think just reversing the prefix notation converts it to postfix notation


 On Fri, Jun 29, 2012 at 7:46 PM, Gobind Kumar Hembram 
 gobind@gmail.com wrote:

 Given an integer expression in a prefix format (i.e. the operator
 precedes the number it is operating on) ,  print the expression in the
 post fix format .

 Example: If the integer expression is in the prefix format is *+56-78,
 the postfix format expression is 56+78-*. Both of these
 correspond to the expression (5+6)*(7-8).

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




 --
 regards,
 Bhaskar Kushwaha
 Student
 Final year
 CSE
 M.N.N.I.T.  Allahabad

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




-- 
Thanks  Regards
Amritpal singh

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



Re: [algogeeks] Explain the output

2012-06-28 Thread amrit harry
print statement become
printf(char *str= %c%s%c; main...,34,str,34);
now 34 is ascii value of double quote so first %c will get value
ascii_code_of(34) and %s will get same string and last %c again get
ascii_code_of(34) i.e   so total string is  char *str=+
asci(34)+str+ascii(34)+;main() { printf(str,34,str,34);}

On Thu, Jun 28, 2012 at 2:01 PM, Mad Coder imamadco...@gmail.com wrote:

 Please explain the output of following C code

 #includestdio.hchar *str = char *str = %c%s%c; main(){ printf(str, 34, 
 str, 34);};
 int main()
 {
 printf(str, 34, str, 34);
 return 0;
 }

 Output--
 char *str = char *str = %c%s%c; main(){ printf(str, 34, str, 34);}; main(){ 
 printf(str, 34, str, 34);}


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




-- 
Thanks  Regards
Amritpal singh

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



[algogeeks] segment Tree problem

2012-06-27 Thread amrit harry
Hi. I'm new to segment tree. im solving a problem in which we have to find 
most frequent element in given range
so for the below testcase im trying to constructing tree but i stuck.

-1 -1 1 1 1 1 3 8 8 8

[i,j] is range of segment and x is the element that occur frequently and y 
is the count of x.
[i,j]=[x,y] 
[0,0]=[-1,1]
[1,1]=[-1,1]
[0,1]=[-1,2]// because the sub tree[0,0]-x==[1,1]--x so we added value. 
[2,2]=[1,1]
[0,2]=[-1,2]// becuase the subtree [0,1][2,2] have value [-1,2]  [1,1] so 
first set have higher value

[3,3]=[1,1]
[4,4]=[1,1]
[3,4]=[1,2]// same reason as [0,1] set
problem occur here
while updating the value of [0,4]
[0,4] has 2 child [0,2]=[-1,2]  [3,4]=[1,2] so updating the set we can 
determine which value should belongs
to [0,4] and set [2,2]=[1,1] which we neglect. then how to update value 
[0,4] while intializing the segment tree???

 

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



Re: [algogeeks] 1/x + 1/y = 1/(n factorial)

2012-06-26 Thread amrit harry
x+y/(x*y)=1/N!
N!=x*y/(x+y)
assume x=y
N!=x^2/(2x)
x/2=N!
x=2*N!

1/(2*N!)+1/(2*N!)=1/N!

for example for N=4
1/48+1/48=1/24

On Mon, Jun 25, 2012 at 5:30 PM, Kumar Vishal kumar...@gmail.com wrote:


 We have to find number of Pair(x,y)
 which will satisfy the eq:
 1/x + 1/y = 1/(n factorial)

 for large 0  N  10 ^ 4 N is integer
 Its problem from Code Sprint
 I tried to solve it by taking LOG but the sol
 was very slow , can any one please help

 Thanks
 Kumar Vishal

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




-- 
Thanks  Regards
Amritpal singh

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



Re: [algogeeks] SPOJ problem : CANDY III

2012-06-21 Thread amrit harry
@Mayank coding style not seems gud.. try this...

int main()
{
int testCases;
scanf(%d,testCases);
while(testCases--0)
   {
//perform ur logic
//print output for each test case here instead of storing it into
an array.
}
}
return 0;
}

On Thu, Jun 21, 2012 at 10:35 PM, Mayank Singh
singh13490may...@gmail.comwrote:



 thanx it worked

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




-- 
Thanks  Regards
Amritpal singh

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



Re: [algogeeks] Reverse Queue

2012-06-20 Thread amrit harry
can we create other methods or we have to use only enqueue and dequeue...?
if yes then simply
for(i=0;i=n/2;i++)
swap(i,n-i);


On Wed, Jun 20, 2012 at 6:46 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 @Saurabh: queue will be remain unchanged according to your algorithm.
 Because if you will delete an element from front and add at rear no change
 will be there. After n iteration front will be pointing to same element and
 rear will also point to same element.

 Correct me if i am wrong. :)


 On Wed, Jun 20, 2012 at 6:39 PM, saurabh singh saurabh.n...@gmail.comwrote:

 count the size of queue : O(n)
 loop for n and do remove and add in queue : O(n)

 Total : O(n)


 On Wed, Jun 20, 2012 at 6:34 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 How to reverse a Queue .

 Constraints: Time complexity O(n). space complexity: O(1)

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




 --
 Thanks  Regards,
 Saurabh

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


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




-- 
Thanks  Regards
Amritpal singh

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



Re: [algogeeks] Reverse Queue

2012-06-20 Thread amrit harry
i doesn't seem possible without using stack...

On Wed, Jun 20, 2012 at 10:13 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 @Rishabh: i know using stack or recursion it can be done easily with O(n)
 space. I want to know whether there exist more space efficient algo for
 this problem or not?


 On Wed, Jun 20, 2012 at 9:20 PM, Rishabh Agarwal rishabh...@gmail.comwrote:

 @Navin: as you say you have to take stack or some other data structure
 then it will definately not be donw in O(1) space complexity i think the
 recursive solution is best because we are not explicitly using any extra
 space its internal stack is using this space.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/oKM6PICuD6oJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


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




-- 
Thanks  Regards
Amritpal singh

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



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

2012-06-06 Thread amrit harry
@abhishek pls send link me too... thanks.

On Mon, Jun 4, 2012 at 5:54 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 mailing you the link for same


 On Mon, Jun 4, 2012 at 1:31 AM, Dhaval Moliya moliyadha...@gmail.comwrote:

 If any one have algorithms for interviews by adnan aziz ebook... Please
 mail ...
 Thanks

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




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

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




-- 
Thanks  Regards
Amritpal singh

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



[algogeeks] find error

2012-05-29 Thread amrit harry
#includeiostream
using namespace std;
class complex_number
{
public: int x,*ptr;

  ostream  operator (ostream out, complex_number c)
{
outsize=c.xendl;
for(int i=0;ic.x;i++)
outc.ptr[i] ;
out\n;
return out;
}

complex_number(int a)
{
x=a;
ptr=(int *) malloc(a*sizeof(int));
for(int i=0;i5;i++)
ptr[i]=i;
}
};

int main()
{
complex_number p(5);
coutp;
}
above code show error operator  must take only one argument
and when i change code to

#includeiostream
using namespace std;
class complex_number
{
public: int x,*ptr;

   friend ostream  operator (ostream out, complex_number c);
complex_number(int a)
{
x=a;
ptr=(int *) malloc(a*sizeof(int));
for(int i=0;i5;i++)
ptr[i]=i;
}
};
ostream  operator (ostream out, complex_number c)
{
outsize=c.xendl;
for(int i=0;ic.x;i++)
outc.ptr[i] ;
out\n;
return out;
}

int main()
{
complex_number p(5);
coutp;
}
 then there is no error why so...?

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



[algogeeks] Cpp problem

2012-05-27 Thread amrit harry
complex_number const  operator =(complex_number  temp) const
{
return *this;
}


what is the job of marked 'const'???

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



Re: [algogeeks] Re: how to approach this kinda problmls

2012-04-21 Thread amrit harry
@all above  you are suggesting brute force solution and have a look at the
constraints and time limits which are too strict so such solution would
work over here i need a DP approach.
@vandana we can't make hash because of the high value of N.
@ramindar actually not only reverse there exist all the permutation of each
number.
for 123
132
213
231
312
321 all exist.
Thanks for you response.

On Sat, Apr 21, 2012 at 2:02 AM, Ramindar Singh ramin...@gmail.com wrote:

 Just to add to Vandana

 certain observations like

 1) consider 1,2,3,4. 9  as 01,02,03,04.. 09  so the reverse of the
 strings are also present in the answer ie 10,20,30,40 90
 2) when you traverse the numbers like 11,12,13,14 19 and you dont find
 any PDS number you are omitting the numbers 21,31,41,51 91 so you need
 not to verify on these numbers
  Also in the next traversal you are not checking it for 21 as explained
 and for 22,23,24 29 you would omit the numbers 32,42,52 92
  In the next line for 33,34,35,3639, we have a PDS number 36 and also
 we have its reverse 63 as a PDS.

 So by the time you reach the 9* line you just need to verify the 99 digit
 as you have verified the others earlier.
 Hope this helps :)


 Thanks
 Ramindar Singh

 On Friday, 20 April 2012 23:49:48 UTC+5:30, amrit harry wrote:

 http://www.codechef.com/**APRIL12/problems/PDSNUMhttp://www.codechef.com/APRIL12/problems/PDSNUM


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/m1GvKl8FWcMJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
AMRIT

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



Re: [algogeeks] Re: how to approach this kinda problmls

2012-04-21 Thread amrit harry
@atul as the problem said i have to find Nth PDS number so N could be 10^9
so 9 digits and pds number can be of 10digits so scanning from 1 to 10^10
in each case (because we can make such a large hash) will cross time limits
as there would be 1 test cases so it become 10^14  and which can't
complete in 20s so need some dp algo.
http://www.codechef.com/wiki/april-2012-contest-problem-editorials
here is link to solution but i cant understand it... if some one get that
what approach they used please explain.
Thanks

On Sat, Apr 21, 2012 at 8:29 PM, atul anand atul.87fri...@gmail.com wrote:

 numbers from 1 to 9 and 10,20,30,4090 are pds number . so you just
 need on if() check to count it directly when this numbers occurs no need of
 checking these numbers by applying reverse and checking  for all other
 numbers this can be done.

 On Sat, Apr 21, 2012 at 2:02 AM, Ramindar Singh ramin...@gmail.comwrote:

 Just to add to Vandana

 certain observations like

 1) consider 1,2,3,4. 9  as 01,02,03,04.. 09  so the reverse of
 the strings are also present in the answer ie 10,20,30,40 90
 2) when you traverse the numbers like 11,12,13,14 19 and you dont
 find any PDS number you are omitting the numbers 21,31,41,51 91 so you
 need not to verify on these numbers
  Also in the next traversal you are not checking it for 21 as explained
 and for 22,23,24 29 you would omit the numbers 32,42,52 92
  In the next line for 33,34,35,3639, we have a PDS number 36 and also
 we have its reverse 63 as a PDS.

 So by the time you reach the 9* line you just need to verify the 99 digit
 as you have verified the others earlier.
 Hope this helps :)


 Thanks
 Ramindar Singh

 On Friday, 20 April 2012 23:49:48 UTC+5:30, amrit harry wrote:

 http://www.codechef.com/**APRIL12/problems/PDSNUMhttp://www.codechef.com/APRIL12/problems/PDSNUM


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/m1GvKl8FWcMJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


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




-- 
AMRIT

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



[algogeeks] how to approach this kinda problmls

2012-04-20 Thread amrit harry
http://www.codechef.com/APRIL12/problems/PDSNUM 

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



Re: [algogeeks] Slang Decoder chatBot... give a try...

2012-03-27 Thread amrit harry
@Andreas i used XAMPP protocol to connect and designed this using PHP i
hardcode only those keywords that i know... it would be my pleasure if you
help me to expand library.
Thanks. Contact me @ dabbcomput...@gmail.com

On Tue, Mar 27, 2012 at 9:34 AM, atul anand atul.87fri...@gmail.com wrote:

 i had made similar gtalk long time back...but it was for chatting and has
 gtalk look alike gui interface but more colorful :P .
 i had used smack library. most of the text chatting application uses xmpp
 protocol.

 On Tue, Mar 27, 2012 at 2:24 AM, Andreas Hahn 
 www.gal...@googlemail.comwrote:

 Hi,

 I've tested your slang decoder bot and my first impression is: nice
 work, well done =)
 Unfortunetely the slang decoder's vocabulary isn't very big and most
 of the times I tested some exotic abbreviations, it just echoed my
 input =).

 But anyway, nice work. If you would like to expand the vocabulary of
 your bot, feel free to ask me, I would like to help you on that =).
 Furthermore, if you're planning to extend it someday to do some other
 useful stuff too, I would be grateful to be of help for you.

 But there is one question, I'd like to have answered: Do you use XMPP
 protocol to connect to Google Talk ? And which library do you use ?

 Thanks for answering.

 Regards
 Andreas

 2012/3/25 amrit harry dabbcomput...@gmail.com:
  Hi Friends i designed a chatbot for gmail. some time our friend use some
  slang terms in chat and we feel hesitation in asking the meaning of that
  slangs from friends so from now no need to do so or even googling it.
 just
  invite 'slangdeco...@gmail.com' for chat and query those slangs and get
  their meanings.
  sample data:
  lol
  rofl
  afk
  wtf
  brb
 
  GIVE IT A TRY
 
  i added a script to update database at midnight so currently some
 slangs are
  missing in database and those will be updated soon.
 
  Thanks Regards
  Amritpal Singh
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To view this discussion on the web visit
  https://groups.google.com/d/msg/algogeeks/-/kDUqpYummrAJ.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.

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


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




-- 
AMRIT

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



[algogeeks] Slang Decoder chatBot... give a try...

2012-03-25 Thread amrit harry
Hi Friends i designed a chatbot for gmail. some time our friend use some 
slang terms in chat and we feel hesitation in asking the meaning of that 
slangs from friends so from now no need to do so or even googling it. just 
invite 'slangdeco...@gmail.com' for chat and query those slangs and get 
their meanings.
sample data:
lol
rofl
afk
wtf
brb

*GIVE IT A TRY*
*
*
i added a script to update database at midnight so currently some slangs 
are missing in database and those will be updated soon.

Thanks Regards
Amritpal Singh

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



Re: [algogeeks] networking

2012-03-22 Thread amrit harry
using ajax..hit google for ajax...

On Fri, Mar 23, 2012 at 10:07 AM, Aman Kumar amanas...@gmail.com wrote:

 Hii to all

 how to make a call of class's method(function) from client side to
 server in java?

 please replyit's urgent

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




-- 
AMRIT

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



Re: [algogeeks] Re: Check if one tree is sub tree of other

2012-03-21 Thread amrit harry
@sidarth
your method would not work it think.
let a case

sub tree:   4Main tree:
 6
   5 6
   4   7
 5
  8

inorder traversal of sub tree str1= 5,4,6 and  inorder traversal of Main
tree str2=5,4,6,7,8
and str1 is subset of str2 but the sub-tree is not actually a sub tree...
correct me if im wrong.
Thanks
Amrit


On Wed, Mar 21, 2012 at 11:20 AM, Dheeraj Sharma 
dheerajsharma1...@gmail.com wrote:

 No..am nt talking about binary search tree..bt about binary tree.. It
 was asked in  my amazon written

 @shady..doing the substring search..as we have to search for subset of
 tree..it searchng substrn might find some false nodes..that doesnt
 belong to that subtree

 On 3/21/12, Don dondod...@gmail.com wrote:
  bool equals(node *t1, node *t2)
  {
return (t1  t2) ? (t1-value == t2-value)  equals(t1-left, t2-
 left)  equals(t1-right, t2-right) : !t1  !t2;
  }
 
  bool check(node *t1, node *subtree)
  {
return t1 ? equals(t1, subtree) || check(t1-left, subtree) ||
  check(t1-right, subtree) : !subtree;
  }
 
  On average this is the same as a traversal, but worst case could be
  very slow. Imagine a large tree with millions of nodes, where all the
  nodes = 1, and a somewhat smaller subtree with 100,000 nodes=1 and one
  node at the far right of the tree = 2. It would require a lengthy
  comparision at each node which would ultimately find no matching sub
  tree.
 
  If they are binary search trees, it could be more efficient. Did you
  mean to ask about binary search trees?
 
  Don
 
  On Mar 20, 7:24 am, Dheeraj Sharma dheerajsharma1...@gmail.com
  wrote:
  How to check if one binary tree is a sub tree of other?
  Any Solution other then bruteforce?
  Prototype
  bool check(node *t1,node *subtree)
 
  --
  Sent from my mobile device
 
  *Dheeraj Sharma*
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 Sent from my mobile device

 *Dheeraj Sharma*

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




-- 
AMRIT

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



[algogeeks] Amazon question

2012-03-21 Thread amrit harry
hi i found this qstn frum career cup pls help to solve this.

Given an integer n, compute 2 integers x, y satisfying: n=x*y=n+2; |x-y| 
is minimal. 
Thanks  Regards
Amrit

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



Re: [algogeeks] Re: Check if one tree is sub tree of other

2012-03-21 Thread amrit harry
@shady consider this case
Main tree   1
 subtree   1
2 3
  2
4
   3

preorder of Main= 1234  subtree= 123 but not subtree
On Wed, Mar 21, 2012 at 1:24 PM, shady sinv...@gmail.com wrote:

 seems correct with pre-order traversal if not give some example

 On Wed, Mar 21, 2012 at 10:32 AM, Mahesh Thakur tmahesh...@gmail.comwrote:

 First Tree:
 1
   2 3
  4  5   67

 Inorder traverse will be : 4251637

 Second Tree:
   6
1 3

 Inorder traversal is 163.

 But they second tree is not subset. let me know if i got the question
 wrong.

 On Wed, Mar 21, 2012 at 10:27 AM, shady sinv...@gmail.com wrote:

 @Sid +100


 On Wed, Mar 21, 2012 at 10:20 AM, siddharam suresh 
 siddharam@gmail.com wrote:

 get the inorder traversal both tree (into strings) check weather one
 string substring of other if yes then one tree is sub tree of other.


 Thank you,
 Sid.
 phone:+91-8971070727,
 +91-9916809982



 On Wed, Mar 21, 2012 at 9:23 AM, HARSHIT PAHUJA 
 hpahuja.mn...@gmail.com wrote:

 bool isSubtree(Tree * A,Tree *B)
 {

 if(!B) return true;
 if(!A)return false;
 if(A-data==B-data)
return (isSubtree(A-left,B-left)
  isSubtree(A-right,B-right));
 else
  return (isSubtree(A-left,B)  isSubtree(A-right,B));
 }










 }

 On Wed, Mar 21, 2012 at 2:33 AM, Don dondod...@gmail.com wrote:

 bool equals(node *t1, node *t2)
 {
  return (t1  t2) ? (t1-value == t2-value)  equals(t1-left, t2-
 left)  equals(t1-right, t2-right) : !t1  !t2;
 }

 bool check(node *t1, node *subtree)
 {
  return t1 ? equals(t1, subtree) || check(t1-left, subtree) ||
 check(t1-right, subtree) : !subtree;
 }

 On average this is the same as a traversal, but worst case could be
 very slow. Imagine a large tree with millions of nodes, where all the
 nodes = 1, and a somewhat smaller subtree with 100,000 nodes=1 and one
 node at the far right of the tree = 2. It would require a lengthy
 comparision at each node which would ultimately find no matching sub
 tree.

 If they are binary search trees, it could be more efficient. Did you
 mean to ask about binary search trees?

 Don

 On Mar 20, 7:24 am, Dheeraj Sharma dheerajsharma1...@gmail.com
 wrote:
  How to check if one binary tree is a sub tree of other?
  Any Solution other then bruteforce?
  Prototype
  bool check(node *t1,node *subtree)
 
  --
  Sent from my mobile device
 
  *Dheeraj Sharma*

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




 --
 HARSHIT PAHUJA
 M.N.N.I.T.
 ALLAHABAD


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


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


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


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


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




-- 
AMRIT

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 

Re: [algogeeks] Re: Check if one tree is sub tree of other

2012-03-21 Thread amrit harry
i have an idea to solve this.
use preorder traversal and a sentinal(#) on the place of Null nodes.
lets take a example
 Main tree   1
 subtree   1
  2 3
2
  4
 3

preorder travesal for Main: 12##34###for sub tree 12#3###
now chk for the sub string in Main string

one more case
Main1
  / \
34
  /   \
 51
/  \
   34
preorder traversal= 1353##4##1##4##
sub
5
/\
3  4

preorder traversal  53##4##
now this substring exist in Main substring so it is a sub tree
correct me if me wrong.
Thanks
Amrit
On Wed, Mar 21, 2012 at 1:34 PM, amrit harry dabbcomput...@gmail.comwrote:

 @shady consider this case
 Main tree   1
  subtree   1
 2 3
 2
 4
  3

 preorder of Main= 1234  subtree= 123 but not subtree
 On Wed, Mar 21, 2012 at 1:24 PM, shady sinv...@gmail.com wrote:

 seems correct with pre-order traversal if not give some example

 On Wed, Mar 21, 2012 at 10:32 AM, Mahesh Thakur tmahesh...@gmail.comwrote:

 First Tree:
 1
   2 3
  4  5   67

 Inorder traverse will be : 4251637

 Second Tree:
   6
1 3

 Inorder traversal is 163.

 But they second tree is not subset. let me know if i got the question
 wrong.

 On Wed, Mar 21, 2012 at 10:27 AM, shady sinv...@gmail.com wrote:

 @Sid +100


 On Wed, Mar 21, 2012 at 10:20 AM, siddharam suresh 
 siddharam@gmail.com wrote:

 get the inorder traversal both tree (into strings) check weather one
 string substring of other if yes then one tree is sub tree of other.


 Thank you,
 Sid.
 phone:+91-8971070727,
 +91-9916809982



 On Wed, Mar 21, 2012 at 9:23 AM, HARSHIT PAHUJA 
 hpahuja.mn...@gmail.com wrote:

 bool isSubtree(Tree * A,Tree *B)
 {

 if(!B) return true;
 if(!A)return false;
 if(A-data==B-data)
return (isSubtree(A-left,B-left)
  isSubtree(A-right,B-right));
 else
  return (isSubtree(A-left,B)  isSubtree(A-right,B));
 }










 }

 On Wed, Mar 21, 2012 at 2:33 AM, Don dondod...@gmail.com wrote:

 bool equals(node *t1, node *t2)
 {
  return (t1  t2) ? (t1-value == t2-value)  equals(t1-left, t2-
 left)  equals(t1-right, t2-right) : !t1  !t2;
 }

 bool check(node *t1, node *subtree)
 {
  return t1 ? equals(t1, subtree) || check(t1-left, subtree) ||
 check(t1-right, subtree) : !subtree;
 }

 On average this is the same as a traversal, but worst case could be
 very slow. Imagine a large tree with millions of nodes, where all the
 nodes = 1, and a somewhat smaller subtree with 100,000 nodes=1 and
 one
 node at the far right of the tree = 2. It would require a lengthy
 comparision at each node which would ultimately find no matching sub
 tree.

 If they are binary search trees, it could be more efficient. Did you
 mean to ask about binary search trees?

 Don

 On Mar 20, 7:24 am, Dheeraj Sharma dheerajsharma1...@gmail.com
 wrote:
  How to check if one binary tree is a sub tree of other?
  Any Solution other then bruteforce?
  Prototype
  bool check(node *t1,node *subtree)
 
  --
  Sent from my mobile device
 
  *Dheeraj Sharma*

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




 --
 HARSHIT PAHUJA
 M.N.N.I.T.
 ALLAHABAD


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


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


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


  --
 You received this message because you are subscribed to the Google
 Groups

[algogeeks] object model

2012-03-15 Thread amrit harry
interviewer told me that design a model for car sharing which use same 
structure as google groups i designed the below design but i have some 
doubts mention as comment pls make them clear.
Class POI// Point of interest 
{
Parm:
double Lat,Lon;
}

Class Route
{
Parm:
POI start,end;
Time start,end;
int type=2;// type of route define purpose of adding route its value could 
be 0,1,2.
// 0 defines that only for search
// 1 defines that only for share
// 2 defines that  for both share  search

METHODS:
Route(POI,POI,Time,Time);
}


Class Member
{
Parm:
int ID,Age,RegisteredGroupID[]// group id is array contains the id of those 
groups which are registered by that member;
String Name;
POI POIList[];
Route RouteList[];

METHODS:
POI AddPOI(), void RemovePOI(POI), Route CreateRoute(POIList), void 
DeleteRoute(Route), Route[] searchRoute(Route), void RegisterGroup(GroupID)
void CreateGroup(member);
}

Class Admin:: Member
{
Parm: 
int OwnedGroupsID[];

METHODS:

void AddMember(Group,Member)// I HAVE A DOUBT ABOUT THIS FUNCTIONS. IS THIS 
FUNCTION SHOULD BE IN GROUP CLASS OR ADMIN CLASS? DO COMMENTS
void RemoveMeber(Group,Member)//I HAVE A DOUBT ABOUT THIS FUNCTIONS. IS 
THIS FUNCTION SHOULD BE IN GROUP CLASS OR ADMIN CLASS? DO COMMENTS
void RemoveGroup(Group);
void ListMembers()
}

Class Group
{
Parm:
Admin admin;
Member MemberList[];

METHODS:
Group(Admin);
}

// Add the missing components And Give feedback.

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



Re: [algogeeks] Re: Explain algo behind code

2012-03-05 Thread amrit harry
could you refer a number theory book..?

On Tue, Mar 6, 2012 at 7:01 AM, Gene gene.ress...@gmail.com wrote:

 It's a fact from number theory that

  x * (x^(M-2)) = 1 (mod M)

 if M is prime.  So x^(M-2) is the multiplicative inverse of x (mod
 M).  It follows by identities of modulo arithmetic that

  n!/(r!(n-r)!) = n! * inv(r!) * inv( (n-r)! )  (mod M)

 This is what the code is computing.  A basic number theory book will
 cover this stuff in the early chapters.


 On Mar 5, 5:13 am, amrit harry dabbcomput...@gmail.com wrote:
  #include cstdio
 
  #define MOD 17
 
  int powmod(int base, int expo){
  if(expo==0)
  return 1;
  else if(expo1)
  return (long long)base*powmod(base, expo-1)%MOD;
  else{
  int root=powmod(base, expo1);
  return (long long)root*root%MOD;
  }
 
  }
 
  int inverse(int x){
  return powmod(x, MOD-2);
 
  }
 
  void init(){
  fact[0]=1;
  for(int i=1; i=5000; i++)
  fact[i]=(long long)i*fact[i-1]%MOD;
  invfact[5000]=inverse(fact[5000]);
  for(int i=5000; i0; i--)
  invfact[i-1]=(long long)i*invfact[i]%MOD;
 
  }
 
  int nCr(int n, int r){
  if(rn || r0)
  return 0;
  return (long long)((long
 long)fact[n]*invfact[r]%MOD)*invfact[n-r]%MOD;
 
  }
 
  int main(){
  init();
  int N, K;
  while(scanf(%d %d, N, K)  (N||K)){
 
  print(%d,nCr(N,K));
  }
 
  }
 
  This is code for calculating binomial cofficient =
 fact(n)/fact(n-r)*fact(r) value of fact(r)*fact(n-r) lead to overflow so in
 this code they use a method of calculating inverse of fact. i could not
 able to understand how inverse function work please explain.
 
  Thanks.

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




-- 
AMRIT

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



Re: [algogeeks] AllBinomialCoefficients

2012-03-03 Thread amrit harry
i miss type recursion it is iterative algo but recursion can be use.

On Sat, Mar 3, 2012 at 6:29 PM, amrit harry dabbcomput...@gmail.com wrote:

 use recursion
 c[1][1]=1;
 c[2][1]=1;
 c[2][2]=1;
 for(i=0;in;i++)

 for(j=0;(2*i)-1;j++)
 {
 c[i][j]=(c[i-1][j]+c[i-1][j+1])
 if(c[i][j]P)
 c[i][j]-=P;//dont use module because it is slow we know the value never
 exceede 2*P because we are adding 2 variable so just use subtract operation.

 }
 On Sat, Mar 3, 2012 at 5:56 PM, jai gupta sayhelloto...@gmail.com wrote:

 use pascal's triangle

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




 --
 AMRIT




-- 
AMRIT

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



Re: [algogeeks] AllBinomialCoefficients

2012-03-03 Thread amrit harry
use recursion
c[1][1]=1;
c[2][1]=1;
c[2][2]=1;
for(i=0;in;i++)

for(j=0;(2*i)-1;j++)
{
c[i][j]=(c[i-1][j]+c[i-1][j+1])
if(c[i][j]P)
c[i][j]-=P;//dont use module because it is slow we know the value never
exceede 2*P because we are adding 2 variable so just use subtract operation.
}
On Sat, Mar 3, 2012 at 5:56 PM, jai gupta sayhelloto...@gmail.com wrote:

 use pascal's triangle

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




-- 
AMRIT

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



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

2012-02-26 Thread amrit harry
@dave +1.. :)

On Mon, Feb 27, 2012 at 10:55 AM, karthikeya s karthikeya.a...@gmail.comwrote:

 oh my bad.really nice concept+1 dave.

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




-- 
AMRIT

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



Re: [algogeeks] nvidia qstn

2012-02-03 Thread amrit harry
use TRIE to implement it and read about it from wiki... :)

On Fri, Feb 3, 2012 at 5:42 PM, Ravi Ranjan ravi.cool2...@gmail.com wrote:

 Implement a MS key suggest like tool where on typing the first letters
 will give a list of words starting with the typed text. The corpus will be
 provided as a text file. Max number of characters in a word is 10.
  - Say you type 'i', it should provide 'include | if ' as the words in the
 dropdown

 do it with minimum complexity???

 less than O(n)

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




-- 
AMRIT

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



Re: [algogeeks] Histogram rectangle

2012-01-17 Thread amrit harry
find the lowest height of the bar multiply it with the number of the bars
in graph. it would be the minimum area.

On Tue, Jan 17, 2012 at 5:33 PM, Ashish Goel ashg...@gmail.com wrote:

 You are given an array which represents the heights of every bar of a
 histogram. Now all these bars are contiguous (juxtaposed wrt each other)
 and have the same width. For Example, A={2,1,4} represents a histogram
 having 3 bars of height 2,1and 4 in that order. Now you need to find a
 rectangle in this histogram that has the maximum area.


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652

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




-- 
AMRIT

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



Re: [algogeeks] Histogram rectangle

2012-01-17 Thread amrit harry
sorry for last comment i misunderstand the problem.

On Tue, Jan 17, 2012 at 5:54 PM, amrit harry dabbcomput...@gmail.comwrote:

 find the lowest height of the bar multiply it with the number of the bars
 in graph. it would be the minimum area.


 On Tue, Jan 17, 2012 at 5:33 PM, Ashish Goel ashg...@gmail.com wrote:

 You are given an array which represents the heights of every bar of a
 histogram. Now all these bars are contiguous (juxtaposed wrt each other)
 and have the same width. For Example, A={2,1,4} represents a histogram
 having 3 bars of height 2,1and 4 in that order. Now you need to find a
 rectangle in this histogram that has the maximum area.


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652

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




 --
 AMRIT




-- 
AMRIT

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



Re: [algogeeks] find point lies in side circle

2012-01-05 Thread amrit harry
@shady this problem is not from the online  contest. i need this in my
project
@utkarsh please elloborate your idea in more detail

On Fri, Jan 6, 2012 at 9:40 AM, UTKARSH SRIVASTAV
usrivastav...@gmail.comwrote:

 we can do bfs. from the point A do bfs until distance = R

 On Fri, Jan 6, 2012 at 12:47 AM, shady sinv...@gmail.com wrote:

 problem link ?


 On Thu, Jan 5, 2012 at 5:47 PM, dabbcomputers dabbcomput...@gmail.comwrote:

 you are given with N points on graph. and a point A on graph and range
 R you have to find the points that lies within the radius of R from
 point A. with complexity less than O(N).

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


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




 --
 *UTKARSH SRIVASTAV
 CSE-3
 B-Tech 3rd Year
 @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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
AMRIT

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



Re: [algogeeks] Re: find point lies in side circle

2012-01-05 Thread amrit harry
i also think so data must be represent in some special form i heard
about K-D trees but not yet studied about it

On Fri, Jan 6, 2012 at 12:26 PM, Lucifer sourabhd2...@gmail.com wrote:

 @all..
 To decide which points are within the range R, we need to look a each
 point..Hence the lower bound would be O(N)..

 Now, for doing it in  O(N) we need to have the input being given in a
 particular order, basically the datastructure which stores the graph
 projects some releationship b/w all the points..

 @utkarsh..
 Say, the graph is represented as an adjancency matrix or list with
 edges showing the connection and weights defined the distance b/w the
 points...and assuming that this datastructure is given to u.. then its
 as good as applying dijikstra's to find the shortest path from A to
 all other vertices... and check which shortest paths are smaller than
 R...

 Basically it all depends on how the data is being represented..

 @dabbcomputer
 Correct me if i m wrong..

 On Jan 6, 11:48 am, shady sinv...@gmail.com wrote:
  how will one come to know which points are cut-out from the circle ?
  i fail to understand how can it be less than O(n) unless you store the
  given N points in a data structure ... where preprocessing itself
 involves
  O(N)...

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




-- 
AMRIT

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



Re: [algogeeks] Re: find point lies in side circle

2012-01-05 Thread amrit harry
@shady the N is same we just have to query the data again and again

On Fri, Jan 6, 2012 at 12:47 PM, shady sinv...@gmail.com wrote:

 the reason i asked you about problem link is because the solution to your
 problem depends on the way you want to use it...

 1. if each time there are new N points and radius R,   and only one query
 for it...then it just can't be O(n)

 2. if N points are fixed and there are like 1+ queries then you can
 store it in some dataset and retrieve the result for that in O(logn)

 On Fri, Jan 6, 2012 at 12:29 PM, amrit harry dabbcomput...@gmail.comwrote:

 i also think so data must be represent in some special form i
 heard about K-D trees but not yet studied about it


 On Fri, Jan 6, 2012 at 12:26 PM, Lucifer sourabhd2...@gmail.com wrote:

 @all..
 To decide which points are within the range R, we need to look a each
 point..Hence the lower bound would be O(N)..

 Now, for doing it in  O(N) we need to have the input being given in a
 particular order, basically the datastructure which stores the graph
 projects some releationship b/w all the points..

 @utkarsh..
 Say, the graph is represented as an adjancency matrix or list with
 edges showing the connection and weights defined the distance b/w the
 points...and assuming that this datastructure is given to u.. then its
 as good as applying dijikstra's to find the shortest path from A to
 all other vertices... and check which shortest paths are smaller than
 R...

 Basically it all depends on how the data is being represented..

 @dabbcomputer
 Correct me if i m wrong..

 On Jan 6, 11:48 am, shady sinv...@gmail.com wrote:
  how will one come to know which points are cut-out from the circle ?
  i fail to understand how can it be less than O(n) unless you store the
  given N points in a data structure ... where preprocessing itself
 involves
  O(N)...

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




 --
 AMRIT


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


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




-- 
AMRIT

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



Re: [algogeeks] Re: Best algorithm possible

2011-12-12 Thread amrit harry
@kay bigger number is 9918 not 9891...

On Mon, Dec 12, 2011 at 11:39 PM, Lucifer sourabhd2...@gmail.com wrote:

 @above..
 just to add to the above post... L(n) is basically reordering of the
 elements of A[n] which would produce the largest possible integer when
 read from L(0) to L(n).

 On Dec 12, 11:07 pm, Lucifer sourabhd2...@gmail.com wrote:
  Thinking on the same lines:
 
  1) First sort the array in descending order.. A[n]
 
  2) Use the following equation solve the prob:
  L(n) = the largest no. that can be formed by placing the A[n] in
  (n-2) possible positions of L(n-1)...
 
  Complexity : O(nlogn) + O(n^2)
 
  What do u guys think?
 
  On Dec 12, 10:23 pm, KAY amulya.manches...@gmail.com wrote:
 
 
 
 
 
 
 
   @sravan- Sorting would fail in this case:
   consider   8,91, 9
   sorting in desc order is going to give us 91, 9, 8.
   printing this is going to give us 9198.
   However, a bigger number can be formed 9891.
 
   After sorting lexicographically, we have to consider whether tied
   elements in list can be combined with other elements such that the new
   number is bigger than the lexicographically biggest number...
   for eg, 91,9,8,
   91 and 9 are tied because the most significant digit is the same 9.
   now is there any single digit number in the sorted list(because 91 is
   2 digits long), such that when concatenated with 9, gives a number
   bigger than 91(which is head of the list)..
   if u think carefully, this single digit number would have to be the
   next single digit number in the sorted list...
 
   Can this algo be improved?
 
   On Dec 12, 9:00 pm, Lucifer sourabhd2...@gmail.com wrote:
 
+1 @sravan
 
On Dec 12, 8:55 pm, sravanreddy001 sravanreddy...@gmail.com wrote:
 
 Sort the numbers based on the 'index_position' (starting at most
 significat
 digit) -- a modified version of MSD radix to be used.
 
 or sort the numbers as sorting the strings,  (print all in desc
 order).- 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
AMRIT

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



Re: [algogeeks] Given a int N, write a function to return the closest Fibonacci Number

2011-11-20 Thread amrit harry
nyone pls xpalin the  algo

On Sun, Nov 20, 2011 at 2:39 PM, kartik sachan kartik.sac...@gmail.comwrote:

 yup using matrix method we can solve it in O(log(n)).

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




-- 
AMRIT

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



Re: [algogeeks] Given a int N, write a function to return the closest Fibonacci Number

2011-11-20 Thread amrit harry
ThnQ...

On Sun, Nov 20, 2011 at 3:32 PM, Amol Sharma amolsharm...@gmail.com wrote:

 http://www.geeksforgeeks.org/archives/10120 have a look at method 5 in
 this article...they have explained quite well
 --


 Amol Sharma
 Third Year Student
 Computer Science and Engineering
 MNNIT Allahabad
 http://gplus.to/amolsharma99 
 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99





 On Sun, Nov 20, 2011 at 3:29 PM, amrit harry dabbcomput...@gmail.comwrote:

 nyone pls xpalin the  algo


 On Sun, Nov 20, 2011 at 2:39 PM, kartik sachan 
 kartik.sac...@gmail.comwrote:

 yup using matrix method we can solve it in O(log(n)).

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




 --
 AMRIT


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


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




-- 
AMRIT

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



[algogeeks] Silly question

2011-11-20 Thread amrit harry
i have a silly question to ask.
im gud in ALGO and gud in DATA STR. but i can solve a problem if i
know the algorithm or if earlier faced it.
i can't able to think my own logics and solve new mathematical
problems. even i dont know about how to come up with new TEST DATA. i
knw we can develop this skill only by practice. but is there any
method or steps to be followed during solving a problem?

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

2011-10-28 Thread amrit harry
let this statement int x=100,y=5;printf(%*d,x,y);
in this line first x is assign to '*' and it become %100d
and it will padd 100 spaces before print. and if we use( %*d,x)
then x is assign to '*' and garbage value wud be printed.

On Fri, Oct 28, 2011 at 8:53 PM, annarao kataru kataruanna...@gmail.comwrote:

 can u plz tell me what exactly %*d  means?

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




-- 
AMRIT

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



Re: [algogeeks] Code it...

2011-10-16 Thread amrit harry
use a file...every time we run it... get number from file increment it print
it and again replace back to filedats it.

On Sat, Oct 15, 2011 at 3:56 PM, kumar raja rajkumar.cs...@gmail.comwrote:


 you have to write a program which tell about how many times it has run.
 ex:
 if you run first time it will print 1.
 if you run second time it will print 2.
 like this.

 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in


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




-- 
AMRIT

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



Re: [algogeeks] Re: rise and fall of power

2011-10-04 Thread amrit harry
we have to find X^N let it would be N
YlogX=log(N)
antiLog(YlogX)=N
antilog for base 10 is power of 10
so 10^(YlogX)=N
and if we want to find  3^5
pow(10,5log3)--- pow(10,2.3856062735)=243
and if u want to find first 2 digits pow(10,(2.3856062735-1))=24.3=24

On Tue, Oct 4, 2011 at 1:46 AM, sunny agrawal sunny816.i...@gmail.comwrote:

 For Last K Gene has posted the right Approach.
 For First K
 Hint : Logarithms log(N^N) = NlgN

 On Tue, Oct 4, 2011 at 1:14 AM, Gene gene.ress...@gmail.com wrote:

 I have not done this, so I'm not sure.  But there are some tricks.

 You can first break up the computation to exploit repeated squaring.
 Rather than n-1 multiplications, you can get away with log_2 n by
 computing

 n_1 = n^2
 n_2 = n_1^2
 n_3 = n_2^2
 so that n_i = n^{2^i}
 for i=1..N where n_N = n and n_{N+1}  n

 Let b_i be the i'th bit of n.

 Then n^n = product_{ i | b_i = 1 } ( n_i )

 Now as you say you can't afford to do the full multiply.  So you'll
 need two arbitrary precision multiplication algorithms keeping k
 digits of precision each.  The first is easy.  Compute n^n as above
 modulo 10^k (always throwing away higher order digits) to get the last
 k digits.

 The high order digits is the tricky part.  I think the basic idea is
 to implement floating point yourself.  I.e. keep k+some extra digits
 of mantissa plus an exponent to show where the decimal place is.  The
 problem is you always need to keep enough extra digits beyond k to be
 sure rounding up won't affect to top k.  There should be simple
 algorithm to determine when you can stop.

 Or you can take a chance and count on the fact that the probability of
 carry out is limited for each digit, so with about 30 extra digits the
 chances are pretty close to zero.


 On Oct 3, 8:18 pm, g4ur4v gauravyadav1...@gmail.com wrote:
  can anyone please help me on how to approach this problem=
 http://www.codechef.com/problems/MARCHA4

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




 --
 Sunny Aggrawal
 B.Tech. V year,CSI
 Indian Institute Of Technology,Roorkee


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




-- 
AMRIT

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



Re: [algogeeks] Find lowest common ancestor of Binary Tree

2011-09-28 Thread amrit harry
http://community.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor
chk it out..

On Wed, Sep 28, 2011 at 11:04 AM, sukran dhawan sukrandha...@gmail.comwrote:

 it has already been discussed .. search in the archives

 On Wed, Sep 28, 2011 at 10:57 AM, Ankuj Gupta ankuj2...@gmail.com wrote:

 Find lowest common ancestor of Binary Tree

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


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




-- 
AMRIT

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



[algogeeks] What is the maximum no. of arguments that can be given in a command line in C...??

2011-09-23 Thread amrit harry
solve it.

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



Re: [algogeeks] What is the maximum no. of arguments that can be given in a command line in C...??

2011-09-23 Thread amrit harry
R U SUREI DONT THINK SOO...? HAD U CHKED IT...?

On Fri, Sep 23, 2011 at 7:58 PM, rahul sharma rahul23111...@gmail.comwrote:

 two

 On Fri, Sep 23, 2011 at 7:25 PM, amrit harry dabbcomput...@gmail.comwrote:

 solve it.

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


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




-- 
AMRIT

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



Re: [algogeeks] easy c output....

2011-09-22 Thread amrit harry
@balaji +1 :)

On Thu, Sep 22, 2011 at 2:01 PM, Anil Arya anilarya...@gmail.com wrote:

 thanx Balaji:)


 On Thu, Sep 22, 2011 at 6:07 AM, Balaji balaji.subraman...@gmail.comwrote:

 Hi Anil,

 #a is a preprocessor operator to convert the argument specified as string
 or enclosing in double quotes. so, after macro expansion, the printf
 statement would become

 printf(%d\n,*432); =

 printf(%d\n,432[0]);=

 printf(%d\n,*4);

 which prints the ASCII equivalent 52.


 Similarly, using printf(%d\n, 432[1]),printf(%d\n, 432[2]) would 
 yield 52 and 51 respectively. Let me know.


 Thanks,

 Balaji



 On Wed, Sep 21, 2011 at 4:34 PM, Anil Arya anilarya...@gmail.com wrote:





 #includestdio.h

 #define  power(a) #a

 int main(){printf(%d\n,*power(432));return 0;}

 why it is giving 52 as output?





 --
 *Anil  Arya,
 Computer Science *
 *Motilal Nehru National Institute of Technology,Allahabad .
 *


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


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




 --
 *Anil  Arya,
 Computer Science *
 *Motilal Nehru National Institute of Technology,Allahabad .
 *


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




-- 
AMRIT

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



[algogeeks] SPOJ problem

2011-09-17 Thread amrit harry
http://www.spoj.pl/problems/POUR1/
hw the 2nd given test is correct.

2
3
4
first we fill 3 littre jar with water and put into 4 littre jar den
again fill 3 littre and pour it in 2 littre remaining water in jar is
1 littre put it into 4 littre and we can measure 4 littre of water den
why answer is -1...?

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



Re: [algogeeks] Re: SPOJ problem

2011-09-17 Thread amrit harry
@dave +1

On Sat, Sep 17, 2011 at 8:10 PM, Dave dave_and_da...@juno.com wrote:

 @Amrit: You only have 2 and 3 litre jars. You are trying to get 4
 litres into one of them. There is no 4 litre jar, nor any other vessel
 into which you can capture the 4 litres.

 Dave

 On Sep 17, 6:15 am, amrit harry dabbcomput...@gmail.com wrote:
  http://www.spoj.pl/problems/POUR1/
  hw the 2nd given test is correct.
 
  2
  3
  4
  first we fill 3 littre jar with water and put into 4 littre jar den
  again fill 3 littre and pour it in 2 littre remaining water in jar is
  1 littre put it into 4 littre and we can measure 4 littre of water den
  why answer is -1...?

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




-- 
AMRIT

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



Re: [algogeeks] Re: Thoughtworks and Tejas network

2011-09-14 Thread amrit harry
dey would only look for OPPS concept with proper working knowledge and DB
concepts..

On Tue, Sep 13, 2011 at 8:15 PM, Brijesh brijeshupadhyay...@gmail.comwrote:

 yes..please anyone post questions asked in  thoughtworks interview

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




-- 
AMRIT

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



Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread amrit harry
Euclid's GCD Algorithm:
http://www.cs.berkeley.edu/~vazirani/s99cs170/notes/lec3.pdf

On Sat, Sep 10, 2011 at 8:54 PM, Neha Singh neha.ndelhi.1...@gmail.comwrote:


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




-- 
AMRIT

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



Re: [algogeeks] tree traversal

2011-09-10 Thread amrit harry
level order and spiral traversing

On Sat, Sep 10, 2011 at 9:27 PM, sukran dhawan sukrandha...@gmail.comwrote:

 level order traversal

 On Sat, Sep 10, 2011 at 10:48 AM, ravi maggon maggonr...@gmail.comwrote:

 give some traversal other then pre,in and post order to print all elements
 of tree?
 Asked in informatica interview.

 --

 Regards
 Ravi Maggon
 Final Year, B.E. CSE
 Thapar University

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


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




-- 
AMRIT

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



Re: [algogeeks] tree traversal

2011-09-09 Thread amrit harry
there is one more way  called as.. Level order traversing or spiral
traversing google this term u will find a new method.

On Sat, Sep 10, 2011 at 11:08 AM, ravi maggon maggonr...@gmail.com wrote:

 can u elaborate its algo


 On Sat, Sep 10, 2011 at 10:58 AM, Shravan Kumar shrava...@gmail.comwrote:

 zigzag, level by level ?

 On Sat, Sep 10, 2011 at 10:48 AM, ravi maggon maggonr...@gmail.comwrote:

 give some traversal other then pre,in and post order to print all
 elements of tree?
 Asked in informatica interview.

 --

 Regards
 Ravi Maggon
 Final Year, B.E. CSE
 Thapar University

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


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




 --

 Regards
 Ravi Maggon
 Final Year, B.E. CSE
 Thapar University

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




-- 
AMRIT

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



Re: [algogeeks] DE shaw question- urgent

2011-09-05 Thread amrit harry
hey guys fro where i can find open source project to workon??

On Mon, Sep 5, 2011 at 9:44 PM, sukran dhawan sukrandha...@gmail.comwrote:

 for singletion class


 On Mon, Sep 5, 2011 at 9:42 PM, Sanjay Rajpal srn...@gmail.com wrote:

 I think when we have to create a singleton class, we can use private
 constructor. Objects of such classes can be constructed using static
 functions that can be accessed using class name and scope resolution
 operators. This is useful because user can create only one object of that
 class, which is sometimes required.

 other case might be using static functions, but return a new object each
 time. We can also keep a limit on the no. of objects that can be created for
 a class.


 Sanju
 :)



 On Mon, Sep 5, 2011 at 9:06 AM, Neha Singh neha.ndelhi.1...@gmail.comwrote:

 When do u hv a private constructor for a class ???
 How to create an object of such a class ??
 What's its utility ??


 Anyone plz explain asap??

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


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


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




-- 
AMRIT

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