Re: [algogeeks] Max sum circular array
This is similar to maximum sum contiguous subarray problem. Consider the circular array as a normal array, except that once you reach the end of the array, if the sum found upto that element(using Kandane's algo, refer Wiki) is negative, then try including elements from the beginning of the array(circular fashion), until you find a sum that is greater. Keeping track of the sum is obvious necessity. Finally return the sum. On Tue, Jul 10, 2012 at 10:58 AM, deepikaanand swinyanand...@gmail.comwrote: What is best approach to find max sum in a circular array... -- You received this message because you are subscribed to the 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] [India specific] KBookSearch - A book comparison engine.
Hi Friends, I know this is a little bit 'off-topic', but I think it would serve the overall purpose to educate ourselves well. I will still apologize if this seems like spam to you. We'd like to present to you www.kbooksearch.com, a site that compares the prices of a book across the different online booksellers in India. We believe it is neat, elegant and quick and would serve you well in finding out which site is offering you the best price for the book and expected delivery times, there is also auto-suggest to help you remember the book in case you just had the name on the tip of your ton??? (something of that sorts). We compare the prices from 11 bookstores to give you the best deal and do so quickly! We would greatly appreciate if you use it, suggest feedback (both bouquets and brickbats) and spread the word around! As an illustration, the prices for the Complete Works of William Shakespearehttp://goo.gl/dKxUI vary quite a bit (almost by 400%) on different online booksellers. Keep tuned for our updates: Facebook - https://www.facebook.com/kbooksearch Twitter - https://twitter.com/kbooksearch G+ - https://plus.google.com/b/107572714465768003807/107572714465768003807 Regards KBookSearch Team -- Mehnaaz Mohiuddin -- You received this message because you are subscribed to the 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] Adobe interview question
@himanshu making constructor protected is okay because even for abstract base class u cannot create objects in derived class -- You received this message because you are subscribed to the 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] C o/p
yeahu r ryt On Tue, Jul 10, 2012 at 10:01 AM, Firoz Khursheed firozkhursh...@gmail.comwrote: Well, when i compiled the code the output ie i is alway i=2, http://ideone.com/AFljo http://ideone.com/87waz This expression is ambiguous, and compiler dependent. -- You received this message because you are subscribed to the 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] Adobe interview question
If the constructor is made protected u cannot make object of that class anywhere On Tue, Jul 10, 2012 at 3:10 PM, Bhaskar Kushwaha bhaskar.kushwaha2...@gmail.com wrote: @himanshu making constructor protected is okay because even for abstract base class u cannot create objects in derived class -- regards, Bhaskar Kushwaha Student Final year CSE M.N.N.I.T. Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Directi question
int no_of_steps[arr_length] = {MAX}; if ( (arr_length==0) || (arr[0] == 0) ) //if there are no elements or the very first element is 0 - we can't jump anywhere return MAX; no_of_steps[0] = 0; //no jumps required to jump from element 0 to itself. for (int i=1; iarr_length; i++) { no_of_steps [i] = MAX; for(int j=0; ji; j++) //from 0th element till the element we need to jump to. { if( arr[j] = (i - j) )//if it is possible for us to jump from jth element to ith element. { if( no_of_steps[i] no_of_steps[j] + 1)// if no. of steps to reach the ith element recorded till now is greater than the no of { // steps reqd to reach jth element + 1, then replace. no_of_steps[i] no_of_steps[j] + 1; } } } } coutno_of_steps[n-1]; On Mon, Jul 9, 2012 at 8:32 PM, Mr.B sravanreddy...@gmail.com wrote: There is a greedy solution discussion about this approach. I don't have a formal proof for this. Any counter example will be helpful. at every place 'k' .. do the following. -- find max ( a[k+i]+i ) where 1 = i = a[i] for the given example: A = {4 0 0 3 6 5 4 7 1 0 1 2} initially a 4, the loop will be. 0+1,0+2,3+3,6+4 -- 10 is max. jump to 6. now at 6. (since, you can't reach end.) 5+1, 4+2, 7+3, 1+4, 0+5, 1 + 6, == 10 is max. jump to 7. make another step. (but you can reach the end.) so jump to last. this is greedy approach.. and a linear time soultion. On Monday, 9 July 2012 09:32:08 UTC-4, Akshat wrote: Given an array A and the elements stored in an array denotes how much jump an element can make from that array position. For example there is an array A = {4 0 0 3 6 5 4 7 1 0 1 2} Now Ist element which is 4 can make a jump to element 0, 0, 3 and 6. You are stuck if you end up at 0. You have to output the minimum number of jumps that can be made from starting position to end position of an array. -- Akshat Sapra Under Graduation(B.Tech) IIIT-Allahabad(Amethi Campus) *--* sapraaks...@gmail.com akshatsapr...@gmail.com rit20009008@ rit20009...@gmail.comiiita.ac.in -- 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/-/QRWxd8B2DzcJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Directi question
This can be solved using Dynamic Programming approach. Let MinJump(n) = Minimum number of Jumps required to reach the Nth index of array A. then, for 1 i N, MinJump(i) = Min{1 + MinJump(j)} for all j such that (0= j i) and (j + A[j] = i). We can prepare an auxiliary array say MinJump[1..N] where for MinJump[i] contains the minimum jump required to reach ith index of array A and use MinJump[1...i] and A[1i] to calculate the value of A[i+1] and so on.. HTH, Sumit On Mon, Jul 9, 2012 at 7:02 PM, Akshat Sapra sapraaks...@gmail.com wrote: Given an array A and the elements stored in an array denotes how much jump an element can make from that array position. For example there is an array A = {4 0 0 3 6 5 4 7 1 0 1 2} Now Ist element which is 4 can make a jump to element 0, 0, 3 and 6. You are stuck if you end up at 0. You have to output the minimum number of jumps that can be made from starting position to end position of an array. -- Akshat Sapra Under Graduation(B.Tech) IIIT-Allahabad(Amethi Campus) *--* sapraaks...@gmail.com akshatsapr...@gmail.com rit20009008@ rit20009...@gmail.comiiita.ac.in -- You received this message because you are subscribed to the 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: candies - interviewstreet -- how to go about solving this problem
@g4... : Is the sequence in which children are arranged is fixed or the teacher can change the sequence to minimize the candies ? On Mon, Jul 9, 2012 at 3:58 PM, Anshu Mishra anshumishra6...@gmail.comwrote: @sanjay it's not like that e.g : (3 5 6 7 8 4) 7 1 2 3 4 5 1 2 Yes we have to increase just by one, but while decreasing choose the lowest possible such that each trivial component, if it is in decreasing phase, should end with 1. On Mon, Jul 9, 2012 at 12:53 PM, sanjay pandey sanjaypandey...@gmail.comwrote: does ur sol seems lyk incerasing 1 if next number is greater that prev n decreasing 1 if less..??? -- You received this message because you are subscribed to the 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. -- Anshuman Mishra | Software Development Engineer | Amazon -- You received this message because you are subscribed to the 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: Given only a pointer to a node to be deleted in a singly linked list how you handle deleting last node
For such case .. circular linked list will come handy to be able to delete last node. On Tue, Jul 10, 2012 at 8:28 AM, deepikaanand swinyanand...@gmail.comwrote: No there is no way to delete the last node in such a situation though u can replace the info part of such a last node with '#'though it wont delete the node but now u know that u can traverse the list while node-info != '#' -- You received this message because you are subscribed to the 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. -- best wishes!! Vaibhav -- You received this message because you are subscribed to the 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: Directi question
^ cout no_of_steps[arr_length -1]; On Mon, Jul 9, 2012 at 8:44 PM, algo bard algo.b...@gmail.com wrote: int no_of_steps[arr_length] = {MAX}; if ( (arr_length==0) || (arr[0] == 0) ) //if there are no elements or the very first element is 0 - we can't jump anywhere return MAX; no_of_steps[0] = 0; //no jumps required to jump from element 0 to itself. for (int i=1; iarr_length; i++) { no_of_steps [i] = MAX; for(int j=0; ji; j++) //from 0th element till the element we need to jump to. { if( arr[j] = (i - j) )//if it is possible for us to jump from jth element to ith element. { if( no_of_steps[i] no_of_steps[j] + 1)// if no. of steps to reach the ith element recorded till now is greater than the no of { // steps reqd to reach jth element + 1, then replace. no_of_steps[i] no_of_steps[j] + 1; } } } } coutno_of_steps[n-1]; On Mon, Jul 9, 2012 at 8:32 PM, Mr.B sravanreddy...@gmail.com wrote: There is a greedy solution discussion about this approach. I don't have a formal proof for this. Any counter example will be helpful. at every place 'k' .. do the following. -- find max ( a[k+i]+i ) where 1 = i = a[i] for the given example: A = {4 0 0 3 6 5 4 7 1 0 1 2} initially a 4, the loop will be. 0+1,0+2,3+3,6+4 -- 10 is max. jump to 6. now at 6. (since, you can't reach end.) 5+1, 4+2, 7+3, 1+4, 0+5, 1 + 6, == 10 is max. jump to 7. make another step. (but you can reach the end.) so jump to last. this is greedy approach.. and a linear time soultion. On Monday, 9 July 2012 09:32:08 UTC-4, Akshat wrote: Given an array A and the elements stored in an array denotes how much jump an element can make from that array position. For example there is an array A = {4 0 0 3 6 5 4 7 1 0 1 2} Now Ist element which is 4 can make a jump to element 0, 0, 3 and 6. You are stuck if you end up at 0. You have to output the minimum number of jumps that can be made from starting position to end position of an array. -- Akshat Sapra Under Graduation(B.Tech) IIIT-Allahabad(Amethi Campus) *--* sapraaks...@gmail.com akshatsapr...@gmail.com rit20009008@ rit20009...@gmail.comiiita.ac.in -- 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/-/QRWxd8B2DzcJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] seperate diff types of coins
Minimum no. weighings: Divide 8 coins in group of 3, 3 and 2. For minimum weighsing group1 's total weight is x units(say) --FIrst weighing Groups 2nd total weights is y units Second weighing. Lastly one more weighing among a unit and b unit coins.---3 rd weighing So minimum 3 weighing is required. On Tue, Jul 10, 2012 at 11:03 AM, payal gupta gpt.pa...@gmail.com wrote: You have 8 coins. 3 of them weigh x units, 3 y units, 1 a units and 1 b units. They are all mixed and look identical. What are the minimum no of weighings reqd to seperate the for types of coins??? -- 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/-/HhIaN4zgpxMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Algorithm page
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.
[algogeeks] Re: Secure computation of Intersection of two sets
But again.. this can be reconstructed at the sever. taking first number and adding the differences. On Monday, 9 July 2012 23:54:23 UTC-4, enchantress wrote: Give the first first number and set of cosecutive diffrence. On Sunday, 8 July 2012 10:55:55 UTC+5:30, Sairam wrote: How do you find the intersection of two sets in a secured way? Which means imagine a situation where there is a client who has got a set S1={1,2,3}, and there is a server who has got a set S2[{2,3}. Client wants to find the count of intersection which is |S1 intersection S2| = 2. But, it doesn't want to give the set S1 directly to the server? How should the client give the set S1, such that server computes the intersection of S1 and S2 and gives the count to client. -- 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/-/dklhSxUDXg0J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] seperate diff types of coins
@navin...Sorry didnt get you how come u were able to segregate all the coins by the proposed method?? On 7/10/12, Navin Kumar algorithm.i...@gmail.com wrote: Minimum no. weighings: Divide 8 coins in group of 3, 3 and 2. For minimum weighsing group1 's total weight is x units(say) --FIrst weighing Groups 2nd total weights is y units Second weighing. Lastly one more weighing among a unit and b unit coins.---3 rd weighing So minimum 3 weighing is required. On Tue, Jul 10, 2012 at 11:03 AM, payal gupta gpt.pa...@gmail.com wrote: You have 8 coins. 3 of them weigh x units, 3 y units, 1 a units and 1 b units. They are all mixed and look identical. What are the minimum no of weighings reqd to seperate the for types of coins??? -- 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/-/HhIaN4zgpxMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] seperate diff types of coins
Let we have 8 coins named (for simplicity) x1, x2, x3, y1, y2, y3, a, b According to your question 3 of them weigh x units : x1+x2+x3 =x 3 of them weigh y units: y1+y2+y3 =y now consider the case when i grouped (x1, x2 x3) in single group (y1,y2 ,y3) in one group and (a,b) in one group. Now we will measure weight of 1st group (x1, x2, x3) :It will give x then we conclude that all elements in this group are those element whose total weight is x :Type 1 element. similarly for y. and for the last group we will pick up any element and measure its weight ..its weight will be either a or b. Depending upon outcome we will categorize them a and b. So 3 weighing is required. On Tue, Jul 10, 2012 at 7:05 PM, payal gupta gpt.pa...@gmail.com wrote: @navin...Sorry didnt get you how come u were able to segregate all the coins by the proposed method?? On 7/10/12, Navin Kumar algorithm.i...@gmail.com wrote: Minimum no. weighings: Divide 8 coins in group of 3, 3 and 2. For minimum weighsing group1 's total weight is x units(say) --FIrst weighing Groups 2nd total weights is y units Second weighing. Lastly one more weighing among a unit and b unit coins.---3 rd weighing So minimum 3 weighing is required. On Tue, Jul 10, 2012 at 11:03 AM, payal gupta gpt.pa...@gmail.com wrote: You have 8 coins. 3 of them weigh x units, 3 y units, 1 a units and 1 b units. They are all mixed and look identical. What are the minimum no of weighings reqd to seperate the for types of coins??? -- 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/-/HhIaN4zgpxMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] balanced tree
for complete tree tree at last level can have left child and no right child , thus condition shd be somewhat like this... if(node[right]==NULLnode[left]==NULL) return true; if(node[right]!=NULL) // if the node Rchild!=NULL then there shd be Lchild present. if(node[left]==NULL) return FALSE; On Wednesday, 4 July 2012 18:24:54 UTC+5:30, amrit harry wrote: bool checkTree(Tree node) { if(node[right]==NULLnode[left]==NULL) return true; if(node[right]==NULLnode[left]!=NULL||node[left]==NULLnode[right]!=NULL) return false; else return checkTree(node[right])checkTree(node[left]); } i think this algo can solve problem just traverse the node and keep eye on that either a node have 2 childs or no child On Wed, Jul 4, 2012 at 3:08 PM, Ashish Goel ashg...@gmail.com wrote: i think checking full is easy, find height(0to h) and then check if level h has 2^(h+1) nodes how to check if it is complete..level order traversal? ensure that every node has two children or left for the last one just before first leaf( till you find the first leaf). Now on, every node should be a leaf. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Wed, Jul 4, 2012 at 2:36 PM, Ashish Goel ashg...@gmail.com wrote: ok, lets modify the problem to find if the tree is complete binary tree The tree is a complete binary tree; that is, all levels of the tree, except possibly the last one (deepest) are fully filled, and, if the last level of the tree is not complete, the nodes of that level are filled from left to right Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Wed, Jul 4, 2012 at 11:09 AM, atul anand atul.87fri...@gmail.comwrote: http://www.geeksforgeeks.org/archives/5230 modify this to meet the requirnment. On 7/4/12, Ashish Goel ashg...@gmail.com wrote: WAP to find if a tree is balanced/fully balanced? 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 post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Thanks Regards Amritpal singh -- 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/-/XJ_ZvcBZv-8J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: seperate diff types of coins
@Gupta: You haven't defined the problem sufficiently. What type of scale do we have, a balance scale or one that gives a numeric reading? Do we know x, y, a, and b, or are you just saying that one set of three coins weigh the same, another set of three also weigh the same but have different weight that the first set, and the remaining two weigh different amounts than each other and the two sets? Is there any known relationship between x, y, a, and b? We can assume without loss of generality that x y and a b, but what about the relationships between x and a, x and b, y and a, and y and b? Knowing more will allow a solution with fewer weighings than knowing less. Dave On Tuesday, July 10, 2012 12:33:47 AM UTC-5, payal gupta wrote: You have 8 coins. 3 of them weigh x units, 3 y units, 1 a units and 1 b units. They are all mixed and look identical. What are the minimum no of weighings reqd to seperate the for types of coins??? -- 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/-/c41Sw3CqNz4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: candies - interviewstreet -- how to go about solving this problem
@sumit the sequence is fixed -- You received this message because you are subscribed to the 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] Google : Print in interleaved fashion
Given two strings .Print all the interleavings of the two strings. Interleaving means that the if B comes after A .It should also come after A in the interleaved string. ex- AB and CD ABCD ACBD ACDB CABD CADB CDAB -- 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/-/oAU32CrEVYYJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 : Print in interleaved fashion
http://www.geeksforgeeks.org/archives/17743 On Tue, Jul 10, 2012 at 11:16 PM, Navin Kumar algorithm.i...@gmail.comwrote: Given two strings .Print all the interleavings of the two strings. Interleaving means that the if B comes after A .It should also come after A in the interleaved string. ex- AB and CD ABCD ACBD ACDB CABD CADB CDAB -- 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/-/oAU32CrEVYYJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] how to print tata from tatapower using only strcat and strcpy???
-- 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/-/zLgbYxJdPYwJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] C o/p
he is right. On Tue, Jul 10, 2012 at 3:13 PM, rahul sharma rahul23111...@gmail.comwrote: yeahu r ryt On Tue, Jul 10, 2012 at 10:01 AM, Firoz Khursheed firozkhursh...@gmail.com wrote: Well, when i compiled the code the output ie i is alway i=2, http://ideone.com/AFljo http://ideone.com/87waz This expression is ambiguous, and compiler dependent. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: candies - interviewstreet -- how to go about solving this problem
can u explain ur algorithm for the sequence * 5 4 3 2 1* -- You received this message because you are subscribed to the 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] C o/p
++i/i++= 6/6 ++i * i++ = 36.00 http://ideone.com/j4n0Q On Tue, Jul 10, 2012 at 3:13 PM, rahul sharma rahul23111...@gmail.comwrote: yeahu r ryt On Tue, Jul 10, 2012 at 10:01 AM, Firoz Khursheed firozkhursh...@gmail.com wrote: Well, when i compiled the code the output ie i is alway i=2, http://ideone.com/AFljo http://ideone.com/87waz This expression is ambiguous, and compiler dependent. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: candies - interviewstreet -- how to go about solving this problem
for your example 5 4 3 2 1 5 4 3 2 1 -- candies assignement. (since the length of the longest decreasing sequence is 4, and length of increasing seq. before it is 0. its max(0+1,4)+1 = 5 --Sravan Reddy On Tue, Jul 10, 2012 at 8:09 AM, bala bharath bagop...@gmail.com wrote: can u explain ur algorithm for the sequence * 5 4 3 2 1* -- You received this message because you are subscribed to the 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] Directi Interview Ques
Here you have to first sort both the arrays A and B and merge both the arrays to form the sorted array C -- Akshat Sapra Under Graduation(B.Tech) IIIT-Allahabad(Amethi Campus) *--* sapraaks...@gmail.com akshatsapr...@gmail.com rit20009008@ rit20009...@gmail.comiiita.ac.in -- You received this message because you are subscribed to the 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] Directi Interview Ques
I think you missed the question: Its a stable merge. (order of elements in each array should be same) Sorting will destroy the original order. Thanks, Mr.B [Please include complexities and pseudo-code] On Tuesday, 10 July 2012 16:18:04 UTC-4, Akshat wrote: Here you have to first sort both the arrays A and B and merge both the arrays to form the sorted array C -- Akshat Sapra Under Graduation(B.Tech) IIIT-Allahabad(Amethi Campus) *--* sapraaks...@gmail.com akshatsapr...@gmail.com rit20009008@ rit20009...@gmail.comiiita.ac.in -- 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/-/uCRLEzDBWAAJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: [Google] Finds all the elements that appear more than n/3 times
I found a similar solution looking somewhere else. The solution for this problem is: a. There can be atmost 3 elements (only 3 distinct elements with each repeating n/3 times) -- check for this and done. -- O(n) time. b. There can be atmost 2 elements if not above case. 1. Find the median of the input. O(N) 2. Check if median element is repeated N/3 times or more -- O(n) - *{mark for output if yes}* 3. partition the array based on median found above. - O(n) -- {partition is single step in quicksort} 4. find median in left partition from (3). - O(n) 5. check if median element is repeared n/3 times or more - O(n) *{mark for output if yes}* 6. find median in right partition from (3). - O(n) 7. check if median element is repeared n/3 times or more - O(n) *{mark for output if yes}* its 7*O(N) = O(N) solution. Constant space. we need not check further down or recursively. {why? reason it.. its simple} On Wednesday, 27 June 2012 18:35:12 UTC-4, Navin Kumar wrote: Design an algorithm that, given a list of n elements in an array, finds all the elements that appear more than n/3 times in the list. The algorithm should run in linear time ( n =0 ). You are expected to use comparisons and achieve linear time. No hashing/excessive space/ and don't use standard linear time deterministic selection algo. -- 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/-/OYZtR1iwbGQJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: seperate diff types of coins
@ Dave sir the balance considered here is simple balance scale incapable of giving any numeric reading and the we are unaware of any relationship between x,y,a,b or any kind denominations prioirity in terms of weights... @navin.. 3 of them weigh x means 3 of the coins individually weigh x gms,it isnt the cumulative sum of the coins as u considered ,thats what i got from the question.. Correct me if i'm wrong. Could it be done it done in lesser than 8 weighings?? Regards, PAYAL GUPTA. On 7/10/12, Dave dave_and_da...@juno.com wrote: @Gupta: You haven't defined the problem sufficiently. What type of scale do we have, a balance scale or one that gives a numeric reading? Do we know x, y, a, and b, or are you just saying that one set of three coins weigh the same, another set of three also weigh the same but have different weight that the first set, and the remaining two weigh different amounts than each other and the two sets? Is there any known relationship between x, y, a, and b? We can assume without loss of generality that x y and a b, but what about the relationships between x and a, x and b, y and a, and y and b? Knowing more will allow a solution with fewer weighings than knowing less. Dave On Tuesday, July 10, 2012 12:33:47 AM UTC-5, payal gupta wrote: You have 8 coins. 3 of them weigh x units, 3 y units, 1 a units and 1 b units. They are all mixed and look identical. What are the minimum no of weighings reqd to seperate the for types of coins??? -- 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/-/c41Sw3CqNz4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Directi Interview Ques
http://www.geeksforgeeks.org/archives/17743 Using the above problem we get all possible merges , at each possible merge, we can calculate the sum. On 7/11/12, Mr.B sravanreddy...@gmail.com wrote: I think you missed the question: Its a stable merge. (order of elements in each array should be same) Sorting will destroy the original order. Thanks, Mr.B [Please include complexities and pseudo-code] On Tuesday, 10 July 2012 16:18:04 UTC-4, Akshat wrote: Here you have to first sort both the arrays A and B and merge both the arrays to form the sorted array C -- Akshat Sapra Under Graduation(B.Tech) IIIT-Allahabad(Amethi Campus) *--* sapraaks...@gmail.com akshatsapr...@gmail.com rit20009008@ rit20009...@gmail.comiiita.ac.in -- 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/-/uCRLEzDBWAAJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: seperate diff types of coins
@payal: In this case too i think minimum number of weighing required is 3. Slightly change in my previous solution. x1+x2+x3 = 3x and y1+y2+y3 = 3y. On Wed, Jul 11, 2012 at 8:00 AM, payal gupta gpt.pa...@gmail.com wrote: @ Dave sir the balance considered here is simple balance scale incapable of giving any numeric reading and the we are unaware of any relationship between x,y,a,b or any kind denominations prioirity in terms of weights... @navin.. 3 of them weigh x means 3 of the coins individually weigh x gms,it isnt the cumulative sum of the coins as u considered ,thats what i got from the question.. Correct me if i'm wrong. Could it be done it done in lesser than 8 weighings?? Regards, PAYAL GUPTA. On 7/10/12, Dave dave_and_da...@juno.com wrote: @Gupta: You haven't defined the problem sufficiently. What type of scale do we have, a balance scale or one that gives a numeric reading? Do we know x, y, a, and b, or are you just saying that one set of three coins weigh the same, another set of three also weigh the same but have different weight that the first set, and the remaining two weigh different amounts than each other and the two sets? Is there any known relationship between x, y, a, and b? We can assume without loss of generality that x y and a b, but what about the relationships between x and a, x and b, y and a, and y and b? Knowing more will allow a solution with fewer weighings than knowing less. Dave On Tuesday, July 10, 2012 12:33:47 AM UTC-5, payal gupta wrote: You have 8 coins. 3 of them weigh x units, 3 y units, 1 a units and 1 b units. They are all mixed and look identical. What are the minimum no of weighings reqd to seperate the for types of coins??? -- 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/-/c41Sw3CqNz4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Directi Interview Ques
pls discuss about prilims, online coding round too !! regards, Karthikeyan.M On 7/11/12, arumuga abinesh arumugaabin...@gmail.com wrote: http://www.geeksforgeeks.org/archives/17743 Using the above problem we get all possible merges , at each possible merge, we can calculate the sum. On 7/11/12, Mr.B sravanreddy...@gmail.com wrote: I think you missed the question: Its a stable merge. (order of elements in each array should be same) Sorting will destroy the original order. Thanks, Mr.B [Please include complexities and pseudo-code] On Tuesday, 10 July 2012 16:18:04 UTC-4, Akshat wrote: Here you have to first sort both the arrays A and B and merge both the arrays to form the sorted array C -- Akshat Sapra Under Graduation(B.Tech) IIIT-Allahabad(Amethi Campus) *--* sapraaks...@gmail.com akshatsapr...@gmail.com rit20009008@ rit20009...@gmail.comiiita.ac.in -- 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/-/uCRLEzDBWAAJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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.