[algogeeks] Re:

2010-08-22 Thread Ukil
use suffix trie. On Aug 16, 9:36 pm, ashita dadlani ash@gmail.com wrote: You have a string say foobarfoo in which fo and oo aree repeated twice.You have to find all such repeated pairs in O(n) time,The string can only have alphanumeric elements in it. -- You received this message because

Re: [algogeeks] Re: Permutation of Array.

2010-08-22 Thread srinivas reddy
@aravind prasad cool man check this case consider the case 12 122 so if u arrange sub string(i.e; 12) as the first one so u have the best value 12 122 ok its good now suppose the case is 21 211 so according to the above way the solution is 21 211 which is not best so you have to add

[algogeeks] Re: BFS

2010-08-22 Thread R.ARAVINDH
@manohar and @giri:: doesn recursion itself use stacks( implicitly)?? On Aug 18, 9:26 pm, Giri giri.pe...@gmail.com wrote: @manohar: thnks man.. this solution would be apt.. if there's any better algo which doesn't use an extra stack or queue, but does the purpose in recursion, do post it..

[algogeeks] How can i get all post in my gmail inbox?

2010-08-22 Thread Chandan Balu
I joined this group recently.. and i wanna all the previous post in my gmail inbox... how can i get the post??? Please help me -- 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.

[algogeeks] Re: Time complexity - is anybody bothered about it anyway?

2010-08-22 Thread R.ARAVINDH
@asutosh:: all ur efforts 2 write some code wud be worthless if it cant work for some inputs...if it can , then no one does bother about time complexity. since it doesn for large i/ps v hav 2 write some efficient code (although i agree wid u dat its painful :P ) On Aug 17, 9:45 pm, Dave

[algogeeks] Re: Reading large numbers?

2010-08-22 Thread R.ARAVINDH
if the file is standard i/p then go for strings or linked list. On Aug 16, 10:44 am, janani thiru janani.th...@gmail.com wrote: How can I read a file which has 10^9 characters or more efficiently? -- Janani T -- You received this message because you are subscribed to the Google Groups

[algogeeks] Re:

2010-08-22 Thread R.ARAVINDH
can anyone post a good article on tries??? i am a newbie...so pls help!! On Aug 22, 11:26 am, Ukil ukil.sou...@gmail.com wrote: use suffix trie. On Aug 16, 9:36 pm, ashita dadlani ash@gmail.com wrote: You have a string say foobarfoo in which fo and oo aree repeated twice.You have to

[algogeeks] Re: Alternative merge

2010-08-22 Thread R.ARAVINDH
link nt working...so can anyone explain fr new users?? On Aug 16, 6:52 pm, Minotauraus anike...@gmail.com wrote: Please check link. On Aug 15, 8:25 pm, Gene gene.ress...@gmail.com wrote: http://groups.google.com/group/algogeeks/browse_thread/thread/f56bac6... The best solution given

Re: [algogeeks] Re: Adobe Questions

2010-08-22 Thread Raj N
2. Google dutch national flag problem. This has already been discussed. 3. *printLevelorder(tree)* bool ltr = 0; for d = 1 to height(tree) printGivenLevel(tree, d, ltr); ltr ~= ltr /*flip ltr*/ Function to print all nodes at a given level *printGivenLevel(tree, level)* if tree is

Re: [algogeeks] Algorithm to find all subsets of size K

2010-08-22 Thread Raj N
Generate all binary strings of length k. For eg: S={1,2,3,4,5} generate all binary strings of length 5. 0 represents that particular number is absent and 1 for the presence of the number. On Fri, Aug 13, 2010 at 11:35 PM, asdf gyanendra1...@gmail.com wrote: Most efficient algorithm to find all

Re: [algogeeks] Re: Permutation of Array.

2010-08-22 Thread Raj N
I've forgotten a case for the numbers like 632, 635. In this case while inserting, if the remainders are same 6 in this example, check the mod values for the equal length numbers. But for unequal lengths like, 12 and 126 compare the last digit of one number with the first digit of second i.e 6 1

Re: [algogeeks] Permutation of Array.

2010-08-22 Thread Nikhil Agarwal
@chonku our desired result is 312313355 On Sat, Aug 21, 2010 at 7:30 PM, Chonku cho...@gmail.com wrote: Treat each number as string and make a trie out of it. For the first input [55,31,312,33], it would look like the following .

Re: [algogeeks] Re:

2010-08-22 Thread Raj N
Could anyone of you elaborate on how to implement the algo ? On Sun, Aug 22, 2010 at 11:56 AM, Ukil ukil.sou...@gmail.com wrote: use suffix trie. On Aug 16, 9:36 pm, ashita dadlani ash@gmail.com wrote: You have a string say foobarfoo in which fo and oo aree repeated twice.You have to

Re: [algogeeks] Re: Permutation of Array.

2010-08-22 Thread Raj N
Take the input from the user of the min length number he would input i.e min_length. Then accept the the numbers in the form of strings and calculate the length of every number. Construct a binary search tree with fields as follows: struct node { int number;// atoi(input) int remainder;

[algogeeks] Re: how to implement TAIL command of unix.

2010-08-22 Thread R.ARAVINDH
read the i/p file count the no. of '\n' characters if count k (argument of tail) then print all chars till EOF correct me if m wrong !!! On Aug 16, 9:16 am, vikas kumar vikas.kumar...@gmail.com wrote: the method of farword seek is inefficient. consider case of 10 lines and you want to

[algogeeks] Re: Generate all bit strings of length n

2010-08-22 Thread R.ARAVINDH
hw abt this? start from right most bit.. if it is the right most bit and if its 0 then flip it and proceed to the prev. bit else flip the rightmost zero to 1 and invert the subsequent bits follow the above proc. till the left most bit is flipped to 1. correct me if m wrong!! -- You received

[algogeeks] Re: BST Problem

2010-08-22 Thread R.ARAVINDH
can v do like this??? findnodes(root,sum) { if(root==abs(sum-root-data)) print (the data is root-data, sum-(root-data)); else if(rootabs(sum-root-data)) findnodes(root-right,sum-root-data) else if(rootabs(sum-root-data)) findnodes(root-left,sum-root-data) else if(root-left==NULL ||

[algogeeks] Counting number of rectangles

2010-08-22 Thread Saikat Debnath
Can anyone help in finding number of rectangles having a given recatngle number. A rectangle number is defined as the number of unit sided square formed inside the given rectangle having a common point with a diagonal of rectangle. The sides of rectangle have integer length. E.g. number of

[algogeeks] Microsoft interview question

2010-08-22 Thread Saikat Debnath
How to find last unique character in a given string. Unique character means non-repeated number. Give an optimized way. -- 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

[algogeeks] Re: Google Interview Question

2010-08-22 Thread arpit agarwal
Just find out the max and 2nd max in n + log(n) -2 steps and add them. there is no need for sorting as such -- 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

Re: [algogeeks] Re: Google Interview Question

2010-08-22 Thread ashish agarwal
but addition also should be in array On Sun, Aug 22, 2010 at 3:05 AM, arpit agarwal erarpitagar...@gmail.comwrote: Just find out the max and 2nd max in n + log(n) -2 steps and add them. there is no need for sorting as such -- You received this message because you are subscribed to the

Re: [algogeeks] Re: Array Problem

2010-08-22 Thread ashita dadlani
a={1,2,2,3,4} b={1,2,3,3,4} in this case??? elements are not equal but they certainly consist equal set of integers(1,2,3,4) which is what question says. On Sun, Aug 22, 2010 at 7:53 AM, UMarius mar...@aseara.ro wrote: @Nikhil : I considered the array to be a linked list. xoring the indexes

[algogeeks] Re: BST Problem

2010-08-22 Thread R.ARAVINDH
for the above post i have assumed that the two nodes whose sum is k is present in the BST... so correct me if m wrong -- 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

[algogeeks] reasoning

2010-08-22 Thread srinivas reddy
today there will be a test on reasoning at night 10:00 PM. -- 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] Google Interview Question

2010-08-22 Thread bittu
@Arpit i think finding max second max does n't reuire to mach time as u have told n + log(n) -2 step check out my solution if i am wrong plz xplain me n + log(n) -2 step required to solve this problem public class array { public void getMax( double ar[] ) {

[algogeeks] Re: Microsoft interview question

2010-08-22 Thread Saikat Debnath
This is the answer i have given and interviewer said, Optimise it further in terms of memory and character need not be ASCII On Aug 22, 6:28 pm, Ashish Goel ashg...@gmail.com wrote: use a array arr[char]=count char represent say a-z count is # of occurances while (*s!='\0') {

Re: [algogeeks] Re: Microsoft interview question

2010-08-22 Thread nipun batra
Maybe to reduce the memory usage and to include all types of characters we could create a one to one mapping between the character and the number of occurrences.And while retrieving start from reverse checking the mapping value,print if it's one. On Sun, Aug 22, 2010 at 7:59 PM, Saikat Debnath

Re: [algogeeks] Re: Microsoft interview question

2010-08-22 Thread Ashish Goel
optimization, use bitmap instead of array... char can be unicode, char may take 1 or 2 bytes, that can be written, big deal.. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sun, Aug 22, 2010 at 7:59 PM, Saikat Debnath saikat@gmail.comwrote:

[algogeeks] Re: Longest Palindromic Substring

2010-08-22 Thread Giri
urs s correct 1ly for few cases.. but in the following case it doesnt give the longest seq: abadabac here 'aba' will be printed and not 'abadaba', which s d correct ans On Aug 22, 5:18 am, venkatesan B venkat_b_engin...@yahoo.co.in wrote: use stackpush one by one element before compare to top 2

[algogeeks] Re: BFS

2010-08-22 Thread Giri
by stacks i meant the usage of extra space.. recursion stack is handled by the OS.. so it doesnt bother.. ok On Aug 22, 1:08 pm, R.ARAVINDH aravindhr...@gmail.com wrote: @manohar and @giri:: doesn recursion itself use stacks( implicitly)?? On Aug 18, 9:26 pm, Giri giri.pe...@gmail.com wrote:

Re: [algogeeks] Cube root of a number

2010-08-22 Thread Manjunath Manohar
@apporve ..can u pls elaborate on that ..also on the square root of a number.. -- 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

Re: [algogeeks] Re: Time complexity - is anybody bothered about it anyway?

2010-08-22 Thread Manjunath Manohar
can anyone say how to calculate the complexity of a recurrence relation -- 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] Re: BFS

2010-08-22 Thread Chi
Hi Giri, I don't think you can ask for help this way. By stack or recursion can mean you are looking for a linear solution, too. Next time you should be more precise in your question and I don't think this leet speech will help you much. Although some can graps the sound, but it is hard to read,

[algogeeks] Re: BST Problem

2010-08-22 Thread Giri
frnd check ur code.. t contains much errors.. consider the following eg.: k=5;3 1 4 2 5 On Aug 22, 2:30 pm, R.ARAVINDH aravindhr...@gmail.com wrote: can v do like  this??? findnodes(root,sum) { if(root==abs(sum-root-data)) print (the data

[algogeeks] solutions

2010-08-22 Thread srinivas reddy
sorry friends here i am mentioning only the solutions explanation is not possible to give all the questions if you need it plz post the question then i will send it *1*. the value of E is 4. *2*. the occupation of mr.horton is doctor *3*. thevalue of G

[algogeeks] To sort an array of 0,1,2

2010-08-22 Thread AlgoBoy
An algorithm to sort an array of 0's,1's,2's in a single pass... -- 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

Re: [algogeeks] solutions

2010-08-22 Thread Subhranil Banerjee
what are these solutions for -- 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

[algogeeks] Re: solutions

2010-08-22 Thread Chi
It's a turing test. On Aug 22, 10:40 pm, Subhranil Banerjee riku...@gmail.com wrote: what are these solutions for -- 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

[algogeeks] Re: Alternative merge

2010-08-22 Thread Gene
Sorry. Let's try again: http://groups.google.com/group/algogeeks/browse_thread/thread/f56bac6fc244a49b/f0214957224b3010 On Aug 22, 4:27 am, R.ARAVINDH aravindhr...@gmail.com wrote: link nt working...so can anyone explain fr new users?? On Aug 16, 6:52 pm, Minotauraus anike...@gmail.com

[algogeeks] Re: Microsoft interview question

2010-08-22 Thread Gene
This doesn't work on abb for example. On Aug 22, 9:28 am, Ashish Goel ashg...@gmail.com wrote: use a array arr[char]=count char represent say a-z count is # of occurances while (*s!='\0') { arr[*s-'a']++; if (arr[*s-'a']==1) lastchar=*s; } lastchar is the last non repeating char

Re: [algogeeks] Cube root of a number

2010-08-22 Thread Apoorve Mohan
Depending upon the accuracy you need you can fix the number of iterations On Sun, Aug 22, 2010 at 10:25 PM, Apoorve Mohan apoorvemo...@gmail.comwrote: Using this method u can find any root of any number See this link... http://en.wikipedia.org/wiki/Newton%27s_method On Sun, Aug

Re: [algogeeks] Longest Palindromic Substring

2010-08-22 Thread Nikhil Jindal
@Aravind: Ur soln will be O(n^2)*O(n). It is similar to nipun's soln. On Sun, Aug 22, 2010 at 6:15 AM, aravind prasad raja@gmail.com wrote: 1)maintain 2 pointers.. one from left and other from right.. 2)run two nested loops to compre each element from right with the element in left..

Re: [algogeeks] Cube root of a number

2010-08-22 Thread Apoorve Mohan
Using this method u can find any root of any number See this link... http://en.wikipedia.org/wiki/Newton%27s_method On Sun, Aug 22, 2010 at 10:16 PM, Manjunath Manohar manjunath.n...@gmail.com wrote: @apporve ..can u pls elaborate on that ..also on the square root of a number.. --

Re: [algogeeks] Re: Longest Palindromic Substring

2010-08-22 Thread venkatesan B
so maintain 2 pointers , one for start and other for finish for aba , start=1 and finish=3for next  aba , Tempstart=5, Tempfinish =8 check with previous start and finish if ( Tempstart==finish+1 or finish+2)finish=Tempfinish;elseif(finish-start Tempfinish-Tempstart)start=Tempstart and

[algogeeks] Re: BST Problem

2010-08-22 Thread R.ARAVINDH
@giri: thnx frnd...sorry ppl . ignore my post :( -- 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] Re: BST Problem

2010-08-22 Thread R.ARAVINDH
@giri: can u post d correct answer?? -- 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

[algogeeks] Re: To sort an array of 0,1,2

2010-08-22 Thread Jameel Mohamed
Use counting sort. time complexity is O(n) On Aug 22, 1:11 pm, AlgoBoy manjunath.n...@gmail.com wrote: An algorithm to sort an array of 0's,1's,2's in a single pass... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,