Re: [algogeeks] Palindrome tree

2013-11-07 Thread siddharam suresh
if the given tree is complete B tree then its similar to the mirror tree problem On Fri, Sep 6, 2013 at 3:38 AM, subrat kumar prasad wrote: > bool check_palin(vector v){ > > vector v1(v); > reverse(v1.begin(),v1.end()); > > for(int i = 0;i if(v[i] != v1[i]) > return

Re: [algogeeks] Palindrome tree

2013-09-05 Thread subrat kumar prasad
1. take the nodes at current level i in an array. 2. check if the current level is palindrome. On Mon, Sep 2, 2013 at 3:25 PM, Bhawin wrote: > Given a binary tree design an algorithm to check if the tree is a > palindrome tree or not. > > Palindromic tree: String formed by characters at each l

Re: [algogeeks] Palindrome tree

2013-09-05 Thread subrat kumar prasad
bool check_palin(vector v){ vector v1(v); reverse(v1.begin(),v1.end()); for(int i = 0;i q; q.push(root); q.push(NULL); vector v; while(!q.empty()){ while(q.front()){ node *l = q.front(); q.pop(); v.push_back(l->ch);

[algogeeks] Palindrome tree

2013-09-05 Thread Bhawin
Given a binary tree design an algorithm to check if the tree is a palindrome tree or not. Palindromic tree: String formed by characters at each level should be palindrome. Tree need not to be a complete BT. e.g. a

[algogeeks] Palindrome

2011-05-26 Thread ankit sambyal
You are given a large string. You need to cut the string into chunks such that each substring that you get is a palindrome. Remember that each 1 length string is always a palindrome. You need to find the minimum number of cuts that you need to make such that each substring is a palindrome. -- Yo

Re: [algogeeks] palindrome

2010-12-22 Thread Azhar Hussain
Hi, Here is the simple solution unsigned int r = v; // r will be reversed bits of v; first get LSB of v int s = sizeof(v) * CHAR_BIT - 1; // extra shift needed at end for (v >>= 1; v; v >>= 1) { r <<= 1; r |= v & 1;

Re: [algogeeks] palindrome

2010-12-22 Thread pacific pacific
On Wed, Dec 22, 2010 at 12:11 PM, mo...@ismu wrote: > > > if x is a 32 bit number > if((x&0x)==((x>>16)&0x))) >x's bit pattern is a polyndrome > > @snehal :Do you want to consider binary representation of 5 as 101 or ..0101 ? -- > You received this message because you

Re: [algogeeks] palindrome

2010-12-21 Thread mohan@ismu
if x is a 32 bit number if((x&0x)==((x>>16)&0x))) x's bit pattern is a polyndrome -- 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 g

[algogeeks] palindrome

2010-12-21 Thread snehal jain
Algorithms to check if binary representation of a number is palindrome or not -- 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 algo

Re: [algogeeks] palindrome problem

2010-11-16 Thread anoop chaurasiya
the idea for O(|S|^2) is as follows Let string be s[1..n] p[i][j]=1 if s[i...j] is a palindrome p[i][j]=0 otherwise. we can precalculate table p[i][j] as follows..in O(|s|^2) p[i][i]= 1 p[i][i+1]=1 if s[i]==s[i+1], 0 otherwise for all others.. p[i][j]= (s[i]==s[j] && p[i+1][j-1]==1). now le

Re: [algogeeks] palindrome problem

2010-11-16 Thread cheng lee
how to do that in O(|s|^2)? 2010/11/16 anoop chaurasiya > will O(|s|^2) dp workor u need something more efficient than that > > > On Tue, Nov 16, 2010 at 1:51 PM, lichenga2404 wrote: > >> A palindrome is a string which is identical to itself in reverse >> order. For example >> \ABAAABA"

Re: [algogeeks] palindrome problem

2010-11-16 Thread anoop chaurasiya
will O(|s|^2) dp workor u need something more efficient than that On Tue, Nov 16, 2010 at 1:51 PM, lichenga2404 wrote: > A palindrome is a string which is identical to itself in reverse > order. For example > \ABAAABA" is a palindrome. Given a string, we'd like to break it up > into the s

[algogeeks] palindrome problem

2010-11-16 Thread lichenga2404
A palindrome is a string which is identical to itself in reverse order. For example \ABAAABA" is a palindrome. Given a string, we'd like to break it up into the small- est possible number of palindromes. Of course, any one-character string is a palindrome so we can always break a length n string in

Re: [algogeeks] palindrome substring

2010-06-20 Thread Anand
Here is code to find palindrome in linear time: http://codepad.org/PMJzjpPJ On Fri, Jun 18, 2010 at 5:28 AM, Chunyuan Ge wrote: > good point, i am wrong, sorry > > > > On Fri, Jun 18, 2010 at 5:54 PM, Rohit Saraf > wrote: > >> abcqwertycba >> >> So is abc a palindrome?? >> -

Re: [algogeeks] palindrome substring

2010-06-18 Thread Amir hossein Shahriari
here's a linear time solution: http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/ On Fri, Jun 18, 2010 at 4:58 PM, Chunyuan Ge wrote: > good point, i am wrong, sorry > > > > On Fri, Jun 18, 2010 at 5:54 PM, Rohit Saraf > wrote: > >> abcqwertycba >> >> So i

Re: [algogeeks] palindrome substring

2010-06-18 Thread Ratnesh Thakur
check this http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/ On Fri, Jun 18, 2010 at 3:36 PM, Manzoor Ahmed wrote: > What do you mean by origin string? > > > On Fri, Jun 18, 2010 at 2:38 PM, Chunyuan Ge wrote: > >> Origin string a, reverse the string to g

Re: [algogeeks] palindrome substring

2010-06-18 Thread Chunyuan Ge
good point, i am wrong, sorry On Fri, Jun 18, 2010 at 5:54 PM, Rohit Saraf wrote: > abcqwertycba > > So is abc a palindrome?? > -- > Rohit Saraf > Second Year Undergraduate, > Dept. of Computer Science and Engineering > IIT Bombay > http://www.cse

Re: [algogeeks] palindrome substring

2010-06-18 Thread Manzoor Ahmed
What do you mean by origin string? On Fri, Jun 18, 2010 at 2:38 PM, Chunyuan Ge wrote: > Origin string a, reverse the string to get b > get the longest common string between a and b > > that's it. > > Chunyuan > > > On Thu, Jun 17, 2010 at 8:38 PM, debajyotisarma > wrote: > >> Find the longest

Re: [algogeeks] palindrome substring

2010-06-18 Thread Rohit Saraf
abcqwertycba So is abc a palindrome?? -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Fri, Jun 18, 2010 at 3:08 PM, Chunyuan Ge wrote: > Origin string a, reve

Re: [algogeeks] palindrome substring

2010-06-18 Thread Chunyuan Ge
Origin string a, reverse the string to get b get the longest common string between a and b that's it. Chunyuan On Thu, Jun 17, 2010 at 8:38 PM, debajyotisarma wrote: > Find the longest palindrome in the given string. > Minimum time-space complexity required > (i have not solved it so don't kno

Re: [algogeeks] palindrome substring

2010-06-18 Thread Avinash Dubey
check two types of palindromes.. even and odd and as soon as u get one. just expand on both sides to get the longest one.. even palindromes are arr[i]==arr[i+1] and odd palindromes are arr[i]==arr[i=2] On Fri, Jun 18, 2010 at 9:20 AM, Antony Vincent Pandian.S. < sant...@gmail.com> wrote: > I rem

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 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) > > -- > You received this mess

[algogeeks] palindrome substring

2010-06-17 Thread debajyotisarma
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) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegrou