[algogeeks] square root problem

2010-08-18 Thread bittu
1 can anyone tell me the algo used by below problem & provide which is the best algo to compute square root of number.?? 2. can any one provide the solution of converting no. from base b1 to b2 without using intermediate base. #include #include int main() { float a,b,e=0.0

[algogeeks] Re: Array Problem

2010-08-18 Thread Dave
@Srinivas, Make that: Your algorithm seems to fail on A = {0,1,-2), B = (0,2,-3). I was thinking ones-complement arithmetic instead of twos- complement. Dave On Aug 18, 11:59 pm, Dave wrote: > @Srinivas, Your algorithm seems to fail on A = {0,1,-1), B = > (0,2,-2). > > Dave > > On Aug 18, 10:53

[algogeeks] Re: Array Problem

2010-08-18 Thread Dave
@Chonku, Make that: Your algorithm seems to fail on A = {0,1,-2), B = (0,2,-3). I was thinking onwa-complement arithmetic instead of twos- complement. Dave On Aug 18, 11:57 pm, Dave wrote: > @Chonku, Your algorithm seems to fail on A = {0,1,-1), B = (0,2,-2). > > Dave > > On Aug 18, 7:52 am, Cho

[algogeeks] Re: Array Problem

2010-08-18 Thread Dave
@Srinivas, Your algorithm seems to fail on A = {0,1,-1), B = (0,2,-2). Dave On Aug 18, 10:53 pm, srinivas reddy wrote: > add one more thing to the solution suggested by nikhil i.e;count the number > of elements in array 1 and number of elements in array2 if these two values > are equal then afte

[algogeeks] Re: Array Problem

2010-08-18 Thread Dave
@Chonku, Your algorithm seems to fail on A = {0,1,-1), B = (0,2,-2). Dave On Aug 18, 7:52 am, Chonku wrote: > 1. Sum all the elements of both arrays. If the sum are same then perform > step 2. If the sum is not different, then arrays are different. > 2. Xor elements of first array and then xor t

[algogeeks] Re: Array Problem

2010-08-18 Thread Dave
@Nikhil, Your algorithm seems to fail on A = {0,1,-1), B = (0,2,-2). Dave On Aug 17, 8:47 pm, Nikhil Agarwal wrote: > Sum all the elements of both the arrays..let it be s1 and s2 > Multiply the elements and call as m1 and m2 > if(s1==s2) &&(m1==m2) > return 1;else > return 0; > > O(n) > > > > >

Re: [algogeeks] Array Problem

2010-08-18 Thread srinivas reddy
add one more thing to the solution suggested by nikhil i.e;count the number of elements in array 1 and number of elements in array2 if these two values are equal then after follow the algo proposed by nikhil agarwal.. On Wed, Aug 18, 2010 at 8:50 PM, Rais Khan wrote: > @Chonku: Your algo seems t

Re: [algogeeks] Re: Longest Common Subsequence

2010-08-18 Thread ♪ ѕяiηivαѕαη ♪
Example: If my sequence is ABC..the longest common subsequence is AC,BC,AB. It is a very common problem... On Wed, Aug 18, 2010 at 11:58 AM, vinodh kumar wrote: > heh could u explain the question with a example..??!! > > On Aug 18, 8:47 pm, ♪ ѕяiηivαѕαη ♪ <21.sr...@gmail.com> wrote: > > Hi.. > >

[algogeeks] Re: BFS

2010-08-18 Thread Giri
@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 level

[algogeeks] Re: Longest Common Subsequence

2010-08-18 Thread vinodh kumar
heh could u explain the question with a example..??!! On Aug 18, 8:47 pm, ♪ ѕяiηivαѕαη ♪ <21.sr...@gmail.com> wrote: > Hi.. >  Can anyone here explain me /provide me with an algorithm/source code in C > which efficiently finds out the *longest common substring in the given > string??* -- You rec

[algogeeks] Longest Common Subsequence

2010-08-18 Thread ♪ ѕяiηivαѕαη ♪
Hi.. Can anyone here explain me /provide me with an algorithm/source code in C which efficiently finds out the *longest common substring in the given string??* -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email

Re: [algogeeks] Array Problem

2010-08-18 Thread Rais Khan
@Chonku: Your algo seems to fail with following input. Arr1[]= {1,6} Arr2[]={7} On Wed, Aug 18, 2010 at 8:42 PM, Rais Khan wrote: > @Nikhil: Your algo seems to fail with following input. What do you say? > Arr1[]= {1,2,3} > Arr2[]={6} > > > > > On Wed, Aug 18, 2010 at 7:17 AM, Nikhil Agarwal

Re: [algogeeks] Array Problem

2010-08-18 Thread Rais Khan
@Nikhil: Your algo seems to fail with following input. What do you say? Arr1[]= {1,2,3} Arr2[]={6} On Wed, Aug 18, 2010 at 7:17 AM, Nikhil Agarwal wrote: > Sum all the elements of both the arrays..let it be s1 and s2 > Multiply the elements and call as m1 and m2 > if(s1==s2) &&(m1==m2) > return

Re: [algogeeks] Array Problem

2010-08-18 Thread Chonku
1. Sum all the elements of both arrays. If the sum are same then perform step 2. If the sum is not different, then arrays are different. 2. Xor elements of first array and then xor the result with elements of second array. If result is zero, then the arrays are same. On Tue, Aug 17, 2010 at 11:33

Re: [algogeeks] Longest SubSequence with Sum < K

2010-08-18 Thread Amit Jaspal
You have to return the length of the subsequence with longest length and sum < K . If there are multiple solutions report anyone. On Wed, Aug 18, 2010 at 12:40 PM, srinivas reddy wrote: > sorry man to say that in your example so many solutions exist and one more > thing is problem is not clear tr

Re: [algogeeks] Brent's algorithm

2010-08-18 Thread jaladhi dave
Check out this link http://en.wikipedia.org/wiki/Cycle_detection On Wed, Aug 18, 2010 at 5:12 AM, jayapriya surendran wrote: > hi..i wanna know what is brent's algorithm n whether it can be used to > detect loops in linked list.If yes..is it better than Floyd's cycle > finding algo? > > -- >

Re: [algogeeks] Re: Brent's algorithm

2010-08-18 Thread jayapriya surendran
ya i checked out the algo..all i need is whether we can use it to detect loop in a linked list..if yes please do give the implementation.Thanks in advance. On Wed, Aug 18, 2010 at 12:16 PM, Prem Mallappa wrote: > information is available on Internet, >  - Wikipedia is a ocean of knowledge. >  - G

Re: [algogeeks] Re: Shuffling a deck of cards

2010-08-18 Thread Nikhil Jindal
Use Knuth Shuffle algo. On Sun, Aug 15, 2010 at 8:34 PM, Rahul Singhal wrote: > Let X1, X2…. XN (In this case N=52) be the set of N numbers to be shuffled. > >1. Set j to N >2. Generate a random number R. (uniformly distributed between 0 and 1) >3. Set k to (jR+1). k is now a random

Re: [algogeeks] Array Problem

2010-08-18 Thread Nikhil Agarwal
Sum all the elements of both the arrays..let it be s1 and s2 Multiply the elements and call as m1 and m2 if(s1==s2) &&(m1==m2) return 1;else return 0; O(n) On Tue, Aug 17, 2010 at 11:33 PM, amit wrote: > Given two arrays of numbers, find if each of the two arrays have the > same set of integers

Re: [algogeeks] Brent's algorithm

2010-08-18 Thread Nikhil Agarwal
On Wed, Aug 18, 2010 at 5:12 AM, jayapriya surendran wrote: > hi..i wanna know what is brent's algorithm n whether it can be used to > detect loops in linked list.If yes..is it better than Floyd's cycle > finding algo? > Brent's algorithm is also called Tortoise and Rabbit algorithm.It has been p

Re: [algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-18 Thread Rahul Singhal
Hi example (83)base 5 --> ()base7 num temp_num resultcarry 83 3* 1 (3/7) =0(3%7)=3 838*5 (40/7)=5 (40%7)=5 result=0+5=5 carry= 3+5=8 temp_carry=call convert for carry in which base is 10 and

[algogeeks] Tennis Doubles Tournament

2010-08-18 Thread Gene
You are given 4N doubles tennis players for some N>0. Say they are numbered 1,2,...,4N. A game of doubles is a 2-set of two 2-sets. {{A,B},{C,D}}, where A thru D are distinct players. Here the team of players A and B plays against the team of C and D. Your algorithm must print 4N-1 games that m

[algogeeks] Re: Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-18 Thread Gene
Since any modern computer is going to do all its operations in base 2, this is impossible. You have to allow the base that the computer uses for fundamental arithmetic. On Aug 18, 8:33 am, luckyzoner wrote: > I would again say that you don't have to use any intermediate base > while converting.

Re: [algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-18 Thread sumant hegde
It is not clear whether 'subtraction' operation for given base B1 is granted defined or you should write code for it. If it is already defined, then simulating division (working wrt base B1) is easy (repeated subtraction). Then the normal procedure of converting a number from base 10 to base b2 wou

[algogeeks] Re: Linked List

2010-08-18 Thread Vijay
1. typedef is used to rename the data type. Here struct node is actual data type of linked list node and is renamed to NODE using typedef .Instead of using struct node each time we declares a new node variable we can use simply NODE. 2.**start is required if you pass actual parameter as address,

[algogeeks] Linked List

2010-08-18 Thread bittu
can any one tell me in the below post struct node { int info; struct node *next; }; typedef struct node NODE; 1. why typedef used & whats d benifet of doing this NODE *start; void createmptylist(NODE **start) 2. why Node **start used instead we can also use Node *start & get same re. { *

[algogeeks] Re: Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-18 Thread luckyzoner
I would again say that you don't have to use any intermediate base while converting. -- 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 t

Re: [algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-18 Thread Rais Khan
Below formula seems working to me for converting number from base B1 to base B2. But For intermediate operation we have to be careful, as comiler does all operation with base 10. newNum = (oldNum/newBase)*oldBase + oldNum%newBase; So Algo, 1. Number, oldBase, newbase; 2. First convert number from

Re: [algogeeks] Longest SubSequence with Sum < K

2010-08-18 Thread srinivas reddy
sorry man to say that in your example so many solutions exist and one more thing is problem is not clear try to give clear idea On Tue, Aug 17, 2010 at 11:47 PM, amit wrote: > Given an array, find the longest subarray which the sum of the > subarray less or equal then the given MaxSum > int[] Fi