Re: [algogeeks] Re: amazon qn

2012-05-27 Thread atul anand
http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance On Tue, May 22, 2012 at 7:06 PM, aanchal goyal goyal.aanch...@gmail.comwrote: @Lucifer, do we need to add insert and del operations in the transformation formula u gave? Isn't it just the number of substitutions/2? -- You

Re: [algogeeks] Re: MS question : string compression

2012-05-27 Thread Ashish Goel
Will fail for the sing having say 257characters all same Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sat, May 26, 2012 at 12:26 PM, Navin Gupta navin.nit...@gmail.comwrote: This is called Run-Length-Encoding (RLE) of a string. Its purpose

[algogeeks] Re: classic problem to tree to circular doubly linked list

2012-05-27 Thread Gene
Another approach is to form a singly linked, NULL-terminated list (connected e.g. by 'left' pointers). This is a harder problem, and it might be required if you have a purpose for the other (right) pointer. If you need a doubly linked list it's easy to walk down the singly linked one, creating

Re: [algogeeks] Re: classic problem to tree to circular doubly linked list

2012-05-27 Thread atul anand
@Gene : NODE *convert(NODE *root, NODE *list) { if (root == NULL) return list; NODE *left_subtree = root-left; root-left = convert(root-right, list); return *tree(left_subtree, root);* } what *tree(left_subtree, root)* function doing here?? On Sun, May 27, 2012 at 7:12 PM, Gene

Re: [algogeeks] Re: Google Q : all anagrams next to each other

2012-05-27 Thread Navin Gupta
@jalaj :- we will be sorting a copy of the word and then matching the sorted_sequence with the sorted_sequence of the copy of other words. It will still be in-place, because we are using a space of Word size where the input is a dictionary. This is an amortized in-place. -- Navin Kumar Gupta

Re: [algogeeks] amazon

2012-05-27 Thread saurabh agrawal
@atul: if i have understood .. ur solution will break when the string has repeated characters. e.g. for baa On Tue, May 22, 2012 at 3:43 PM, partha sarathi Mohanty partha.mohanty2...@gmail.com wrote: sorry it was treeset Here is the code.. public class asd1 { public static

Re: [algogeeks] amazon

2012-05-27 Thread atul anand
@saurabh : i kinda assumed that string will not contain repeated character. reason being if string has repeated character , say in your case baa then baa will be repeated twice hence it would be difficult to justify the output for this input answer could be say 2 or 3 or both are correct. On

[algogeeks] Cpp problem

2012-05-27 Thread amrit harry
complex_number const operator =(complex_number temp) const { return *this; } what is the job of marked 'const'??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] amazon

2012-05-27 Thread saurabh agrawal
@atul: i dont agree that baa should come once or twice is arguable. It definitely have to be one time only.. we are supposed to get all lexicographic combinations (which implicitly means no two strings will be same..) On Mon, May 28, 2012 at 12:23 AM, atul anand atul.87fri...@gmail.comwrote:

Re: [algogeeks] Cpp problem

2012-05-27 Thread saurabh agrawal
const allows this function to be called on constant object. So if someone creates an const obj of this class. Assignments can be done. On Mon, May 28, 2012 at 12:23 AM, amrit harry dabbcomput...@gmail.comwrote: complex_number const operator =(complex_number temp) const { return

Re: [algogeeks] Cpp problem

2012-05-27 Thread Manikanta Babu
Its a const member function, you cant return reference to the object. Const member function never allows you to modify the data until unless its a mutable. So here we are passing the reference to object which is modifiable, it conflicts with the const member function property. So the compiler

Re: [algogeeks] Re: Algo for Search in a 2D Matrix

2012-05-27 Thread saurabh agrawal
Yes, navin thats a good solution... ... we dont need to work on the whole array but of size k x k (k rows and k columsn only). Rest of the array we can simply ignore.. complexity of youngify is O(k) for every removing every element. we have to remove k-1 elements so complexity of whole

[algogeeks] Re: Cpp problem

2012-05-27 Thread Lucifer
@amrit Every non-static member function of a class has an implicit parameter that is passed to the function (when called) This implicit parameter is nothing but the this pointer. Now if you want to make the implicit parameter (this pointer) a const, how would u do it? This is done by placing the

[algogeeks] Re: # of paths betweek two nodes in a DAG

2012-05-27 Thread Lucifer
1) Linearize the DAG using DFS. ( topological sorting) 2) Now take an array of size A[N] ( N - nodes in the DAG ), where A[i] mimics the 'i'th node in the linearized list. 3) Scan the linearized list from left to right to get to the source node and initialize all the corresponding values in array

Re: [algogeeks] Re: Cpp problem

2012-05-27 Thread Bhaskar Kushwaha
the job of marked const here is to make the member function operator= as const so it can't modify any member function values unless that member function is mutable @manikanta the compiler will throw an error only when we try to modify any members inside a const member function but here we are not

Re: [algogeeks] Re: Cpp problem

2012-05-27 Thread Manikanta Babu
@Bhaskar u r right. I mean wen u are trying to access this function on non constant object. On May 28, 2012 2:08 AM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: the job of marked const here is to make the member function operator= as const so it can't modify any member function