[algogeeks] string

2010-07-18 Thread Ratnesh Thakur
Given a string A, and a string B, and a dictionary, how would you
convert A to B in the minimum no of operations, given that:

i) All the intermediate words must be from the dictionary

ii) An ‘operation’ is defined as:

a) Delete any character from a string ex dog → do

b) Insert any character into a string ex cat → cart

c) Replace any character in the string with another ex cat → cot

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: graph

2010-07-18 Thread Ratnesh Thakur
@jalaj..he has asked for a linear algo


On Sat, Jul 17, 2010 at 12:47 AM, jalaj jaiswal
jalaj.jaiswa...@gmail.comwrote:

 can be done in O(n^2) also
 below is a rough pseudocode
 initialize visited[v]=0
 for every vertex v{
  call dfs(v)
  check if al visited are 1 or not
   if all visited break;
   else do visited[v]=0 again.
 }

 correcf me if i'm missing anything


 On Fri, Jul 16, 2010 at 5:38 AM, Gene gene.ress...@gmail.com wrote:

 Construct the transitive closure of the graph.  You can use Warshall's
 algorithm, which is O(v^3) in run time.  If any row of the adjacency
 matrix is all 1's, the corresponding vertex can reach all others.  You
 can ignore the diagonal element if you don't care whether vertices are
 reachable from themselves (i.e. whether they are contained in a
 cycle).

 On Jul 12, 1:06 pm, Love-143 lovekesh6mn...@gmail.com wrote:
  1.Give an efficient algorithm which takes as input a directed graph G =
  (V,E), and determines whether or not there is a vertex s is in V from
 which
  all other vertices are reachable.?

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 With Regards,
 Jalaj Jaiswal
 +919026283397
 B.TECH IT
 IIIT ALLAHABAD

  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Array with 0 and 1

2010-07-08 Thread Ratnesh Thakur
my algo is flawed..i took the matrix to be sorted

On 7/8/10, Ashish Goel ashg...@gmail.com wrote:
 can you clarify ratnesh please

 i was thinknig on these lines...

 int temp=0; int rowcount=0;
 for (int row=0;rownrows;row++)
 if (a[row]||temp!=temp)
 if (a[row]~0!=0) rowcount++;


 for (int col=0;colncols;col++)
 if (a[col]||temp!=temp)
 if (a[col]~0!=0) colcount++;



 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Wed, Jul 7, 2010 at 9:53 PM, Ratnesh Thakur
 ratneshthaku...@gmail.comwrote:

 for(i=0 to n-1)
   if( binarysearch(i,n-1,1) + 1)
   count++
 print count.
 binarysearch(first,last,item)
  if(1 is there)
  return mid
  else
  return -1.
 similarly we can go for coloumns.
 o(nlogn)

 On 7/5/10, divya jain sweetdivya@gmail.com wrote:
  i think u need to visit every element atleast once to see if its 1 or 0,
 nd
  so update the count.
  so i dont think it will be possible in less than O(n2)
 
  On 5 July 2010 15:41, amit amitjaspal...@gmail.com wrote:
 
 
 
  For a given matrix NxN having 0 or 1’s only. You have to find the
  count of rows and columns where atleast one 1 occurs.
 
  e,g
 
  0 0 0 0
 
  1 0 0 1
 
  1 0 0 1
 
  1 1 0 1
 
  Row count having 1 atleast once: 3
 
  Col count having 1 atleast once: 3
 
  Any Solution less than O(n^2) will do
 
  --
  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.comalgogeeks%2bunsubscr...@googlegroups.com
 algogeeks%2bunsubscr...@googlegroups.comalgogeeks%252bunsubscr...@googlegroups.com
 
  .
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
  --
  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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



 --
 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, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Array with 0 and 1

2010-07-07 Thread Ratnesh Thakur
for(i=0 to n-1)
   if( binarysearch(i,n-1,1) + 1)
   count++
print count.
binarysearch(first,last,item)
  if(1 is there)
  return mid
  else
  return -1.
similarly we can go for coloumns.
o(nlogn)

On 7/5/10, divya jain sweetdivya@gmail.com wrote:
 i think u need to visit every element atleast once to see if its 1 or 0, nd
 so update the count.
 so i dont think it will be possible in less than O(n2)

 On 5 July 2010 15:41, amit amitjaspal...@gmail.com wrote:



 For a given matrix NxN having 0 or 1’s only. You have to find the
 count of rows and columns where atleast one 1 occurs.

 e,g

 0 0 0 0

 1 0 0 1

 1 0 0 1

 1 1 0 1

 Row count having 1 atleast once: 3

 Col count having 1 atleast once: 3

 Any Solution less than O(n^2) will do

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



 --
 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, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] rotation

2010-07-02 Thread Ratnesh Thakur
i think this should work.


for(i=1;i=k;i++)
{
var=a[n-1]
for(j=n-1;j=1;j--)
a[i]=a[i-1]
a[0]=var
}

On Fri, Jul 2, 2010 at 5:36 PM, Saurabh Ahuja nsit.saur...@gmail.comwrote:

 a[0] = a[2]
 a[1] = a[3]
 a[2] = a[4]

 a[0] and a[1] has been changed
 a[3] = a[0]
 a[4] = a[1]

 so this solution would not work.


 On Fri, Jul 2, 2010 at 5:14 PM, Akash Gangil akashg1...@gmail.com wrote:

 wouldn't this work:



 for i in range(0,len)
 a[i] = a[(i+2)%5];

 where len is the length of array


 On Sat, Jun 26, 2010 at 3:37 PM, sharad kumar 
 sharad20073...@gmail.comwrote:

 i have to right rotate an array by k positions
 1 2 3 4 5 for k=2 o/p shud be
 3 4 5 1 2


 P.S---do not give block reversal method for array rotation and soln must
 be inplace.plzz write ur logic also along with d code

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Best Regards
 Akash Gangil

  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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 manzoo...@gmail.com wrote:

 What do you mean by origin string?


 On Fri, Jun 18, 2010 at 2:38 PM, Chunyuan Ge hhy...@gmail.com 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 
 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)

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Manzoor Ahmed

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] doubly linked list

2010-06-15 Thread Ratnesh Thakur
how to implement doubly linked list using only one pointer ?

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.