[algogeeks] Re: help..
@mohit: nice soln :) On Jul 2, 2:50 pm, mohit goel mohitgoel291...@gmail.com wrote: May be this can work.give any counter example... int count; main() { int l,rope,cuts; scanf(%d%d,l,rope); count =0; find_cuts(l,rope); printf(cuts needed is %d,count); getch(); return 0; } int find_cuts(int l,int rope) { if(l==rope) return count; count++; printf(%d,count); l=l/2; if(l==rope) return count; if(ropel) rope =rope-l; find_cuts(l,rope); } -- 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.
[algogeeks] Re: help..
@mohit: a little change in your function to make it work.. int find_cuts(int l,int rope) int find_cuts(int l,int rope) { if(l==rope) return count; count++; // printf(%d,count); l=l/2; if(l==rope) return count; if(ropel) rope =rope-l; return find_cuts(l,rope); } -- 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.
[algogeeks] Re: help..
@avi dullu: explanation of your code plz.. On Jul 3, 3:57 am, Avi Dullu avi.du...@gmail.com wrote: Another alternative soln. int rec_cut(int l, int k) { if (l == k) return 0; int tmp = k - (l1); return 1 + rec_cut(l1, tmp = 0 ? k : tmp); } int main() { int l, k; scanf(%d%d, l, k); printf(%d\n, rec_cut(l, k)); return 0; } Veni Vedi Slumber ! On Sat, Jul 2, 2011 at 9:47 PM, varun pahwa varunpahwa2...@gmail.comwrote: @sunny thnx for the correction. On Sat, Jul 2, 2011 at 9:16 AM, varun pahwa varunpahwa2...@gmail.comwrote: @sunny ya i wanted to write the while(k % m == 0) On Sat, Jul 2, 2011 at 3:47 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: nn-1 is the expression to find out if n is a power of 2...If nn-1 returns 0 its a power of 2 else its not. And what sunny said is also ryt On Sat, Jul 2, 2011 at 3:47 PM, sunny agrawal sunny816.i...@gmail.comwrote: @cegprakash Expression resets the least significant set bit On Sat, Jul 2, 2011 at 3:20 PM, mohit goel mohitgoel291...@gmail.comwrote: May be this can work.give any counter example... int count; main() { int l,rope,cuts; scanf(%d%d,l,rope); count =0; find_cuts(l,rope); printf(cuts needed is %d,count); getch(); return 0; } int find_cuts(int l,int rope) { if(l==rope) return count; count++; printf(%d,count); l=l/2; if(l==rope) return count; if(ropel) rope =rope-l; find_cuts(l,rope); } -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: help..
i was actually trying this problem.. www.spoj.pl/problems/LQDCANDY I'm getting WA still.. #includemath.h #includestdio.h int cnt; inline int find_cuts(int l,int rope) { if(l==rope) return cnt; cnt++; l=l/2; if(l==rope) return cnt; if(ropel) rope-=l; return find_cuts(l,rope); } int main(){ int t; scanf(%d,t); while(t--){ int n,needed; scanf(%d,n); int x=log2(n); int p=(int)pow(2,x); if(n!=p) needed=(int)pow(2,x+1); else{ printf(%d 0\n,n); continue; } if(n%2==1) printf(%d %d\n,needed,(int)log2(needed)); else{ cnt=0; printf(%d %d\n,needed,find_cuts(needed,n)); } } } -- 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.
Re: [algogeeks] Re: help..
I think its problem of overflow? the input data is 10^18.Otherwise the problem is trivial On Sun, Jul 3, 2011 at 7:02 PM, cegprakash cegprak...@gmail.com wrote: i was actually trying this problem.. www.spoj.pl/problems/LQDCANDY I'm getting WA still.. #includemath.h #includestdio.h int cnt; inline int find_cuts(int l,int rope) { if(l==rope) return cnt; cnt++; l=l/2; if(l==rope) return cnt; if(ropel) rope-=l; return find_cuts(l,rope); } int main(){ int t; scanf(%d,t); while(t--){ int n,needed; scanf(%d,n); int x=log2(n); int p=(int)pow(2,x); if(n!=p) needed=(int)pow(2,x+1); else{ printf(%d 0\n,n); continue; } if(n%2==1) printf(%d %d\n,needed,(int)log2(needed)); else{ cnt=0; printf(%d %d\n,needed,find_cuts(needed,n)); } } } -- 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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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.
[algogeeks] Re: help..
that will not work. for example we need a rope of length 4 from a rope of length 16 we need 2 cuts 16== 8 + 8 == 8+ 4+ 4 -- 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.
[algogeeks] Re: help..
nope On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote: yup :) On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: i guess the no. of 1s in the binary representation of the number is the answer..for 6 its 2... On Sat, Jul 2, 2011 at 1:32 PM, cegprakash cegprak...@gmail.com wrote: the length of the rope is l units. I can only cut any rope into two halves. for example if the length of the rope is 8 and we need a length of rope 6 we first cut into two halves and we get 4, 4 now we cut any of the half again and we get 4,2,2 now we can merge 4 and 2 and form a rope of length 6. in this example we need a minimum of 2 cuts to get the length of rope 6 from 8 assume that l is always a power of 2 and we need always a even length of rope from it how to find the number of minimum cuts needed to get the new rope?. -- 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.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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: help..
k - rope of desired length. l - rope of given length m = 2; while(k % m) m *= 2; ans :: (log2(l) - log2(m) + 1). ex. k = 6,l = 8 so initially m = 2; after 1st iteration m = 4; then break; so min = log2(8) - log2(4) + 1 = 3 -2 + 1 = 2. On Sat, Jul 2, 2011 at 1:16 AM, cegprakash cegprak...@gmail.com wrote: nope On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote: yup :) On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: i guess the no. of 1s in the binary representation of the number is the answer..for 6 its 2... On Sat, Jul 2, 2011 at 1:32 PM, cegprakash cegprak...@gmail.com wrote: the length of the rope is l units. I can only cut any rope into two halves. for example if the length of the rope is 8 and we need a length of rope 6 we first cut into two halves and we get 4, 4 now we cut any of the half again and we get 4,2,2 now we can merge 4 and 2 and form a rope of length 6. in this example we need a minimum of 2 cuts to get the length of rope 6 from 8 assume that l is always a power of 2 and we need always a even length of rope from it how to find the number of minimum cuts needed to get the new rope?. -- 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.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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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.
Re: [algogeeks] Re: help..
xor the length of the rope with the required length and difference between the indexes of first set and last set bit *may* be the answer !! On Sat, Jul 2, 2011 at 1:46 PM, cegprakash cegprak...@gmail.com wrote: nope On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote: yup :) On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: i guess the no. of 1s in the binary representation of the number is the answer..for 6 its 2... On Sat, Jul 2, 2011 at 1:32 PM, cegprakash cegprak...@gmail.com wrote: the length of the rope is l units. I can only cut any rope into two halves. for example if the length of the rope is 8 and we need a length of rope 6 we first cut into two halves and we get 4, 4 now we cut any of the half again and we get 4,2,2 now we can merge 4 and 2 and form a rope of length 6. in this example we need a minimum of 2 cuts to get the length of rope 6 from 8 assume that l is always a power of 2 and we need always a even length of rope from it how to find the number of minimum cuts needed to get the new rope?. -- 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.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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
[algogeeks] Re: help..
k is an even number and m=2 in your code. k%2 is always 0. your while loop does nothing. On Jul 2, 1:26 pm, varun pahwa varunpahwa2...@gmail.com wrote: k - rope of desired length. l - rope of given length m = 2; while(k % m) m *= 2; ans :: (log2(l) - log2(m) + 1). ex. k = 6,l = 8 so initially m = 2; after 1st iteration m = 4; then break; so min = log2(8) - log2(4) + 1 = 3 -2 + 1 = 2. On Sat, Jul 2, 2011 at 1:16 AM, cegprakash cegprak...@gmail.com wrote: nope On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote: yup :) On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: i guess the no. of 1s in the binary representation of the number is the answer..for 6 its 2... On Sat, Jul 2, 2011 at 1:32 PM, cegprakash cegprak...@gmail.com wrote: the length of the rope is l units. I can only cut any rope into two halves. for example if the length of the rope is 8 and we need a length of rope 6 we first cut into two halves and we get 4, 4 now we cut any of the half again and we get 4,2,2 now we can merge 4 and 2 and form a rope of length 6. in this example we need a minimum of 2 cuts to get the length of rope 6 from 8 assume that l is always a power of 2 and we need always a even length of rope from it how to find the number of minimum cuts needed to get the new rope?. -- 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.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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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.
Re: [algogeeks] Re: help..
@varun I think u want to write while (k % m == 0) On Sat, Jul 2, 2011 at 1:56 PM, varun pahwa varunpahwa2...@gmail.comwrote: k - rope of desired length. l - rope of given length m = 2; while(k % m) m *= 2; ans :: (log2(l) - log2(m) + 1). ex. k = 6,l = 8 so initially m = 2; after 1st iteration m = 4; then break; so min = log2(8) - log2(4) + 1 = 3 -2 + 1 = 2. On Sat, Jul 2, 2011 at 1:16 AM, cegprakash cegprak...@gmail.com wrote: nope On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote: yup :) On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: i guess the no. of 1s in the binary representation of the number is the answer..for 6 its 2... On Sat, Jul 2, 2011 at 1:32 PM, cegprakash cegprak...@gmail.com wrote: the length of the rope is l units. I can only cut any rope into two halves. for example if the length of the rope is 8 and we need a length of rope 6 we first cut into two halves and we get 4, 4 now we cut any of the half again and we get 4,2,2 now we can merge 4 and 2 and form a rope of length 6. in this example we need a minimum of 2 cuts to get the length of rope 6 from 8 assume that l is always a power of 2 and we need always a even length of rope from it how to find the number of minimum cuts needed to get the new rope?. -- 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.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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
[algogeeks] Re: help..
whats mean by first set bit and last set bit? do you simply mean the index of first and last bit? On Jul 2, 1:25 pm, sunny agrawal sunny816.i...@gmail.com wrote: xor the length of the rope with the required length and difference between the indexes of first set and last set bit *may* be the answer !! On Sat, Jul 2, 2011 at 1:46 PM, cegprakash cegprak...@gmail.com wrote: nope On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote: yup :) On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: i guess the no. of 1s in the binary representation of the number is the answer..for 6 its 2... On Sat, Jul 2, 2011 at 1:32 PM, cegprakash cegprak...@gmail.com wrote: the length of the rope is l units. I can only cut any rope into two halves. for example if the length of the rope is 8 and we need a length of rope 6 we first cut into two halves and we get 4, 4 now we cut any of the half again and we get 4,2,2 now we can merge 4 and 2 and form a rope of length 6. in this example we need a minimum of 2 cuts to get the length of rope 6 from 8 assume that l is always a power of 2 and we need always a even length of rope from it how to find the number of minimum cuts needed to get the new rope?. -- 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.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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
Re: [algogeeks] Re: help..
yes i have written that only difference between indexes of first set bit and last set bit On Sat, Jul 2, 2011 at 2:08 PM, cegprakash cegprak...@gmail.com wrote: whats mean by first set bit and last set bit? do you simply mean the index of first and last bit? On Jul 2, 1:25 pm, sunny agrawal sunny816.i...@gmail.com wrote: xor the length of the rope with the required length and difference between the indexes of first set and last set bit *may* be the answer !! On Sat, Jul 2, 2011 at 1:46 PM, cegprakash cegprak...@gmail.com wrote: nope On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote: yup :) On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: i guess the no. of 1s in the binary representation of the number is the answer..for 6 its 2... On Sat, Jul 2, 2011 at 1:32 PM, cegprakash cegprak...@gmail.com wrote: the length of the rope is l units. I can only cut any rope into two halves. for example if the length of the rope is 8 and we need a length of rope 6 we first cut into two halves and we get 4, 4 now we cut any of the half again and we get 4,2,2 now we can merge 4 and 2 and form a rope of length 6. in this example we need a minimum of 2 cuts to get the length of rope 6 from 8 assume that l is always a power of 2 and we need always a even length of rope from it how to find the number of minimum cuts needed to get the new rope?. -- 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.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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
Re: [algogeeks] Re: help..
l = 81 0 0 0 k = 6 0 1 1 0 xor 1 1 1 0 difference = 2 l = 161 0 0 0 0 k = 4 0 0 1 0 0 xor On Sat, Jul 2, 2011 at 2:09 PM, sunny agrawal sunny816.i...@gmail.comwrote: yes i have written that only difference between indexes of first set bit and last set bit On Sat, Jul 2, 2011 at 2:08 PM, cegprakash cegprak...@gmail.com wrote: whats mean by first set bit and last set bit? do you simply mean the index of first and last bit? On Jul 2, 1:25 pm, sunny agrawal sunny816.i...@gmail.com wrote: xor the length of the rope with the required length and difference between the indexes of first set and last set bit *may* be the answer !! On Sat, Jul 2, 2011 at 1:46 PM, cegprakash cegprak...@gmail.com wrote: nope On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote: yup :) On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: i guess the no. of 1s in the binary representation of the number is the answer..for 6 its 2... On Sat, Jul 2, 2011 at 1:32 PM, cegprakash cegprak...@gmail.com wrote: the length of the rope is l units. I can only cut any rope into two halves. for example if the length of the rope is 8 and we need a length of rope 6 we first cut into two halves and we get 4, 4 now we cut any of the half again and we get 4,2,2 now we can merge 4 and 2 and form a rope of length 6. in this example we need a minimum of 2 cuts to get the length of rope 6 from 8 assume that l is always a power of 2 and we need always a even length of rope from it how to find the number of minimum cuts needed to get the new rope?. -- 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.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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
[algogeeks] Re: help..
even that won't work for example: if we need a length of rope 14 from a length of rope 16 according to varun's algo initially m=2 14%2 is 0.. so m=4 14%4 is not 0.. break.. so log2(16)-log2(14)+ 1 == 4-3+1 = 2 which is wrong but actually we need atleast 3 cuts. 16== 8 + 8 == 8+ 4+ 4 == 8 + 4+ 2 + 2.. now we can merge 2,4 and 8 to form 14 On Jul 2, 1:35 pm, sunny agrawal sunny816.i...@gmail.com wrote: @varun I think u want to write while (k % m == 0) On Sat, Jul 2, 2011 at 1:56 PM, varun pahwa varunpahwa2...@gmail.comwrote: k - rope of desired length. l - rope of given length m = 2; while(k % m) m *= 2; ans :: (log2(l) - log2(m) + 1). ex. k = 6,l = 8 so initially m = 2; after 1st iteration m = 4; then break; so min = log2(8) - log2(4) + 1 = 3 -2 + 1 = 2. On Sat, Jul 2, 2011 at 1:16 AM, cegprakash cegprak...@gmail.com wrote: nope On Jul 2, 1:14 pm, keyan karthi keyankarthi1...@gmail.com wrote: yup :) On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah shalinisah.luv4cod...@gmail.com wrote: i guess the no. of 1s in the binary representation of the number is the answer..for 6 its 2... On Sat, Jul 2, 2011 at 1:32 PM, cegprakash cegprak...@gmail.com wrote: the length of the rope is l units. I can only cut any rope into two halves. for example if the length of the rope is 8 and we need a length of rope 6 we first cut into two halves and we get 4, 4 now we cut any of the half again and we get 4,2,2 now we can merge 4 and 2 and form a rope of length 6. in this example we need a minimum of 2 cuts to get the length of rope 6 from 8 assume that l is always a power of 2 and we need always a even length of rope from it how to find the number of minimum cuts needed to get the new rope?. -- 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.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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
[algogeeks] Re: help..
@varun: i think it works.. could u tell me how u found it -- 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.
[algogeeks] Re: help..
@ sunny: so your's doesn't work right? -- 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.
Re: [algogeeks] Re: help..
why ? On Sat, Jul 2, 2011 at 2:20 PM, cegprakash cegprak...@gmail.com wrote: @ sunny: so your's doesn't work right? -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
[algogeeks] Re: help..
@varun: explanation or proof for your soln. plz.. -- 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.
[algogeeks] Re: help..
oh fine.. got it now.. set bit is '1' right.. and is there any short ways to find the difference between first set and short set bit without dividing by 2 repeatedly? -- 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.
Re: [algogeeks] Re: help..
for a number N first set bit(From Left) is simply integer value of log(N) last set bit can be calculated as N = N-(N(N-1)); and then Log(N) int i = log(n); n -= n(n-1); int j = log(n); i-j will be the answer. On Sat, Jul 2, 2011 at 2:34 PM, cegprakash cegprak...@gmail.com wrote: oh fine.. got it now.. set bit is '1' right.. and is there any short ways to find the difference between first set and short set bit without dividing by 2 repeatedly? -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
[algogeeks] Re: help..
awesome!! thank you so much :) On Jul 2, 2:11 pm, sunny agrawal sunny816.i...@gmail.com wrote: for a number N first set bit(From Left) is simply integer value of log(N) last set bit can be calculated as N = N-(N(N-1)); and then Log(N) int i = log(n); n -= n(n-1); int j = log(n); i-j will be the answer. On Sat, Jul 2, 2011 at 2:34 PM, cegprakash cegprak...@gmail.com wrote: oh fine.. got it now.. set bit is '1' right.. and is there any short ways to find the difference between first set and short set bit without dividing by 2 repeatedly? -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
[algogeeks] Re: help..
btw what N = N-(N(N-1)) does actually On Jul 2, 2:11 pm, sunny agrawal sunny816.i...@gmail.com wrote: for a number N first set bit(From Left) is simply integer value of log(N) last set bit can be calculated as N = N-(N(N-1)); and then Log(N) int i = log(n); n -= n(n-1); int j = log(n); i-j will be the answer. On Sat, Jul 2, 2011 at 2:34 PM, cegprakash cegprak...@gmail.com wrote: oh fine.. got it now.. set bit is '1' right.. and is there any short ways to find the difference between first set and short set bit without dividing by 2 repeatedly? -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
Re: [algogeeks] Re: help..
try out with examples!! u will surely get in 2-3 examples N(N-1) is a very famous expression, used in counting set bits. see what this expression return On Sat, Jul 2, 2011 at 2:51 PM, cegprakash cegprak...@gmail.com wrote: btw what N = N-(N(N-1)) does actually On Jul 2, 2:11 pm, sunny agrawal sunny816.i...@gmail.com wrote: for a number N first set bit(From Left) is simply integer value of log(N) last set bit can be calculated as N = N-(N(N-1)); and then Log(N) int i = log(n); n -= n(n-1); int j = log(n); i-j will be the answer. On Sat, Jul 2, 2011 at 2:34 PM, cegprakash cegprak...@gmail.com wrote: oh fine.. got it now.. set bit is '1' right.. and is there any short ways to find the difference between first set and short set bit without dividing by 2 repeatedly? -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
Re: [algogeeks] Re: help..
@sunny that will work fine(xoring). In place of Xoring u can also do OR of two number and find the distance between fist set bit from left and first set bit from right, Since bit operation is really fast operation so best algo this is of complexity O(1); Explanation How it works: In l only one bit will be set. In m multiple bit would be set with all bit before the bit set in l. NOW suppose u divde l in 2 parts means u have shifted set bit of l to the right. dividing again will shift set bit in l to the right. u have to divide till set bit in l reached the position where first bit of m is set. how many times u have shifted is count of dividng the rope its Simple. u can check with any example Thanks Santosh On Sat, Jul 2, 2011 at 2:41 PM, sunny agrawal sunny816.i...@gmail.comwrote: for a number N first set bit(From Left) is simply integer value of log(N) last set bit can be calculated as N = N-(N(N-1)); and then Log(N) int i = log(n); n -= n(n-1); int j = log(n); i-j will be the answer. On Sat, Jul 2, 2011 at 2:34 PM, cegprakash cegprak...@gmail.com wrote: oh fine.. got it now.. set bit is '1' right.. and is there any short ways to find the difference between first set and short set bit without dividing by 2 repeatedly? -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: help..
@sunny the no of set bits in m will tell what all length(4,2 in above case) are need to be merged. e.g if if m ==6 then m = 0110 since bit set position are 2 and 1. so length of rope need to combine is 2^2=4 and 2^1 = 2;i.e 4 and 2 Thnaks Santosh On Sat, Jul 2, 2011 at 2:58 PM, santosh mahto santoshbit2...@gmail.comwrote: @sunny that will work fine(xoring). In place of Xoring u can also do OR of two number and find the distance between fist set bit from left and first set bit from right, Since bit operation is really fast operation so best algo this is of complexity O(1); Explanation How it works: In l only one bit will be set. In m multiple bit would be set with all bit before the bit set in l. NOW suppose u divde l in 2 parts means u have shifted set bit of l to the right. dividing again will shift set bit in l to the right. u have to divide till set bit in l reached the position where first bit of m is set. how many times u have shifted is count of dividng the rope its Simple. u can check with any example Thanks Santosh On Sat, Jul 2, 2011 at 2:41 PM, sunny agrawal sunny816.i...@gmail.comwrote: for a number N first set bit(From Left) is simply integer value of log(N) last set bit can be calculated as N = N-(N(N-1)); and then Log(N) int i = log(n); n -= n(n-1); int j = log(n); i-j will be the answer. On Sat, Jul 2, 2011 at 2:34 PM, cegprakash cegprak...@gmail.com wrote: oh fine.. got it now.. set bit is '1' right.. and is there any short ways to find the difference between first set and short set bit without dividing by 2 repeatedly? -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: help..
@ sunny 21 is 0 32 is 2 43 is 0 5 4 is 4 65 is 4 I don't find anything -- 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.
[algogeeks] Re: help..
power of 2 less than n right? On Jul 2, 2:38 pm, cegprakash cegprak...@gmail.com wrote: @ sunny 21 is 0 32 is 2 43 is 0 5 4 is 4 65 is 4 I don't find anything -- 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.
[algogeeks] Re: help..
no no.. it should be multiple of 2 less than n? even that doesn't satisfies for 43 On Jul 2, 2:41 pm, cegprakash cegprak...@gmail.com wrote: power of 2 less than n right? On Jul 2, 2:38 pm, cegprakash cegprak...@gmail.com wrote: @ sunny 21 is 0 32 is 2 43 is 0 5 4 is 4 65 is 4 I don't find anything -- 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.
Re: [algogeeks] Re: help..
May be this can work.give any counter example... int count; main() { int l,rope,cuts; scanf(%d%d,l,rope); count =0; find_cuts(l,rope); printf(cuts needed is %d,count); getch(); return 0; } int find_cuts(int l,int rope) { if(l==rope) return count; count++; printf(%d,count); l=l/2; if(l==rope) return count; if(ropel) rope =rope-l; find_cuts(l,rope); } -- 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.
Re: [algogeeks] Re: help..
@cegprakash Expression resets the least significant set bit On Sat, Jul 2, 2011 at 3:20 PM, mohit goel mohitgoel291...@gmail.comwrote: May be this can work.give any counter example... int count; main() { int l,rope,cuts; scanf(%d%d,l,rope); count =0; find_cuts(l,rope); printf(cuts needed is %d,count); getch(); return 0; } int find_cuts(int l,int rope) { if(l==rope) return count; count++; printf(%d,count); l=l/2; if(l==rope) return count; if(ropel) rope =rope-l; find_cuts(l,rope); } -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
Re: [algogeeks] Re: help..
nn-1 is the expression to find out if n is a power of 2...If nn-1 returns 0 its a power of 2 else its not. And what sunny said is also ryt On Sat, Jul 2, 2011 at 3:47 PM, sunny agrawal sunny816.i...@gmail.comwrote: @cegprakash Expression resets the least significant set bit On Sat, Jul 2, 2011 at 3:20 PM, mohit goel mohitgoel291...@gmail.comwrote: May be this can work.give any counter example... int count; main() { int l,rope,cuts; scanf(%d%d,l,rope); count =0; find_cuts(l,rope); printf(cuts needed is %d,count); getch(); return 0; } int find_cuts(int l,int rope) { if(l==rope) return count; count++; printf(%d,count); l=l/2; if(l==rope) return count; if(ropel) rope =rope-l; find_cuts(l,rope); } -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: help..
@sunny ya i wanted to write the while(k % m == 0) On Sat, Jul 2, 2011 at 3:47 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: nn-1 is the expression to find out if n is a power of 2...If nn-1 returns 0 its a power of 2 else its not. And what sunny said is also ryt On Sat, Jul 2, 2011 at 3:47 PM, sunny agrawal sunny816.i...@gmail.comwrote: @cegprakash Expression resets the least significant set bit On Sat, Jul 2, 2011 at 3:20 PM, mohit goel mohitgoel291...@gmail.comwrote: May be this can work.give any counter example... int count; main() { int l,rope,cuts; scanf(%d%d,l,rope); count =0; find_cuts(l,rope); printf(cuts needed is %d,count); getch(); return 0; } int find_cuts(int l,int rope) { if(l==rope) return count; count++; printf(%d,count); l=l/2; if(l==rope) return count; if(ropel) rope =rope-l; find_cuts(l,rope); } -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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.
Re: [algogeeks] Re: help..
@sunny thnx for the correction. On Sat, Jul 2, 2011 at 9:16 AM, varun pahwa varunpahwa2...@gmail.comwrote: @sunny ya i wanted to write the while(k % m == 0) On Sat, Jul 2, 2011 at 3:47 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: nn-1 is the expression to find out if n is a power of 2...If nn-1 returns 0 its a power of 2 else its not. And what sunny said is also ryt On Sat, Jul 2, 2011 at 3:47 PM, sunny agrawal sunny816.i...@gmail.comwrote: @cegprakash Expression resets the least significant set bit On Sat, Jul 2, 2011 at 3:20 PM, mohit goel mohitgoel291...@gmail.comwrote: May be this can work.give any counter example... int count; main() { int l,rope,cuts; scanf(%d%d,l,rope); count =0; find_cuts(l,rope); printf(cuts needed is %d,count); getch(); return 0; } int find_cuts(int l,int rope) { if(l==rope) return count; count++; printf(%d,count); l=l/2; if(l==rope) return count; if(ropel) rope =rope-l; find_cuts(l,rope); } -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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.
Re: [algogeeks] Re: help..
Another alternative soln. int rec_cut(int l, int k) { if (l == k) return 0; int tmp = k - (l1); return 1 + rec_cut(l1, tmp = 0 ? k : tmp); } int main() { int l, k; scanf(%d%d, l, k); printf(%d\n, rec_cut(l, k)); return 0; } Veni Vedi Slumber ! On Sat, Jul 2, 2011 at 9:47 PM, varun pahwa varunpahwa2...@gmail.comwrote: @sunny thnx for the correction. On Sat, Jul 2, 2011 at 9:16 AM, varun pahwa varunpahwa2...@gmail.comwrote: @sunny ya i wanted to write the while(k % m == 0) On Sat, Jul 2, 2011 at 3:47 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: nn-1 is the expression to find out if n is a power of 2...If nn-1 returns 0 its a power of 2 else its not. And what sunny said is also ryt On Sat, Jul 2, 2011 at 3:47 PM, sunny agrawal sunny816.i...@gmail.comwrote: @cegprakash Expression resets the least significant set bit On Sat, Jul 2, 2011 at 3:20 PM, mohit goel mohitgoel291...@gmail.comwrote: May be this can work.give any counter example... int count; main() { int l,rope,cuts; scanf(%d%d,l,rope); count =0; find_cuts(l,rope); printf(cuts needed is %d,count); getch(); return 0; } int find_cuts(int l,int rope) { if(l==rope) return count; count++; printf(%d,count); l=l/2; if(l==rope) return count; if(ropel) rope =rope-l; find_cuts(l,rope); } -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Need help
can any one tell the best compiler for c and c++... Thanks, G. Shashank Reddy -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/g2ZE6Sm9p-MJ. 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.
Re: [algogeeks] Need help
In windows you can choose codeblocks or best is use linux gnu compiler On Wed, Jun 15, 2011 at 8:50 PM, shashankreddy509 shashankreddy...@gmail.com wrote: can any one tell the best compiler for c and c++... Thanks, G. Shashank Reddy -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/g2ZE6Sm9p-MJ. 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. -- **With Regards Deoki Nandan Vishwakarma IITR MCA * * -- 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.
Re: [algogeeks] Need help
intel icc compiler On Wed, Jun 15, 2011 at 08:20:39AM -0700, shashankreddy509 wrote: can any one tell the best compiler for c and c++... Thanks, G. Shashank Reddy -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/ algogeeks/-/g2ZE6Sm9p-MJ. 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. -- TAOCP 大地母亲在忽悠着你. http://cn.linkedin.com/pub/feng-li/29/95b/640 http://gentoo-taocp.blogspot.com http://groups.google.com/group/szlug -- 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.
Re: [algogeeks] Need help
i need compiler for windows 7... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/Y9OZdeYwmggJ. 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.
Re: [algogeeks] need help in Desktop applications
I would recommend you to read complete Java Reference book by Herbert Schildt, it will take you nicely through the basics of creating window based applications. First read the chapters on Applets and AWT and then you should be able to easily and naturally graduate to using Swing. On Thu, Jun 9, 2011 at 1:39 PM, snehi jain snehijai...@gmail.com wrote: hi, I am trying to create a Desktop application in JAVA and somebody referred JAVA swing for designing such apps. i need help in creating one. If Anybody has any knowledge or is aware of links or pdfs then please reply. Thanks -- 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. -- --Navneet -- 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.
Re: [algogeeks] need help in Desktop applications
@naveen Thanks for the prompt reply I am already aware of Applets and AWT and have started getting acquainted to Swing but the problem lies where to start from. Its like I want a small example or few starting steps. Complete Reference is the book that i refer. On Thu, Jun 9, 2011 at 1:48 PM, Navneet Gupta navneetn...@gmail.com wrote: I would recommend you to read complete Java Reference book by Herbert Schildt, it will take you nicely through the basics of creating window based applications. First read the chapters on Applets and AWT and then you should be able to easily and naturally graduate to using Swing. On Thu, Jun 9, 2011 at 1:39 PM, snehi jain snehijai...@gmail.com wrote: hi, I am trying to create a Desktop application in JAVA and somebody referred JAVA swing for designing such apps. i need help in creating one. If Anybody has any knowledge or is aware of links or pdfs then please reply. Thanks -- 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. -- --Navneet -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] need help in Desktop applications
As soon as i type Java Swing PDFs in google, i get lots of results. See if anyone of them can help you. No tutorial i am having as such specifically for Swing. On Thu, Jun 9, 2011 at 1:53 PM, snehi jain snehijai...@gmail.com wrote: @naveen Thanks for the prompt reply I am already aware of Applets and AWT and have started getting acquainted to Swing but the problem lies where to start from. Its like I want a small example or few starting steps. Complete Reference is the book that i refer. On Thu, Jun 9, 2011 at 1:48 PM, Navneet Gupta navneetn...@gmail.com wrote: I would recommend you to read complete Java Reference book by Herbert Schildt, it will take you nicely through the basics of creating window based applications. First read the chapters on Applets and AWT and then you should be able to easily and naturally graduate to using Swing. On Thu, Jun 9, 2011 at 1:39 PM, snehi jain snehijai...@gmail.com wrote: hi, I am trying to create a Desktop application in JAVA and somebody referred JAVA swing for designing such apps. i need help in creating one. If Anybody has any knowledge or is aware of links or pdfs then please reply. Thanks -- 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. -- --Navneet -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- --Navneet -- 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.
Re: [algogeeks] need help in Desktop applications
i Did that before asking for help on the group. anyways thanks :) Swing isnt necessary, someone referred so i am trying to learn it. Any info regarding desktop or phone apps. will be appreciated. On Thu, Jun 9, 2011 at 2:00 PM, Navneet Gupta navneetn...@gmail.com wrote: As soon as i type Java Swing PDFs in google, i get lots of results. See if anyone of them can help you. No tutorial i am having as such specifically for Swing. On Thu, Jun 9, 2011 at 1:53 PM, snehi jain snehijai...@gmail.com wrote: @naveen Thanks for the prompt reply I am already aware of Applets and AWT and have started getting acquainted to Swing but the problem lies where to start from. Its like I want a small example or few starting steps. Complete Reference is the book that i refer. On Thu, Jun 9, 2011 at 1:48 PM, Navneet Gupta navneetn...@gmail.com wrote: I would recommend you to read complete Java Reference book by Herbert Schildt, it will take you nicely through the basics of creating window based applications. First read the chapters on Applets and AWT and then you should be able to easily and naturally graduate to using Swing. On Thu, Jun 9, 2011 at 1:39 PM, snehi jain snehijai...@gmail.com wrote: hi, I am trying to create a Desktop application in JAVA and somebody referred JAVA swing for designing such apps. i need help in creating one. If Anybody has any knowledge or is aware of links or pdfs then please reply. Thanks -- 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. -- --Navneet -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- --Navneet -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] need help in Desktop applications
Hi Snehi...Follow following links to kick-start your Swing!! http://www.herongyang.com/Swing/Introduction-First-Swing-Program-SwingHello.html http://www.herongyang.com/Swing/Introduction-First-Swing-Program-SwingHello.html http://www.dreamincode.net/forums/topic/206319-first-swing-application/ We may further help if you can tell us more about ur App which ur planning to create!! On Thu, Jun 9, 2011 at 2:06 PM, snehi jain snehijai...@gmail.com wrote: i Did that before asking for help on the group. anyways thanks :) Swing isnt necessary, someone referred so i am trying to learn it. Any info regarding desktop or phone apps. will be appreciated. On Thu, Jun 9, 2011 at 2:00 PM, Navneet Gupta navneetn...@gmail.comwrote: As soon as i type Java Swing PDFs in google, i get lots of results. See if anyone of them can help you. No tutorial i am having as such specifically for Swing. On Thu, Jun 9, 2011 at 1:53 PM, snehi jain snehijai...@gmail.com wrote: @naveen Thanks for the prompt reply I am already aware of Applets and AWT and have started getting acquainted to Swing but the problem lies where to start from. Its like I want a small example or few starting steps. Complete Reference is the book that i refer. On Thu, Jun 9, 2011 at 1:48 PM, Navneet Gupta navneetn...@gmail.com wrote: I would recommend you to read complete Java Reference book by Herbert Schildt, it will take you nicely through the basics of creating window based applications. First read the chapters on Applets and AWT and then you should be able to easily and naturally graduate to using Swing. On Thu, Jun 9, 2011 at 1:39 PM, snehi jain snehijai...@gmail.com wrote: hi, I am trying to create a Desktop application in JAVA and somebody referred JAVA swing for designing such apps. i need help in creating one. If Anybody has any knowledge or is aware of links or pdfs then please reply. Thanks -- 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. -- --Navneet -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- --Navneet -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards, Karan Sachan | System Engineer Infosys Technologies Ltd.| Bangalore Mobile: +91 9663373478 -- 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.
Re: [algogeeks] need help in Desktop applications
hey Karan... thanks a lot the links are helpful :) its an app. that can help in building one's vocab. its basically a thought right now. Will ask more when things start taking desired shape a little bit. On Thu, Jun 9, 2011 at 4:59 PM, karan sachan karansac...@gmail.com wrote: Hi Snehi...Follow following links to kick-start your Swing!! http://www.herongyang.com/Swing/Introduction-First-Swing-Program-SwingHello.html http://www.herongyang.com/Swing/Introduction-First-Swing-Program-SwingHello.html http://www.dreamincode.net/forums/topic/206319-first-swing-application/ We may further help if you can tell us more about ur App which ur planning to create!! On Thu, Jun 9, 2011 at 2:06 PM, snehi jain snehijai...@gmail.com wrote: i Did that before asking for help on the group. anyways thanks :) Swing isnt necessary, someone referred so i am trying to learn it. Any info regarding desktop or phone apps. will be appreciated. On Thu, Jun 9, 2011 at 2:00 PM, Navneet Gupta navneetn...@gmail.comwrote: As soon as i type Java Swing PDFs in google, i get lots of results. See if anyone of them can help you. No tutorial i am having as such specifically for Swing. On Thu, Jun 9, 2011 at 1:53 PM, snehi jain snehijai...@gmail.com wrote: @naveen Thanks for the prompt reply I am already aware of Applets and AWT and have started getting acquainted to Swing but the problem lies where to start from. Its like I want a small example or few starting steps. Complete Reference is the book that i refer. On Thu, Jun 9, 2011 at 1:48 PM, Navneet Gupta navneetn...@gmail.com wrote: I would recommend you to read complete Java Reference book by Herbert Schildt, it will take you nicely through the basics of creating window based applications. First read the chapters on Applets and AWT and then you should be able to easily and naturally graduate to using Swing. On Thu, Jun 9, 2011 at 1:39 PM, snehi jain snehijai...@gmail.com wrote: hi, I am trying to create a Desktop application in JAVA and somebody referred JAVA swing for designing such apps. i need help in creating one. If Anybody has any knowledge or is aware of links or pdfs then please reply. Thanks -- 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. -- --Navneet -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- --Navneet -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards, Karan Sachan | System Engineer Infosys Technologies Ltd.| Bangalore Mobile: +91 9663373478 -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] please help me
I am last year student preparing for placements can any one give some ebooks on data structure, algo etc. like beofre some time , some one posted a book how to crack the coding interview that was an awesome book thanks to the guy who send the book . if anyone has some good ebooks or links loke these then please post. thanks. -- 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.
[algogeeks] hajime help:
can anyone tell me how to think about this problem? -- 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.
[algogeeks] Need help on fenwick trees
Hi Guys , Can any one give link for tutorial or videos about segment trees. I am unable to understand the basic idea behind it . Regards, vinod -- 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.
[algogeeks] Need help on Divide and Conquer Algorithm
Question :Let A[1..n] be an array of integers. Design an efficient divide and conquer algorithm to determine if A contains a majority element, i.e an element appears more than n/2 times in A. What is the time complexity of your algorithm? Answer: a[1..n] is an array int majorityElement(int a[], int first, int last) { If (first = = last) { return a[first]; // Array has one element and its count = 1 and it is major element } mid= (first+last)/2; (majorL,countL)= majorityElement(a,first,mid); (majorR,countR)= majorityElement(a,mid +1,last); n = total elements in an array; If(majorL==majorR) return(countL+countR); else { If(countLcountR) return(majorL,countL); elseif(countL countR) return(majorR,countR); else return(majorL,majorR); } if(countLn/2) temp1=majorL; if(countRn/2) temp2=majorR; If(temp1 = = temp2) return temp1; elseif(countLcountR) return temp1; else (countRcountL) return temp2; else return -1; } int main() { int a[8] = {2,3,2,2,4,2,2,2}; int first =1; int last=8; //change the value of last when the array increases or decreases in size int x = majorityElement(a,first,last); if(x= = -1) printf(“No Majority Element”) else Majority element = x; } -- 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.
[algogeeks] Need help regarding the SPOJ problem...
You have N marbles and K slots. You have to follow the below mentioned rules : 1. You can put in a marble or take out a marble from slot numbered 1 at any time. 2. You can put in a marble or take out a marble from slot numbered i only if there exists a marble at the slot i - 1. 3. The game stops when a marble reaches the slot numbered K for the first time. Your task is to finish the game in minimum number of valid moves. for further clarification one can visit: http://www.spoj.pl/problems/MOVMRBL/ I am not able to calculate manually the steps for some (N,K) pair (except the cases where K is less than or equal to N*(N-1)/2). e.g how to proceed with just 3 marbles and 10 slots... any idea in this direction will be appreciated... -- 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.
Re: [algogeeks] Need help regarding the SPOJ problem...
Hi, I hope this is correct. Please correct if I am wrong. Short answer: Let a = (k-n)/(n-1) Let b = (k-n)%(n-1) steps = (n-1)(a)(a+1)/2 + b Put = steps + n Remove = steps Explanation: Example with n = 3 k =10: Start by putting balls in 1,2,3 1 2 3 x x x x x x Now move balls from 1-3 to 3-5 using (n-1) steps 1 x 3 4 x x x x x REMOVE 2, PUT 4 x x 3 4 5 x x x x REMOVE 1, PUT 5 Moving balls from 3-5 to 5-7 using steps 1 and 2. 1) move first n-1 balls to 1 to n -1 slots. This takes ( reached_so_far - n ) steps x x 3 4 5 x x x x REMOVE 4, PUT 2 x 2 3 x 5 x x x x REMOVE 3, PUT 1 1 2 x x 5 x x x x 2) move balls in 1 to n-1 slots to (reached_so_far + 1) to (reached_so_far + n -1) slots. This takes (n-1) steps 1 2 x x 5 x x x x REMOVE 2, PUT 6 1 x x x 5 6 x x x REMOVE 1, PUT 7 x x x x 5 6 7 x x Similarly we can move from 5-7 to 7-9 in ( 4 + 2 = 6 steps ) Now we can directly complete with one more step. Summary: Move from 1-3 to 3-5 in 2 steps Move from 3-5 to 5-7 in 4 steps Move from 5-7 to 7-9 in 6 steps Move 1 ball to 10 in 1 step PUT = 13(steps) + 3 (initial) REMOVE = 13(steps) Thanks, Balaji. On Fri, Mar 18, 2011 at 7:06 PM, shubham shubh2...@gmail.com wrote: You have N marbles and K slots. You have to follow the below mentioned rules : 1. You can put in a marble or take out a marble from slot numbered 1 at any time. 2. You can put in a marble or take out a marble from slot numbered i only if there exists a marble at the slot i - 1. 3. The game stops when a marble reaches the slot numbered K for the first time. Your task is to finish the game in minimum number of valid moves. for further clarification one can visit: http://www.spoj.pl/problems/MOVMRBL/ I am not able to calculate manually the steps for some (N,K) pair (except the cases where K is less than or equal to N*(N-1)/2). e.g how to proceed with just 3 marbles and 10 slots... any idea in this direction will be appreciated... -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] need help with a classic algorithm
You are given n coins, at least one of which is bad. All the good coins weigh the same, and all the bad coins weigh the same. The bad coins are lighter than the good coins. Find the exact number of bad coins by making O(logn)^2 weighings on a balance. Each weighing tells you whether the total weight of the coins you put on the left side of the balance is smaller than, equal to, or larger than the total weight of the coins you put on the right side. -- 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.
[algogeeks] please help..
http://www.spoj.pl/problems/PIGBANK/ can anyone give me an idea how to solve this problem...?? I dont think the knapsack algo would be of help here as here we need to find minimum value..please refer to the link and if anyone can help, i would be very thankful. regards, aksha -- 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.
Re: [algogeeks] please help..
a small modification in normal knapsack algo ll do :) On Thu, Feb 24, 2011 at 4:06 PM, Akshata Sharma akshatasharm...@gmail.comwrote: http://www.spoj.pl/problems/PIGBANK/ can anyone give me an idea how to solve this problem...?? I dont think the knapsack algo would be of help here as here we need to find minimum value..please refer to the link and if anyone can help, i would be very thankful. regards, aksha -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Please Help
Consider a simple polygon P over vertices, on the plane, and a point s, which maybe inside or outside P. Design an O(nlogn) algorithm that finds a line segment starting from, and cutting a maximum number of edges of P. An edge of P is any one of the line segments making up its boundary. (Note that if your segment passes through a vertex of P, it is considered as one cut.) -- 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.
[algogeeks] Re: Help
Mike Johnson wrote: Plesae rite a program for me to find prime nummers. It should be recursive prorgram. What duz that mean? If u type a nummer like 10 it should say 1 is prime, 2 is prime, 3 is prime, 4 is not prime up to 10. This iz not homewurk I just thout of it myself. Lol. /* Sure Mike, Happy to help! This program implements a blindingly fast O(n^n) algorithm to find prime numbers, using an elegant recursive method. */ int _(int n, int m, int d, int t) { int r; if (t) return d?1+_(n,m,d-1,d):n?_(n-1,m,m,n):0; for(r=m!=n; d*(tn); ++t) r = _(n,_(t,m,0,1),d-1,0)|!_(t,1,t,0); return r*n; } /*-- Print primes up to the requested value */ int main(int argc, char* argv[]) { int max; scanf(%d, max); for(int n = 2; n = max; n++) printf(%d is%s prime\n,n, _(n,1,n,0)?: not); 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 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.
[algogeeks] Complexity Help ??
fun(n) { if(n=2) return (1); else return ((fun(n-1)*fun(n-2)); } find the order of complexity . -- 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.
Re: [algogeeks] Complexity Help ??
O(2^n) On Sat, Jan 22, 2011 at 8:58 PM, Decipher ankurseth...@gmail.com wrote: fun(n) { if(n=2) return (1); else return ((fun(n-1)*fun(n-2)); } find the order of complexity . -- 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.comalgogeeks%2bunsubscr...@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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Complexity Help ??
Could u pls explain ?? -- 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.
Re: [algogeeks] Complexity Help ??
T(n) = T(n-1) + T(n-2) + O(1) On Sat, Jan 22, 2011 at 11:28 PM, Decipher ankurseth...@gmail.com wrote: Could u pls explain ?? -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Preetam Purbia http://twitter.com/preetam_purbia -- 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.
[algogeeks] Re: help me debug this
Got AC with your code with small corrections to the output - don't use getchar(); output specification says: Each line of output should be followed by a blank line (so, add blank line to match the sample output) you print a whitespace after each number, so the last character in your line is a whitespace (but it is wrong, so take a care of this) -- 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.
Re: [algogeeks] Re: help me debug this
i improved upon my code but still i get a presentation error dunno wts the judge judging it shows me the correct way when i output test cases on my compiler but on the judge it says wrong answer or presentation error #includeiostream #includecstdio #includevector #includealgorithm #includecmath using namespace std; int prime(int N,int C);// the function used to print the cut primes int main() { int N,C; vectorintv;// used for holding the test cases while(scanf(%d %d,N,C)==2) { v.push_back(N);v.push_back(C); } int i;// counter for(i=0;iv.size();i+=2) prime(v[i],v[i+1]); return 0; } int prime(int N,int C) { vectorintp; vectorints; p.clear();s.clear(); int i,j,k;// counters for(i=0;i=N;i++) p.push_back(i); for(i=2;ip.size();i++) { for(j=2;i*jp.size();j++) p[i*j]=0; } for(i=0;ip.size();i++) { if(p[i]!=0) s.push_back(i); } printf(%d %d: ,N,C); if((2*C)s.size()) { for(i=0;is.size();i++) printf(%d ,s[i]); } else if((s.size())%2==0) { // the evaluate the number of prime numbers to be left out j=(s.size()-2*C)/2; for(i=j;i(j+2*C);i++) printf(%d ,s[i]); } else { j=(s.size()-2*C+1)/2; for(i=j;i(j+2*C-1);i++) printf(%d ,s[i]); } printf(\n\n); return 0; } On Tue, Jan 18, 2011 at 1:05 AM, juver++ avpostni...@gmail.com wrote: Got AC with your code with small corrections to the output - don't use getchar(); output specification says: Each line of output should be followed by a blank line (so, add blank line to match the sample output) you print a whitespace after each number, so the last character in your line is a whitespace (but it is wrong, so take a care of this) -- 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.comalgogeeks%2bunsubscr...@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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: help me debug this
Redirect your output to the file, and you'll see that at the end of line you have extra blank. You need to write something like this (in all sections): for(i=j;i(j+2*C-1);i++) { if (i != j) printf( ); printf(%d,s[i]); // note there is no space } -- 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.
Re: [algogeeks] Synopsis Help ???
Polish your Mathematical aptitude, basic data structures, matrices and linear programming(added advantage) might help - Azhar. On Sat, Jan 15, 2011 at 7:07 PM, Decipher ankurseth...@gmail.com wrote: Can anyone help me find some questions or post some questions on Synopsys(EDA tool-based company) for Software Engineer profile ? Or did anyone had an interview with them ? It is visiting our college in few weeks for campus recruitment . I will be thankful if anyone could give some suggestions about it . -- 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.comalgogeeks%2bunsubscr...@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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Synopsis Help ???
Can anyone help me find some questions or post some questions on Synopsys(EDA tool-based company) for Software Engineer profile ? Or did anyone had an interview with them ? It is visiting our college in few weeks for campus recruitment . I will be thankful if anyone could give some suggestions about it . -- 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.
[algogeeks] need help solving this ACM ICPC prelims problem
Problem D: Numbered Grid A grid of size N rows and M columns is filled with numbers, one in each cell. You start at the centre of the cell at the top-left corner (1,1) and your destination is the centre of the cell at the bottom- right corner(N,M). In each step, you are only allowed to move to the centre of the cell to the right or to the centre of the cell to the bottom. There are many paths you can take to reach your destination from your start - however, every path can be uniquely broken down into a series of straight line-segments joined at right-angles. Each straight line-segment in your path is termed a 'leg' of your path. Your task is to choose a subset of the cells along your path in such a way that the sum of the numbers in the chosen cells is maximized. Your choice of cells must be such that exactly one chosen cell is present on each leg of the path. Note that cells at the intersection of two legs belong to both legs. What is the maximum possible sum you can form? Input Format: The first line contains one integer T, the number of testcases. The first line of each test case contains two space-separated integers N and M. Each of the next N lines contains M space separated integers, denoting cell values. The jth integer in the ith line denotes the value of the cell (i, j). Constraints: 1 = T = 10 1 = N, M = 100 Numbers in each cell will be between -1 and 1 inclusive. Output Format: For each testcase output a single line containing the maximum sum you can form. Sample Input: 3 2 2 -1 -2 5 -1 3 4 -1 2 -3 -4 -2 -3 5 -2 -1 -1 -2 3 2 2 3 1 5 3 Sample Output: 5 10 6 Explanation: In the first test case, you can first move down and then move right. Your path now has 2 legs and you can choose only the cell containing 5. This is valid as it satisfies the condition that you must choose exactly one cell in each leg (because 5 is a part of both legs). In the second test case, one best path is to walk right, choose 2, go right again and then down to choose 5, go further down and then right to pick up the final 3 (There are also other ways to pick-up the same numbers). In the third test case, the best path is either (down, right) or (right, down). Note that since you can pick-up only one number in each leg you cannot select the '5' in the lower left corner (If you decide to pick-up 5, then you cannot pick up any other number because '5' is shared by both legs. We can do better by selecting both 3s). Time limit: 2 seconds Memory: 64 MB ACM International Collegiate Programming Contest, 2010, Asia- Amritapuri Site -- 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] need help solving this ACM ICPC prelims problem
its a dp prob... -- 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] Need help for this problem
I am trying to solve this problem, got some idea but am not clear...please give your input... http://www.codechef.com/problems/MONEY -- 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] ALgo help pls
http://userweb.cs.utexas.edu/users/moore/best-ideas/mjrty/index.html _Asit On Wed, Sep 22, 2010 at 9:12 AM, pre pre.la...@gmail.com wrote: Hi all, pls help me solve this problem.. Design an algorithm to find the majority element of an array.. majority element must be an element tht has the cardinality greater than 2n/3 where n is the number of elements in the array and the time complexity must be a linear time.. ie o(n).. hint : use mode or median to solve .. -- 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.comalgogeeks%2bunsubscr...@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] ALgo help pls
Use majority vote algorithm: http://userweb.cs.utexas.edu/~moore/best-ideas/mjrty/index.html On Wed, Sep 22, 2010 at 9:12 AM, pre pre.la...@gmail.com wrote: Hi all, pls help me solve this problem.. Design an algorithm to find the majority element of an array.. majority element must be an element tht has the cardinality greater than 2n/3 where n is the number of elements in the array and the time complexity must be a linear time.. ie o(n).. hint : use mode or median to solve .. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards, - NMN -- 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] A help please
printf(%d%d,scanf(%d%d,a b)) -- Rahul K Rai rahulpossi...@gmail.com -- 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] A help please
output will be 2 garbage_value scanf returns numbers of inputs taken from std input and since there should be 2 arguments in printf according to the format, so garbage value will print On Wed, Sep 22, 2010 at 2:25 PM, rahul rai raikra...@gmail.com wrote: printf(%d%d,scanf(%d%d,a b)) -- Rahul K Rai rahulpossi...@gmail.com -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- :-) * Nishant Agarwal Computer Science and Engineering NIT Allahabad * -- 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] A help please
it accepts input into a,b an prints garbage value cos scanf returns the number of values that accept nput ad in printf there is no variable from where value is printed On Wed, Sep 22, 2010 at 2:25 PM, rahul rai raikra...@gmail.com wrote: printf(%d%d,scanf(%d%d,a b)) -- Rahul K Rai rahulpossi...@gmail.com -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- yezhu malai vaasa venkataramana Govinda Govinda -- 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: Help with Increment Operators in C!
@Dave: Thanks alot for enlightening us! @Manju: ya.. you are right. The same was stated by me in the my prev reply! :-) On Aug 29, 10:50 pm, Manjunath Manohar manjunath.n...@gmail.com wrote: it is compiler dependant da..the evaluation of this kind of expressions -- 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: Help with Increment Operators in C!
In php it is 19. ?php $x=5; printf(%d,($x++ + ++$x + $x++)); ? On Aug 28, 1:35 pm, jagadish jagadish1...@gmail.com wrote: I ran this code.. int main() { int x=5; printf(%d,(x++ + ++x + x++)); } The output printed was 18 instead of 19.. Should it not be 19? -- 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: Help with Increment Operators in C!
Ya after some reading i got to know that it was implementation dependent.. And that the answer is undefined! On Aug 28, 5:07 pm, Chi c...@linuxdna.com wrote: In php it is 19. ?php $x=5; printf(%d,($x++ + ++$x + $x++)); ? On Aug 28, 1:35 pm, jagadish jagadish1...@gmail.com wrote: I ran this code.. int main() { int x=5; printf(%d,(x++ + ++x + x++)); } The output printed was 18 instead of 19.. Should it not be 19? -- 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: Help with Increment Operators in C!
Your code violates the C standard, which says: Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value to be stored. Regarding postfix increment operators, the standard also states that The side effect of updating the stored value of the operand shall occur between the previous and the next sequence point. Updating x in your example does not necessarily occur before the next time x is used. The results of code that violates the C standard are compiler- dependent. Dave On Aug 28, 6:35 am, jagadish jagadish1...@gmail.com wrote: I ran this code.. int main() { int x=5; printf(%d,(x++ + ++x + x++)); } The output printed was 18 instead of 19.. Should it not be 19? -- 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] a help
can anyone suggest me lectures / videos for BASICS of BITS manipulation? thanks in advance Rahul K Rai rahulpossi...@gmail.com -- 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] a help
http://graphics.stanford.edu/~seander/bithacks.html http://graphics.stanford.edu/~seander/bithacks.htmlit has all that you need. On Sat, Aug 14, 2010 at 7:53 PM, rahul rai raikra...@gmail.com wrote: can anyone suggest me lectures / videos for BASICS of BITS manipulation? thanks in advance Rahul K Rai rahulpossi...@gmail.com -- 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.comalgogeeks%2bunsubscr...@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] a help
Thanks a lot , it's a life saver , i will work it out fully . 2010/8/14, Asit Baran Das asitbaran@gmail.com: http://graphics.stanford.edu/~seander/bithacks.html http://graphics.stanford.edu/~seander/bithacks.htmlit has all that you need. On Sat, Aug 14, 2010 at 7:53 PM, rahul rai raikra...@gmail.com wrote: can anyone suggest me lectures / videos for BASICS of BITS manipulation? thanks in advance Rahul K Rai rahulpossi...@gmail.com -- 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.comalgogeeks%2bunsubscr...@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. -- Rahul K Rai rahulpossi...@gmail.com -- 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] Plz help with multidimensional array
@ashish cant u make use of char *p[30] for 2 d array On Wed, Jul 7, 2010 at 9:34 AM, Ashish Goel ashg...@gmail.com wrote: char name[][10] is a auto variable on stack, so no pointers here Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Wed, Jul 7, 2010 at 9:10 AM, UMESH KUMAR kumar.umesh...@gmail.comwrote: char name[][10]={jan,feb,march}; Name is a 2-D Array of character so if you wish to store in a Pointer variable then must take a Character of Pointer of 10 characters of type char. char (*p)[10]=name; Umesh Kumar MCA D.U. -- 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- yezhu malai vaasa venkataramana Govinda Govinda -- 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] Need help
Hey anyone doing topcoder srm 375, please help me out in medium question, question is.. Rabbits often feel lonely, so one group of rabbits decided to gather together and play a game. The game is played on a horizontal row of N cells (N = 2), numbered 0 to N - 1 from left to right. Each cell is colored white, black or red. You are given a string field of length N, where the i-th character is the color of cell i ('W' for white, 'B' for black and 'R' for red). There are r rabbits playing the game. The rabbits choose their starting cells randomly such that no two rabbits are on the same cell. Each subset of r distinct cells has the same probability of being chosen as their starting cells. The size of the field is the number of cells it contains (which is initially N). The following is repeated while the size of the field is greater than 2: Each rabbit steps onto a neighboring cell. Since each cell potentially has up to two neighboring cells, the following rules are used to determine which cell the rabbit will choose: If a rabbit is on cell 0, she must step onto cell 1. If a rabbit is on cell size - 1 or size - 2, she must step onto the left neighboring cell. All other rabbits choose which neighboring cell to step onto according to the color of the cell they are currently on: White: She must step onto the left neighboring cell. Black: She must step onto the right neighboring cell. Red: If this is her first move, she must step onto the left neighboring cell. Otherwise, she must return to the cell she was on immediately before she was on the current cell. After all rabbits finished their steps, for each cell that contains more than one rabbit, all rabbits on that cell will be removed from the field. The rightmost cell will disappear (causing the size of the field to decrease by 1). By the rules above, this cell will always be empty. When the game ends, 0, 1 or 2 rabbits will remain on the field. Return the expected number of rabbits left on the field when the game ends. Samples : WRBRW 4 Returns: 0.8 The initial positions of the rabbits are cells { 0, 1, 2, 3 }, { 0, 1, 2, 4 }, { 0, 1, 3, 4 }, { 0, 2, 3, 4 }, or { 1, 2, 3, 4 }. For example, if { 0, 1, 2, 4 } is chosen, they will step as follows and 2 rabbits will remain on the field: 1) WWB 2 Returns: 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] Need help
can you specify the question name or link of question on topcoder -- Regards Jitendra Kushwaha MNNIT, Allahabad -- 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] Need help
Contest in running and you are posting the 550 points problem? Its unfair. Ask after it gets over. On 6 July 2010 17:30, crazysaikat crazysai...@gmail.com wrote: Hey anyone doing topcoder srm 375, please help me out in medium question, question is.. Rabbits often feel lonely, so one group of rabbits decided to gather together and play a game. The game is played on a horizontal row of N cells (N = 2), numbered 0 to N - 1 from left to right. Each cell is colored white, black or red. You are given a string field of length N, where the i-th character is the color of cell i ('W' for white, 'B' for black and 'R' for red). There are r rabbits playing the game. The rabbits choose their starting cells randomly such that no two rabbits are on the same cell. Each subset of r distinct cells has the same probability of being chosen as their starting cells. The size of the field is the number of cells it contains (which is initially N). The following is repeated while the size of the field is greater than 2: Each rabbit steps onto a neighboring cell. Since each cell potentially has up to two neighboring cells, the following rules are used to determine which cell the rabbit will choose: If a rabbit is on cell 0, she must step onto cell 1. If a rabbit is on cell size - 1 or size - 2, she must step onto the left neighboring cell. All other rabbits choose which neighboring cell to step onto according to the color of the cell they are currently on: White: She must step onto the left neighboring cell. Black: She must step onto the right neighboring cell. Red: If this is her first move, she must step onto the left neighboring cell. Otherwise, she must return to the cell she was on immediately before she was on the current cell. After all rabbits finished their steps, for each cell that contains more than one rabbit, all rabbits on that cell will be removed from the field. The rightmost cell will disappear (causing the size of the field to decrease by 1). By the rules above, this cell will always be empty. When the game ends, 0, 1 or 2 rabbits will remain on the field. Return the expected number of rabbits left on the field when the game ends. Samples : WRBRW 4 Returns: 0.8 The initial positions of the rabbits are cells { 0, 1, 2, 3 }, { 0, 1, 2, 4 }, { 0, 1, 3, 4 }, { 0, 2, 3, 4 }, or { 1, 2, 3, 4 }. For example, if { 0, 1, 2, 4 } is chosen, they will step as follows and 2 rabbits will remain on the field: 1) WWB 2 Returns: 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards, Priyanka Chatterjee Final Year Undergraduate Student, Computer Science Engineering, National Institute Of Technology,Durgapur India http://priyanka-nit.blogspot.com/ -- 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] Plz help with multidimensional array
char name[3][10]={jan,feb,march}; name[0],name[1],name[2] are the elements of an array 'name'. Can we think of name as an array of pointers where each pointer is of type char (*p)[10]? -- 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] Plz help with multidimensional array
char name[][10] is a auto variable on stack, so no pointers here Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Wed, Jul 7, 2010 at 9:10 AM, UMESH KUMAR kumar.umesh...@gmail.comwrote: char name[][10]={jan,feb,march}; Name is a 2-D Array of character so if you wish to store in a Pointer variable then must take a Character of Pointer of 10 characters of type char. char (*p)[10]=name; Umesh Kumar MCA D.U. -- 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.comalgogeeks%2bunsubscr...@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] Recursion help!
This a good example of dynamic programming. On Fri, Jun 4, 2010 at 10:15 AM, satwik krishna sathi...@gmail.com wrote: i think the best way to trace is to draw a picture of the stack and put the values and acc understand the flow On Fri, Jun 4, 2010 at 7:22 AM, Prashant Kulkarni prashant.r.k...@gmail.com wrote: int Max(int a[],int n) { int max; if(n==1) ---( 1 ) return a[0]; else max=Max(a,n-1); ---( 2 ) if(maxa[n-1]) return max; ---( 3 ) } else return a[n-1]; ---( 4 ) } Statement (1) will executed when there is only single present in the array Statement (2) otherwise else part will executed in this section we calling same function with array index n,n-1,..,0 (position of the elements) Statement (3) checking whether this present element is larger than previous one ie here we are comparing ( n )th and (n-1) th element; if (n) th is greater then it will return its value Statement (4) here if (n-1) th is greater so it will return its value -- Prashant Kulkarni On Fri, Jun 4, 2010 at 7:13 PM, Raj N rajn...@gmail.com wrote: int Max(int a[],int n) { int max; if(n==1) return a[0]; else max=Max(a,n-1); if(maxa[n-1]) return max; else return a[n-1]; } Hi, the above is a code to find the max in an array recursively. I find very difficult in understanding the flow of recursive programs. Can someone help me out in explaining the flow of the program with stack sections if possible. Thanks!! -- 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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] Recursion help!
int Max(int a[],int n) { int max; if(n==1) return a[0]; else max=Max(a,n-1); if(maxa[n-1]) return max; else return a[n-1]; } Hi, the above is a code to find the max in an array recursively. I find very difficult in understanding the flow of recursive programs. Can someone help me out in explaining the flow of the program with stack sections if possible. Thanks!! -- 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] Recursion help!
int Max(int a[],int n) { int max; if(n==1) ---( 1 ) return a[0]; else max=Max(a,n-1); ---( 2 ) if(maxa[n-1]) return max; ---( 3 ) } else return a[n-1]; ---( 4 ) } Statement (1) will executed when there is only single present in the array Statement (2) otherwise else part will executed in this section we calling same function with array index n,n-1,..,0 (position of the elements) Statement (3) checking whether this present element is larger than previous one ie here we are comparing ( n )th and (n-1) th element; if (n) th is greater then it will return its value Statement (4) here if (n-1) th is greater so it will return its value -- Prashant Kulkarni On Fri, Jun 4, 2010 at 7:13 PM, Raj N rajn...@gmail.com wrote: int Max(int a[],int n) { int max; if(n==1) return a[0]; else max=Max(a,n-1); if(maxa[n-1]) return max; else return a[n-1]; } Hi, the above is a code to find the max in an array recursively. I find very difficult in understanding the flow of recursive programs. Can someone help me out in explaining the flow of the program with stack sections if possible. Thanks!! -- 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.comalgogeeks%2bunsubscr...@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] Recursion help!
@Prashant: Are you saying that after the base case has been reached, only then statements 3,4 will be executed for all the recursive calls? On Fri, Jun 4, 2010 at 7:52 PM, Prashant Kulkarni prashant.r.k...@gmail.com wrote: int Max(int a[],int n) { int max; if(n==1) ---( 1 ) return a[0]; else max=Max(a,n-1); ---( 2 ) if(maxa[n-1]) return max; ---( 3 ) } else return a[n-1]; ---( 4 ) } Statement (1) will executed when there is only single present in the array Statement (2) otherwise else part will executed in this section we calling same function with array index n,n-1,..,0 (position of the elements) Statement (3) checking whether this present element is larger than previous one ie here we are comparing ( n )th and (n-1) th element; if (n) th is greater then it will return its value Statement (4) here if (n-1) th is greater so it will return its value -- Prashant Kulkarni On Fri, Jun 4, 2010 at 7:13 PM, Raj N rajn...@gmail.com wrote: int Max(int a[],int n) { int max; if(n==1) return a[0]; else max=Max(a,n-1); if(maxa[n-1]) return max; else return a[n-1]; } Hi, the above is a code to find the max in an array recursively. I find very difficult in understanding the flow of recursive programs. Can someone help me out in explaining the flow of the program with stack sections if possible. Thanks!! -- 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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] Recursion help!
loop recurs with array index n,n-1,..,0 as stated in this thread. will return Max value from array, for (n-1) upon each integer of iteration n, upon condition present element is larger than previous element, otherwise, it will return the previous value. the algorithm seems to provide a series of values of a maximum compared between an array value and it's previous value. On 6/4/10, Prashant Kulkarni prashant.r.k...@gmail.com wrote: int Max(int a[],int n) { int max; if(n==1) ---( 1 ) return a[0]; else max=Max(a,n-1); ---( 2 ) if(maxa[n-1]) return max; ---( 3 ) } else return a[n-1]; ---( 4 ) } Statement (1) will executed when there is only single present in the array Statement (2) otherwise else part will executed in this section we calling same function with array index n,n-1,..,0 (position of the elements) Statement (3) checking whether this present element is larger than previous one ie here we are comparing ( n )th and (n-1) th element; if (n) th is greater then it will return its value Statement (4) here if (n-1) th is greater so it will return its value -- Prashant Kulkarni On Fri, Jun 4, 2010 at 7:13 PM, Raj N rajn...@gmail.com wrote: int Max(int a[],int n) { int max; if(n==1) return a[0]; else max=Max(a,n-1); if(maxa[n-1]) return max; else return a[n-1]; } Hi, the above is a code to find the max in an array recursively. I find very difficult in understanding the flow of recursive programs. Can someone help me out in explaining the flow of the program with stack sections if possible. Thanks!! -- 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.comalgogeeks%2bunsubscr...@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] Recursion help!
i think the best way to trace is to draw a picture of the stack and put the values and acc understand the flow On Fri, Jun 4, 2010 at 7:22 AM, Prashant Kulkarni prashant.r.k...@gmail.com wrote: int Max(int a[],int n) { int max; if(n==1) ---( 1 ) return a[0]; else max=Max(a,n-1); ---( 2 ) if(maxa[n-1]) return max; ---( 3 ) } else return a[n-1]; ---( 4 ) } Statement (1) will executed when there is only single present in the array Statement (2) otherwise else part will executed in this section we calling same function with array index n,n-1,..,0 (position of the elements) Statement (3) checking whether this present element is larger than previous one ie here we are comparing ( n )th and (n-1) th element; if (n) th is greater then it will return its value Statement (4) here if (n-1) th is greater so it will return its value -- Prashant Kulkarni On Fri, Jun 4, 2010 at 7:13 PM, Raj N rajn...@gmail.com wrote: int Max(int a[],int n) { int max; if(n==1) return a[0]; else max=Max(a,n-1); if(maxa[n-1]) return max; else return a[n-1]; } Hi, the above is a code to find the max in an array recursively. I find very difficult in understanding the flow of recursive programs. Can someone help me out in explaining the flow of the program with stack sections if possible. Thanks!! -- 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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] Please Help!!! store fractional numbers with high precision
On Wed, Apr 14, 2010 at 1:22 PM, vikrant singh vikrantsing...@gmail.comwrote: there is a problem to find first K digits of no. N^N , where N can be as large as 10^9. so, the algo goes like, take fractional part(f) of Nlog10(N). and temp=pow(10,f), result =(long )10^k * temp. I want to assure myself that f has enough fractional part precision so that at most first 9 digits can be correctly found. I more doubt , does the maximum value of any type assures that it can hold all intermediate value. my ques is the maximum number of digits after decimal a type can hold. Can any1 clear my doubt related to long double that i initially asked. Help appreciated. *Apologies for any stupidity. On Wed, Apr 14, 2010 at 6:31 AM, sharad kumar aryansmit3...@gmail.comwrote: Do u have to use only C++ ,cant u use scripting languages like Pythonwhere precision is very good in Python..esp wen u use Si-Py On Tue, Apr 13, 2010 at 10:10 PM, Himanshu Aggarwal lkml.himan...@gmail.com wrote: I think it should depend on the underlying architecture, on how it stores the floating data types In case floats and double are implemented using IEEE 754, then floats have 8 bits for precision and double have 11 bits for precision. Normally the exponents are biased, which means that for float it ranges from 2^(-127) to 2^(+ 127) and for double it ranges from 2^(-1024) to 2^(+1024). ~Himanshu Aggarwal On Tue, Apr 13, 2010 at 6:10 AM, Anil C R cr.a...@gmail.com wrote: correct me if I'm wrong but, float has a precision of around 8 digits. and double 16 digits... if you want arbitrary precision floating point numbers, try GNU BigNum library... Anil On Mon, Apr 12, 2010 at 9:54 PM, Himanshu Aggarwal lkml.himan...@gmail.com wrote: On Sun, Apr 11, 2010 at 6:55 PM, GentLeBoY vikrantsing...@gmail.comwrote: how to store fractional numbers with a fractional part having 25-30 digits after decimal place, does long double has the same precision as double?. 1 more prob. format specifier for long double is %lf and same for double, so if i write long double a; scanf(%lf,a); a=a*2; printf(%lf,a); why is the output -2. ? -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. Float has single precision. double has double precision. Long double has extended precision. For your requirement, even a float would suffice. check out the value of FLT_MAX . It is of the order of 10^37. ~Himanshu Aggarwal -- 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Vikrant Singh -- Vikrant Singh -- 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] Please help..Simple MST problem.
Can anyone please solve any of the following problems? I need a detailed solution. It is my data structure assignment, and i have to submit it by the 4th of april. Please someone help me... its urgent. Show that if an edge(u,v)is contained in some MST, then it is a light edge crossing some cut of the graph. OR Make a 3-by-3 chart with row and column labels WHITE, GRAY and BLAC. in each cell(i,j), indicate whetehr, at any point during DFS of a directed graph, thr can be an edge from a vertex of color i to a vertex of colour j. for each possible edge, indicate what edge types it can be. Make a second chart for DFS for an undirected graph. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[algogeeks] Re: Help
GOOD ONE- Data Structures , Algorithms and Applications in C++ by Sartaj Sahani On Feb 7, 1:58 pm, Atul Aggarwal [EMAIL PROTECTED] wrote: Hello Everybody, I am beginner in Algorithms. Which book I should prefer for understanding basic algos? Also tell me some good book for graph Theory and its basic algos. Thanx in advance. Atul Aggarwal --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: Help
corman for algorithms On 2/9/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: GOOD ONE- Data Structures , Algorithms and Applications in C++ by Sartaj Sahani On Feb 7, 1:58 pm, Atul Aggarwal [EMAIL PROTECTED] wrote: Hello Everybody, I am beginner in Algorithms. Which book I should prefer for understanding basic algos? Also tell me some good book for graph Theory and its basic algos. Thanx in advance. Atul Aggarwal -- Gurbinder Singh placement-info.blogspot.com --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: Help
I can vouch for 'algorithm design' by Jon Klienberg if CLR becomes a bit heavy. On Feb 7, 2008 11:13 PM, dor [EMAIL PROTECTED] wrote: I used Cormen as an intro to algorithms (Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Cliff Stein, Introduction to Algorithms 2nd edition, published by MIT Press and McGraw-Hill). On Feb 7, 1:58 pm, Atul Aggarwal [EMAIL PROTECTED] wrote: Hello Everybody, I am beginner in Algorithms. Which book I should prefer for understanding basic algos? Also tell me some good book for graph Theory and its basic algos. Thanx in advance. Atul Aggarwal --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: Help
I used Cormen as an intro to algorithms (Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Cliff Stein, Introduction to Algorithms 2nd edition, published by MIT Press and McGraw-Hill). On Feb 7, 1:58 pm, Atul Aggarwal [EMAIL PROTECTED] wrote: Hello Everybody, I am beginner in Algorithms. Which book I should prefer for understanding basic algos? Also tell me some good book for graph Theory and its basic algos. Thanx in advance. Atul Aggarwal --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Need Help - Constrained linear least square optimization C code
Hi I need to find x that will minimize Ax-b=0, under the inequality constraints Cxd. Actually the constraints in my problem are only upper and lower bounds to x values. x is 4x1 vector, A is about 100x4 (and b is of course 100x1(. What is the appropriate algorithm? Is there any C / C++ code available? I succeeded solving the non-constrained problem with SVD, but some times it give non-legal solution. Thanks a lot in advance Ariel --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: help with serie-parallel recognition algorithm
Series-parallel graphs may be recognized in linear time and their series-parallel decomposition may be constructed in linear time as well. See en.wikipedia.org/wiki/Series-parallel_graph. Reference 3 in that article may be what you are looking for. Dave On Nov 14, 5:31 am, fpalamariu [EMAIL PROTECTED] wrote: Hi, i need a little help with an algorithm... an algorithm to recognize a series-parallel graph using (a adaptation probably) the algorithm for detecting articulation points in a graph. I have no ideea how this finally algoritm might look i've open a lot of books on graph theory data design... and nothing... so i ask for your help... because my algorithm solving abilities sucks hard. thank's --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---