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

2010-08-22 Thread Manjunath Manohar
is it possible to do without any extra space...

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



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



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 finish=Tempfinish
--- On Sun, 22/8/10, Giri  wrote:

From: Giri 
Subject: [algogeeks] Re: Longest Palindromic Substring
To: "Algorithm Geeks" 
Date: Sunday, 22 August, 2010, 9:29 PM

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 
wrote:
> use stackpush one by one element before compare to top 2 element in stack {if 
> same then pop element and compare next char of string with top char in 
> stackif same continue otherwise clear stack}else{push element to stack}
> if wrong correct 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.
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] 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  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..
>
> 3)if they are same  pass the subset(the characters in between) to function
> that checks if it is a palindrome or not.
>
>
> complexity==> O(n^2)+O(n)
>
> correct me if am wrong
>
>
> On Sun, Aug 22, 2010 at 5:48 AM, venkatesan B <
> venkat_b_engin...@yahoo.co.in> wrote:
>
>> use stack
>> push one by one element before compare to top 2 element in stack
>> {
>> if same then pop element and compare next char of string with top char in
>> stack
>> if same continue otherwise clear stack
>> }
>> else
>> {push element to stack}
>>
>> if wrong correct me
>>
>>
>>
>>
>> --- On *Sat, 21/8/10, nipun batra * wrote:
>>
>>
>> From: nipun batra 
>> Subject: Re: [algogeeks] Longest Palindromic Substring
>> To: algogeeks@googlegroups.com
>> Date: Saturday, 21 August, 2010, 4:18 PM
>>
>>
>> An O(n^3) solution.Wanna know if it's possible to optimize without using
>> trees.
>>
>> #include
>> #include
>> using namespace std;
>> char* substring(char*s,int start,int finish)
>> {
>> int ctr=0;
>> char str[1000];
>> while(start<=finish)
>> {
>> str[ctr]=s[start];
>> start+=1;
>> ctr+=1;
>> }
>> str[ctr]='\0';
>> return str;
>> }
>> bool isPalindrome(char *s)
>> {
>> int size=strlen(s);
>> int j=size-1;
>> int i=0;
>> while((s[i]==s[j])&&(i> {
>> i+=1;
>> j-=1;
>> }
>> if (i>=j)
>> return true;
>> else
>> return false;
>> }
>> int main()
>> {
>>
>> int i,j;
>> char s[100];
>> cin>>s;
>>
>> int size=strlen(s);
>> int tempMax=size-1;
>> while(tempMax>1)
>> {
>> for(i=0;i+tempMax> {
>> if(isPalindrome(substring(s,i,i+tempMax)))//O(n)
>> {
>> puts(substring(s,i,i+tempMax));
>> cout<<" of size "<> break;
>> }
>> }
>> tempMax-=1;
>> }
>>
>>
>> return 0;
>> }
>>
>>
>>
>>
>> On Sat, Aug 21, 2010 at 12:12 PM, Chonku 
>> http://mc/compose?to=cho...@gmail.com>
>> > wrote:
>>
>> I definitely meant a suffix Tree and not a trie. Apologize for that. :)
>>
>> On Fri, Aug 20, 2010 at 8:47 PM, Nikhil Jindal 
>> http://mc/compose?to=fundoon...@yahoo.co.in>
>> > wrote:
>>
>> @chonku
>> As i understand, a trie is used when we have a lot of strings (such as a
>> dictionary).
>> Here we just have a single string. The resultant trie will be:
>>
>> a
>>  \
>>   b
>>\
>> c
>>  \
>>   l
>>\
>> e
>>  \
>>   v
>>\
>> e
>>  \
>>   l
>>\
>> a
>>  \
>>   b
>>\
>> c
>>
>> We get a similar trie for the reverse string.
>>
>> So why are you using a trie here? I cant see any advantage of it here.
>>
>> On Fri, Aug 20, 2010 at 8:36 AM, Chonku 
>> http://mc/compose?to=cho...@gmail.com>
>> > wrote:
>>
>> Can we use a trie here.
>> Make first pass from left to right and construct the trie.
>> Make second pass from right to left and look for the trie branch with
>> maximum nodes that match the characters.
>>
>>   On Thu, Aug 19, 2010 at 7:46 PM, Nikhil Jindal 
>> http://mc/compose?to=fundoon...@yahoo.co.in>
>> > wrote:
>>
>>  Hi All,
>>
>> Givan a string, you have to find the longest palindromic substring.
>> For ex: Longest Palindromic substring for abclevelabc is level.
>>
>> What is the most optimised solution possible?
>>
>> Please access the attached hyperlink for an important electronic 
>> communications disclaimer: 
>> http://dce.edu/web/Sections/Standalone/Email_Disclaimer.php
>>
>>
>>
>>
>>
>>
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups 
>> "Algorithm Geeks" group.
>>
>> To post to this group, send email to algogeeks@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 
>> algogeeks@googlegroups.com
>> .
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.

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..
>
> --
> 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.
>



-- 
regards

Apoorve Mohan

-- 
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] 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 wrote:

> 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..
>>
>> --
>> 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.
>>
>
>
>
> --
> regards
>
> Apoorve Mohan
>
>


-- 
regards

Apoorve Mohan

-- 
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] 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  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
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
> On Sun, Aug 22, 2010 at 3:30 PM, Saikat Debnath wrote:
>
>
>
> > 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 unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com > .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] 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"  wrote:
> link nt working...so can anyone explain fr new users??
>
> On Aug 16, 6:52 pm, Minotauraus  wrote:
>
>
>
> > Please check link.
>
> > On Aug 15, 8:25 pm, Gene  wrote:
>
> > >http://groups.google.com/group/algogeeks/browse_thread/thread/f56bac6...
>
> > > The best solution given there is O(n) with only constant additional
> > > storage.
>
> > > On Aug 15, 1:51 pm, Debajyoti Sarma  wrote:
>
> > > > so what was the optimal solution found in the previous discussion?? 
> > > > give a link
> > > > I don't remember the name of the thread...so only i posted this.
>
> > > > On 8/15/10, Gene  wrote:
>
> > > > > In fact this solution was suggested (without code) in the original
> > > > > discussion.
>
> > > > > It's O(n^2).
>
> > > > > You're only re-ordering a constant number (4) of elements in each
> > > > > recursive pass, and each pass requires O(n) time to execute.  You also
> > > > > need to assume your compiler will remove the tail recursion.
> > > > > Otherwise it will also require O(n) space, which misses the whole
> > > > > point of the problem.
>
> > > > > On Aug 15, 12:29 pm, Debajyoti Sarma 
> > > > > wrote:
> > > > >> Array of 2n length is given {a1,a2,a3,...,an,b1,b2,b3,...,bn}
> > > > >> we have to make the array like as {a1,b1,a2,b2,a3,b3,...,an,bn}
> > > > >> without using extra buffer space.
> > > > >> here a solution i came up withhttp://codepad.org/ub5Ie4sI
> > > > >> I know this was discussed before .
> > > > >> But i want to know the time complexity of the code i have given(i m
> > > > >> confused)
>
> > > > > --
> > > > > 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.



[algogeeks] Re: solutions

2010-08-22 Thread Chi
It's a turing test.

On Aug 22, 10:40 pm, Subhranil Banerjee  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 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] 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 options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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



[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 is 2

   A->8,1
   B->9
   G->2
   E->4
   C>1,8
   D>6,3
   F-->3,6


*4.*

anitha should take from second file

(i think it's very good one out of all).


*5.*

 3 hours ago ramesh did ramesh light  the two candles.


*6.*


   8 members
 *
7.

  1)E

  2)A

  3)B

  4)C

  5)B

*so these are the solutions friends i hope that these two exams are helps
you at least a little bit.


*

*

-- 
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] 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"  wrote:
> 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(rootdata))
> findnodes(root->right,sum-root->data)
> else if(root>abs(sum-root->data))
> findnodes(root->left,sum-root->data)
> else if(root->left==NULL || root->right==NULL) print(root,sum-root);
>
>
>
> }

-- 
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] 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, and not very respectfull to the others.

That's my opinion.

Kind regards,

Chi

On Aug 22, 6:20 pm, Giri  wrote:
> 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"  wrote:
>
> > @manohar and @giri::
>
> > doesn recursion itself use stacks( implicitly)??
>
> > On Aug 18, 9:26 pm, Giri  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..
>
> > > On Aug 18, 8:01 am, Manjunath Manohar 
> > > wrote:
>
> > > > Tree *node
> > > > for(i=1;i<=height;i++)
> > > > {
> > > >    levelorder(node,i);}
>
> > > > void levelorder(Tree *node,int level)
> > > > {
> > > >    if(level==1)
> > > >      printf(node->value);
> > > >   else
> > > >      levelorder(node->left,level-1)
> > > >      levelorder(node->right,level-1);
>
> > > > }

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



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



[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"  wrote:
> @manohar and @giri::
>
> doesn recursion itself use stacks( implicitly)??
>
> On Aug 18, 9:26 pm, Giri  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..
>
> > On Aug 18, 8:01 am, Manjunath Manohar 
> > wrote:
>
> > > Tree *node
> > > for(i=1;i<=height;i++)
> > > {
> > >    levelorder(node,i);}
>
> > > void levelorder(Tree *node,int level)
> > > {
> > >    if(level==1)
> > >      printf(node->value);
> > >   else
> > >      levelorder(node->left,level-1)
> > >      levelorder(node->right,level-1);
>
> > > }

-- 
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] 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 
wrote:
> use stackpush one by one element before compare to top 2 element in stack {if 
> same then pop element and compare next char of string with top char in 
> stackif same continue otherwise clear stack}else{push element to stack}
> if wrong correct 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.
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: 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 wrote:

> 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  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
> >
> > Best Regards
> > Ashish Goel
> > "Think positive and find fuel in failure"
> > +919985813081
> > +919966006652
> >
> > On Sun, Aug 22, 2010 at 3:30 PM, Saikat Debnath  >wrote:
> >
> >
> >
> > > 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 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.
>
>

-- 
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: 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 wrote:

> 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  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
> >
> > Best Regards
> > Ashish Goel
> > "Think positive and find fuel in failure"
> > +919985813081
> > +919966006652
> >
> > On Sun, Aug 22, 2010 at 3:30 PM, Saikat Debnath  >wrote:
> >
> >
> >
> > > 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 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.
>
>

-- 
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] 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  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
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
> On Sun, Aug 22, 2010 at 3:30 PM, Saikat Debnath wrote:
>
>
>
> > 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 unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com > .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] Microsoft interview question

2010-08-22 Thread Ashish Goel
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



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


On Sun, Aug 22, 2010 at 3:30 PM, Saikat Debnath wrote:

> 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 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.



[algogeeks] Re: 0's and 1's yet again!!!

2010-08-22 Thread Dave
@Aravind: The intent was to do it in in one pass without extra memory,
and leave the input unchanged if the number of zeros does not equal
the number of ones. It seems to me that the combination of
requirements is tough.

Dave

On Aug 21, 10:22 pm, Aravind Prasad  wrote:
> if the intention of the problem is to do it in O(n)..
>
> then we can do 2 passses.. one to find the no of 0 and 1..
>
> then in 2nd pass,, put 0 in even and 1 in odd and leave the rest of
> the array as such..
>
> O(n)+O(n)=O(n).
>
> On Aug 20, 5:40 pm, Ashutosh Tamhankar  wrote:
>
>
>
> > Here is a C++ version of the algorithm to solve this problem.
>
> > #include 
> > #define TRUE 1
> > #define FALSE 0
> > typedef struct Binarr{
> >     int iNumber;
>
> > };
>
> > class binaryarr{
> >     Binarr * arr;
>
> > public:
> >     int iHead;
> >      int iSize;
> >     int iZeroes;
> >     int iOnes;
> >     int iTail;
> >     binaryarr(void);
> >     ~binaryarr(void);
> >     bool Rearrange(void);
> >     bool IsOdd(int iNumber);
> >     bool IsZero(int iNumber);
> >     bool SwapElements(int iUnexpected, int iCurrTail, int iExpected);
> >     bool ZeroOneBalanced(void);
> >     void Display(void);
>
> > };
>
> > void binaryarr:: Display(void){
> >     std::cout << std::endl << "Contents of the arr are";
> >     for(int j=0; j >         std::cout << std::endl<< arr[j].iNumber;
>
> > }
>
> > bool binaryarr:: ZeroOneBalanced(void){
> >     int iTotal = -1;
> >     iTotal = iOnes + iZeroes;
> >     if (iTotal == iSize && iOnes != iZeroes){
> >         std::cout << std::endl<<"Number of Ones =
> > "< >     std::cin >> iSize;
>
> >     if(iSize != 0){
> >         if ((iSize % 2) == 0)
> >         {
> >             std::cout << std::endl<<"Enter each zero or one and press
> > enter"< >             arr = (Binarr *) malloc(iSize-1);
> >             for (iIndex = 0 ; iIndex < iSize ; iIndex ++ )
> >                 std::cin >> arr[iIndex].iNumber;
> >             iHead = 0;
> >             iTail = iSize-1;
> >             iZeroes = 0;
> >             iOnes = 0;
> >         }
> >         else
> >         {
> >             std::cout << "The size of the arr cant fit equal number of zeros
> > and ones\n";
> >             iHead = -1;
> >         }
> >     }
> >     else
> >         {
> >             std::cout << "The size of the arr cant fit equal number of zeros
> > and ones\n";
> >             iHead = -1;
> >         }
>
> > }
>
> > // Free the memory
> > binaryarr::~binaryarr(void){
> >     /*if (iHead != -1)
> >     free(arr);*/
>
> > }
>
> > // is the given number odd or even
> > bool binaryarr::IsOdd(int iNumber){
> >     if ( (iNumber == 0 ) )
> >         return TRUE;
> >     else
> >         if (( (iNumber % 2) == 0 )  && (iNumber!=1) )
> >         return TRUE;
> >     else
> >         return FALSE;
>
> > }
>
> > // is the given number zero or one
> > bool binaryarr::IsZero(int iNumber){
>
> >     if (arr[iNumber].iNumber == 0){
> >         iZeroes = iZeroes + 1;
> >         return TRUE;
> >     }
> >     else
> >     {
> >         iOnes = iOnes + 1;
> >         return FALSE;
> >     }
>
> > }
>
> > bool binaryarr:: SwapElements(int iUnexpected, int iCurrTail, int
> > iExpected){
> >     int iTemp = -1;
> >     int iFound = -1;
> >     /*while !((IsZero(iUnexpected)) && iExpected){
> >         iCurrTail = iCurrTail - 1;
> >         iFound = 1;
> >     }*/
> >     for (int iDecr = iCurrTail; iDecr >= iUnexpected; iDecr--)
> >     {
> >         if((IsZero(iDecr)) && (iExpected == 0) || (!(IsZero(iDecr))) &&
> > (iExpected == 1))
> >         {
> >             iFound = 1;
> >             iTail = iDecr; // Reposition current tail.
> >             iTemp = arr[iUnexpected].iNumber;
> >             arr[iUnexpected].iNumber = arr[iDecr].iNumber;
> >             arr[iDecr].iNumber = iTemp;
> >             return TRUE;
> >         }
> >     }
> >     //
>
> >     if ((iFound == -1) || (iOnes != iZeroes))
> >     {
> >         std::cout << std::endl << "binaryarr:: SwapElements: Mismatch or
> > mismatch in num of zeros : ones. Expected = "< > "< >         return FALSE;
> >     }
>
> > }
>
> > // sort the input arr such that every odd position has a 1 and even position
> > a zero.
> > bool binaryarr::Rearrange(void){
>
> >     for (iHead = 0; iHead < iTail; iHead++) {
> >         if (IsOdd(iHead)) // Determine if the position on the arr is ODD
> >         {
> >             if (IsZero(iHead)) // Position is odd; but a zero encountered
> >             {
> >                 /*if (iTail == iHead)
> >                     iTail = iTail +1;*/
> >                 // Expected is 1.
> >                 if (!(SwapElements(iHead,iTail, 1))) {
> >                     std::cout << std::endl <<"No matching element found for
> > element @:"< >                     return FALSE;
> >                 }
> >                 else
> >                     std::cout << std::endl <<"Successfully swapped between
> > "< >             }
> >              // arr head is 1
> >         }
> > 

[algogeeks] Re: Google Interview Question

2010-08-22 Thread bittu
@debajyoti

can u xplain ur problm more clearly e.g. by example

Regards
Shashank

-- 
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] 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[] )
{
double max1 = ar[0]; // Assume the first
double max2 = ar[0]; // element in the array

int ZERO = 0; // Variable to store inside it the index of the 
max
value to set it to zero.

for( int i = 0; i < ar.length; i++ )
{
if( ar[i] >= max1)
{
max1 = ar[i];
ZERO = i;
}
}

ar[ZERO] = 0; // Set the index contains the 1st max to ZERO.

   //remove elemmn from reset length of array i..e. shrink
array


for( int j = 0; j < ar.length; j++ )
{
if( ar[j] >= max2 )
{
max2 = ar[j];
ZERO = j;
}
}



System.out.println("The 1st maximum element in the array is: " +
max1 + ", the 2nd is: " + max2);
}

public static void main(String[] args)
{
// Creating an object from the class Array to be able to use its
methods.
array array = new array();
// Creating an array of type double.
double a[] = {2.2, 3.4, 5.5, 5.5, 6.6, 5.6};

array.getMax( a ); // Calling the method that'll find the 1st 
max,
2nd max, and 3rd max.
}

}

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



[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 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: 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  wrote:

> @Nikhil : I considered the array to be a linked list. xoring the
> indexes helps when you don't know how many elements you have.
>
> Marius.
>
> On Aug 22, 5:04 am, Nikhil Agarwal  wrote:
> > @marius Why are you xorring the indexes along with nos.?any special
> reason?
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Sun, Aug 22, 2010 at 7:19 AM, UMarius  wrote:
> > > @Dave: I read the question correctly and for A = { 1 , 2} B = { 2 , 1}
> > > the output is correct.
> > > Maybe I didn't explain the steps correctly. This is the code:
> >
> > > for(int i = 0 ; i < arr1.Length ; i++)
> > >{
> > >arr1XOR ^= arr1[i];
> > >arr1XOR ^= i;
> >
> > >arr1SUM += arr1[i];
> > >arr1MUL *= arr1[i];
> > >}
> >
> > >for (int i = 0; i < arr2.Length; i++)
> > >{
> > >arr2XOR ^= arr2[i];
> > >arr2XOR ^= i;
> >
> > >arr2SUM += arr2[i];
> > >arr2MUL *= arr2[i];
> > >}
> >
> > >if(arr1XOR == arr2XOR && arr1SUM == arr2SUM && arr1MUL ==
> > > arr2MUL)
> > >{
> > >//SAME VALUES - IDENTICAL ARRAYS
> > >}
> > >else
> > >{
> > >//NOT IDENTICAL
> > >}
> >
> > > Please correct me if I'm wrong.
> >
> > > Marius.
> >
> > > On Aug 22, 3:45 am, Dave  wrote:
> > > > @UMarius: A = {1,2}, B = {2,1} fails your test. If you reread the
> > > > original problem, you see that the question is not whether the arrays
> > > > are identical (which is easily determined by simply comparing them
> > > > element-by-element in O(n)), but whether they contain the same
> values,
> > > > possibly in a different order.
> >
> > > > Dave
> >
> > > > On Aug 21, 11:01 am, UMarius  wrote:
> >
> > > > > What about this?
> >
> > > > > 1. xor all elements of each array and their corresponding indexes &
> > > > > sum all the elements of each array & mul all elements of each array
> > > > > 2. if all results are the same then the arrays are identical
> >
> > > > > Nice to "meet" you all, I just joined and this is my first post :)
> ...
> >
> > > > > > Given two arrays of numbers, find if each of the two arrays have
> the
> > > > > > same set of integers ? Suggest an algo which can run faster than
> > > NlogN
> > > > > > without extra space?- Hide quoted text -
> >
> > > > > - Show quoted text -
> >
> > > --
> > > 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.
> >
> > --
> > Thanks & Regards
> > Nikhil Agarwal
> > Senior Undergraduate
> > Computer Science & Engineering,
> > National Institute Of Technology,
> Durgapur,Indiahttp://tech-nikk.blogspot.comhttp://
> beta.freshersworld.com/communities/nitd
>
> --
> 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] 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 wrote:

> 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 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.



[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 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] 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 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] 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 rectangle with rectangle number 4 is 4, i.e.
1X4, 2X4, 2X3 and 4X4.

-- 
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] 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(rootdata))
findnodes(root->right,sum-root->data)
else if(root>abs(sum-root->data))
findnodes(root->left,sum-root->data)
else if(root->left==NULL || root->right==NULL) print(root,sum-root);
}

-- 
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] 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 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] Re: Algorithm to find all subsets of size K

2010-08-22 Thread R.ARAVINDH
@raj


really cool

On Aug 22, 1:08 pm, Raj N  wrote:
> 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  wrote:
> > Most efficient algorithm to find all subsets of size K??
>
> > --
> > 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 > .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] 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  wrote:
> the method of farword seek is inefficient. consider case of 10
> lines and you want to display only 3-4 lines. better seek from end.
>
> se a buffer[buf_size].
>
> let size =filesize.
> lc = 0;
> while(lc <= given line input)
> {
> fseek(fp, size);
> if(size < buf_size)
>   fread(fp, size, buffer);
> else
>   fread(fp, size, buf_size);
>
> parse buf_size for '\n'
>  if( \n is in buffer )
>    increment line counter(lc ++)
> if(size < buf_size)
>    size -= buf_size
>
> }
>
> // you know the size, read the buffer one by one and print it
> OR
> // you could have put them while reading on to stack and print it out
> now
>
> On Aug 15, 8:46 am, Dave  wrote:
>
>
>
> > Enter the lines into a FIFO queue as you read them. After you have
> > enqueued n lines, dequeue a line every time you enqueue one, so that
> > the queue will contain the last n (or fewer) lines of the file.
>
> > Dave
>
> > On Aug 13, 1:13 pm, amit  wrote:
>
> > > I am trying using fseek but somehow its not working?- Hide quoted text -
>
> > - Show quoted text -

-- 
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: 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;  // number/pow(10,string_length-min_length) if
string_length > min_length

else remainder = number
   struct node *left;
   struct node *right;
};

My idea is reduce all the numbers to the smallest digit number and then sort
the remainders and output the respective numbers.
Construct binary tree based on the remainder and perform the inorder
traversal i.e

while ( p!=NULL)
{
   inorder(p->left);
   printf("%d",p->number);
   inorder(p->right);
}

For eg:  635, 12, 9, 76, 4
Every number is reduced to one digit
635=> number=635 remainder=635/100=6
12=> number=12 remainder=12/10=1
9=>number=9 remainder=9
76=>number=76 remainder=76/10=7
4=> number=4 remainder=4

Inorder traversal based on remainder 1-4-6-7-9
But we output the numbers instead of remainders i.e
12-4-635-76-9

Correct me if I'm wrong !!

On Sun, Aug 22, 2010 at 11:08 AM, aravind prasad  wrote:

> @srinivas reddy
>
> i suppose u took my algo wrongly..
>
> consider ur eg: 2,242
>
> first digits== 2,2(same)
>
> 2nd digits== 2,4(here 2 remains as it is as there is no futher digit for no
> 2)
>
> now arrange==> 2242(output)...
>
> my algo works correctly here too..
>
> correct me if am wrong..
>
>
>
> On Sun, Aug 22, 2010 at 10:41 AM, srinivas reddy
>  wrote:
> > @aravind prasad
> >
> > ho can u arrange the numbers
> > 2,202
> >
> > suppose if u arrange 202 2
> > ok u wiil get the least value
> >
> > now 2,242
> > if u arrange in same manner as above u will get 242 2
> > which is not smallest one...
> >
> > so better luck next time.
> >
> > On Sun, Aug 22, 2010 at 8:41 AM, Aravind Prasad 
> wrote:
> >>
> >> for the method of comparison in insertion sort,, consider
> >>
> >> 1)compare the first digit of all nos and sort them
> >>
> >> 2)if they are same, go for next digit...
> >>
> >>
> >> correct me if am wrong...
> >>
> >>
> >> On Aug 21, 7:00 pm, Chonku  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
> >> >   .
> >> > /\
> >> >  3/ 5\
> >> >1/  3\5\
> >> > 31/ 2\   33\  \55
> >> >312\
> >> > Once we have a trie, just print it out by based on the smallest number
> >> > first. In this case, the print would go as follows.
> >> >
> >> > 313123355
> >> >
> >> > On Sat, Aug 21, 2010 at 12:53 PM, Nikhil Agarwal
> >> > wrote:
> >> >
> >> >
> >> >
> >> > > Suppose the test is like:
> >> >
> >> > > 21 71 217
> >> > > after sorting and msb appending we get: 217 712 217
> >> > > sort: 217 217 712
> >> >
> >> > > here we have 2 same elements 217 and 217 so we remove the 7 from the
> >> > > following logic:
> >> >
> >> > > 1.if msb > lsb we delete from the 2nd 217.else
> >> > > 2.we delete 7 from 1st one.
> >> >
> >> > > so this gives 2121771
> >> >
> >> > > if it wud have been 41 200 412->412 200 412->200 412 412
> >> > > here we will remove 2 from last one.giving 20041241 instead of
> >> > > 20041412 .
> >> >
> >> > > On Sat, Aug 21, 2010 at 12:26 PM, BALARUKESH SIVARAMAN <
> >> > > sbalarukesh1...@gmail.com> wrote:
> >> >
> >> > >> @Nikhil
> >> > >> I am clear with your first 2 algos but not with the change u
> >> > >> introduced
> >> > >> ie., adding a check. please give a working example
> >> >
> >> > >> --
> >> > >> 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
>  >> > >> .com>
> >> > >> .
> >> > >> For more options, visit this group at
> >> > >>http://groups.google.com/group/algogeeks?hl=en.
> >> >
> >> > > --
> >> > > Thanks & Regards
> >> > > Nikhil Agarwal
> >> > > Senior Undergraduate
> >> > > Computer Science & Engineering,
> >> > > National Institute Of Technology, Durgapur,India
> >> > >http://tech-nikk.blogspot.com
> >> > >http://beta.freshersworld.com/communities/nitd
> >> >
> >> > > --
> >> > >  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
>  >> > > .com>
> >> > > .
> >> > > For more options, visit this group at
> >> > >http://groups.google.com/group/algogeeks?hl=en.
> >>
> >> --
> >> You received this message be

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 hence 12 should appear first.

On Sun, Aug 22, 2010 at 12:39 PM, Raj N  wrote:

> 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;  // number/pow(10,string_length-min_length) if
> string_length > min_length
>
> else remainder = number
>struct node *left;
>struct node *right;
> };
>
> My idea is reduce all the numbers to the smallest digit number and then
> sort the remainders and output the respective numbers.
> Construct binary tree based on the remainder and perform the inorder
> traversal i.e
>
> while ( p!=NULL)
> {
>inorder(p->left);
>printf("%d",p->number);
>inorder(p->right);
> }
>
> For eg:  635, 12, 9, 76, 4
> Every number is reduced to one digit
> 635=> number=635 remainder=635/100=6
> 12=> number=12 remainder=12/10=1
> 9=>number=9 remainder=9
> 76=>number=76 remainder=76/10=7
> 4=> number=4 remainder=4
>
> Inorder traversal based on remainder 1-4-6-7-9
> But we output the numbers instead of remainders i.e
> 12-4-635-76-9
>
> Correct me if I'm wrong !!
>
> On Sun, Aug 22, 2010 at 11:08 AM, aravind prasad wrote:
>
>> @srinivas reddy
>>
>> i suppose u took my algo wrongly..
>>
>> consider ur eg: 2,242
>>
>> first digits== 2,2(same)
>>
>> 2nd digits== 2,4(here 2 remains as it is as there is no futher digit for
>> no 2)
>>
>> now arrange==> 2242(output)...
>>
>> my algo works correctly here too..
>>
>> correct me if am wrong..
>>
>>
>>
>> On Sun, Aug 22, 2010 at 10:41 AM, srinivas reddy
>>  wrote:
>> > @aravind prasad
>> >
>> > ho can u arrange the numbers
>> > 2,202
>> >
>> > suppose if u arrange 202 2
>> > ok u wiil get the least value
>> >
>> > now 2,242
>> > if u arrange in same manner as above u will get 242 2
>> > which is not smallest one...
>> >
>> > so better luck next time.
>> >
>> > On Sun, Aug 22, 2010 at 8:41 AM, Aravind Prasad 
>> wrote:
>> >>
>> >> for the method of comparison in insertion sort,, consider
>> >>
>> >> 1)compare the first digit of all nos and sort them
>> >>
>> >> 2)if they are same, go for next digit...
>> >>
>> >>
>> >> correct me if am wrong...
>> >>
>> >>
>> >> On Aug 21, 7:00 pm, Chonku  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
>> >> >   .
>> >> > /\
>> >> >  3/ 5\
>> >> >1/  3\5\
>> >> > 31/ 2\   33\  \55
>> >> >312\
>> >> > Once we have a trie, just print it out by based on the smallest
>> number
>> >> > first. In this case, the print would go as follows.
>> >> >
>> >> > 313123355
>> >> >
>> >> > On Sat, Aug 21, 2010 at 12:53 PM, Nikhil Agarwal
>> >> > wrote:
>> >> >
>> >> >
>> >> >
>> >> > > Suppose the test is like:
>> >> >
>> >> > > 21 71 217
>> >> > > after sorting and msb appending we get: 217 712 217
>> >> > > sort: 217 217 712
>> >> >
>> >> > > here we have 2 same elements 217 and 217 so we remove the 7 from
>> the
>> >> > > following logic:
>> >> >
>> >> > > 1.if msb > lsb we delete from the 2nd 217.else
>> >> > > 2.we delete 7 from 1st one.
>> >> >
>> >> > > so this gives 2121771
>> >> >
>> >> > > if it wud have been 41 200 412->412 200 412->200 412 412
>> >> > > here we will remove 2 from last one.giving 20041241 instead of
>> >> > > 20041412 .
>> >> >
>> >> > > On Sat, Aug 21, 2010 at 12:26 PM, BALARUKESH SIVARAMAN <
>> >> > > sbalarukesh1...@gmail.com> wrote:
>> >> >
>> >> > >> @Nikhil
>> >> > >> I am clear with your first 2 algos but not with the change u
>> >> > >> introduced
>> >> > >> ie., adding a check. please give a working example
>> >> >
>> >> > >> --
>> >> > >> 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
>> > >> > >> .com>
>> >> > >> .
>> >> > >> For more options, visit this group at
>> >> > >>http://groups.google.com/group/algogeeks?hl=en.
>> >> >
>> >> > > --
>> >> > > Thanks & Regards
>> >> > > Nikhil Agarwal
>> >> > > Senior Undergraduate
>> >> > > Computer Science & Engineering,
>> >> > > National Institute Of Technology, Durgapur,India
>> >> > >http://tech-nikk

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  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
>   .
> /\
>  3/ 5\
>1/  3\5\
> 31/ 2\   33\  \55
>312\
> Once we have a trie, just print it out by based on the smallest number
> first. In this case, the print would go as follows.
>
> 313123355
>
> On Sat, Aug 21, 2010 at 12:53 PM, Nikhil Agarwal <
> nikhil.bhoja...@gmail.com> wrote:
>
>> Suppose the test is like:
>>
>> 21 71 217
>> after sorting and msb appending we get: 217 712 217
>> sort: 217 217 712
>>
>> here we have 2 same elements 217 and 217 so we remove the 7 from the
>> following logic:
>>
>> 1.if msb > lsb we delete from the 2nd 217.else
>> 2.we delete 7 from 1st one.
>>
>> so this gives 2121771
>>
>> if it wud have been 41 200 412->412 200 412->200 412 412
>> here we will remove 2 from last one.giving 20041241 instead of 20041412 .
>>
>> On Sat, Aug 21, 2010 at 12:26 PM, BALARUKESH SIVARAMAN <
>> sbalarukesh1...@gmail.com> wrote:
>>
>>> @Nikhil
>>> I am clear with your first 2 algos but not with the change u introduced
>>> ie., adding a check. please give a working example
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> Thanks & Regards
>> Nikhil Agarwal
>> Senior Undergraduate
>> Computer Science & Engineering,
>> National Institute Of Technology, Durgapur,India
>> http://tech-nikk.blogspot.com
>> http://beta.freshersworld.com/communities/nitd
>>
>>
>> --
>>  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.
>



-- 
Thanks & Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science & Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

-- 
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:

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  wrote:

> use suffix trie.
>
> On Aug 16, 9:36 pm, ashita dadlani  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 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] 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 NULL then return;
if level is 1, then
print(tree->data);
else if level greater than 1, then
if(rtl)
printGivenLevel(tree->right, level-1, ltr);
printGivenLevel(tree->left, level-1, ltr);
else
printGivenLevel(tree->left, level-1, ltr);
printGivenLevel(tree->right, level-1, ltr);


Perform normal level order traversal but after each level, invert the
direction of traversal


On Sun, Aug 22, 2010 at 9:47 AM, luckyzoner  wrote:

> to traverse the tree in a spiral manner...
> 1. Insert the root into stack.
> 2. then in a loop check not both stack and queue are empty
> 3. {
>  while(stack not empty)
>{
>   node =pop(stack);
>   cout   insertintoqueue(node->left);
>   insertintoqueue(node->right);
>}
>
>   while(queue not empty)
> {
>node = dequeue(queue);
>cout
>push(node->left);
>push(node->right);
>
>}
>}
>
>
> On Aug 22, 6:41 am, Aravind Prasad  wrote:
> > can anyone provide the correct and full logic for printing BST
> > spirally ..
> >
> > consider a tree
> >
> >  a
> > /  \
> >bc
> >   / \   / \
> >  d  e f   g
> >
> > output==>> abcgfeh
> >
> > here my doubt is ==>>
> >
> > how to find the level at wihich we are present (considering we are
> > using a stack for even levels and queue for odd levels)
> >
> > On Aug 21, 9:50 am, Stanley Cai  wrote:
> >
> > > this one is not very right...
> >
> > >  public void solution(String str) {
> >
> > > int t = Integer.parseInt(str, 2);
> >
> > > System.out.printf(Integer.toBinaryString((int)((1l<<32) - t)));
> >
> > > }
> >
> > > Still for this issue, it could be hard if the string is very long,
> length is
> > > more than 32
> >
> > > On Fri, Aug 20, 2010 at 6:46 PM, GOBIND KUMAR 
> wrote:
> > > > This is the code for question no-4
> >
> > > > #include
> > > > #include
> > > > using namespace std;
> > > > int main(){
> > > > char str[20];
> > > > char *sp=str;
> > > > int n=0;
> > > > int count=0;int carry=1;
> > > > gets(str);
> > > > //cout<<"\n"< > > > while(*sp!='\0'){
> > > > *sp=(*sp=='1')?'0':'1';
> > > > sp++;
> > > > count++;
> > > > }
> > > > //cout<<"\n"< > > > sp--;
> > > > if(*sp=='1'){
> > > >  *sp='0';
> > > >  carry=1;
> > > >  }
> > > > else {
> > > > *sp='1';
> > > > cout<<"\n"< > > > getch();
> > > > return 0;
> > > > }
> > > >  sp--;
> > > >  while(count && carry){
> > > >if(*sp=='1'){
> > > >  *sp='0';
> > > >  carry=1;
> > > >  }
> > > >else{
> > > > *sp='1';
> > > > carry=0;
> > > >}
> > > > sp--;
> > > >   count--;
> > > >  }
> > > > cout<<"\n"< > > > getch();
> > > > return 0;
> >
> > > > }
> >
> > > >  --
> > > > 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.
>
>

-- 
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] 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  wrote:

> Most efficient algorithm to find all subsets of size K??
>
> --
> 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.



[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  wrote:
> Please check link.
>
> On Aug 15, 8:25 pm, Gene  wrote:
>
>
>
> >http://groups.google.com/group/algogeeks/browse_thread/thread/f56bac6...
>
> > The best solution given there is O(n) with only constant additional
> > storage.
>
> > On Aug 15, 1:51 pm, Debajyoti Sarma  wrote:
>
> > > so what was the optimal solution found in the previous discussion?? give 
> > > a link
> > > I don't remember the name of the thread...so only i posted this.
>
> > > On 8/15/10, Gene  wrote:
>
> > > > In fact this solution was suggested (without code) in the original
> > > > discussion.
>
> > > > It's O(n^2).
>
> > > > You're only re-ordering a constant number (4) of elements in each
> > > > recursive pass, and each pass requires O(n) time to execute.  You also
> > > > need to assume your compiler will remove the tail recursion.
> > > > Otherwise it will also require O(n) space, which misses the whole
> > > > point of the problem.
>
> > > > On Aug 15, 12:29 pm, Debajyoti Sarma 
> > > > wrote:
> > > >> Array of 2n length is given {a1,a2,a3,...,an,b1,b2,b3,...,bn}
> > > >> we have to make the array like as {a1,b1,a2,b2,a3,b3,...,an,bn}
> > > >> without using extra buffer space.
> > > >> here a solution i came up withhttp://codepad.org/ub5Ie4sI
> > > >> I know this was discussed before .
> > > >> But i want to know the time complexity of the code i have given(i m
> > > >> confused)
>
> > > > --
> > > > 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.



[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  wrote:
> use suffix trie.
>
> On Aug 16, 9:36 pm, ashita dadlani  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 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] 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  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 
"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] 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  wrote:
> For 30 years, I developed mathematical software (linear equation
> solvers, eigenvalue routines, fast Fourier transforms, etc.) on a wide
> variety of high-performance computers with interesting architectures.
> For those, the optimal-order algorithms are well known. My principal
> goal was to implement a variant of the best algorithm that made the
> constant as small as possible.
>
> Dave
>
> On Aug 17, 8:24 am, Ashutosh Tamhankar  wrote:
>
>
>
> > Greetings
>
> > How many of you guys calculate the time complexity of an algorithm
> > before implementing it on a day to day basis?
>
> > When you review your code, before committing it to the live source
> > code base, does anybody discuss the time complexity?
>
> > Would love to hear your interesting experiences..
>
> > Regards
> > Ashutosh

-- 
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] 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.
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] Re: BFS

2010-08-22 Thread R.ARAVINDH
@manohar and @giri::

doesn recursion itself use stacks( implicitly)??


On Aug 18, 9:26 pm, Giri  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..
>
> On Aug 18, 8:01 am, Manjunath Manohar 
> wrote:
>
>
>
> > Tree *node
> > for(i=1;i<=height;i++)
> > {
> >    levelorder(node,i);}
>
> > void levelorder(Tree *node,int level)
> > {
> >    if(level==1)
> >      printf(node->value);
> >   else
> >      levelorder(node->left,level-1)
> >      levelorder(node->right,level-1);
>
> > }

-- 
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: Adobe Questions

2010-08-22 Thread padmanaban sahadevan
@luckyzoner: thank u fr de logic dude

-- 
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: 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 some more things
good luck...

from:

srinivasa reddy eevuri
M.C.A NIT DURGAPUR



On Sun, Aug 22, 2010 at 11:08 AM, aravind prasad  wrote:

> @srinivas reddy
>
> i suppose u took my algo wrongly..
>
> consider ur eg: 2,242
>
> first digits== 2,2(same)
>
> 2nd digits== 2,4(here 2 remains as it is as there is no futher digit for no
> 2)
>
> now arrange==> 2242(output)...
>
> my algo works correctly here too..
>
> correct me if am wrong..
>
>
>
> On Sun, Aug 22, 2010 at 10:41 AM, srinivas reddy
>  wrote:
> > @aravind prasad
> >
> > ho can u arrange the numbers
> > 2,202
> >
> > suppose if u arrange 202 2
> > ok u wiil get the least value
> >
> > now 2,242
> > if u arrange in same manner as above u will get 242 2
> > which is not smallest one...
> >
> > so better luck next time.
> >
> > On Sun, Aug 22, 2010 at 8:41 AM, Aravind Prasad 
> wrote:
> >>
> >> for the method of comparison in insertion sort,, consider
> >>
> >> 1)compare the first digit of all nos and sort them
> >>
> >> 2)if they are same, go for next digit...
> >>
> >>
> >> correct me if am wrong...
> >>
> >>
> >> On Aug 21, 7:00 pm, Chonku  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
> >> >   .
> >> > /\
> >> >  3/ 5\
> >> >1/  3\5\
> >> > 31/ 2\   33\  \55
> >> >312\
> >> > Once we have a trie, just print it out by based on the smallest number
> >> > first. In this case, the print would go as follows.
> >> >
> >> > 313123355
> >> >
> >> > On Sat, Aug 21, 2010 at 12:53 PM, Nikhil Agarwal
> >> > wrote:
> >> >
> >> >
> >> >
> >> > > Suppose the test is like:
> >> >
> >> > > 21 71 217
> >> > > after sorting and msb appending we get: 217 712 217
> >> > > sort: 217 217 712
> >> >
> >> > > here we have 2 same elements 217 and 217 so we remove the 7 from the
> >> > > following logic:
> >> >
> >> > > 1.if msb > lsb we delete from the 2nd 217.else
> >> > > 2.we delete 7 from 1st one.
> >> >
> >> > > so this gives 2121771
> >> >
> >> > > if it wud have been 41 200 412->412 200 412->200 412 412
> >> > > here we will remove 2 from last one.giving 20041241 instead of
> >> > > 20041412 .
> >> >
> >> > > On Sat, Aug 21, 2010 at 12:26 PM, BALARUKESH SIVARAMAN <
> >> > > sbalarukesh1...@gmail.com> wrote:
> >> >
> >> > >> @Nikhil
> >> > >> I am clear with your first 2 algos but not with the change u
> >> > >> introduced
> >> > >> ie., adding a check. please give a working example
> >> >
> >> > >> --
> >> > >> 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
>  >> > >> .com>
> >> > >> .
> >> > >> For more options, visit this group at
> >> > >>http://groups.google.com/group/algogeeks?hl=en.
> >> >
> >> > > --
> >> > > Thanks & Regards
> >> > > Nikhil Agarwal
> >> > > Senior Undergraduate
> >> > > Computer Science & Engineering,
> >> > > National Institute Of Technology, Durgapur,India
> >> > >http://tech-nikk.blogspot.com
> >> > >http://beta.freshersworld.com/communities/nitd
> >> >
> >> > > --
> >> > >  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
>  >> > > .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.
> >
>
>
>
> --