[algogeeks] Re: DS Q

2011-11-17 Thread shady
you can't do binary search with linked lists. On Nov 17, 1:14 pm, Vijay Khandar vijaykhand...@gmail.com wrote: Linked lists are not suitable data structures of which one of the following problems? a) Insertion sort b) Binary search c) Radix sort d) Polynomial manipulation Plz explain

Re: [algogeeks] Re: DS Q

2011-11-17 Thread sumit mahamuni
On Thu, Nov 17, 2011 at 4:05 PM, shady sinv...@gmail.com wrote: you can't do binary search with linked lists. Yes you can do the binary search on the linked list. But the only difference it makes from the array is that array elements can be accessed in O(1) time and finding the mid in array is

Re: [algogeeks] Re: DS Q

2011-11-17 Thread shady
roflmao, that's what i mean, else the whole purpose of binary search is defeated, instead just linearly traverse the array and find the element On Thu, Nov 17, 2011 at 4:17 PM, sumit mahamuni sumit143smail...@gmail.comwrote: On Thu, Nov 17, 2011 at 4:05 PM, shady sinv...@gmail.com wrote:

[algogeeks] Re: DS QUESTION

2011-09-18 Thread wasim
2n!/n!(n+1)! catalan number also asked by directi in written ... wasim akram MCA 3rd year -- 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

Re: [algogeeks] Re: ds

2010-06-13 Thread Pramod Negi
Hello All, What every algorithm mentioned above have some problem. The Recursive swapping won’t work if you don’t have 2^n elements. Same with getting the indexes, it will form a cycle. Thanks Pramod Negi On Fri, Jun 11, 2010 at 7:09 PM, sharad kumar sharad20073...@gmail.comwrote:

[algogeeks] Re: ds

2010-06-13 Thread Minotauraus
a1a2a3b1b2b3 = [a1 a2] a3 [b1 b2] b3 = [a1 a2] [b1 b2] a3 b3 = a1 a2 b1 b2 a3 b3 = a1 b1 a2 b2 a3 b3 The algo. that I put forth works. And I think Sourav's will as well. The grouping needs to be in numbers of 4. The total number of elements need not. -Minotauraus. On Jun 13, 1:46 pm, Pramod Negi

Re: [algogeeks] Re: ds

2010-06-11 Thread sharad kumar
excellent soln!! -- 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,

Re: [algogeeks] Re: ds

2010-06-10 Thread Anurag Sharma
nice algo! Anurag Sharma On Wed, Jun 9, 2010 at 11:23 PM, souravsain souravs...@gmail.com wrote: Guys We can solve this in O(n) time like this: Let me say total elements in array is 2N such that 1 to N are a's and N +1 to 2N (which I will again refer to as 1 to N) are b's Observation:

Re: [algogeeks] Re: ds

2010-06-09 Thread Jitendra Kushwaha
here is a sel explainatory algo given: abcd1234 abc1d234 ab1c2d34 a1b2c3d4 here is the link for the code : http://codepad.org/SZnufGc6 -- Regards Jitendra Kushwaha MNNIT, Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] Re: ds

2010-06-09 Thread Anurag Sharma
Its not O(n) time. Anurag Sharma On Wed, Jun 9, 2010 at 5:46 PM, Jitendra Kushwaha jitendra.th...@gmail.comwrote: here is a sel explainatory algo given: abcd1234 abc1d234 ab1c2d34 a1b2c3d4 here is the link for the code : http://codepad.org/SZnufGc6 -- Regards Jitendra Kushwaha

[algogeeks] Re: ds

2010-06-09 Thread souravsain
Guys We can solve this in O(n) time like this: Let me say total elements in array is 2N such that 1 to N are a's and N +1 to 2N (which I will again refer to as 1 to N) are b's Observation: If an element is on first 1 to N (an 'a') and has index i then in the final array its position index (in

[algogeeks] Re: ds

2010-06-08 Thread Minotauraus
Actually the solution is best thought of with recursion. See, for a simple 4 element array: a1 a2 b1 b2, you can get the result by swapping only the two elements in the middle. Now think, if you had an 8 element array: a1 a2 a3 a4 b1 b2 b3 b4, group these into pairs of 2 like: a1 a2 - b1 b2 / a3

Re: [algogeeks] Re: ds

2010-06-08 Thread Rohit Saraf
which is just the recursive version of the abovementioned iterative solution. P.S. -Please remove this quoted text when you are composing -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay

[algogeeks] Re: ds

2010-06-06 Thread souravsain
In order to make it inplace, time complexity has gone to n^2. Rearrange(array,int N) //So array size is 2N { int i = 1;//points to index array[1] which has a2 since a1 is already at the correct place; int j = N;//array[0] to array[N-1] is a1 to aN. so j is index of b1 //it

[algogeeks] Re: DS question

2009-10-13 Thread Raghavendra Sharma
For the first problem. All occurrence of a duplicate character in a word. void RemoveDuplicates(char *word) { int count[256] = {0, 0}; char *p = word; while ( p ) { count[(int)(*p)] = 1; p++; } p = word; char *q = word; while ( q ) { if ( count[*q] ) { *p = *q;

[algogeeks] Re: DS question

2009-10-13 Thread Debanjan
On Oct 13, 12:05 pm, Raghavendra Sharma raghavendra.vel...@gmail.com wrote: For the first problem. All occurrence of a duplicate character in a word. void RemoveDuplicates(char *word) {   int count[256] = {0, 0};   char *p = word;   while ( p ) { This would be while(*p) {    

[algogeeks] Re: DS question

2009-10-13 Thread Debanjan
OOPS sorry the code is not correct. --~--~-~--~~~---~--~~ 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

[algogeeks] Re: DS question

2009-10-13 Thread Debanjan
On Sep 8, 10:47 am, yash yashpal.j...@gmail.com wrote: wap a program in efficient manner to remove all occurrence of duplicate character in the word and all occurrence of duplicate word in the file. i break the problem in two section( this is my approach it may be better one ) wap to

[algogeeks] Re: DS question

2009-10-13 Thread Debanjan
On Sep 8, 10:47 am, yash yashpal.j...@gmail.com wrote: wap a program in efficient manner to remove all occurrence of duplicate character in the word and all occurrence of duplicate word in the file. i break the problem in two section( this is my approach it may be better one ) wap to

[algogeeks] Re: DS question

2009-10-13 Thread Raghavendra Sharma
@Debanjan Thanks for correcting this. On Tue, Oct 13, 2009 at 5:12 PM, Debanjan debanjan4...@gmail.com wrote: On Oct 13, 12:05 pm, Raghavendra Sharma raghavendra.vel...@gmail.com wrote: For the first problem. All occurrence of a duplicate character in a word. void

[algogeeks] Re: DS question

2009-09-08 Thread Bharath
You can use a hash map. What do u mean by preserving order? Keep inserting the characters into hash, whenever u find a duplicate, delete it. The order is maintained still. Can you please elaborate on what is mean by preserving order? On Sep 8, 10:47 am, yash yashpal.j...@gmail.com wrote: wap a