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

2010-04-14 Thread BlackdiamonD
, 2010 at 10:58 AM, BlackdiamonD patidarc...@gmail.comwrote: thank kartik thanks but it was with lot of optimized code i was unable to understand though i have changed my code more know it is taking around 8 to 8.5 seconds in my computer but still i am getting TLE on server #includestdio.h

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

2010-04-12 Thread BlackdiamonD
thank kartik thanks but it was with lot of optimized code i was unable to understand though i have changed my code more know it is taking around 8 to 8.5 seconds in my computer but still i am getting TLE on server #includestdio.h #define ten8 (1) const int mod=32; unsigned int

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

2010-04-10 Thread BlackdiamonD
this is dynamic programming problem. try to use dynamic programming... On Sat, Apr 10, 2010 at 9:12 AM, «« ÄÑÜJ »» anujlove...@gmail.com 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

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

2010-04-10 Thread BlackdiamonD
here is simple way to do it..: A[1000] //1000 is maximum formadable sum can be provided.. S is set of coins that you have,K is the sum to be formed initialize the array A by larege value for(x in S): A[x]=1 for 0i1000 for 0j1000 if(i+j1000 A[i]+A[j]A[i+j] )

Re: [algogeeks]

2010-03-31 Thread BlackdiamonD
is the list is sorted...or in some order... i feel unless the point in the list in some order eg: sorted, it will be difficult to get soluiton less than O(n) On Wed, Mar 31, 2010 at 4:59 AM, Priyanka Chatterjee dona.1...@gmail.comwrote: Design an efficient algorithm to report all the

Re: [algogeeks]

2010-03-31 Thread BlackdiamonD
ok...sorry u asked the data structure.. On Wed, Mar 31, 2010 at 11:54 AM, BlackdiamonD patidarc...@gmail.comwrote: is the list is sorted...or in some order... i feel unless the point in the list in some order eg: sorted, it will be difficult to get soluiton less than O(n) On Wed

Re: [algogeeks] Implementation of Algorithms

2010-03-31 Thread BlackdiamonD
you can go through this.: http://www.topcoder.com/tc?d1=tutorialsd2=alg_indexmodule=Static and you can follow: Art of Uva online judge for getting started in this contest... On Wed, Mar 31, 2010 at 12:05 AM, scanfile rahul08k...@gmail.com wrote: I am new to the world of programming. I have to

Re: [algogeeks]

2010-03-31 Thread BlackdiamonD
) On Wed, Mar 31, 2010 at 11:55 AM, BlackdiamonD patidarc...@gmail.comwrote: ok...sorry u asked the data structure.. On Wed, Mar 31, 2010 at 11:54 AM, BlackdiamonD patidarc...@gmail.comwrote: is the list is sorted...or in some order... i feel unless the point in the list in some order eg

Re: [algogeeks] Implementation of Algorithms

2010-03-31 Thread BlackdiamonD
ok i previously i written wrong it is :*Art-of-Programming*-Contest-SE-for- *Uva book for basic of programming and some of the solving methods for problems. here is the Link Art_of_Programming_Contest_SE_for_uva.pdfhttp://online-judge.uva.es/p/Art_of_Programming_Contest_SE_for_uva.pdf * On Wed,

Re: [algogeeks]

2010-03-31 Thread BlackdiamonD
*Binary Indexed Trees* or *Segment Interval trees*. building them also it will take O(n log(n)) ..i feel for a particular query it will be difficult less than O(n) .because .u must know all the element. On Wed, Mar 31, 2010 at 8:26 PM, Priyanka Chatterjee dona.1...@gmail.comwrote: The list of

Re: [algogeeks] First k smallest elements

2010-03-29 Thread blackDiamond
suggestions ? Thanks On Sun, Mar 28, 2010 at 7:57 PM, blackDiamond patidarc...@gmail.comwrote: there are better solution of O(n) are posted in the thread...[?]. using order statices On Sun, Mar 28, 2010 at 6:49 PM, Mukesh Kumar thakur mukeshraj8...@gmail.com wrote: Create a temp

Re: [algogeeks] Finding the middle of the linked list which has also cycle in the list

2010-03-28 Thread blackDiamond
vikrant you havent read properly the post by Gaurav when the second pointer will come back to the head first will be pointing the middle.(Think it)!! On Sun, Mar 28, 2010 at 10:21 AM, vikrant singh vikrantsing...@gmail.comwrote: Well gaurav, i think by this method you can only check for a cycle

Re: [algogeeks] Finding the middle of the linked list which has also cycle in the list

2010-03-28 Thread blackDiamond
...@gmail.comwrote: @diamond sorry but how do we know the fast pointer is pointing to head again? u see, in case u dont have O(n) space to record visited nodes On Sun, Mar 28, 2010 at 10:28 AM, blackDiamond patidarc...@gmail.comwrote: vikrant you havent read properly the post by Gaurav when

Re: [algogeeks] First k smallest elements

2010-03-28 Thread blackDiamond
in an array. When m is large even an O(n) algorithm would be slow. I thinking that each query could be answered in O(sqrt(n)) time So any suggestions ? Thanks On Sun, Mar 28, 2010 at 7:57 PM, blackDiamond patidarc...@gmail.comwrote: there are better solution of O(n) are posted in the thread

Re: [algogeeks] basic problem

2010-03-24 Thread blackDiamond
struct are passed by value..not by reference... On Wed, Mar 24, 2010 at 2:42 AM, aman goyal aman...@gmail.com wrote: why do we use malloc funtcn to allocate memory for a stuct node variable pointer.. why dont we simply write struct node p; instead we do struct node *p p=malloc();