Re: [algogeeks] palindrome substring

2010-06-17 Thread Antony Vincent Pandian.S.
I remember this question under discussion recently. Please check the existing threads... On 6/17/10, debajyotisarma sarma.debajy...@gmail.com wrote: Find the longest palindrome in the given string. Minimum time-space complexity required (i have not solved it so don't know what is min) --

Re: [algogeeks] level order traversal

2010-06-09 Thread Antony Vincent Pandian.S.
Thanks Sharad On Wed, Jun 9, 2010 at 10:01 PM, sharad kumar sharad20073...@gmail.comwrote: 1 /\ 2 3 / \/

Re: [algogeeks] circularly sorted array

2010-06-08 Thread Antony Vincent Pandian.S.
Check whether the first element in the array is greater than the last element in the array. If it is true, it means the array is rotated after sorting. Now, take the middle element of the array and check whether it is greater than the last element of the array. If true, it means the first half of

Re: [algogeeks] ds

2010-06-08 Thread Antony Vincent Pandian.S.
I dont think so This approach is better than O(nlogn) On Tue, Jun 8, 2010 at 9:10 AM, harit agarwal agarwalha...@gmail.comwrote: @vadivel selvaraj your approach is O(nlogn) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] Print the string in reverse order (not revstr

2010-06-05 Thread Antony Vincent Pandian.S.
@Shobhit @Rohit Is it done it linear time?? I dont think so... On Sat, Jun 5, 2010 at 9:33 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: Tokenize the string and print it reverse! -- -- Rohit Saraf Second Year Undergraduate, Dept. of

Re: [algogeeks] Print the string in reverse order (not revstr)

2010-06-05 Thread Antony Vincent Pandian.S.
Rohit, you are very well awake On Sat, Jun 5, 2010 at 9:49 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: Have you posted the same question twice or i am feeling sleepy? -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer

Re: [algogeeks] Largest even length palindrome in a string!!

2010-06-05 Thread Antony Vincent Pandian.S.
Follow hare and tortoise algorithm. For even length, once the traversal through out the string is done, move the fast pointer to slow pointer +1 location and start iterating for (length/2) times with 2 indices. One indice increasing for fast pointer and the other for slow pointer. Keep checking

Re: [algogeeks] Largest even length palindrome in a string!!

2010-06-05 Thread Antony Vincent Pandian.S.
Apologies. I thought the question was about just checking for palindrome. On 6/6/10, Antony Vincent Pandian.S. sant...@gmail.com wrote: Follow hare and tortoise algorithm. For even length, once the traversal through out the string is done, move the fast pointer to slow pointer +1 location

Re: [algogeeks] Re: Median of BST

2010-06-04 Thread Antony Vincent Pandian.S.
I think kaushik's solution of inorder traversal with hare and tortoise technique should do the trick. On Fri, May 21, 2010 at 3:48 PM, Koolvord Starbust kolvo...@gmail.comwrote: Sorry, but.. why don't you.. a) compute the height of each subtree. Recusrively, takes O(n). b) start from the

Re: [algogeeks] Removing extra parentheses in an infix string

2010-06-04 Thread Antony Vincent Pandian.S.
, To add to your logic, I hope we must also be checking at the precedence of the first operator that appears after the closing parenthesis ')' before we can decided if the parenthesis can be removed or not . On Thu, Jun 3, 2010 at 11:37 PM, Antony Vincent Pandian.S. sant...@gmail.com wrote

Re: [algogeeks] Removing extra parentheses in an infix string

2010-06-03 Thread Antony Vincent Pandian.S.
If the base logic follows the below rule, it should work. If any operator within parenthesis is of less precedence to the operator before the opening parenthesis, the parenthesis can not be removed. For cases of equal precedence of operators before parenthesis and within parenthesis,

Re: [algogeeks] Check if 2 linked lists are identical

2010-06-03 Thread Antony Vincent Pandian.S.
Consider two linked lists l1 and l2. Create 2 hash maps,h1 and h2, one for each list with the format, element, number of occurrence. Traverse one element in each list at a time. For each element in list l1, check whether it is present in h2. If yes, remove the element from h2 if the number of

Re: [algogeeks] Check if 2 linked lists are identical

2010-06-02 Thread Antony Vincent Pandian.S.
@Raj What do you mean by identical? You are just concerned about the presence of one element in another LL or you are concerned about the equality of number of elements too? On 6/2/10, Raj N rajn...@gmail.com wrote: @sharad kumar: But don't you think this'll consume a lot of space. Merge sort

Re: [algogeeks] how can i find size of an object in java

2009-11-25 Thread Antony Vincent Pandian.S.
But you cant actually say that this is the size of the object from calling freememory before and after object creation.. On Wed, Nov 25, 2009 at 5:15 PM, Phani Kumar gsphaniku...@gmail.com wrote: java.lang.Runtime class has a method* freeMemory

[algogeeks] Re: find the index of a number in a sorted array

2009-10-25 Thread Antony Vincent Pandian.S.
Do a binary search On Sun, Oct 25, 2009 at 12:13 AM, naren lalavat38na...@gmail.com wrote: You have a sorted array of n elements some of them occur more than once. How can we find the index of an element in time t which is less than O(n). -- Luv, S.Antony Vincent Pandian