Re: [algogeeks] Re: Find the later version

2011-10-11 Thread DIPANKAR DUTTA
what's happen if the versions are not in same length.. For example v1: 1.1.1.133.2 v2: 1.2 v3: 1.2.3.4..333 v4: 1.2.3.4.5554.222 v5: 1.3.2.2.2.2.2.2.2.2.2.2.2.2 It implies we must be scan from left side one by one ... In general the we make a some sort of lexical comparison where each

Re: [algogeeks] Given a String with unnecessary spaces, compact it in place

2011-10-11 Thread DIPANKAR DUTTA
Solution 1: need two scan : start from left and replace one by one by non-space character ( thus have minimal replacemnt) count =0; for (int i=0;ilen(str);i++) { if(str[i] !=NONSPCECHAR) {str[count++]=str[i] } } ps: any way it needs Left shift...and all solution must need left

[algogeeks] Re: subset of an array

2011-10-11 Thread Navneet
This is a very standard algorithm called subset sum problem and as mentioned above DP gives an efficient solution as the expense of extra space. On Oct 11, 9:14 am, abhishek sharma abhishek.p...@gmail.com wrote: yea DP will be O(given no * n) if all array entries are positive and the given no

Re: [algogeeks] remove duplicate words from a string

2011-10-11 Thread rahul sharma
if the string is sorted then int rmvDup(char arr[],int arrLen) { int i,j; for (i =1,j=0; i arrLen;i++) { if (arr[j] != arr[i]) { arr[j+1] = arr[i]; j = j+1; } } arr[j]='\0'; return j+1; } On Tue, Oct 11, 2011 at 9:18

Re: [algogeeks] adobe question help

2011-10-11 Thread Gaurav Kumar
This is a question from Laakman. This code operates by clearing all bits in N between position i and j, and then ORing to put M in there 1 public static int updateBits(int n, int m, int i, int j) { 2 int max = ~0; /* All 1's */ 3 4 // 1's through position j, then 0's 5 int left = max

Re: [algogeeks] remove duplicate words from a string

2011-10-11 Thread sachin goyal
lets take an example... hello naveen how are you naveen? how we can store the word each seperated by space into array if we are considering binary tree??? how we can measure which is smaller than other according to property?? if we store each word into hash table then how

Re: [algogeeks] remove duplicate words from a string

2011-10-11 Thread sunny agrawal
1. how we can store the word each seperated by space into array if we are considering binary tree??? Ans: Each Node will Have an array of Some Const Size limited by Max Word length 2. how we can measure which is smaller than other according to property?? Ans Obviously strcmp(str1,

Re: [algogeeks] Memorization

2011-10-11 Thread arvind kumar
ya ya,realy sorry..typo!its MEMOIZATION. On Mon, Oct 10, 2011 at 10:56 PM, Ankur Garg ankurga...@gmail.com wrote: Memoization ? On Mon, Oct 10, 2011 at 6:34 PM, arvind kumar arvindk...@gmail.comwrote: Can anyone tell me how to go about with the memorization technique to retrieve values

Re: [algogeeks] Re: Find the later version

2011-10-11 Thread sumit kumar pathak
* *regards - Sumit Kumar Pathak (Sumit/ Pathak/ SKP ...) *Smile is only good contagious thing.* *Spread it*! On Tue, Oct 11, 2011 at 11:22 AM, DIPANKAR DUTTA dutta.dipanka...@gmail.com wrote: what's happen if the versions are not in same length.. For example v1: 1.1.1.133.2 v2: 1.2

Re: [algogeeks] Memorization

2011-10-11 Thread Deepak Garg
go for Dynamic Programing On Tue, Oct 11, 2011 at 1:47 PM, arvind kumar arvindk...@gmail.com wrote: ya ya,realy sorry..typo!its MEMOIZATION. On Mon, Oct 10, 2011 at 10:56 PM, Ankur Garg ankurga...@gmail.com wrote: Memoization ? On Mon, Oct 10, 2011 at 6:34 PM, arvind kumar

[algogeeks] Re: Memorization

2011-10-11 Thread Gene
Memoization just adds a persistent map for the memoized function. It stores mappings from tuples of function arguments to the corresponding return value. Each time the function is called, its memoized version first checks the map to see if a result has already been computed. If so, it just

Re: [algogeeks] Memorization

2011-10-11 Thread Vandana Bachani
Hi Arvind, For the fibonacci series, we need to memoize only the the last 2 fibonacci numbers. We can even avoid recursion... So our regular fibonacci algorithm is the simplest example of a dynamic programming algorithm with memoization. To find nth fibonacci number: int p = 0, q = 1, f; for

Re: [algogeeks] adobe question help

2011-10-11 Thread prasad jondhale
grt -- 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

Re: [algogeeks] Given a String with unnecessary spaces, compact it in place

2011-10-11 Thread prasad jondhale
*ptr1=*ptr2=string; for(i=0;istrlen(string);i++) if(*str==' ') ptr2++; else { *ptr1=*ptr2; ptr1++; ptr2++; } hey guys if anything wrong in this code pls let me know On Tue, Oct 11, 2011 at 11:04 AM, DIPANKAR DUTTA dutta.dipanka...@gmail.com wrote:

Re: [algogeeks] Re: why we can not swap values using macro?

2011-10-11 Thread prasad jondhale
hey man u have made a very silly mistakeyou have swaped only pointers not values. #includestdio.h #define swap(a,b,c) c t;t=a,a=b,b=t; main() { float x=10,y=20; float *p,*q; p=x,q=y; swap(p,q,float *); printf(%f %f\n,*p,*q); } gives result 20.00 10.00 if want to change values of

Re: [algogeeks] How to Solve This

2011-10-11 Thread prasad jondhale
23 has 3 in its unit place but it is not multiple of 111 or 11 or . will u pls elaborate on the problem statement? On Mon, Oct 10, 2011 at 2:17 PM, anshu mishra anshumishra6...@gmail.comwrote: string all1Multiple(int x) { string s; setint mySet; mySet.push(0); int psize, r=1; do {

Re: [algogeeks] Additive sequence

2011-10-11 Thread prasad jondhale
i dont see any other approach than brute force On Mon, Oct 10, 2011 at 1:04 PM, anand karthik anandkarthik@gmail.comwrote: Hi, I dont remember the question text exactly but the following should convey it well The question: A number is said to be an additive number if it has the

[algogeeks] Re: How to Solve This

2011-10-11 Thread Dave
@Prasad: The number with 22 1s, 1,111,111,111,111,111,111,111, is divisible by 23. The quotient is 48,309,178,743,961,352,657. Dave On Oct 11, 5:00 pm, prasad jondhale jondhale.pra...@gmail.com wrote: 23 has 3 in its unit place but it is not multiple of 111 or 11 or . will u pls elaborate

Re: [algogeeks] Additive sequence

2011-10-11 Thread Rujin Cao
This looks like concatenation of Fibonacci sequence。 On Mon, Oct 10, 2011 at 3:34 PM, anand karthik anandkarthik@gmail.comwrote: Hi, I dont remember the question text exactly but the following should convey it well The question: A number is said to be an additive number if it has

Re: [algogeeks] How to Solve This

2011-10-11 Thread Deoki Nandan
@moderator now is it not voilation of ur group terms ...Another code has been posted ... What u 'll say now.. On 12 October 2011 03:30, prasad jondhale jondhale.pra...@gmail.com wrote: 23 has 3 in its unit place but it is not multiple of 111 or 11 or . will u pls elaborate on the problem

[algogeeks] Re: How to Solve This

2011-10-11 Thread vickywiz
Does multiple 1 means that number with 3 in units place has all 1's or there can be other digits in the multiple of number like 34111232?... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] How to Solve This

2011-10-11 Thread shady
thanks a lot for replying to the post... but try posting algorithm rather than actual code... On Mon, Oct 10, 2011 at 2:17 PM, anshu mishra anshumishra6...@gmail.comwrote: string all1Multiple(int x) { string s; setint mySet; mySet.push(0); int psize, r=1; do { psize = mySet.size(); s