Fwd: [algogeeks] Re: MICROSOFT

2011-09-11 Thread Ankur Garg
If its a BST then the rightmost element will be the maximum followed by root and left node So we can use recursion Working Code struct node* findKthLargest(node* root, int& k) { if(root==NULL){ return NULL; } struct node* temp; temp=findKthLargest(root->right,k); k--; if(k==0)

Fwd: [algogeeks] Re: String passing

2011-08-27 Thread raj kumar
"monsters are monsters" -- Forwarded message -- From: raj kumar Date: Sat, Aug 27, 2011 at 10:30 PM Subject: Re: [algogeeks] Re: String passing To: algogeeks@googlegroups.com can't understand what are you trying to say source -- You received this message because you are subs

Re: Fwd: [algogeeks] Re: recursive nearest square

2011-08-09 Thread Ankuj Gupta
My bad but it can be made recursive :) On Aug 9, 8:17 pm, Dave wrote: > @Ankuj: Yeah, but he asked for it to be recursive. Yours is iterative. > > Dave > > On Aug 9, 9:56 am, Ankuj Gupta wrote: > > > > > > > > > we can do it in logn by using binary search approach found > > n is the number w

Re: Fwd: [algogeeks] Re: recursive nearest square

2011-08-09 Thread Dave
@Ankuj: Yeah, but he asked for it to be recursive. Yours is iterative. Dave On Aug 9, 9:56 am, Ankuj Gupta wrote: > we can do it in logn by using binary search approach found > n is the number whose square root has to be > >         if(n==1) >                 return 1; >         if(n==0) >      

Re: Fwd: [algogeeks] Re: recursive nearest square

2011-08-09 Thread Ankuj Gupta
we can do it in logn by using binary search approach found n is the number whose square root has to be if(n==1) return 1; if(n==0) return 0; int low=0,high=n/2,mid,temp; while(1) { mid = (low+high)/2;

Fwd: [algogeeks] Re: recursive nearest square

2011-08-09 Thread Nikhil Veliath
@dave:Ma mistake should have been nearest square root :) -- 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...@goo

Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
Thanx for pointitn out the case :) Hope dis wil wrk. https://ideone.com/0LNkW On , Pankaj wrote: aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwzzyyzzabc output: Length of largest unique substring : 51 Sorry it gt posted thrice. On Jul 22, 7:50 pm, vaibhavmitta...@gmail.com wrote

Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwzzyyzzabc output: Length of largest unique substring : 51 Sorry it gt posted thrice. > > On Jul 22, 7:50 pm, vaibhavmitta...@gmail.com wrote: > > https://ideone.com/kzo2L > > > > Regards > > Vaibhav Mittal > > Computer Science > > Netaji Subhas Inst

Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread svm11
Sorry it gt posted thrice. On Jul 22, 7:50 pm, vaibhavmitta...@gmail.com wrote: > https://ideone.com/kzo2L > > Regards > Vaibhav Mittal > Computer Science > Netaji Subhas Institute Of Technology > Delhi. > > On , Pankaj wrote: > > > > > > > > > Vaibhav, Ok write your code and paste on ideone. It

Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com> wrote: U

Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com> wrote: U

Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com> wrote: U

Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, wrote: > U hv got my algo completely wrong. Gimme a smaller test case so that i may > wrk it out fr u. This one is freakingly large :P. > > > Regards > Vaibhav Mittal > Compu

Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
*abcdea*ifjlbmnodpq For this once you encounter a at 6th position, You can update your max. Now You will have to do following operation. First clear all the hash. 2. You now can not start from 6th position. You will have to do back and start from 2 position that is b. Right? What is the maximum un

Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
U hv got my algo completely wrong. Gimme a smaller test case so that i may wrk it out fr u. This one is freakingly large :P. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj wrote: abcdeaifjlbmnodpq For this once you encounter a at 6th position

Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal Compu

Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
Vaibhav What do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have i

Fwd: [algogeeks] Re: strings

2011-06-22 Thread oppilas .
May be I didn't understood your logic. According to original question for I/P kapilra O/P --kaapilr.. Now, -what if we create a binary tree with root as the first element of the string and if the next character is equal then place it to left else place it to right. Similar comparison will be d

Fwd: [algogeeks] Re: Design an algorithm

2010-09-30 Thread Rashmi Shrivastava
@ Modeling Expert,,thanx -- 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,

Fwd: [algogeeks] Re: String- Anagrams.

2009-09-01 Thread Nagendra Kumar
@Anil: I will request you to completly explain the things. Not just write a bit of code. So what is map and how are you implementing the insert operation. -- Forwarded message -- From: Anil C R Date: Mon, Aug 31, 2009 at 7:59 PM Subject: [algogeeks] Re: String- Anag

Fwd: [algogeeks] Re:

2009-06-02 Thread Avinash Dubey
-- Forwarded message -- From: Dhruva Sagar Date: Tue, Jun 2, 2009 at 4:23 PM Subject: [algogeeks] Re: To: algogeeks@googlegroups.com Yea! You could confirm from the excel sheet...This place is not for such jokes Thanks & Regards, Dhruva Sagar. George Bernard Shaw

Re: Fwd: [algogeeks] Re: Binary search

2009-03-04 Thread Prakhar Jain
no the order is log(n) On Wed, Mar 4, 2009 at 4:45 PM, sharad kumar wrote: > but commplexity is O(n2) rite??wat about my solution?? > > On Wed, Mar 4, 2009 at 4:32 PM, Prakhar Jain wrote: >> >> I would call search() >> not binsearch() >> search() find any index and then iterates sequentially t

Re: Fwd: [algogeeks] Re: Binary search

2009-03-04 Thread sharad kumar
but commplexity is O(n2) rite??wat about my solution?? On Wed, Mar 4, 2009 at 4:32 PM, Prakhar Jain wrote: > > I would call search() > not binsearch() > search() find any index and then iterates sequentially till the highest > index. > > Prakhar > > On Wed, Mar 4, 2009 at 4:27 PM, Kapil wrote:

Re: Fwd: [algogeeks] Re: Binary search

2009-03-04 Thread Prakhar Jain
I would call search() not binsearch() search() find any index and then iterates sequentially till the highest index. Prakhar On Wed, Mar 4, 2009 at 4:27 PM, Kapil wrote: > > @Prakhar how would you ensure that this is highest index > > On Mar 1, 3:05 pm, Prakhar Jain wrote: >> I guess the Soln

Re: Fwd: [algogeeks] Re: Binary search

2009-03-04 Thread Kapil
@Prakhar how would you ensure that this is highest index On Mar 1, 3:05 pm, Prakhar Jain wrote: > I guess the Soln given is O(n) > Much better can be achieved through binary serach O(nlogn) > > int binsearch(int a[],int start,int end,int key) > { > int mid=(start+end)/2; > if(start==end && a[mid

Fwd: [algogeeks] Re: Binary search

2009-03-01 Thread Prakhar Jain
I guess the Soln given is O(n) Much better can be achieved through binary serach O(nlogn) int binsearch(int a[],int start,int end,int key) { int mid=(start+end)/2; if(start==end && a[mid]!=key) return -1; if(a[mid]>key) end=mid; else if(a[mid]=0) while(a[p]==key) p++; return p-

[algogeeks] Re: Fwd: [algogeeks] Re: the sum of two unsigned integers

2007-01-24 Thread Lego Haryanto
*Santhosh Suresh > *Sent:* Wednesday, January 24, 2007 8:02 AM > *To:* algogeeks@googlegroups.com > *Subject:* [algogeeks] Fwd: [algogeeks] Re: the sum of two unsigned > integers > > > > > say, given the limit of the unsigned as k bits. Find log to base 2^k. If > i

[algogeeks] Re: Fwd: [algogeeks] Re: the sum of two unsigned integers

2007-01-24 Thread Ming \(Amos\) Zhang
: [algogeeks] Fwd: [algogeeks] Re: the sum of two unsigned integers say, given the limit of the unsigned as k bits. Find log to base 2^k. If it's one in both, it'll result in an overflow. -- Forwarded message -- From: aravind kumar <[EMAIL PROTECTED]> Date: Jan 24, 2007

[algogeeks] Fwd: [algogeeks] Re: the sum of two unsigned integers

2007-01-24 Thread Santhosh Suresh
say, given the limit of the unsigned as k bits. Find log to base 2^k. If it's one in both, it'll result in an overflow. -- Forwarded message -- From: aravind kumar <[EMAIL PROTECTED]> Date: Jan 24, 2007 7:10 PM Subject: [algogeeks] Re: the sum of two unsigned integers To: algogeeks