[algogeeks] sum of primes

2010-09-23 Thread Debajyoti Sarma
How to find the sum of prime numbers between 1 and 1. I don't expected traversal of the whole range and find primes and sum uping Any other logic is there?? i think we need deep mathematics for this . -- You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] Re: How to print path of a node

2010-09-08 Thread Debajyoti Sarma
@Adam input : root node address of the tree and root address of the node to be searched. assume depth of the tree is also given. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com.

[algogeeks] Re: How to print path of a node

2010-09-08 Thread Debajyoti Sarma
@ Yan Wang superb idea ! how much will be time space complexity? but actually i was expecting any solution without modifying the tree. If a tree {value,lptr,rptr} is given then we have to create another tree or temp-array to represent parent. any sort of recursion will help?? -- You received

[algogeeks] How to print path of a node

2010-09-07 Thread Debajyoti Sarma
How to print the path from root to a specific node in a binary tree?? I want to store the path in a array[] of node*. can it b done in O(n) or less? Remember it's not BST. 1 / \ 2 3 / \ / \ 4 5 67 / \/ \

[algogeeks] Re: call google search from a java program

2010-09-04 Thread Debajyoti Sarma
thanks to all -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this

[algogeeks] call google search from a java program

2010-09-01 Thread Debajyoti Sarma
Hi , I am working on a project where i need to call Google search form a Java servlet program.1 string containing the query is supposed to pass to the Google search engine and results must display through my program .I am also trying to copy the top results and some text(first 2-3 lines what

[algogeeks] Re: Adobe Questions

2010-08-20 Thread Debajyoti Sarma
what is actually spiral traversal ??? can any please give sample tree and spiral traversal . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send

[algogeeks] Alternative merge

2010-08-15 Thread Debajyoti Sarma
Array of 2n length is given {a1,a2,a3,...,an,b1,b2,b3,...,bn} we have to make the array like as {a1,b1,a2,b2,a3,b3,...,an,bn} without using extra buffer space. here a solution i came up with http://codepad.org/ub5Ie4sI I know this was discussed before . But i want to know the time complexity of

Re: [algogeeks] Re: algorithm

2010-07-31 Thread Debajyoti Sarma
why u have chosen that 23 ? why dividing by 3 ? don't understand the logic. Please explain so that it become understandable. On 7/31/10, Dave dave_and_da...@juno.com wrote: Use the rejection method... int rand7() { int i; do i = 5 * rand5() + rand5() - 3; while( i 23

[algogeeks] Re: BST

2010-07-25 Thread Debajyoti Sarma
@rahul how to convert bst ot doubly linked list. I m understanding the logic but not able to code give a pseudo code to understand. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: unset leftmost bit

2010-07-23 Thread Debajyoti Sarma
for(i=sizeof(int)*8-1;i=0;i--) { if((numberi)1) { number=number^(1i); break; } } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

[algogeeks] XOR list

2010-07-16 Thread Debajyoti Sarma
how to implement xor list ? i.e. doubly linked list using single pointer . I don't understand how we can write code insertion deletion (beginning,end,middle ) traversing ( forward and backward ) Please give a easy code(C) to understand. -- You received this message because you are subscribed

[algogeeks] Google Interview Question

2010-07-14 Thread Debajyoti Sarma
An array contains the set of positive integer. Find the largest number c such that c=a+b where a,b,c are distinct number of the set? [Consider , reducing complexity] -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] Re: partition a number

2010-07-12 Thread Debajyoti Sarma
@Gene Please explain the recursive function and the first if condition i m not getting it. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group,

[algogeeks] Re: Sub-2Dmatrix maximum

2010-07-11 Thread Debajyoti Sarma
I was talking about this approach. for( left_top_i=0 ; left_top_irow_no ; left_top_i++ ) for( left_top_j=0 ; left_top_jcol_size ; left_top_j++ ) for( bottom_right_i=left_top_i ; bottom_right_irow_size ; bottom_right_i++ ) for( bottom_right_j=left_top_j ; bottom_right_jrow_size ; bottom_right_j++

[algogeeks] Re: seg fault

2010-06-22 Thread Debajyoti Sarma
i don't understand what this statement will do ? scanf(%2d%3d,a,b); -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] c code.....explaine output

2010-06-20 Thread Debajyoti Sarma
p=(char *)a; this statement assigns value of 7 to p after type converting to char*, so as p is a pointer it points to memory location 7 p[b] will give to the value at location 9 same as *(p+b) = *(7 + 2) just like array p[b] will give the address of that location i.e. 9 which is char* so we type

Re: [algogeeks] Re: Endian-ness check

2010-06-15 Thread Debajyoti Sarma
@ souravsain Don't understand your solution. if u type convert to char how u can say that msb is in higher memory address? i think (char) will alway give the value of the lsb. How u r checking endian ness? normal endian ness check program main() { int i=1; char *p=(char*)i; if(*p==1) printf(Small

Re: [algogeeks] Re: unique number in an array

2010-06-15 Thread Debajyoti Sarma
@jalaj jaiswal given array contain 3,6 both r unique. Is this the exact question? if array is 6,3,4,1,4,5,6,1,5 than we can solve using xor properties. int a,b=5; a=b^b; //value of a is 0 convert in binery form and do u will get a=0^a;//value of a is a itselt Program:

Re: [algogeeks] Best method to choose a quadrant

2010-06-15 Thread Debajyoti Sarma
Don't understand the question. explain differently. On 6/14/10, siddharth srivastava akssps...@gmail.com wrote: I have this code snippet: This code snippet defines a boundary coordinates on the screen wrt to the center(of the screen). if( x x_center ) x_border = x_center -

Re: [algogeeks] bits

2010-06-13 Thread Debajyoti Sarma
1. i think if the total no of bits is within no of bits in a int , the size will b same as int . here total bits 3 32 (bits in int according to gcc, in Turbo c its 16) so size of structure will be 4(in gcc), 2 (in TC) if total no of bits is 40 (suppose) than size will be 8(in GCC) , 4(in TC)

Re: [algogeeks] Derivation

2010-06-11 Thread Debajyoti Sarma
Its not a tough question.Basic arithmetics/algebra question. ACB Suppose speed of train from A =x Suppose speed of train from B =y They meet at C 1st train take a sec to reach C from B CB=ax 2nd train take b sec to reach C from A CA=bx Time taken for

Re: [algogeeks] Re: binary nos

2010-06-11 Thread Debajyoti Sarma
0,1,01000,00100,00010,1,10100,10010,10001,01010,01001,00101,10101 no of sequence =13 so its coming in fibo no. no of sequence =fibo(n+2)if you exclude 0 from fibo no no of sequence =fibo(n+3)if you include 0 in fibo no On Fri, Jun 11, 2010 at 1:55 PM, Debajyoti Sarma sarma.debajy...@gmail.comwrote

Re: [algogeeks] Re: binary nos

2010-06-11 Thread Debajyoti Sarma
and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Wed, Jun 9, 2010 at 2:37 PM, Debajyoti Sarma sarma.debajy...@gmail.com wrote: First 20 fibo no as follows with binary form 0 = 0 1 = 1 1 = 1 2 = 10 3 = 11 5 = 101 8

Re: [algogeeks] Re: binary nos

2010-06-09 Thread Debajyoti Sarma
First 20 fibo no as follows with binary form 0 = 0 1 = 1 1 = 1 2 = 10 3 = 11 5 = 101 8 = 1000 13 = 1101 21 = 10101 34 = 100010 55 = 110111 89 = 1011001 144 = 1001 233 = 11101001 377 = 10001 610 = 1001100010 987 = 011011 1597 = 1100001 2584 = 10111000 4181 =

Re: [algogeeks] Which doors will be open?

2010-05-31 Thread Debajyoti Sarma
because, only the perfect square number has odd number of factors. so, toggling will make those door to remain open. Like open-close-open-close-open (odd no of toggle) On 5/31/10, sharad kumar aryansmit3...@gmail.com wrote: @veera:only the perfect square numbers will be open 1,4,9,16,25...100