Re: [algogeeks] Re: Write a program

2011-09-10 Thread praveen raj
@brijesh ..+1 but character range.. from 0 to 255... With regards, Praveen Raj DCE-IT 3rd yr 735993 praveen0...@gmail.com On Sat, Sep 10, 2011 at 7:03 PM, Brijesh brijeshupadhyay...@gmail.comwrote: If you are talking about character array then it can be done in space O(128)=constant

Re: [algogeeks] Re: Write a program

2011-09-10 Thread Ishan Aggarwal
Hi, Actually I am not good at hash tables. can u plzz suggest me some gud link from where I can study hash tables... and also tell me the logic for integer arrays for which the complexity will be o(n logn). Thanks in advance. -- Kind Regards Ishan Aggarwal Phone : +91-9654602663 On Sat, Sep

Re: [algogeeks] Re: Write a program

2011-09-10 Thread sukran dhawan
yes for integer arrays we need to sort o(nlogn) and den compare in o(n) On Sat, Sep 10, 2011 at 7:12 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Hi, Actually I am not good at hash tables. can u plzz suggest me some gud link from where I can study hash tables... and also tell me

Re: [algogeeks] Re: Write a program

2011-09-10 Thread Ishan Aggarwal
Howz this solution?? void main() { int a[10] = {9,3,9,3,9,3,2}; int c[10],i,j,k,co; k=0; for(i=0;i7;i++) { co = 0; for( j = 1+1; j7; j++) if( a[i] == a[j]) co++ ; if( co == 0) { c[k++] = a[i]; } for (i=0;ik;i++) printf(%d,c[i]); } } On Sat, Sep 10, 2011 at 9:26 PM, sukran dhawan

Re: [algogeeks] Re: Write a program

2011-09-10 Thread bharatkumar bagana
@brijesh: if we don't want to print .. and want to eliminate duplicates ...then ? means..want to store in some place which doesn't have any duplicate for further purpose ... On Sun, Sep 11, 2011 at 12:08 AM, Brijesh brijeshupadhyay...@gmail.comwrote: Watch this video for the concepts of

Re: [algogeeks] Re: Write a program

2011-09-10 Thread Ishan Aggarwal
What would be the complexity in that case ?? On Sun, Sep 11, 2011 at 10:29 AM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: @brijesh: if we don't want to print .. and want to eliminate duplicates ...then ? means..want to store in some place which doesn't have any duplicate for

Re: [algogeeks] Re: Write a program

2011-09-10 Thread praveen raj
Use of binary tree.. which has node(value,count) count -number of elements having having element = value... With regards, Praveen Raj DCE-IT 3rd yr 735993 praveen0...@gmail.com On Sun, Sep 11, 2011 at 10:32 AM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: What would be the

[algogeeks] Re: Write a program to arrange numbers from 1 to 16 such that the sum of two consecutive numbers is a perfect square

2010-09-18 Thread ash
is there any general algo for this question,ie, upto any n(here 16) ? ? On Sep 15, 2:46 am, Minotauraus anike...@gmail.com wrote: I guess the problem could be modified for any 1..n where n is 2^m. so say 132 or 1...64 Try it out. It still works! The time complexity in this case is O(log

[algogeeks] Re: Write a program to arrange numbers from 1 to 16 such that the sum of two consecutive numbers is a perfect square

2010-09-18 Thread Dave
@ash: I would treat it as a graph problem. The nodes are the numbers from 1 to n, and the edges connect nodes that sum to a perfect square. The problem then reduces to finding a Hamiltonian path through the graph. This can be done with a depth-first search. Start with a node of degree 1 if you

[algogeeks] Re: Write a program to arrange numbers from 1 to 16 such that the sum of two consecutive numbers is a perfect square

2010-09-14 Thread bittu
@Davhw can u compute in contant time where runing time dwepends on elements of array e.g. its has complexcity O(n) isn'tit..?? import java.util.Arrays; import java.util.LinkedList; class SolutionFinder { public static void find(final LinkedListInteger remaining, final

[algogeeks] Re: Write a program to arrange numbers from 1 to 16 such that the sum of two consecutive numbers is a perfect square

2010-09-14 Thread Dave
@Bittu: First, it makes no sense to say O(n) when n is fixed. Second, if you know the solution, a program to print it out just consists of a printf statement, e.g., printf(16, 9, 7, 2, 14, 11, 5, 4, 12, 13, 3, 6, 10, 15, 1, 8\n); plus whatever language stuff you need to get it to compile and

[algogeeks] Re: Write a program to arrange numbers from 1 to 16 such that the sum of two consecutive numbers is a perfect square

2010-09-14 Thread Minotauraus
I guess the problem could be modified for any 1..n where n is 2^m. so say 132 or 1...64 Try it out. It still works! The time complexity in this case is O(log n). On Sep 14, 6:02 am, Dave dave_and_da...@juno.com wrote: @Bittu: First, it makes no sense to say O(n) when n is fixed. Second, if

[algogeeks] Re: Write a program to arrange numbers from 1 to 16 such that the sum of two consecutive numbers is a perfect square

2010-09-13 Thread Dave
You don't really need a program. Only one number, 9, can be added to 16 to make a perfect square, so 16 must be at one end of the list. Through a sequence of forced choices, you can build the list 16, 9, 7, 2, 14, 11, 5, 4, 12, 13, 3. At this point, you can choose either 1 or 6. Trying 1, you can