Re: [algogeeks] INTRVIEW QUESTION
is output is depend on no of digits in a number like 123 example for odd no of digits and 121224 example for even digits??? can you make it clear pls?? On Sat, Aug 11, 2012 at 5:22 PM, payal gupta gpt.pa...@gmail.com wrote: Given the start and an ending integer as user input, generate all integers with the following property. Example : 123 , 1+2 = 3 , valid number 121224 12+12 = 24 , valid number 1235 1+2 = 3 , 2+3 = 5 , valid number 125 1+2 5 , invalid number -- 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/-/zeZVnoP0sOEJ. 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] google paper
one Q is zig zag traversal in a tree nd d other one is like - A new language is defined called googley and it has two register only 'X' and 'Y' and only two commands are avialable next and print each one has some specific function (i don't remember now) and now u are given a string and u hav to write a series of these commands for d given string lyk for CBC o/p is next next next print. hope this will give u some idea.. On Sat, Aug 11, 2012 at 2:39 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: Can you share the coding questions asked. Thank you. On Fri, Aug 10, 2012 at 10:29 PM, Abhishek Kumar abhivai...@gmail.comwrote: two coding Qs + some mcqs(more than 1 option correct),time is 1.5 hr.. On Fri, Aug 10, 2012 at 4:06 PM, deepikaanand swinyanand...@gmail.comwrote: Somebody from DCE plz tell the paper pattern of google... -- 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/-/BjLRVjRlekIJ. 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. -- Cheers, Vicky -- 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] google paper
1. Print the zig-zag traversal of a BST. 2. There is a language Googley. There are two global registers X and Y both of whom have the character 'A' stored in them. There are only two commands in the language. i) next ii) print next increments the character in the X register. After reaching 'Z', again 'A' will be there. When print is executed, the character in the X register is printed and the contents in the X and Y register are swapped. Now you are given the result of the commands, you have to return a string which contains all the commands which would have generated the final output. These 2 questions were of 10 marks each. There were 10 objective questions of 1 mark each too, out of which 4 had 4 options, and we had to write short one-two lines answers for the other six questions. I remember little of the objective qs : 1. MCQ on various sorting algorithms 2. Numerical on networking ( sub-hosts, Class B ) 3. Numerical on finding the Mean time to failure of a RAID system. Mean time to failure of one disk was given as 10^6 hours and the mean time to repair one disk was 10 hours. 4. Three processes with some mutexes were given. We were to tell if the processes were deadlocked, and if they were, we had to rearrange to avoid the deadlock. 5. Output : int16 value = 10 ; while ( value 0 ) value+= 10 ; print value 6. Two threads were given. They operated on some variables. We had to tell that after the two threads are done, what will be the value of a specific variable k. 7. Numerical involving finding the average waiting time in a shortest job first scheduling. 8. Out of 5 options, we had to tell which all functions we could use to hash the variable x. On Sat, Aug 11, 2012 at 2:39 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: Can you share the coding questions asked. Thank you. On Fri, Aug 10, 2012 at 10:29 PM, Abhishek Kumar abhivai...@gmail.comwrote: two coding Qs + some mcqs(more than 1 option correct),time is 1.5 hr.. On Fri, Aug 10, 2012 at 4:06 PM, deepikaanand swinyanand...@gmail.comwrote: Somebody from DCE plz tell the paper pattern of google... -- 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/-/BjLRVjRlekIJ. 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. -- Cheers, Vicky -- 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] google paper
Hi, Section A - objective type 10 technical questions in OS,Algorithms,DS,C. each carries one mark. no negative marks Section B - coding 2 questions first was very simple second - spiral level order traversal of a BST -- 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] Cisco paper questions
smbody plz post cisco written Qs On Thu, Aug 9, 2012 at 12:29 PM, Abhi abhi120@gmail.com wrote: Hi Guys,I have Cisco Goldman Sachs placement exams next week. If anyone has appeared for cisco or Goldman Sachs recentlyplz post some of the questions asked by them. It would really be of great help for me. Thanks -- 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/-/1DO6JiTEQnQJ. 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] INTRVIEW QUESTION
if i am correctly understand the problem den i hv attchd the solution.. On Sun, Aug 12, 2012 at 12:40 AM, Ankit Singh ask9092516...@gmail.comwrote: is output is depend on no of digits in a number like 123 example for odd no of digits and 121224 example for even digits??? can you make it clear pls?? On Sat, Aug 11, 2012 at 5:22 PM, payal gupta gpt.pa...@gmail.com wrote: Given the start and an ending integer as user input, generate all integers with the following property. Example : 123 , 1+2 = 3 , valid number 121224 12+12 = 24 , valid number 1235 1+2 = 3 , 2+3 = 5 , valid number 125 1+2 5 , invalid number -- 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/-/zeZVnoP0sOEJ. 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. # includeiostream.h # includeconio.h int main() { int n,i,*a,s,e,temp,count,sum1,sum2,num1; coutenter the starting and ending point=; cinse; for(n=s;n=e;n++) { temp=n; count=0; while(temp!=0) { count++; temp=temp/10; } temp=n; a=new int[count]; i=count; while(temp!=0) { a[i-1]=temp%10; temp=temp/10; i--; } sum1=0; sum2=0; num1=0; if(count%2!=0) { for(i=0;icount-1;i++) { sum1+=a[i]; } if(sum1==a[count-1] ) coutn ; } else { for(i=0;icount-3;i=i+2) { num1=a[i]*10+a[i+1]; sum2+=num1; } if(sum2==(a[count-2]*10+a[count-1])) coutn ; } } getch(); return 0; }
[algogeeks] Interview Question - Probability
You are given n white balls in the beginning. Each day you pick up a ball randomly, color it red and put it back. If it is already colored, you simply put it back. This operation is performed for 'd' days. What is the probability that after d days you will have greater than 'k' balls colored? -- 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] Data Structure Real World examples
Can anyone pls share some real world examples for each datastructure nd sorting algos.. -- 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/-/cxuwSiqTuuIJ. 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] INTRVIEW QUESTION
The property seems ambiguous .. On Sat, Aug 11, 2012 at 5:22 PM, payal gupta gpt.pa...@gmail.com wrote: Given the start and an ending integer as user input, generate all integers with the following property. Example : 123 , 1+2 = 3 , valid number 121224 12+12 = 24 , valid number 1235 1+2 = 3 , 2+3 = 5 , valid number 125 1+2 5 , invalid number -- 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/-/zeZVnoP0sOEJ. 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 Daksh Talwar -- 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] Finding Minimum of the maximum values
Hi there, There is a integer Matrix with dimensions n*2, If you want to go from (1,1) to (n,2) and you are allowed just to go down or right, what's the maximum value you can get? Alright this is easy, but we want to consider all the permutations of rows of the matrix which is n!, find this maximum for each permutation, and finally we want the minimum amount among these maximum values. Do you have an Idea to solve this problem better than O(n!)? -- MeHdi KaZemI -- 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] INTRVIEW QUESTION
Always share code using ideone like sites or discuss the algo approach. Attaching code isn't the best idea is my personal feeling. Regards, Vicky On Sun, Aug 12, 2012 at 12:44 AM, Ankit Singh ask9092516...@gmail.comwrote: if i am correctly understand the problem den i hv attchd the solution.. On Sun, Aug 12, 2012 at 12:40 AM, Ankit Singh ask9092516...@gmail.comwrote: is output is depend on no of digits in a number like 123 example for odd no of digits and 121224 example for even digits??? can you make it clear pls?? On Sat, Aug 11, 2012 at 5:22 PM, payal gupta gpt.pa...@gmail.com wrote: Given the start and an ending integer as user input, generate all integers with the following property. Example : 123 , 1+2 = 3 , valid number 121224 12+12 = 24 , valid number 1235 1+2 = 3 , 2+3 = 5 , valid number 125 1+2 5 , invalid number -- 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/-/zeZVnoP0sOEJ. 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. -- Cheers, Vicky -- 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] Finding Minimum of the maximum values
do we sum all cell values when we step over them ? On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Hi there, There is a integer Matrix with dimensions n*2, If you want to go from (1,1) to (n,2) and you are allowed just to go down or right, what's the maximum value you can get? Alright this is easy, but we want to consider all the permutations of rows of the matrix which is n!, find this maximum for each permutation, and finally we want the minimum amount among these maximum values. Do you have an Idea to solve this problem better than O(n!)? -- MeHdi KaZemI -- 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] Finding Minimum of the maximum values
On 8/12/12, Hassan Monfared hmonfa...@gmail.com wrote: do we sum all cell values when we step over them ? On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Hi there, There is a integer Matrix with dimensions n*2, If you want to go from (1,1) to (n,2) and you are allowed just to go down or right, what's the maximum value you can get? Alright this is easy, but we want to consider all the permutations of rows of the matrix which is n!, find this maximum for each permutation, and finally we want the minimum amount among these maximum values. Do you have an Idea to solve this problem better than O(n!)? -- MeHdi KaZemI -- 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. -- MeHdi KaZemI -- 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] Finding Minimum of the maximum values
Yes, and all the values are positive integers. For example 1 2 3 4 5 6 Maximum path in this matrix is 15, Another permutation of the same matrix 5 6 1 2 3 4 Maximum path in this matrix is 17, We want the minimum value among these maximum paths. On 8/12/12, MeHdi KaZemI mehdi.kaze...@gmail.com wrote: On 8/12/12, Hassan Monfared hmonfa...@gmail.com wrote: do we sum all cell values when we step over them ? On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Hi there, There is a integer Matrix with dimensions n*2, If you want to go from (1,1) to (n,2) and you are allowed just to go down or right, what's the maximum value you can get? Alright this is easy, but we want to consider all the permutations of rows of the matrix which is n!, find this maximum for each permutation, and finally we want the minimum amount among these maximum values. Do you have an Idea to solve this problem better than O(n!)? -- MeHdi KaZemI -- 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. -- MeHdi KaZemI -- MeHdi KaZemI -- 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] INTRVIEW QUESTION
@vicky i l keep it in mind nxt tym onwardss.. thnku On Sun, Aug 12, 2012 at 2:01 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: Always share code using ideone like sites or discuss the algo approach. Attaching code isn't the best idea is my personal feeling. Regards, Vicky On Sun, Aug 12, 2012 at 12:44 AM, Ankit Singh ask9092516...@gmail.comwrote: if i am correctly understand the problem den i hv attchd the solution.. On Sun, Aug 12, 2012 at 12:40 AM, Ankit Singh ask9092516...@gmail.comwrote: is output is depend on no of digits in a number like 123 example for odd no of digits and 121224 example for even digits??? can you make it clear pls?? On Sat, Aug 11, 2012 at 5:22 PM, payal gupta gpt.pa...@gmail.comwrote: Given the start and an ending integer as user input, generate all integers with the following property. Example : 123 , 1+2 = 3 , valid number 121224 12+12 = 24 , valid number 1235 1+2 = 3 , 2+3 = 5 , valid number 125 1+2 5 , invalid number -- 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/-/zeZVnoP0sOEJ. 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. -- Cheers, Vicky -- 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] Finding Minimum of the maximum values
DP can help us to find max path, I couldn't find out any specific solution for complexity less than O(n!) but as an initial Idea, I think some kind of sorting rows or modified Floyd-Warshal algorithm may help us.please discuss If you have any Idea for challenge the problem. On Sun, Aug 12, 2012 at 1:22 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Yes, and all the values are positive integers. For example 1 2 3 4 5 6 Maximum path in this matrix is 15, Another permutation of the same matrix 5 6 1 2 3 4 Maximum path in this matrix is 17, We want the minimum value among these maximum paths. On 8/12/12, MeHdi KaZemI mehdi.kaze...@gmail.com wrote: On 8/12/12, Hassan Monfared hmonfa...@gmail.com wrote: do we sum all cell values when we step over them ? On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Hi there, There is a integer Matrix with dimensions n*2, If you want to go from (1,1) to (n,2) and you are allowed just to go down or right, what's the maximum value you can get? Alright this is easy, but we want to consider all the permutations of rows of the matrix which is n!, find this maximum for each permutation, and finally we want the minimum amount among these maximum values. Do you have an Idea to solve this problem better than O(n!)? -- MeHdi KaZemI -- 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. -- MeHdi KaZemI -- MeHdi KaZemI -- 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] Finding Minimum of the maximum values
We can solve using Dynamic programming.. Take n*2 matrix for storing sum. Let A be original matrix and matrix M hold sum. Let M[i, j] contains max sum upto i th row and j th column. recursion will be as follows: M[i, j] = max(M[i - 1, j], M[i, j-1]) + A[i, j] By above formula fill whole M matrix and return the M[n-1, 1] value. P.S. I have not written boundary condition. For this if M[i - 1, j] goes beyond matrix boundary then take M[i, j-1] value and vice versa. Initialize M[0, 0] = A[0, 0] On Sun, Aug 12, 2012 at 3:16 PM, Hassan Monfared hmonfa...@gmail.comwrote: DP can help us to find max path, I couldn't find out any specific solution for complexity less than O(n!) but as an initial Idea, I think some kind of sorting rows or modified Floyd-Warshal algorithm may help us.please discuss If you have any Idea for challenge the problem. On Sun, Aug 12, 2012 at 1:22 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Yes, and all the values are positive integers. For example 1 2 3 4 5 6 Maximum path in this matrix is 15, Another permutation of the same matrix 5 6 1 2 3 4 Maximum path in this matrix is 17, We want the minimum value among these maximum paths. On 8/12/12, MeHdi KaZemI mehdi.kaze...@gmail.com wrote: On 8/12/12, Hassan Monfared hmonfa...@gmail.com wrote: do we sum all cell values when we step over them ? On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Hi there, There is a integer Matrix with dimensions n*2, If you want to go from (1,1) to (n,2) and you are allowed just to go down or right, what's the maximum value you can get? Alright this is easy, but we want to consider all the permutations of rows of the matrix which is n!, find this maximum for each permutation, and finally we want the minimum amount among these maximum values. Do you have an Idea to solve this problem better than O(n!)? -- MeHdi KaZemI -- 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. -- MeHdi KaZemI -- MeHdi KaZemI -- 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] Finding Minimum of the maximum values
Mr. Navin ! the main question is not about finding max path for one permutation among the n! permutations! please read the question again and join us for solving the main problem On Sun, Aug 12, 2012 at 4:19 PM, Navin Kumar algorithm.i...@gmail.comwrote: We can solve using Dynamic programming.. Take n*2 matrix for storing sum. Let A be original matrix and matrix M hold sum. Let M[i, j] contains max sum upto i th row and j th column. recursion will be as follows: M[i, j] = max(M[i - 1, j], M[i, j-1]) + A[i, j] By above formula fill whole M matrix and return the M[n-1, 1] value. P.S. I have not written boundary condition. For this if M[i - 1, j] goes beyond matrix boundary then take M[i, j-1] value and vice versa. Initialize M[0, 0] = A[0, 0] On Sun, Aug 12, 2012 at 3:16 PM, Hassan Monfared hmonfa...@gmail.comwrote: DP can help us to find max path, I couldn't find out any specific solution for complexity less than O(n!) but as an initial Idea, I think some kind of sorting rows or modified Floyd-Warshal algorithm may help us.please discuss If you have any Idea for challenge the problem. On Sun, Aug 12, 2012 at 1:22 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Yes, and all the values are positive integers. For example 1 2 3 4 5 6 Maximum path in this matrix is 15, Another permutation of the same matrix 5 6 1 2 3 4 Maximum path in this matrix is 17, We want the minimum value among these maximum paths. On 8/12/12, MeHdi KaZemI mehdi.kaze...@gmail.com wrote: On 8/12/12, Hassan Monfared hmonfa...@gmail.com wrote: do we sum all cell values when we step over them ? On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Hi there, There is a integer Matrix with dimensions n*2, If you want to go from (1,1) to (n,2) and you are allowed just to go down or right, what's the maximum value you can get? Alright this is easy, but we want to consider all the permutations of rows of the matrix which is n!, find this maximum for each permutation, and finally we want the minimum amount among these maximum values. Do you have an Idea to solve this problem better than O(n!)? -- MeHdi KaZemI -- 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. -- MeHdi KaZemI -- MeHdi KaZemI -- 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. -- 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] Finding Minimum of the maximum values
Thanx hassan for correcting me. I think there must be some DP solution for this problem. On Sun, Aug 12, 2012 at 5:26 PM, Hassan Monfared hmonfa...@gmail.comwrote: Mr. Navin ! the main question is not about finding max path for one permutation among the n! permutations! please read the question again and join us for solving the main problem On Sun, Aug 12, 2012 at 4:19 PM, Navin Kumar algorithm.i...@gmail.comwrote: We can solve using Dynamic programming.. Take n*2 matrix for storing sum. Let A be original matrix and matrix M hold sum. Let M[i, j] contains max sum upto i th row and j th column. recursion will be as follows: M[i, j] = max(M[i - 1, j], M[i, j-1]) + A[i, j] By above formula fill whole M matrix and return the M[n-1, 1] value. P.S. I have not written boundary condition. For this if M[i - 1, j] goes beyond matrix boundary then take M[i, j-1] value and vice versa. Initialize M[0, 0] = A[0, 0] On Sun, Aug 12, 2012 at 3:16 PM, Hassan Monfared hmonfa...@gmail.comwrote: DP can help us to find max path, I couldn't find out any specific solution for complexity less than O(n!) but as an initial Idea, I think some kind of sorting rows or modified Floyd-Warshal algorithm may help us.please discuss If you have any Idea for challenge the problem. On Sun, Aug 12, 2012 at 1:22 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Yes, and all the values are positive integers. For example 1 2 3 4 5 6 Maximum path in this matrix is 15, Another permutation of the same matrix 5 6 1 2 3 4 Maximum path in this matrix is 17, We want the minimum value among these maximum paths. On 8/12/12, MeHdi KaZemI mehdi.kaze...@gmail.com wrote: On 8/12/12, Hassan Monfared hmonfa...@gmail.com wrote: do we sum all cell values when we step over them ? On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Hi there, There is a integer Matrix with dimensions n*2, If you want to go from (1,1) to (n,2) and you are allowed just to go down or right, what's the maximum value you can get? Alright this is easy, but we want to consider all the permutations of rows of the matrix which is n!, find this maximum for each permutation, and finally we want the minimum amount among these maximum values. Do you have an Idea to solve this problem better than O(n!)? -- MeHdi KaZemI -- 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. -- MeHdi KaZemI -- MeHdi KaZemI -- 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. -- 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] Interview Question
Divide 2D array into 4 parts. Compute sum of each partition and get max value from the four of them. For all possible partitions get min value of such max values computed. -- 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/-/G5YC7Lq0ovkJ. 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] Constant time solution needed
say yo have 3*4 matrix... 0 1 2 3 4 5 6 7 8 9 10 11 if the co-ordinates are (0,0),(0,2),(1,0),(1,2) the o/p should be 0+1+2+4+5+6 On Sat, Aug 11, 2012 at 9:57 PM, adarsh kumar algog...@gmail.com wrote: Sum of the integers meaning? Do you mind giving an example test case? regards. On Sat, Aug 11, 2012 at 7:10 PM, Srividhya srisam261...@gmail.com wrote: hi all:) The coordinates of a rectangle will be specified. there is a matrix of integers. yo should find the sum of the integers that fall in the region specified by the coordinates . The solution to be in constant time . -- 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/-/qHSmXBshmS4J. 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] Constant time solution needed
@ Vicky Can yo explain with an illustration ? On Sat, Aug 11, 2012 at 10:07 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: May be you can consider creating a 2d array to pre process and store all the rectangle sums as a dependent subproblem, the sum of larger rect will be currValuesAdded+OldRectSum. So when you get the coordinate as input u can calc the needed sum by subtracting sum of big rect and small rect which is not included in the given coordinates. This can be called constant time if u don't include the preprocessing time. On Sat, Aug 11, 2012 at 9:57 PM, adarsh kumar algog...@gmail.com wrote: Sum of the integers meaning? Do you mind giving an example test case? regards. On Sat, Aug 11, 2012 at 7:10 PM, Srividhya srisam261...@gmail.comwrote: hi all:) The coordinates of a rectangle will be specified. there is a matrix of integers. yo should find the sum of the integers that fall in the region specified by the coordinates . The solution to be in constant time . -- 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/-/qHSmXBshmS4J. 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. -- Cheers, Vicky -- 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] Constant time solution needed
Lets build the array for the example you gave. i/p: 0 1 2 3 4 5 6 7 8 9 10 11 (x1,y1) = (0,0) (x2,y2) = (1,2) sumArray 0 1 23 4 10 18 28 12 27 45 66 (will take O(n^2) to build above array) So now when you get coordinates as input, you can calc the sum by Ans = sumArray[x2][y2] - sumArray[x1][y1] + ip[x1][y1] For our case it will be Ans = 18-0+0 = 18 Please lemme know if any bugs with the logic. On Sun, Aug 12, 2012 at 6:27 PM, Srividhya Sampath srisam261...@gmail.comwrote: @ Vicky Can yo explain with an illustration ? On Sat, Aug 11, 2012 at 10:07 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: May be you can consider creating a 2d array to pre process and store all the rectangle sums as a dependent subproblem, the sum of larger rect will be currValuesAdded+OldRectSum. So when you get the coordinate as input u can calc the needed sum by subtracting sum of big rect and small rect which is not included in the given coordinates. This can be called constant time if u don't include the preprocessing time. On Sat, Aug 11, 2012 at 9:57 PM, adarsh kumar algog...@gmail.com wrote: Sum of the integers meaning? Do you mind giving an example test case? regards. On Sat, Aug 11, 2012 at 7:10 PM, Srividhya srisam261...@gmail.comwrote: hi all:) The coordinates of a rectangle will be specified. there is a matrix of integers. yo should find the sum of the integers that fall in the region specified by the coordinates . The solution to be in constant time . -- 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/-/qHSmXBshmS4J. 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. -- Cheers, Vicky -- 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. -- Cheers, Vicky -- 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] Constant time solution needed
You can traverse in spiral order and add each element with the specified co-ordinate. -- 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] Constant time solution needed
*within -- 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] Constant time solution needed
@Arun: How do you claim your solution to be constant time? :P On Sun, Aug 12, 2012 at 8:46 PM, Arun Kindra arunkin...@gmail.com wrote: *within -- 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. -- Cheers, Vicky -- 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] Constant time solution needed
@vicky can yo explain the logic behind the 'Sum Array' computation (if possible elaborately )? On Sun, Aug 12, 2012 at 8:19 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: Lets build the array for the example you gave. i/p: 0 1 2 3 4 5 6 7 8 9 10 11 (x1,y1) = (0,0) (x2,y2) = (1,2) sumArray 0 1 23 4 10 18 28 12 27 45 66 (will take O(n^2) to build above array) So now when you get coordinates as input, you can calc the sum by Ans = sumArray[x2][y2] - sumArray[x1][y1] + ip[x1][y1] For our case it will be Ans = 18-0+0 = 18 Please lemme know if any bugs with the logic. On Sun, Aug 12, 2012 at 6:27 PM, Srividhya Sampath srisam261...@gmail.com wrote: @ Vicky Can yo explain with an illustration ? On Sat, Aug 11, 2012 at 10:07 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: May be you can consider creating a 2d array to pre process and store all the rectangle sums as a dependent subproblem, the sum of larger rect will be currValuesAdded+OldRectSum. So when you get the coordinate as input u can calc the needed sum by subtracting sum of big rect and small rect which is not included in the given coordinates. This can be called constant time if u don't include the preprocessing time. On Sat, Aug 11, 2012 at 9:57 PM, adarsh kumar algog...@gmail.comwrote: Sum of the integers meaning? Do you mind giving an example test case? regards. On Sat, Aug 11, 2012 at 7:10 PM, Srividhya srisam261...@gmail.comwrote: hi all:) The coordinates of a rectangle will be specified. there is a matrix of integers. yo should find the sum of the integers that fall in the region specified by the coordinates . The solution to be in constant time . -- 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/-/qHSmXBshmS4J. 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. -- Cheers, Vicky -- 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. -- Cheers, Vicky -- 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] Constant time solution needed
Fine, the basic idea of using dp here is sum of each rectangle is a dependent sub problem. So when u find sum for smaller rectangle we can use it to compute sum of bigger rectangle with new coordinates added to previous small rectangle. So u can compute the sum array by using this formula sum[i][j] = sum[i-1][j-1] + (sum[i-1][j] - sum[i-1][j-1]) + (sum[i][j-1] - sum[i-1][j-1])+ip[i][j] [smaller rect] [that row sum value][that col sum value] On Sun, Aug 12, 2012 at 8:54 PM, Srividhya Sampath srisam261...@gmail.comwrote: @vicky can yo explain the logic behind the 'Sum Array' computation (if possible elaborately )? On Sun, Aug 12, 2012 at 8:19 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: Lets build the array for the example you gave. i/p: 0 1 2 3 4 5 6 7 8 9 10 11 (x1,y1) = (0,0) (x2,y2) = (1,2) sumArray 0 1 23 4 10 18 28 12 27 45 66 (will take O(n^2) to build above array) So now when you get coordinates as input, you can calc the sum by Ans = sumArray[x2][y2] - sumArray[x1][y1] + ip[x1][y1] For our case it will be Ans = 18-0+0 = 18 Please lemme know if any bugs with the logic. On Sun, Aug 12, 2012 at 6:27 PM, Srividhya Sampath srisam261...@gmail.com wrote: @ Vicky Can yo explain with an illustration ? On Sat, Aug 11, 2012 at 10:07 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: May be you can consider creating a 2d array to pre process and store all the rectangle sums as a dependent subproblem, the sum of larger rect will be currValuesAdded+OldRectSum. So when you get the coordinate as input u can calc the needed sum by subtracting sum of big rect and small rect which is not included in the given coordinates. This can be called constant time if u don't include the preprocessing time. On Sat, Aug 11, 2012 at 9:57 PM, adarsh kumar algog...@gmail.comwrote: Sum of the integers meaning? Do you mind giving an example test case? regards. On Sat, Aug 11, 2012 at 7:10 PM, Srividhya srisam261...@gmail.comwrote: hi all:) The coordinates of a rectangle will be specified. there is a matrix of integers. yo should find the sum of the integers that fall in the region specified by the coordinates . The solution to be in constant time . -- 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/-/qHSmXBshmS4J. 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. -- Cheers, Vicky -- 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. -- Cheers, Vicky -- 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. -- Cheers, Vicky -- 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] Constant time solution needed
@Arun: This approach is constant time once the array is build for any queries that follows. :) You know sum for all possible rectangles in the given 2d array thats makes it better than computing sum for each input. Hope it makes sense On Sun, Aug 12, 2012 at 9:07 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: Fine, the basic idea of using dp here is sum of each rectangle is a dependent sub problem. So when u find sum for smaller rectangle we can use it to compute sum of bigger rectangle with new coordinates added to previous small rectangle. So u can compute the sum array by using this formula sum[i][j] = sum[i-1][j-1] + (sum[i-1][j] - sum[i-1][j-1]) + (sum[i][j-1] - sum[i-1][j-1])+ip[i][j] [smaller rect] [that row sum value][that col sum value] On Sun, Aug 12, 2012 at 8:54 PM, Srividhya Sampath srisam261...@gmail.com wrote: @vicky can yo explain the logic behind the 'Sum Array' computation (if possible elaborately )? On Sun, Aug 12, 2012 at 8:19 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: Lets build the array for the example you gave. i/p: 0 1 2 3 4 5 6 7 8 9 10 11 (x1,y1) = (0,0) (x2,y2) = (1,2) sumArray 0 1 23 4 10 18 28 12 27 45 66 (will take O(n^2) to build above array) So now when you get coordinates as input, you can calc the sum by Ans = sumArray[x2][y2] - sumArray[x1][y1] + ip[x1][y1] For our case it will be Ans = 18-0+0 = 18 Please lemme know if any bugs with the logic. On Sun, Aug 12, 2012 at 6:27 PM, Srividhya Sampath srisam261...@gmail.com wrote: @ Vicky Can yo explain with an illustration ? On Sat, Aug 11, 2012 at 10:07 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: May be you can consider creating a 2d array to pre process and store all the rectangle sums as a dependent subproblem, the sum of larger rect will be currValuesAdded+OldRectSum. So when you get the coordinate as input u can calc the needed sum by subtracting sum of big rect and small rect which is not included in the given coordinates. This can be called constant time if u don't include the preprocessing time. On Sat, Aug 11, 2012 at 9:57 PM, adarsh kumar algog...@gmail.comwrote: Sum of the integers meaning? Do you mind giving an example test case? regards. On Sat, Aug 11, 2012 at 7:10 PM, Srividhya srisam261...@gmail.comwrote: hi all:) The coordinates of a rectangle will be specified. there is a matrix of integers. yo should find the sum of the integers that fall in the region specified by the coordinates . The solution to be in constant time . -- 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/-/qHSmXBshmS4J. 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. -- Cheers, Vicky -- 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. -- Cheers, Vicky -- 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. -- Cheers, Vicky -- Cheers, Vicky -- You received this message because you are subscribed to the Google Groups Algorithm Geeks
[algogeeks] Given an array of 32bit unsigned integers in which every number appears exactly twice except three of them, find those three numbers in O(n) time using O(1) extra space
-- 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/-/La5cAv04gqQJ. 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] Constant time solution needed
a small question, if matrix has 'r' rows and 'c' columns, how many different rectangles can be there for this problem ? Space Complexity = O( (r*r)*(c*c) ) On Sat, Aug 11, 2012 at 7:10 PM, Srividhya srisam261...@gmail.com wrote: hi all:) The coordinates of a rectangle will be specified. there is a matrix of integers. yo should find the sum of the integers that fall in the region specified by the coordinates . The solution to be in constant time . -- 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/-/qHSmXBshmS4J. 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] Constant time solution needed
@venkat +1 On Sun, Aug 12, 2012 at 9:09 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: @Arun: This approach is constant time once the array is build for any queries that follows. :) You know sum for all possible rectangles in the given 2d array thats makes it better than computing sum for each input. Hope it makes sense On Sun, Aug 12, 2012 at 9:07 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: Fine, the basic idea of using dp here is sum of each rectangle is a dependent sub problem. So when u find sum for smaller rectangle we can use it to compute sum of bigger rectangle with new coordinates added to previous small rectangle. So u can compute the sum array by using this formula sum[i][j] = sum[i-1][j-1] + (sum[i-1][j] - sum[i-1][j-1]) + (sum[i][j-1] - sum[i-1][j-1])+ip[i][j] [smaller rect] [that row sum value][that col sum value] On Sun, Aug 12, 2012 at 8:54 PM, Srividhya Sampath srisam261...@gmail.com wrote: @vicky can yo explain the logic behind the 'Sum Array' computation (if possible elaborately )? On Sun, Aug 12, 2012 at 8:19 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote: Lets build the array for the example you gave. i/p: 0 1 2 3 4 5 6 7 8 9 10 11 (x1,y1) = (0,0) (x2,y2) = (1,2) sumArray 0 1 23 4 10 18 28 12 27 45 66 (will take O(n^2) to build above array) So now when you get coordinates as input, you can calc the sum by Ans = sumArray[x2][y2] - sumArray[x1][y1] + ip[x1][y1] For our case it will be Ans = 18-0+0 = 18 Please lemme know if any bugs with the logic. On Sun, Aug 12, 2012 at 6:27 PM, Srividhya Sampath srisam261...@gmail.com wrote: @ Vicky Can yo explain with an illustration ? On Sat, Aug 11, 2012 at 10:07 PM, ~*~VICKY~*~ venkat.jun...@gmail.com wrote: May be you can consider creating a 2d array to pre process and store all the rectangle sums as a dependent subproblem, the sum of larger rect will be currValuesAdded+OldRectSum. So when you get the coordinate as input u can calc the needed sum by subtracting sum of big rect and small rect which is not included in the given coordinates. This can be called constant time if u don't include the preprocessing time. On Sat, Aug 11, 2012 at 9:57 PM, adarsh kumar algog...@gmail.comwrote: Sum of the integers meaning? Do you mind giving an example test case? regards. On Sat, Aug 11, 2012 at 7:10 PM, Srividhya srisam261...@gmail.comwrote: hi all:) The coordinates of a rectangle will be specified. there is a matrix of integers. yo should find the sum of the integers that fall in the region specified by the coordinates . The solution to be in constant time . -- 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/-/qHSmXBshmS4J. 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. -- Cheers, Vicky -- 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. -- Cheers, Vicky -- 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. -- Cheers, Vicky -- Cheers, Vicky
[algogeeks] Hanoi problem
Please help me out with Hanoi problem of n disks. Algorithm and code preferably in C++. http://en.wikipedia.org/wiki/Tower_of_Hanoi -- 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] direct i online test
A smart 3 year old Sandeep knows counting. But he doesn't know how to read and write properly. He has learnt 1, 2 and 3 but thinks that 4 is another way to write 1. So when given any number with 1, 2, 3 4, he tries to sum up their digits as follows : 213 = 2 + 1 + 3 = 6 33 = 3 + 3 = 6 1341 = 1 + 3 + 1 + 1 = 6 (remember, the kid thinks that 4 = 1) Sandeep gets excited to discover that different numbers can all add up to the same sum. He now wants to know how many numbers there are whose sum is a number N. For N = 2, he can make 5 numbers: 11, 14, 41, 44, and 2. (He knows how to count up beyond five, just not how to write it) He needs your help for other such values of N. Input/Output You don't have to read or write anything from/to stdin and stdout respectively. Use the template code provided in the editor on the submission page, that does the IO for you. In the template, you have to write a function that takes N as argument and returns the count of numbers Sandeep can make such that the sum of their digits is equal to N. Since the count could be very large, return the result mod 17 Function Signature: int dumb_sum(int N); The template code executes the function submitted T times with different arguments.Constraint 0 T 1 1 ≤ N ≤ 1000. Example*Input:* 2 2 3 *Output:* 5 13 -- Author:xyler http://www.codechef.com/users/xylerDate Added:10-08-2012Time Limit:10 secSource Limit:5 BytesLanguages:C, CPP 4.3.2, JAVA -- 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/-/tD_1SLVj0QgJ. 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] Given an array of 32bit unsigned integers in which every number appears exactly twice except three of them, find those three numbers in O(n) time using O(1) extra space
Please help me out with Hanoi problem of n disc problem. Algorithm and code preferably in C++. http://en.wikipedia.org/wiki/Tower_of_Hanoi -- 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] direct i online round
Given N points in 2D plane, you have to calculate the number of right triangles, with their shorter sides parallel to the coordinate axis, that can be formed using these N points. Input/OutputYou don't have to read or write anything from/to stdin and stdout respectively. Use the template code provided in the editor on the submission page, that does the IO for you. In the template, you have to write a function that takes 3 arguments, N and two 1 dimensional arrays X and Y, containing the x-cord and y-cord of the ith point respectively and returns the number of right triangles that can be formed. Function Signature: long long rt_triangle(int N, int X[15000], int Y[15000]); The template code executes the function submitted T times with different arguments.Constraints 0 T = 50 0 N = 15000 -5 = X cord, Y cord = 5 Example rt_triangle(4, {1, -5, -2, -2}, {3, -2, 4, 1}) should return 0. rt_triangle(4, {0, -1, -1, 1}, {1, -2, 1, -2}) should return 0. Sample Input File 2 4 1 3 -5 -2 -2 -4 -2 1 4 0 1 -1 -2 -1 1 1 -2 Output 0 2 -- Author:xyler http://www.codechef.com/users/xylerDate Added:10-08-2012Time Limit:10 secSource Limit:5 BytesLanguages:C, CPP 4.3.2, JAVA -- 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/-/7adddI9bcvgJ. 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: puzzle
Does the pattern comes in this way? HT,TH,TT or HT(X)TH(X)TT ?? Let me know. -- Amitesh On Sat, Aug 11, 2012 at 11:24 PM, Piyush pkjee2...@gmail.com wrote: How can I find the expected number of tosses , required to obtain a {HT,TH,TT} , by using random variables?? On Friday, December 31, 2010 8:27:46 PM UTC+5:30, Dave wrote: @Anuj and Bittu: It is not necessary to know the bias. You can simulate the flip of an unbiased coin with multiple flips of a biased coin: Flip it twice. If the result is HT, consider it a Head. If the result is TH, consider it a Tail. If the result is HH or TT, repeat the process. It terminates with probability 1. Now use the resulting Head or Tail in the procecure for deciding with a biased coin. Dave On Dec 31, 7:07 am, Anuj Kumar anuj.bhambh...@gmail.com wrote: in case the coin is not biased, we can flip the coin twice and define the rules as if {H,H} comes then ignore it i.e. dont take it as a flip and the 3 other events would be valid onces and could occur with equal probabilities. In case of a biased coin please specify the probability of getting heads and that of getting tails. On Fri, Dec 31, 2010 at 4:11 PM, bittu shashank7andr...@gmail.com wrote: At a restaurant, how can Veronica choose one out of three desserts with equal probability with the help of a coin? What if the coin is biased and the bias is unknown? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algo...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+...@**googlegroups.comalgogeeks%** 2Bunsubscribe@googlegroups.**com . For more options, visit this group at http://groups.google.com/**group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en. -- Anuj Kumar Third Year Undergraduate, Dept. of Computer Science and Engineering NIT Durgapur- Hide quoted text - - Show quoted text - -- 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/-/DZdUcelMwtUJ. 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: puzzle
if you meant to calculate the E[x] for [HT,TH,TT]. It can be solvable but very lengthy/boring. I shall give you an example which should help you. Let E[X] = x be the expected no. of coin flips to get [HT] 1) if first flip is a tail, we have wasted one flip hence. E[X1] = 1/2*(1+x) 2) if first flip is a head, and second flip is a head, hence E[X2] = 1/4*(1+1+x) 3) if first flip is a head and second flip is a tail, we are done then. hence E[X3] = 1/4*(1+1) We have, E[X] = E[X1] + E[X2] + E[X3] Solve x here. The same approach you can apply to solve the above problem. I really don't have time to do that for you. Please help yourself. Thanks -- Amitesh Singh On Sun, Aug 12, 2012 at 10:32 PM, Amitesh Singh singh.amit...@gmail.comwrote: Does the pattern comes in this way? HT,TH,TT or HT(X)TH(X)TT ?? Let me know. -- Amitesh On Sat, Aug 11, 2012 at 11:24 PM, Piyush pkjee2...@gmail.com wrote: How can I find the expected number of tosses , required to obtain a {HT,TH,TT} , by using random variables?? On Friday, December 31, 2010 8:27:46 PM UTC+5:30, Dave wrote: @Anuj and Bittu: It is not necessary to know the bias. You can simulate the flip of an unbiased coin with multiple flips of a biased coin: Flip it twice. If the result is HT, consider it a Head. If the result is TH, consider it a Tail. If the result is HH or TT, repeat the process. It terminates with probability 1. Now use the resulting Head or Tail in the procecure for deciding with a biased coin. Dave On Dec 31, 7:07 am, Anuj Kumar anuj.bhambh...@gmail.com wrote: in case the coin is not biased, we can flip the coin twice and define the rules as if {H,H} comes then ignore it i.e. dont take it as a flip and the 3 other events would be valid onces and could occur with equal probabilities. In case of a biased coin please specify the probability of getting heads and that of getting tails. On Fri, Dec 31, 2010 at 4:11 PM, bittu shashank7andr...@gmail.com wrote: At a restaurant, how can Veronica choose one out of three desserts with equal probability with the help of a coin? What if the coin is biased and the bias is unknown? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algo...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+...@**googlegroups.comalgogeeks%** 2Bunsubscribe@googlegroups.**com . For more options, visit this group at http://groups.google.com/**group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en. -- Anuj Kumar Third Year Undergraduate, Dept. of Computer Science and Engineering NIT Durgapur- Hide quoted text - - Show quoted text - -- 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/-/DZdUcelMwtUJ. 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] Given an array of 32bit unsigned integers in which every number appears exactly twice except three of them, find those three numbers in O(n) time using O(1) extra space
I guess O(1) extra space means constant extra space. In that case, you can have a hash map ( or a bool array) and then switch b/w true and false for every occurence. All of those which havent been switched twice , are the result. On Sun, Aug 12, 2012 at 9:16 PM, g4ur4v gauravyadav1...@gmail.com wrote: -- 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/-/La5cAv04gqQJ. 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 Daksh Talwar -- 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: Algorithm page
http://marathoncode.blogspot.com.br/2012/08/truque-paridade-magica.html http://marathoncode.blogspot.com.br/2012/08/matematica-na-babilonia.html http://marathoncode.blogspot.com.br/2012/08/a-beleza-da-matematica.html http://marathoncode.blogspot.com.br/2012/08/jogo-das-cartas.html http://marathoncode.blogspot.com.br/2012/08/multiplicacao-egipcia.html http://marathoncode.blogspot.com.br/2012/08/6-problemas-logicos.html Wladimir Araujo Tavares *Federal University of Ceará http://lia.ufc.br/%7Ewladimir/ Homepage http://lia.ufc.br/%7Ewladimir/ | Maratonahttps://sites.google.com/site/quixadamaratona/| * On Tue, Jul 10, 2012 at 10:32 AM, Wladimir Tavares wladimir...@gmail.comwrote: http://translate.google.com.br/translate?sl=pttl=enjs=nprev=_thl=pt-BRie=UTF-8layout=2eotf=1u=http%3A%2F%2Fmarathoncode.blogspot.com.br%2F2012%2F07%2Fquebra-cabecas-indutivos.html http://translate.googleusercontent.com/translate_c?hl=pt-BRie=UTF8prev=_trurl=translate.google.com.brsl=pttl=entwu=1u=http://marathoncode.blogspot.com.br/2012/07/pilha-umapilha-e-uma-das-varias.htmlusg=ALkJrhj059Lg0n3irAidNipyRDh7UpI4nA http://translate.googleusercontent.com/translate_c?hl=pt-BRie=UTF8prev=_trurl=translate.google.com.brsl=pttl=entwu=1u=http://marathoncode.blogspot.com.br/2012/07/3n1.htmlusg=ALkJrhglAJwrFEt5u5P2V8l8P6Ez3FHXBQ Wladimir Araujo Tavares *Federal University of Ceará http://lia.ufc.br/%7Ewladimir/ Homepage http://lia.ufc.br/%7Ewladimir/ | Maratonahttps://sites.google.com/site/quixadamaratona/| * -- 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] direct i online test
use simple recursive function to solve - int countfun(int sum ){ int i; int count; int total=0; if (sum==0) return 1; for(i=1;i=3;i++){ if (sum-i0) break; count=countfun(sum-i); if(i==1) count*=2; total+=count; } return total; } On Sun, Aug 12, 2012 at 11:22 PM, harsha harshacoo...@gmail.com wrote: A smart 3 year old Sandeep knows counting. But he doesn't know how to read and write properly. He has learnt 1, 2 and 3 but thinks that 4 is another way to write 1. So when given any number with 1, 2, 3 4, he tries to sum up their digits as follows : 213 = 2 + 1 + 3 = 6 33 = 3 + 3 = 6 1341 = 1 + 3 + 1 + 1 = 6 (remember, the kid thinks that 4 = 1) Sandeep gets excited to discover that different numbers can all add up to the same sum. He now wants to know how many numbers there are whose sum is a number N. For N = 2, he can make 5 numbers: 11, 14, 41, 44, and 2. (He knows how to count up beyond five, just not how to write it) He needs your help for other such values of N. Input/Output You don't have to read or write anything from/to stdin and stdout respectively. Use the template code provided in the editor on the submission page, that does the IO for you. In the template, you have to write a function that takes N as argument and returns the count of numbers Sandeep can make such that the sum of their digits is equal to N. Since the count could be very large, return the result mod 17 Function Signature: int dumb_sum(int N); The template code executes the function submitted T times with different arguments.Constraint 0 T 1 1 ≤ N ≤ 1000. Example*Input:* 2 2 3 *Output:* 5 13 -- Author:xyler http://www.codechef.com/users/xylerDate Added:10-08-2012Time Limit:10 secSource Limit:5 BytesLanguages:C, CPP 4.3.2, JAVA -- 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/-/tD_1SLVj0QgJ. 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] Given an array of 32bit unsigned integers in which every number appears exactly twice except three of them, find those three numbers in O(n) time using O(1) extra space
Solution for - all number appears two time except three number which appears 1 or 3 times. array indexing method is used to solve in O(n) time complexity and O(1). first find min - O(n) then in for loop 1 to n a[abs(a[i])-min]=-a[abs(a[i])-min]; then find the -ve number in array then answer will be min + i ; (where i is -ve number index) all three number in array. All done in O(n) time complexity and O(1) space complexity. On Sun, Aug 12, 2012 at 10:38 PM, Daksh Talwar dakshtal...@gmail.comwrote: I guess O(1) extra space means constant extra space. In that case, you can have a hash map ( or a bool array) and then switch b/w true and false for every occurence. All of those which havent been switched twice , are the result. On Sun, Aug 12, 2012 at 9:16 PM, g4ur4v gauravyadav1...@gmail.com wrote: -- 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/-/La5cAv04gqQJ. 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 Daksh Talwar -- 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: AMAZON: given col id, print col name in excel
its base 26 but little modification in code ... @shiv - nice solution . char Carr[26]={a,b,c...z} i=0; int arr[]; do { arrr[i++]=n%26; n=(n/26)-1; } while(n) ; for(int i=n-1;i=0;i--) coutCarr[a[i]]; On Sat, Aug 11, 2012 at 9:52 PM, yq Zhang zhangyunq...@gmail.com wrote: No. It's not base 26 at all. Given input 26, your code will return ba, but the result should be aa. It's not equivalent to a number. On Sat, Aug 11, 2012 at 2:57 AM, shiv narayan narayan.shiv...@gmail.comwrote: yes actually we have to print a,b,c..z instead of nos , so for that i have stored nos in character array so only characters will be printed not nos On Sat, Aug 11, 2012 at 2:18 AM, yq Zhang zhangyunq...@gmail.com wrote: @shiv, your code is correct go compute the base 26 number. However, this question is not base 26 number obviously. On Wed, Aug 8, 2012 at 4:46 AM, shiv narayan narayan.shiv...@gmail.comwrote: this is similar to conversion of no in base 26.( where digits are a,b,c,d...z) just think it like decimal to binary conversion here base is instead 26. char Carr[26]={a,b,c...z} i=0; int arr[]; do { arrr[i++]=n%26; n/=2; } while(n) ; for(int i=n-1;i=0;i--) coutCarr[a[i]]; correct me if i am wrong. On Wednesday, 8 August 2012 12:56:56 UTC+5:30, ashgoel wrote: Imagine a sequence like this: a, b, c...z, aa, ab, ac...zz, aaa, aab, aac aax, aaz, aba, abc... (Its same as excel column names). Given an integer (n), generate n-th string from the above sequence. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- 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/-/Z3kYiTZi_F8J. 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. -- Shiv Narayan Sharma Jt. Secretary CSI-DTU +919971228389 www.jugadengg.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 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] is given number is lucky..?
bool is_lucky(int x){ int pos=x; inr count=2; while(countpos){ if(pos%count) return 0; pos=pos-pos/count; count++; } return 1; } On Sun, Aug 5, 2012 at 1:11 PM, dheeraj hasija dheerajhasija1...@gmail.comwrote: @daksh paaji kya baat hai thanks for the solution. aap har jagah hai :P On Sat, Aug 4, 2012 at 12:21 AM, Daksh Talwar dakshtal...@gmail.comwrote: maintain a bool array of size of limit of int store true for lucky numbers and then cross check using the function. create the bool array like the one they show in the wiki page -- 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] Hanoi problem
have look at : http://codingways.blogspot.ca/2012/08/hanoi-tower-in-c.html On Sun, Aug 12, 2012 at 11:27 PM, Siddharth Malhotra codemalho...@gmail.com wrote: Please help me out with Hanoi problem of n disks. Algorithm and code preferably in C++. http://en.wikipedia.org/wiki/Tower_of_Hanoi -- 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. -- Hassan H. Monfared http://www.linkedin.com/pub/hassan-monfared/55/1b6/33 *I*men *R*ayaneh *S*hargh,+9821-88104832 CEO and technical manager -- 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] direct i online test
what will be the output if the sum is 4 ? On Sun, Aug 12, 2012 at 11:22 PM, harsha harshacoo...@gmail.com wrote: A smart 3 year old Sandeep knows counting. But he doesn't know how to read and write properly. He has learnt 1, 2 and 3 but thinks that 4 is another way to write 1. So when given any number with 1, 2, 3 4, he tries to sum up their digits as follows : 213 = 2 + 1 + 3 = 6 33 = 3 + 3 = 6 1341 = 1 + 3 + 1 + 1 = 6 (remember, the kid thinks that 4 = 1) Sandeep gets excited to discover that different numbers can all add up to the same sum. He now wants to know how many numbers there are whose sum is a number N. For N = 2, he can make 5 numbers: 11, 14, 41, 44, and 2. (He knows how to count up beyond five, just not how to write it) He needs your help for other such values of N. Input/Output You don't have to read or write anything from/to stdin and stdout respectively. Use the template code provided in the editor on the submission page, that does the IO for you. In the template, you have to write a function that takes N as argument and returns the count of numbers Sandeep can make such that the sum of their digits is equal to N. Since the count could be very large, return the result mod 17 Function Signature: int dumb_sum(int N); The template code executes the function submitted T times with different arguments.Constraint 0 T 1 1 ≤ N ≤ 1000. Example*Input:* 2 2 3 *Output:* 5 13 -- Author:xyler http://www.codechef.com/users/xylerDate Added:10-08-2012Time Limit:10 secSource Limit:5 BytesLanguages:C, CPP 4.3.2, JAVA -- 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/-/tD_1SLVj0QgJ. 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.