Re: [algogeeks] xoring

2010-07-13 Thread Ashish Goel
what if the numbers are {0,1,2,3,4,5,6,7} no entry in A1 group!! anything better than O(n2)?? Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, Jul 12, 2010 at 3:32 PM, ankur aggarwal wrote: > i can give an idea.. > start

Re: [algogeeks] Phone Numbers Yet Again!!!

2010-07-12 Thread ashish agarwal
@amit..can you little explain this On Mon, Jul 12, 2010 at 4:50 PM, Amir hossein Shahriari < amir.hossein.shahri...@gmail.com> wrote: > this can be done in O(n) using DP: > > for (i=n-1;i>=0;i--){ > > dp[i]=max(dp[i+2],dp[i+3]); // usual > if (a[i]==a[i+1]) // excellent size 2 > > dp[i]=ma

Re: [algogeeks] graph

2010-07-12 Thread ashish agarwal
@anand ..can you explain it more with example On Mon, Jul 12, 2010 at 10:19 AM, Anand wrote: > topological sort would cover every vertex once. The path given by > Topological sort would be the answer. We can also calculate the vertices > given by topological sort and compare it with given vertic

Re: [algogeeks] algorithm to draw a line

2010-07-12 Thread ashish agarwal
draw a line or equation of a line? On Mon, Jul 12, 2010 at 4:38 PM, Anand wrote: > 2 coordinate points p(x,y)and q(x,y) are given and write an algorithm to > draw aline > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this

Re: [algogeeks] sort in O(n)

2010-07-11 Thread ashish agarwal
this is called k-toinc sorting...solution is very easy for this..you can check topcoder forum On Sun, Jul 11, 2010 at 6:43 AM, srikanth sg wrote: > Given an array of size n wherein elements keep on increasing > monotically upto a certain location > after which they keep on decreasing monotically,

Re: [algogeeks] solutions?

2010-07-11 Thread ashish agarwal
solution for topcoder all available but not others On Sun, Jul 11, 2010 at 2:19 AM, venkat kumar wrote: > are solutions available for problems in > spoj,uva,codedhef,topcoder,etc.etc.?pls tell me > tnkyou > > -- > You received this message because you are subscribed to the Google Groups > "Algori

[algogeeks] data structure for large no stroage

2010-07-10 Thread ashish agarwal
a) Design a data structure to store an arbitrarily large number b) How will you use it to store two such number and add them. c) Write down the class (code) for the data structure -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to thi

Re: [algogeeks] Sort

2010-07-10 Thread ashish agarwal
for sort you have to traverse array atleast once ..and after it some sorting procedure will come. On Fri, Jul 9, 2010 at 12:55 PM, Devendra Pratap Singh < dpsingh.ii...@gmail.com> wrote: > plz write a code to > > Sort n integer in the range 1 to n^2 in O(n) > > -- > You received this message bec

Re: [algogeeks] Array Reconstruction

2010-07-09 Thread Ashish Goel
ase of 5 numbers {1,2,3,4,5} > P={3,4,5,6,5,6,7,7,8,9} > 5C2=10 so n=5 > > //b+c+b+d+b+e+c+d+c+e+d+e=3b+3c+3d+3e > for (int i=0;i {sumX+=p[i];} > > for (int j=i+1;j sumY+=p[j]; > sumY=sumY/(n-2); > a[0]=(sumX-sumY)/(n-1); > > using this rest of the numbe

Re: [algogeeks] Array Reconstruction

2010-07-09 Thread Ashish Goel
nC2 possibilities so n can be found using nC2=say6 then n=4 a+b=p0 a+c=p1 a+d=p2 b+c=p3 b+d=p4 c+d=p5 3a+b+c+d=po+p1+p2 b+c+d=(p3+p4+p5)/2 so a= (2(p0+p1+p2)-p3-p4-p5)/6 take case of 5 numbers {1,2,3,4,5} P={3,4,5,6,5,6,7,7,8,9} 5C2=10 so n=5 //b+c+b+d+b+e+c+d+c+e+d+e=3b+3c+3d+3e for (int

Re: [algogeeks] HIEGHT

2010-07-09 Thread Ashish Goel
http://www.daniweb.com/code/snippet216621.html decent code Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Fri, Jul 9, 2010 at 3:35 PM, UMESH KUMAR wrote: > > > * find height of BINA

Re: [algogeeks] HIEGHT

2010-07-09 Thread Ashish Goel
for loop will terminate at root only Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Fri, Jul 9, 2010 at 10:42 PM, Balaji wrote: > Here is one other way: > > Planning to do a level order traversal using a Queue and a s

Re: [algogeeks] HIEGHT

2010-07-09 Thread Ashish kumar Jain
struct node *templ=root; while(temp1 && templ->left) { templ= templ->left; hl++; } while(root && root->right) { root=root->right; hr++; } return (hl>hr ?(hl+1):(hr+1)); } Thanks and Regards, Ashish On Thu, Jul 8, 2010 at 9:18 PM, jal

Re: [algogeeks] HIEGHT

2010-07-09 Thread Ashish kumar Jain
I made a mistake here.I traversed only the leftmost and the rightmost branches.We need to use stack here. On Fri, Jul 9, 2010 at 11:15 AM, Ashish kumar Jain wrote: > Here is the Iterative function: > > //Function to compute height of a binary tree iteratively > > int GetHeight(st

Re: [algogeeks] Re: adobe problem---array

2010-07-09 Thread Ashish Goel
still thinking... Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Fri, Jul 9, 2010 at 1:10 AM, Anand wrote: > One more approach using XOR to find the element repeated thrice. > Complexity: O(n). > Space :0 > > http:/

Re: [algogeeks] microsoft.

2010-07-08 Thread Ashish Goel
@Priyanka : using my logic, 2,-3,5,4,1,3... 2,-3,-5,4,1,3.. 2,-3,-5,4,-1,3.. -2,-3,-5,4,-1,3.. now -3 implies 3 is the answer to be honest, i hate to ask or be asked such question in interviews :) Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +91

Re: [algogeeks] microsoft.

2010-07-08 Thread Ashish Goel
a[i]; a[i] *=-1; } return -1; //** Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Thu, Jul 8, 2010 at 1:32 PM, Priyanka Chatterjee wrote: > > > I totally agree with Umesh's algo which gives O(K+1) time

Re: [algogeeks] Array with 0 and 1

2010-07-08 Thread Ashish Goel
can you clarify ratnesh please i was thinknig on these lines... int temp=0; int rowcount=0; for (int row=0;rowwrote: > for(i=0 to n-1) > if( binarysearch(i,n-1,1) + 1) > count++ > print count. > binarysearch(first,last,item) > if(1 is there) > return mid > else > return -1. > similarly w

Re: [algogeeks] Re: Approximate String Matching Algorithm

2010-07-07 Thread Ashish Goel
the approach came just from the top of my head :) please check suffix trie @ http://www.allisons.org/ll/AlgDS/Tree/Suffix/ if you understand this as well as levensthien distance concept, you would understand how i thought of this solution Best Regards Ashish Goel "Think positive and find

Re: [algogeeks] ipc

2010-07-07 Thread Ashish Goel
please give the reference whereby the shared memory & kernel stack relation is stated Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Wed, Jul 7, 2010 at 1:24 PM, harit agarwal wrote: > they use only direct blocks to store th

Re: [algogeeks] ipc

2010-07-06 Thread Ashish Goel
shared memory not an ipc mechanism?? please get your fundamentals correct refer galvin or boveti or comer Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Jul 6, 2010 at 5:29 PM, harit agarwal wrote: > shared memory processin

Re: [algogeeks] microsoft.

2010-07-06 Thread Ashish Goel
have a hash map trace through all the elements to store the count now trace through the array again and return the element whose count is found to be 2 as the first repeating element Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On

Re: [algogeeks] adobe problem---array

2010-07-06 Thread Ashish Goel
i thought the same way, but in this case 4 is being repeated twice, but is not nullified it is ctually getting nullified, but it is indeed contributing to bit 2 so how do i rule out 4 here? Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +9199660

Re: [algogeeks] amazon:-

2010-07-06 Thread Ashish Goel
use levenstein distance algo http://en.wikipedia.org/wiki/Levenshtein_distance Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Jul 6, 2010 at 9:30 PM, sharad kuma r wrote: > Given a string A, and a string B, and a dictiona

Re: [algogeeks] adobe problem---array

2010-07-06 Thread Ashish Goel
Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, Jul 5, 2010 at 7:18 PM, jalaj jaiswal wrote: > Given an array of integers where some numbers repeat 1 time, some numbers > repeat 2 times and only one number repeats 3 times, how do you find t

Re: [algogeeks] google

2010-07-06 Thread Ashish Goel
time Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Wed, Jul 7, 2010 at 9:54 AM, Anand wrote: > Since cache can only store the last n requests, Insert the n+1th > request in the cache and delete one of the older requests f

Re: [algogeeks] Need algorithm for Hot data identification

2010-07-06 Thread Ashish Goel
you are right refer http://en.wikipedia.org/wiki/Bloom_filter Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Jul 6, 2010 at 10:22 AM, Prashanth wrote: > Hi all! > > A disk is divided into large number of blocks

Re: [algogeeks] Plz help with multidimensional array

2010-07-06 Thread Ashish Goel
char name[][10] is a auto variable on stack, so no pointers here Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Wed, Jul 7, 2010 at 9:10 AM, UMESH KUMAR wrote: > > char name[][10]={"jan","feb","

Re: [algogeeks] memory usage

2010-07-06 Thread Ashish Goel
you enter a function say main, and then where ever you want an estimate, declare an auto variable and print its address canary concept is also good to make the fundamentals http://en.wikipedia.org/wiki/Stack_buffer_overflow Best Regards Ashish Goel "Think positive and find fuel in fa

Re: [algogeeks] isr

2010-07-06 Thread Ashish Goel
as i understand ISR has two parts, critical and deferable, so when the isr comes, keep this critical part small, need to get into Linux 2.6 kernel to understand this how is this handled Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On

Re: [algogeeks] google

2010-07-06 Thread Ashish Goel
chois, the average response time is very high when someone says that the three operations be in O(1), it is just not possible, even in hashmap, that is not possible with linked list or array or whatever implementation Best Regards Ashish Goel "Think positive and find fuel in failure" +91

Re: [algogeeks] ipc

2010-07-06 Thread Ashish Goel
above all shared memory, refer galvin, once memory is shared, it is quite fast whereas for message passing, system calls are required Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Jul 6, 2010 at 8:43 AM, sharad kumar wrote:

Re: [algogeeks] Need good hashing implementations in Linux (C/C++)

2010-07-06 Thread Ashish Goel
refer burtleburtle.net Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Jul 6, 2010 at 3:28 PM, Prashanth wrote: > Hi all! > > I need some good hash implementations. I am able to find couple of > them but I do

Re: [algogeeks] Re: graphs again

2010-07-06 Thread Ashish Goel
oops, my warshall algo will simply tell if there exists a path or not!! to find if the path exist between two nodes of length K in O(K) is interesting..i donot understand the logic of this problem, why of length k in O(k), any real problem on this? Best Regards Ashish Goel "Think positiv

Re: [algogeeks] google

2010-07-06 Thread Ashish Goel
down) so under such conditions, a DLL is the best Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Jul 6, 2010 at 10:36 AM, Anand wrote: > @topojoy. > > Why do we need linked list. We are use an array of struct which st

Re: [algogeeks] malloc implementations

2010-07-05 Thread Ashish Goel
http://g.oswego.edu/dl/html/malloc.html Inbox X Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Jul 6, 2010 at 2:03 AM, rahul rai wrote: > http://www.youtube.com/user/StanfordUniversity#p/c/9D558D49CA734A02 > > >

Re: [algogeeks] Longest palindrome in a given str (less than O(n^2) )

2010-07-05 Thread Ashish Goel
refer http://www.allisons.org/ll/AlgDS/Tree/Suffix/ this would be at most O(n) Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, Jul 5, 2010 at 10:45 PM, vijay wrote: > Longest palindrome in a given str (less than O(n^2) ) &

Re: [algogeeks] sum of subsequence

2010-07-05 Thread Ashish Goel
please share the algo in words also, it takes a bit to understand the code otherwise Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, Jul 5, 2010 at 11:45 AM, Anand wrote: > Here is one more approach: > http://codepad.org

Re: [algogeeks] Re: amazon

2010-07-05 Thread Ashish Goel
nts forming string with equal zeros and 1s but htis is again o(n square) (: Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, Jul 5, 2010 at 5:19 PM, Sateesh Pragallapati < sateesh2sm...@gmail.com> wrote: > I have 0(N) so

Re: [algogeeks] Re: numbers

2010-07-05 Thread Ashish Goel
i fail to understand how can you give a pointer to a bit which is not starting at the word boundary? Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, Jul 5, 2010 at 7:24 PM, Siddhi wrote: > i think 2 digit combination switc

Re: [algogeeks] Re: amazon

2010-07-05 Thread Ashish Goel
yes, i realised, there need to be one more for loop say over j for start position taking values 1->n the second for loop as used should start from i=j to n so essentially it becomes nsquare Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +91996600

Re: [algogeeks] common question(amazon)

2010-07-05 Thread Ashish Goel
do it something like this 1,2,3,4,5,6, 7,8 swap 4,5 1,2,3,5,4,6,7,8 swap 3,5 and 4,6 1,2,5,3,6,4,7,8 now swap 3,6 and 2,5 and 4,7 1,5,2,6,3,7,4,8 the idea is to bri Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, J

Re: [algogeeks] Re: number of 1's

2010-07-04 Thread Ashish Goel
in general, preprocessing is preferred over run time calculation hence i would have he number of bits on a platform known/calculated upfront and then use the log n algo Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, Jul 5, 20

Re: [algogeeks] graphs again

2010-07-04 Thread Ashish Goel
i would prepare the transitivity matrix while inserting the edge into the matrix the search then would be a O(1) Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sun, Jul 4, 2010 at 3:15 PM, jalaj jaiswal wrote: > A graph is given

Re: [algogeeks] Re: number of 1's

2010-07-04 Thread Ashish Goel
the looping algo in the worst case can be o(n) whereas the anding with 0x555 and so on is a log n algo :) Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sun, Jul 4, 2010 at 10:21 AM, shrinivas yadav wrote: > it is easy > int

Re: [algogeeks] Re: n-ary

2010-07-04 Thread Ashish Goel
additionally the space usage can be optimized by using adjacency list Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sun, Jul 4, 2010 at 11:49 AM, ashgoel wrote: > wouldn't the inorder and postorder traversals sufficient?

Re: [algogeeks] sum of subsequence

2010-07-04 Thread Ashish Goel
knapsack problem alternate :sort the array keep two pointers one from start one from end move inwards till the sum is k (move start pointer if the sum k Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sun, Jul 4, 2010 at 11:46 PM, jal

Re: [algogeeks] Yahoo

2010-07-04 Thread ashish agarwal
it will be 1:1 because probability of guy is 1/2+1/2*1/2+1/2*1/2*1/2.=1 and girls and boys has same probability On Sun, Jul 4, 2010 at 6:00 AM, jalaj jaiswal wrote: > yeah 1:1 > > On Sun, Jul 4, 2010 at 4:57 PM, Amit Jaspal wrote: > >> it will be 1:1 >> >> >> On Sun, Jul 4, 2010 at 4:50 PM,

Re: [algogeeks] google favourite ques

2010-07-03 Thread ashish agarwal
ur browser is a application which uese aplication layer protocol which is HTTP But to formulate packet it needs to find out port and mac address and ip-address to which it wanst to sentd this request so that it can pass these information to lower layer protocol like TCP and IP so, now it send

Re: [algogeeks] amazon question

2010-07-03 Thread ashish agarwal
We can do 4 type of treversal. If we do inorder then we will get sorted array .If we do an inorder traversal then we would get a sorted list which if we convert into a BST would again become a list and we would loose out on the original structure of the tree. and same will be happen with post orde

[algogeeks] Some C language Problem

2010-07-01 Thread Ashish
Q.) How to create our own ? and Q) Can we insert a our function in the existing header file ?? -- 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, s

Re: [algogeeks] arrays

2010-06-27 Thread Ashish kumar Jain
nThe Value of count is:%d",count); return 0; } Regards, Ashish On Sun, Jun 27, 2010 at 9:59 AM, sharad kumar wrote: > Give an unsorted array find count of pairs of numbers[a,b] where a > b and > b comes after a in the array. > > Eg. {8,3,6,10,5} > > the count of suc

[algogeeks] Re: microsoft

2010-06-26 Thread Ashish
desired output. The only problem with the method is it requires extra space !!! Regards, Ashish On Jun 27, 6:18 am, Dave wrote: > j = 0 > for i = 1 to n >     if a(i) not equal 0 >         j = j + 1 >         a(j) = a(i) >     end if > end for > for i = j + 1 to n >    

Re: [algogeeks] c

2010-06-26 Thread Ashish kumar Jain
ence,it accepts this declaration for read-only variable 'x' which in this case cannot be changed. Regards, Ashish On Sat, Jun 26, 2010 at 11:09 AM, sharad kumar wrote: > pls c thz > > > On Sat, Jun 26, 2010 at 10:48 AM, sharad kumar wrote: > >> cos if u declare co

Re: [algogeeks] c

2010-06-26 Thread Ashish kumar Jain
("%d\n",x); return 0; } Output is 0 without any error. const and volatile can be used together with any storage class. Regards, Ashish On Sat, Jun 26, 2010 at 10:48 AM, sharad kumar wrote: > cos if u declare const u cant change na.but volatile changes na.so > practicall

Re: [algogeeks] c array

2010-06-25 Thread Ashish kumar Jain
ractice.c kt...@akjlab /cygdrive/f/Code/linux $ kt...@akjlab /cygdrive/f/Code/linux $ kt...@akjlab /cygdrive/f/Code/linux $ ./a.exe strings 8 7 7 Regards, Ashish On Fri, Jun 25, 2010 at 9:06 PM, Ashish kumar Jain wrote: > It is legal in ANSI C (and perhaps in a few pre-ANSI systems), thou

[algogeeks] Puzzle

2010-06-25 Thread ashish kumar
You have a DNA string that you wish to analyze. Of particular interest is which intervals of the string represent individual genes. You have a number of "gene predictions", each of which assigns a score to an interval within the DNA string, and you want to find the subset of predictions such that t

Re: [algogeeks] c array

2010-06-25 Thread Ashish kumar Jain
ran this piece of code.First thing should be that it is a pure .c file and not .cpp file. Had it been not the case and you ran it in C++ environment,then it will surely throw error for array bounds overflow. Regards, Ashish On Sun, Jun 13, 2010 at 3:03 PM, sankalp srivastava < richi.sanka

Re: [algogeeks]Numbers search in an array

2010-06-18 Thread Ashish Mishra
; -- > yezhu malai vaasa venkataramana Govinda Govinda > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send em

[algogeeks] Re: c output

2010-06-11 Thread Ashish
rom left to right as printf now is: printf("%d %d",6,2); Ashish Kumar Jain On Jun 11, 8:56 am, Rohit Saraf wrote: > c > 1 > 6,2 > > u might be expecting 5,1 if u are forgetting the newline character :) >

Re: [algogeeks] c output

2010-06-11 Thread Ashish kumar Jain
-- > 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 m

[algogeeks] infy color balls

2010-04-30 Thread Ashish Mishra
One of my friend ask me this n i am bad in P & C (will love if smone can provide me a link to learn it though) nyways prob is: there are infy color balls of k different color you are allowed to pick n balls out of those infy(infinite) balls cond is : you must have all k color balls with u obvious

Re: [algogeeks] MXN matrix

2010-04-30 Thread Ashish Mishra
; from (a, b) to (c, d) in O(1) >> >> for N*N matrix, Complexity is O(N^4) >> >> On 28 April 2010 13:36, Ashish Mishra wrote: >> >>> you are given a M x N matrix with 0's and 1's >>> find the matrix with largest number of 1, >>&

Re: [algogeeks] Build BST from binary tree without extra space

2010-04-28 Thread Ashish Mishra
eed to use extra space u have > to just ditach the node from binary tree and attach it in bst. > > On Wed, Apr 28, 2010 at 1:18 AM, Ashish Mishra > wrote: > > How to build BST from binary tree in place i.e without extra space ?? > > > > -- > > You received this

[algogeeks] MXN matrix

2010-04-28 Thread Ashish Mishra
you are given a M x N matrix with 0's and 1's find the matrix with largest number of 1, 1. find the largest square matrix with 1's 2. Find the largest rectangular matrix with 1's -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this

[algogeeks] Build BST from binary tree without extra space

2010-04-27 Thread Ashish Mishra
How to build BST from binary tree in place i.e without extra space ?? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+un

Re: [algogeeks] Re: Implement a queue using a stack

2010-04-14 Thread Ashish Mishra
>>> > > "Algorithm Geeks" group. >>> > >>>> > > To post to this group, send email to >>> algoge...@googlegroups.com. >>> > >>>> > > To unsubscribe from this group, send email to >>> > >>&

Re: [algogeeks] Finding all prime less than 10^8

2010-04-14 Thread Ashish Mishra
ou 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 >&

Re: [algogeeks] efficient backtracking algorithm for the coin changing problem

2010-04-10 Thread Ashish Mishra
y u need backtracking i think it can be done with DP On Sat, Apr 10, 2010 at 9:12 AM, «« ÄÑÜJ »» wrote: > Need help in designing efficient backtracking algorithm for the coin > changing problem. where a1, a2, an are the set of distinct coins > types, where each ai is an integer. and each type is

Re: [algogeeks] Finding youngest common ancestor of two nodes in a binary tree

2010-04-08 Thread Ashish Mishra
yup atul algo is correct (cur_data - node->right) * ( cur_data- node->left) < -1 for ancestors On Thu, Apr 8, 2010 at 10:19 AM, atul verma wrote: > Its very simple to solve this. > > Start from root. > > Compare the value of current node data value to both nodes. > > 1. if both are greater tha

Re: [algogeeks] Divide and Conquer problem

2010-04-08 Thread Ashish Mishra
Can it be done in more or less like merge sort way i.e 1. divide array into half 2. keep on doing it till u have two element left 3. arrang match between two and return winner On Wed, Apr 7, 2010 at 12:20 PM, «« ÄÑÜJ »» wrote: > Can any one help me with this problem > > > Its a divide and co

Re: [algogeeks] Finding youngest common ancestor of two nodes in a binary tree

2010-04-08 Thread Ashish Mishra
i think u mean lowest commen ancestor? On Wed, Apr 7, 2010 at 10:34 PM, Himanshu Aggarwal wrote: > For a given binary tree, given the root and two node pointers, how can we > find their youngest common ancestor. > > Say the node is like: > > struct node{ >int data; >struct node*l

Re: [algogeeks] Re: Largest span of Increasing Pair in an array

2010-03-14 Thread ASHISH MISHRA
@ankur how u can solve it in o(n) i suppose u need atleast o(n lgn) On Sun, Sep 6, 2009 at 2:52 PM, ankur aggarwal wrote: > o(n) is the best sol known to me.. > > > On Sun, Sep 6, 2009 at 1:54 PM, Pramod Negi wrote: > >> i guess sorting will do the work. >> any other constraint?? >> >> >> On Sun

Re: [algogeeks] Re: Merge two BST in O(n) time with O(1)

2010-01-29 Thread Ashish Meena
can choose tree for our step 1 accordingly. This algorithm doesnt need any extra memory and can be almost O(n), if BST3 and BST4 are very small trees. Does anybody see any issues with this approach? Regards, Ashish On Fri, Jan 29, 2010 at 2:52 PM, vivek bijlwan wrote: > @ shingray ... ca

[algogeeks] Re: function problem

2009-09-18 Thread ashish gupta
actually it depends upon whether condition (Awrote: > > 5. void foo1() > { > if(A Then {_/* */} > else > if(C then foo2() > } > How many time foo2() would get called given > A foo1() is called 5000 times > > > > --~--~-~--~~~---~--~~ You received this message b

[algogeeks] Re: probabiltiy + DP

2009-09-18 Thread ashish gupta
>0 > PH(j,0) = (1-P(1))(1-P(2))...(1-P(j)) > > PH(j,w) = PH(j-1,w) + PH(j-1,w-1)PH(j) > and equation should be PH(j, w) = PH(j-1,w) (1-P(j)) + PH( j-1, w-1) PH(j) pls correct if i am wrong... -- ashish > > Any comments? > > On Sep 9, 5:50 pm, Nagendra Kuma

[algogeeks] Re: nth number of k bits

2009-09-11 Thread ashish gupta
you will get the answer. Hope this explanation should work. On Fri, Sep 11, 2009 at 7:14 PM, amarnath . wrote: > can u please explain me the logic behind finding the next number? > > > On Fri, Sep 11, 2009 at 1:42 AM, ashish gupta wrote: > >> I think this should be ea

[algogeeks] Re: nth number of k bits

2009-09-10 Thread ashish gupta
I think this should be easy to understand. #include using namespace std; // this function generated next big number of the list having k bit set. unsigned next_number( unsigned x) { unsigned smallest, ripple, one; smallest = x & (-x); ripple = x + smallest ; one = ripple^x; one

[algogeeks] Re: Ebook needed

2009-07-31 Thread ashish anand
try searching in these websites http://www.hongkiat.com/blog/20-best-websites-to-download-free-e-books/ On Fri, Jul 31, 2009 at 3:20 PM, Anshya Aggarwal wrote: > *Hi, > > I need an ebook of "How to Solve It By Computer* by R. G. Dromey". If > anybody have the link or ebook please upload iht > > >

[algogeeks] Re: read html code of web page

2009-01-20 Thread Ashish Chugh
u can u use htmlparser api, or use http://java-source.net/open-source/crawlers/java-web-crawler On Tue, Jan 20, 2009 at 2:41 PM, Asheesh wrote: > > Can anyone tell me how to read html code of a web page using java > plz help me its urgent > i will be obliged > > > >

[algogeeks] Re: Judging whether a URL exists among millions, insert if not

2008-08-20 Thread Ashish Chugh
u cache or index it using Lucene based indexing you need to synch it with database. Regards, /Ashish On Thu, Aug 21, 2008 at 1:10 AM, Abdul Habra <[EMAIL PROTECTED]> wrote: > I agree with Ashish. Use hashCode. > Here is my suggestion: > Add a new column to your db table, lets cal

[algogeeks] Re: Judging whether a URL exists among millions, insert if not

2008-08-20 Thread Ashish Chugh
Instead of MD5, I think hashCode will suffice. Also it would be unieque for each url and will take lesser number of bytes. Regards, /Ashish On Wed, Aug 20, 2008 at 2:12 PM, Fred <[EMAIL PROTECTED]> wrote: > > Hi, all: > I've got such a problem: there are millions of UR

[algogeeks] Re: Synonym Recognising

2007-12-07 Thread Ashish Chugh
Visit this page http://lucene.zones.apache.org:8080/hudson/job/Lucene-Nightly/javadoc/index.html?org/apache/lucene/analysis/standard/StandardAnalyzer.html this is lucene implementation in java fro synonyms Check if it helps you Cheers, Ashish On Dec 7, 2007 2:01 PM, macoovacany <[EM

[algogeeks] Re: Find the missing integer

2006-06-22 Thread Ashish Chugh
Hi Anil,The code is the tested one. We are converting binary to num, not num to binary so i/10 is right. I have spared my time and after testing i have given the  codecheers,Ashish On 6/21/06, anil kumar <[EMAIL PROTECTED]> wrote: hi asish, thanks for ur reply.. But u

[algogeeks] Re: Find the missing integer

2006-06-21 Thread Ashish Chugh
public getMissingNum(A[]) {long arraySum = 0;long iSum = 0;for (int i = 0; i < n + 1; i++) {iSum += i;arraySum += binaryToNum(A[i]);}missingNum = iSum - arraySum;return missingNum;} public long binaryToNum( i  ) {int powBy =0;long num = 0;    long currentDigitValue = 0;while ( i > 0) {    int mod =

[algogeeks] Re: Algorithmic time

2006-06-02 Thread ashish
2^n is exponential, it grows way faster than n^2 which is polynomial. So asymptotically, limit n^2/2^n tends to zero so n^2 loses its contribution as n grows. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algori

[algogeeks] Re: Friend-machines-assisted approach to downloading via BitTorrent

2006-06-01 Thread ashish
I think this is a good idea, esp if lot of people are ready to co-operate. Though you might need to change or write a new client to include the co-operation bit. Does any client today allow you to download a specified portion of a file instead of the entire file ? Do you plan to modify/write suc

[algogeeks] Re: Finding common elements

2006-05-31 Thread ashish
You need a large enough hash table to avoid collisions. 5 is a small number so the hash table shouldn't be too large. This hashing function can even depend on how your coordinates look like. If they are all integers, you could come up with some simpler hash fn which guarantees no collisions.

[algogeeks] Re: Best way for a tree data structure for fast updating?

2006-05-25 Thread ashish
You can try make sure thay you have minimal collisions in your hash table, by making it large enough, depending on number of children at each node. You will need to experiment a bit for this. Then you can just use a very simple hash function which is fast and simple for this context. This will mak

[algogeeks] Re: How to merge two unsorted single linked list to get a sorted list

2006-05-25 Thread ashish
Yes, my bad there ! Simon Tatham , creator of Putty even has a nice web page dedicated to it : http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html Rahul: He has some C code as well , so you could plug it in where you need it ( understanding it first, of course !) --~--~

[algogeeks] Re: How to merge two unsorted single linked list to get a sorted list

2006-05-24 Thread ashish
This problem is no different from sorting a single linked list as two unsorted linked lists are essentially equivalent to one unsorted linked list by joining their ends. So just joining the two linked lists and sorting them will work. If you don't want to copy the information to an array i.e. spa

<    1   2   3   4   5