Re: [algogeeks] problem
Well this was asked by codechef on it's intern contest...!! Make a recursive algorithm using divide and conquer paradigm On Thu, Mar 10, 2011 at 11:20 AM, Akash Mukherjee akash...@gmail.comwrote: hi, can anybody plzz look at this problem. i tried a recursive greedy approach but it was too slow i guess You have a truck that you need to completely fill up with merchandise. You have an infinite supply of merchandise of dimension 1x1x1, 2x2x2, 4x4x4, 8x8x8, 16x16x16, ..., 2k x 2k x 2k for all k ≥ 0. (Infinite supply of merchandise of each dimension too!) You wish to fill the truck of dimension AxBxC completely using only these merchandise. Given A, B C, what is the smallest number of merchandise you will need to fill the truck completely? The first line of the input will contain a number T (1 ≤ T ≤ 1000) containing the number of test cases. Each line that follows is a separate test case which has exactly 3 space separated integers A B C (1 ≤ A, B, C 106) which denotes the dimensions of the truck. Additionally, min(A,B,C) 1000. For each case, output a single line containing the minimum number of items needed to fill the entire truck. *Sample Input:* 5 1 1 1 1 2 3 3 4 5 4 5 6 123 12345 123456 *Sample Output:* 1 6 32 29 1951997538 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] problem
dc nt givin tle?? On Mon, Mar 28, 2011 at 11:42 AM, sukhmeet singh sukhmeet2...@gmail.comwrote: Well this was asked by codechef on it's intern contest...!! Make a recursive algorithm using divide and conquer paradigm On Thu, Mar 10, 2011 at 11:20 AM, Akash Mukherjee akash...@gmail.comwrote: hi, can anybody plzz look at this problem. i tried a recursive greedy approach but it was too slow i guess You have a truck that you need to completely fill up with merchandise. You have an infinite supply of merchandise of dimension 1x1x1, 2x2x2, 4x4x4, 8x8x8, 16x16x16, ..., 2k x 2k x 2k for all k ≥ 0. (Infinite supply of merchandise of each dimension too!) You wish to fill the truck of dimension AxBxC completely using only these merchandise. Given A, B C, what is the smallest number of merchandise you will need to fill the truck completely? The first line of the input will contain a number T (1 ≤ T ≤ 1000) containing the number of test cases. Each line that follows is a separate test case which has exactly 3 space separated integers A B C (1 ≤ A, B, C 106) which denotes the dimensions of the truck. Additionally, min(A,B,C) 1000. For each case, output a single line containing the minimum number of items needed to fill the entire truck. *Sample Input:* 5 1 1 1 1 2 3 3 4 5 4 5 6 123 12345 123456 *Sample Output:* 1 6 32 29 1951997538 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Ties The Rope With Minimum Cost ..Interesting For Geeks
you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] what to learn python or perl
perl++ Parrot is trying to rock in the programming world.i.e perl6... Again it depends on the application and the requirement to choose either perl or phython.. ~ Saran On Wed, Mar 16, 2011 at 11:54 AM, VENKATARAMAN.GB venki.g...@gmail.comwrote: Perl does magic! :) Cheers, venki http://twitter.com/#!/venki_gbvr VENKATARAMAN GB http://www.facebook.com/venki.gbvr If Its Upto Be, It Is Upto Me On Wed, Mar 16, 2011 at 10:18 AM, pacific pacific pacific4...@gmail.comwrote: I vote for python. On Wed, Mar 16, 2011 at 10:03 AM, kracekumar ramaraju kracethekingma...@gmail.com wrote: Hello Python vs Perl been battle for more than 20 years.Perl is been around 23+ years(not sure,people say 25 years pls check) and python for 21 years. Python would be my choice 1.Python achieves code readability. 2.Python can do what perl can do. more on this fight you can find here http://infohost.nmt.edu/~tcc/help/lang/python/vsperl.html http://www.linuxjournal.com/article/3882 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- regards, chinna. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] [brain teaser ] 28march
Evertime you conduct a race, you eliminate 2 horses. So, 11. On Mar 28, 2011 1:24 PM, Lavesh Rawat lavesh.ra...@gmail.com wrote: *Horse Race Problem Solution* * *Ok, so there are 25 horses and the race track only allows 5 horses to race at a given time. Given that there is no stop watch available your task is to determine the fastest 3 horses. Assume that each horses speed is constant in different races, what is the minimum number of races to determine the fastest 3? Update Your Answers at : Click Here http://dailybrainteaser.blogspot.com/2011/03/28march.html?lavesh=lavesh Solution: Will be updated after 1 day -- Never explain yourself. Your friends don’t need it and your enemies won’t believe it . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Median of Binary Tree
@all try to understand the question as usual we have to do it in min. time space complexity ..in mean Time O(n) space o(1) At-most just tell em after doing in-order traversal where u will store the elements either in array or in set isn'tit it will take O(n) extra space why not looks fro O(1) SPACE..IF M NOT CORRECT otherwise problem just become finding median in array which O(1) ..correct me if m wrong @Anurag wher u will store inorder of tree Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Check out One More Interesting Challenging Question...Longest Consecutive Elements Sequence.
Given an unsorted array, find the longest consecutive elements sequence. Challenge ...Time Complexity O(n) Space o(1) Ex: 5 7 3 4 9 10 1 15 12 Ans: will be 3 4 5 (longest with 3 elements) another Example 5,12,3,13,10,9,4,6,23,8,7. The answer should be 3,4,5,6,7,8,9,10. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Median of Binary Tree
median is defined for a sorted list of numbers.. i cannot understand how you can traverse in O(n) in a normal binary tree. @raunak plz explain the solution On Mon, Mar 28, 2011 at 4:16 PM, bittu shashank7andr...@gmail.com wrote: @all try to understand the question as usual we have to do it in min. time space complexity ..in mean Time O(n) space o(1) At-most just tell em after doing in-order traversal where u will store the elements either in array or in set isn'tit it will take O(n) extra space why not looks fro O(1) SPACE..IF M NOT CORRECT otherwise problem just become finding median in array which O(1) ..correct me if m wrong @Anurag wher u will store inorder of tree Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- thezeitgeistmovement.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.
Re: [algogeeks] Ties The Rope With Minimum Cost ..Interesting For Geeks
if you tie all of them and the cost is sum of invidual lengths then in the end the cost will be sum of all lengths irrespective of any order that we tie them in.. i think the ques would req you to say that the cost is the longer of the two..plz check On Mon, Mar 28, 2011 at 12:11 PM, bittu shashank7andr...@gmail.com wrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- thezeitgeistmovement.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.
Re: [algogeeks] [brain teaser ] 28march
7 races... Regards, Akash Agrawal http://tech-queries.blogspot.com/ On Mon, Mar 28, 2011 at 3:50 PM, anand karthik anandkarthik@gmail.comwrote: Evertime you conduct a race, you eliminate 2 horses. So, 11. On Mar 28, 2011 1:24 PM, Lavesh Rawat lavesh.ra...@gmail.com wrote: *Horse Race Problem Solution* * *Ok, so there are 25 horses and the race track only allows 5 horses to race at a given time. Given that there is no stop watch available your task is to determine the fastest 3 horses. Assume that each horses speed is constant in different races, what is the minimum number of races to determine the fastest 3? Update Your Answers at : Click Here http://dailybrainteaser.blogspot.com/2011/03/28march.html?lavesh=lavesh Solution: Will be updated after 1 day -- Never explain yourself. Your friends don’t need it and your enemies won’t believe it . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: 25march
Worst Case scenario you will get in 3 steps 9 balls Compare 1st:123| 456| 789 if (first second) //The ball is in 1st Second compare : else (second third) take the heavy one now you have 3 balls Third compare : lets send is heaver then you have 3 balls (4, 5 , 6) Compare 4 to 5 if both equals then heaver is 6th one or out of 4 5 one is heaver *Subhransu Panigrahi * *Mobile:* *+91-9840931538* *Email:* subhransu.panigr...@gmail.com On Mar 25, 2:46 am, Lavesh Rawat lavesh.ra...@gmail.com wrote: *Weighing Problem Solution* * *There are 9 similar balls. Eight of them weigh the same and the ninth is a bit heavier. How would you identify the heavier ball if you could use a two-pan balance scale only twice? Update Your Answers at : Click Here http://dailybrainteaser.blogspot.com/2011/03/25march.html?lavesh=lavesh Solution: Will be updated after 1 day Soln -- Posted By lavesh to brain teaser solutions http://solution-dailybrainteaser.blogspot.com/2011/03/25march.htmlat 3/25/2011 12:01:00 AM -- Never explain yourself. Your friends don’t need it and your enemies won’t believe it . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Announcing ITRIX OPC 2011
@rk: thnx... @raunak: https://www.spoj.pl/ITRIX11/problems/main -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Check out One More Interesting Challenging Question...Longest Consecutive Elements Sequence.
its (not aplicable). sorting nlogn i said time O(n) O(1) space i think we can use BST , put all elements in BST O(n) then do inorder to find longest sub sequence still O(n) ..no no no its Ol(ogn) suggest another way to solve it Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Announcing ITRIX OPC 2011
I am able to view the solutions but not able to get the logic behind it... Can you explain it...Or any1 who has solvd it can xplain !! A link, if any, to an article explaining logic behind it would be awesome... Also idea of writing an editorial explaining logic to solve problems in this contest wont be bad !! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Check out One More Interesting Challenging Question...Longest Consecutive Elements Sequence.
@Bittu: Can you elaborate more how Constructing BST (I hope it stands for Binary Search Tree) would be o(n)... I think It would also be O(nlog(n))... My xplanation: Single element can be inserted in BST in O(log n) So inserting n elements would be n * O(log n) -- O(n log n) So as per me your solution is also not correct... correct me if I'm wrong somewhere !!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] interview
i appreciate your concern, but i guess this group is for people who discuss algorithms and their perplexity, i believe that one should do their homework before asking questions, there are lot of great coders in this group who have stopped answering questions just because there are so many mails, asking just to check their code or asking for everything which could be found wikipedia at the least. try problem, if not able to solve - discuss logic if not able to code - only then discuss code On Mon, Mar 28, 2011 at 1:16 AM, Abhishek Sharma jkabhishe...@gmail.comwrote: *@Shady:* buddy lets not discourage som1 interested in learning :) this is the purpose of this group.. * @harry:* as some1 has said: there is no shortcut to success.. first go through any good Datastructures/algorithms book.. try to code those algorithms on ur own..once u feel u r comfortable with the basics u can go through the previous posts of this group and implement the algos for more practice.. On Mon, Mar 28, 2011 at 12:22 AM, shady sinv...@gmail.com wrote: what kind of question is this ? the quality of this group is degrading day by day :( On Sun, Mar 27, 2011 at 10:44 PM, hary rathor harry.rat...@gmail.comwrote: hello friends pls suggest me that which algorithm problem i should implement that are ask in most in interviews -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Ties The Rope With Minimum Cost ..Interesting For Geeks
The question seems to be correct. Think again On Mon, Mar 28, 2011 at 5:24 PM, kunal srivastav kunal.shrivas...@gmail.com wrote: if you tie all of them and the cost is sum of invidual lengths then in the end the cost will be sum of all lengths irrespective of any order that we tie them in.. i think the ques would req you to say that the cost is the longer of the two..plz check On Mon, Mar 28, 2011 at 12:11 PM, bittu shashank7andr...@gmail.comwrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- thezeitgeistmovement.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. -- Regards Gunjan Sharma Chairman IEEE Students Chapter IIT Roorkee B.Tech IV year CSE Contact No- +91 9997767077 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Ties The Rope With Minimum Cost ..Interesting For Geeks
I think the possible solution is : *Tie the highest two ropes at the end of the rope.* * * This is because of the following reason: Eg: Rope 1: Size 10 mtr Rope 2: Size 13 mtr Rope 3: Size 5 mtr Rope1-- Rope2-- Rope3 Cost: (10+13) + (13+5) = 41 Rope1--Rope3-- Rope2 Cost: (10+5) + (5+13) = 33 So the optimum cost is : *1st Highest length Rope + 2*(Length of all other ropes other that two having the highest size) + 2nd Highest Rope*. On Mon, Mar 28, 2011 at 7:49 PM, Gunjan Sharma gunjan.khan...@gmail.comwrote: The question seems to be correct. Think again On Mon, Mar 28, 2011 at 5:24 PM, kunal srivastav kunal.shrivas...@gmail.com wrote: if you tie all of them and the cost is sum of invidual lengths then in the end the cost will be sum of all lengths irrespective of any order that we tie them in.. i think the ques would req you to say that the cost is the longer of the two..plz check On Mon, Mar 28, 2011 at 12:11 PM, bittu shashank7andr...@gmail.comwrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- thezeitgeistmovement.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. -- Regards Gunjan Sharma Chairman IEEE Students Chapter IIT Roorkee B.Tech IV year CSE Contact No- +91 9997767077 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Median of Binary Tree
I am assuming that the median is the sum of all the values stored in the nodes divided by 2. So I am traversing all the nodes recursivelyand finding the median of them. On Mon, Mar 28, 2011 at 5:12 PM, kunal srivastav kunal.shrivas...@gmail.com wrote: median is defined for a sorted list of numbers.. i cannot understand how you can traverse in O(n) in a normal binary tree. @raunak plz explain the solution On Mon, Mar 28, 2011 at 4:16 PM, bittu shashank7andr...@gmail.com wrote: @all try to understand the question as usual we have to do it in min. time space complexity ..in mean Time O(n) space o(1) At-most just tell em after doing in-order traversal where u will store the elements either in array or in set isn'tit it will take O(n) extra space why not looks fro O(1) SPACE..IF M NOT CORRECT otherwise problem just become finding median in array which O(1) ..correct me if m wrong @Anurag wher u will store inorder of tree Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- thezeitgeistmovement.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.
Re: [algogeeks] Output of the code
Here is the correct program : #includeiostream using namespace std; int main() { while(true) { coutIndia will win the World Cup 2010endl; } return 0; } On Mon, Mar 28, 2011 at 8:42 PM, Praveen Kumar praveen97...@gmail.comwrote: true is a keyword representing 1 and false as 0. The program will print the line a single time. On Mon, Mar 28, 2011 at 11:13 AM, balaji a peshwa.bal...@gmail.comwrote: the code will give error as there is nothing called true defined. On Sun, Mar 27, 2011 at 10:38 PM, Umer Farooq the.um...@gmail.comwrote: Hi, Can anyone tell me the output of the following code? #include iostream.h int main() { .. if (true) .. cout Pakistan will win the WorldCup 2011\n; return 0; } -- Umer -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- A.Balaji -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Median of Binary Tree
This is mean not the median On Mon, Mar 28, 2011 at 8:42 PM, Raunak Agrawal raunak.ra...@gmail.comwrote: I am assuming that the median is the sum of all the values stored in the nodes divided by 2. So I am traversing all the nodes recursivelyand finding the median of them. On Mon, Mar 28, 2011 at 5:12 PM, kunal srivastav kunal.shrivas...@gmail.com wrote: median is defined for a sorted list of numbers.. i cannot understand how you can traverse in O(n) in a normal binary tree. @raunak plz explain the solution On Mon, Mar 28, 2011 at 4:16 PM, bittu shashank7andr...@gmail.comwrote: @all try to understand the question as usual we have to do it in min. time space complexity ..in mean Time O(n) space o(1) At-most just tell em after doing in-order traversal where u will store the elements either in array or in set isn'tit it will take O(n) extra space why not looks fro O(1) SPACE..IF M NOT CORRECT otherwise problem just become finding median in array which O(1) ..correct me if m wrong @Anurag wher u will store inorder of tree Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- thezeitgeistmovement.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] Output of the code
python 2.6 print 'India will win the World Cup 2010' On Mon, Mar 28, 2011 at 8:45 PM, Praveen Kumar praveen97...@gmail.comwrote: Here is the correct program : #includeiostream using namespace std; int main() { while(true) { coutIndia will win the World Cup 2010endl; } return 0; } On Mon, Mar 28, 2011 at 8:42 PM, Praveen Kumar praveen97...@gmail.comwrote: true is a keyword representing 1 and false as 0. The program will print the line a single time. On Mon, Mar 28, 2011 at 11:13 AM, balaji a peshwa.bal...@gmail.comwrote: the code will give error as there is nothing called true defined. On Sun, Mar 27, 2011 at 10:38 PM, Umer Farooq the.um...@gmail.comwrote: Hi, Can anyone tell me the output of the following code? #include iostream.h int main() { .. if (true) .. cout Pakistan will win the WorldCup 2011\n; return 0; } -- Umer -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- A.Balaji -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] [brain teaser ] 28march
7 races On Mon, Mar 28, 2011 at 5:39 PM, Akash Agrawal akash.agrawa...@gmail.comwrote: 7 races... Regards, Akash Agrawal http://tech-queries.blogspot.com/ On Mon, Mar 28, 2011 at 3:50 PM, anand karthik anandkarthik@gmail.com wrote: Evertime you conduct a race, you eliminate 2 horses. So, 11. On Mar 28, 2011 1:24 PM, Lavesh Rawat lavesh.ra...@gmail.com wrote: *Horse Race Problem Solution* * *Ok, so there are 25 horses and the race track only allows 5 horses to race at a given time. Given that there is no stop watch available your task is to determine the fastest 3 horses. Assume that each horses speed is constant in different races, what is the minimum number of races to determine the fastest 3? Update Your Answers at : Click Here http://dailybrainteaser.blogspot.com/2011/03/28march.html?lavesh=lavesh Solution: Will be updated after 1 day -- Never explain yourself. Your friends don’t need it and your enemies won’t believe it . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Re: Ties The Rope With Minimum Cost ..Interesting For Geeks
@Bittu. The ungreedy algorithm works. Repeatedly tie the two shortest ropes. E.g., suppose the ropes are 3, 4, 5, and 6 units long. Then tie 3 and 4, giving 7. Now 5 and 6 are the two shortest, so tie them, giving 11. Finally, 7 + 11 = 18. Dave On Mar 28, 1:41 am, bittu shashank7andr...@gmail.com wrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] RR Scheduling
You can solve this problem using Binary Indexed Trees. (copied from spoj forum) On Mon, Mar 21, 2011 at 3:09 PM, Terence technic@gmail.com wrote: In this problem, sum can be as large as 5*10^9. Try breaking the whole interval into several stages (no more than 2*N), each with a fixed amount of tasks. Then in each stage, the schedule is a simple loop: A B C D E A B C D E A B ... Process each stage in O(1) time, then the total time complexity is O(N). On 2011-3-21 17:32, saurabh singh wrote: using scanf and printf and still tle,I am not pretty sure how malloc or new arrays can speed up execution? On Mon, Mar 21, 2011 at 2:25 PM, sanchit mittal sm14it...@gmail.comwrote: use scanf n printf instead of cin n cout, malloc array of structures after reading value of n if working in c else use new in cpp rest i guess...is ok On Sun, Mar 20, 2011 at 11:53 PM, ankit sambyal ankitsamb...@gmail.com wrote: I worked on this problem but cud not get a more efficient algo than yours. Plz get back 2 me if u find a better algo. On Sun, Mar 20, 2011 at 3:24 AM, Akshata Sharma akshatasharm...@gmail.com wrote: I tried to solve this problem https://www.spoj.pl/problems/RRSCHED/ I am getting TLE!! How can I improve my code?? #includeiostream #includestdio.h using namespace std; struct process { long time; int finished; long elapsed_time; }; int main() { long n,sum=0; cinn; struct process prss[5]; for(long i=0;in;i++) { scanf(%ld,prss[i].time); prss[i].finished=0; sum+=prss[i].time; } long index=0; for(long k=1;k=sum;k++) { while(prss[index].finished==1) index++; prss[index].time--; if(prss[index].time==0) { prss[index].finished=1; prss[index].elapsed_time=k; } index++; if(index==n) index=0; } for(long i=0;in;i++) printf(%ld\n,prss[i].elapsed_time); return 0; } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sanchit Mittal Second Year Undergraduate Computer Engineering Delhi College of Engineering ph- +919582414494 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- regards, chinna. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: How to check whether a language isTuring Complete?
Thanks for your reply. I understood lot better than I was previously. So summing up your answers, A language is turing complete, if we can write infinite loops and primitive recursive function. Some of the non turing complete languages that I came across are HTML, CSS, SQL... From this can I assume, that a language is turing complete, if it computes something, rather than just trying to display a interface, or pull records. Coz languages like HTML CSS doesnt do anything to compute something, it just transforms one way of representation to another(HTML - browser readable code), where as C,C++ can compute something and can represent large mathematical problems. Am I right Pardon me if my question is stupid... Thanks.. On Mar 27, 4:07 pm, Wladimir Tavares wladimir...@gmail.com wrote: Theoretically, a language is Turing-complete if it computes all partial recursive functions, ie functions that include all the basic functions and is closed under composition, primitive recursion and minimization. Basic Functions zero () = 0 succ (x) = x +1 proj_i (x1, x2,..., xn) = xi Composition Let f1, f2, f3, fn eg partial recursive functions then h is defined by a composition iff h (x1,..., xn) = g (f1 (x1, .., xn), f2 (x1, ... , xn ),..., fn (x1,..., xn)) The notion of computability is established by Churh-Turing thesis. I believe our general computability is a very difficult task:) Wladimir Araujo Tavares *Federal University of Ceará * On Sun, Mar 27, 2011 at 3:56 PM, Carl Barton odysseus.ulys...@gmail.comwrote: To elaborate why; if your language suffers from the halting problem then it's pretty safe to say it's turing complete and infinite loops would allow you to achieve that. On 27 March 2011 19:03, Carl Barton odysseus.ulys...@gmail.com wrote: If you're not concerned about being that formal then having conditional branching statements and being able to write infinite loops would be a pretty good indication. On 27 March 2011 14:38, Karthik Jayaprakash howtechstuffwo...@gmail.comwrote: Hi, Thanks for replying. I am aware of that. But is there a practical way of checking it On Mar 26, 7:40 pm, Carl Barton odysseus.ulys...@gmail.com wrote: If it can simulate a universal turing machine then it is turing complete On 26 March 2011 22:34, Karthik Jayaprakash howtechstuffwo...@gmail.comwrote: Hi, Is there a way to check that if a language is Turing complete? Thanks. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: How to check whether a language isTuring Complete?
Somewhat; HTML, CSS and SQL aren't programming languages anyway, they're markup, style sheets and query languages respectively. TXL would be an example of a programming language which isn't turing complete but can still do something. Being able to compute something doesn't make it turing complete, being able to compute anything which it is possible to compute is what makes it turing complete. On 28 March 2011 17:42, Karthik Jayaprakash howtechstuffwo...@gmail.comwrote: Thanks for your reply. I understood lot better than I was previously. So summing up your answers, A language is turing complete, if we can write infinite loops and primitive recursive function. Some of the non turing complete languages that I came across are HTML, CSS, SQL... From this can I assume, that a language is turing complete, if it computes something, rather than just trying to display a interface, or pull records. Coz languages like HTML CSS doesnt do anything to compute something, it just transforms one way of representation to another(HTML - browser readable code), where as C,C++ can compute something and can represent large mathematical problems. Am I right Pardon me if my question is stupid... Thanks.. On Mar 27, 4:07 pm, Wladimir Tavares wladimir...@gmail.com wrote: Theoretically, a language is Turing-complete if it computes all partial recursive functions, ie functions that include all the basic functions and is closed under composition, primitive recursion and minimization. Basic Functions zero () = 0 succ (x) = x +1 proj_i (x1, x2,..., xn) = xi Composition Let f1, f2, f3, fn eg partial recursive functions then h is defined by a composition iff h (x1,..., xn) = g (f1 (x1, .., xn), f2 (x1, ... , xn ),..., fn (x1,..., xn)) The notion of computability is established by Churh-Turing thesis. I believe our general computability is a very difficult task:) Wladimir Araujo Tavares *Federal University of Ceará * On Sun, Mar 27, 2011 at 3:56 PM, Carl Barton odysseus.ulys...@gmail.com wrote: To elaborate why; if your language suffers from the halting problem then it's pretty safe to say it's turing complete and infinite loops would allow you to achieve that. On 27 March 2011 19:03, Carl Barton odysseus.ulys...@gmail.com wrote: If you're not concerned about being that formal then having conditional branching statements and being able to write infinite loops would be a pretty good indication. On 27 March 2011 14:38, Karthik Jayaprakash howtechstuffwo...@gmail.comwrote: Hi, Thanks for replying. I am aware of that. But is there a practical way of checking it On Mar 26, 7:40 pm, Carl Barton odysseus.ulys...@gmail.com wrote: If it can simulate a universal turing machine then it is turing complete On 26 March 2011 22:34, Karthik Jayaprakash howtechstuffwo...@gmail.comwrote: Hi, Is there a way to check that if a language is Turing complete? Thanks. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Re: Ties The Rope With Minimum Cost ..Interesting For Geeks
@Dave: Dude...u didn't count the cost for tying the two ropes i.e. (3 and 4) together with (5 and 6). On Mon, Mar 28, 2011 at 9:19 PM, Dave dave_and_da...@juno.com wrote: @Bittu. The ungreedy algorithm works. Repeatedly tie the two shortest ropes. E.g., suppose the ropes are 3, 4, 5, and 6 units long. Then tie 3 and 4, giving 7. Now 5 and 6 are the two shortest, so tie them, giving 11. Finally, 7 + 11 = 18. Dave On Mar 28, 1:41 am, bittu shashank7andr...@gmail.com wrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Ties The Rope With Minimum Cost ..Interesting For Geeks
If you have already tied ropes 1 and 2 then their final length would be 23 now you are left with two ropes o length 23 and 5 which suns out to be 28. This remains the same in each of your two examples. Why did you add 13 twice ? I mean you can tie them in 28 cost if you first tie any two and then tie with the left one. Why use 3 knots when it can be done in 2 !! Sent from my iPhone On Mar 28, 2011, at 8:36 PM, Raunak Agrawal raunak.ra...@gmail.com wrote: I think the possible solution is : Tie the highest two ropes at the end of the rope. This is because of the following reason: Eg: Rope 1: Size 10 mtr Rope 2: Size 13 mtr Rope 3: Size 5 mtr Rope1-- Rope2-- Rope3 Cost: (10+13) + (13+5) = 41 Rope1--Rope3-- Rope2 Cost: (10+5) + (5+13) = 33 So the optimum cost is : 1st Highest length Rope + 2*(Length of all other ropes other that two having the highest size) + 2nd Highest Rope. On Mon, Mar 28, 2011 at 7:49 PM, Gunjan Sharma gunjan.khan...@gmail.com wrote: The question seems to be correct. Think again On Mon, Mar 28, 2011 at 5:24 PM, kunal srivastav kunal.shrivas...@gmail.com wrote: if you tie all of them and the cost is sum of invidual lengths then in the end the cost will be sum of all lengths irrespective of any order that we tie them in.. i think the ques would req you to say that the cost is the longer of the two..plz check On Mon, Mar 28, 2011 at 12:11 PM, bittu shashank7andr...@gmail.com wrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- thezeitgeistmovement.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. -- Regards Gunjan Sharma Chairman IEEE Students Chapter IIT Roorkee B.Tech IV year CSE Contact No- +91 9997767077 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Ties The Rope With Minimum Cost ..Interesting For Geeks
@Kunal: Eg: Rope 1: Size 10 mtr Rope 2: Size 13 mtr Rope 3: Size 5 mtr Cost of tying rope 1 and rope 2 = 10 +13 = 23 Now we have tow end...one for rope 1 and another for rope 2 which can be tied with rope 3. So tie Rope 3 end with rope 2 end : (Length of rope 2 + 3) = (5 + 13) = 18 So total cost = 23 +18 = 41. So for different combination we can have different costplease let me know in case there is any doubt. On Mon, Mar 28, 2011 at 10:35 PM, Kunal kunal.shrivas...@gmail.com wrote: If you have already tied ropes 1 and 2 then their final length would be 23 now you are left with two ropes o length 23 and 5 which suns out to be 28. This remains the same in each of your two examples. Why did you add 13 twice ? I mean you can tie them in 28 cost if you first tie any two and then tie with the left one. Why use 3 knots when it can be done in 2 !! Sent from my iPhone On Mar 28, 2011, at 8:36 PM, Raunak Agrawal raunak.ra...@gmail.com wrote: I think the possible solution is : *Tie the highest two ropes at the end of the rope.* * * This is because of the following reason: Eg: Rope 1: Size 10 mtr Rope 2: Size 13 mtr Rope 3: Size 5 mtr Rope1-- Rope2-- Rope3 Cost: (10+13) + (13+5) = 41 Rope1--Rope3-- Rope2 Cost: (10+5) + (5+13) = 33 So the optimum cost is : *1st Highest length Rope + 2*(Length of all other ropes other that two having the highest size) + 2nd Highest Rope*. On Mon, Mar 28, 2011 at 7:49 PM, Gunjan Sharma gunjan.khan...@gmail.com gunjan.khan...@gmail.com wrote: The question seems to be correct. Think again On Mon, Mar 28, 2011 at 5:24 PM, kunal srivastav kunal.shrivas...@gmail.com kunal.shrivas...@gmail.com wrote: if you tie all of them and the cost is sum of invidual lengths then in the end the cost will be sum of all lengths irrespective of any order that we tie them in.. i think the ques would req you to say that the cost is the longer of the two..plz check On Mon, Mar 28, 2011 at 12:11 PM, bittu shashank7andr...@gmail.com shashank7andr...@gmail.com wrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks%2bunsubscr...@googlegroups.com algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en. -- http://thezeitgeistmovement.comthezeitgeistmovement.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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks%2bunsubscr...@googlegroups.com algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en. -- Regards Gunjan Sharma Chairman IEEE Students Chapter IIT Roorkee B.Tech IV year CSE Contact No- +91 9997767077 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks%2bunsubscr...@googlegroups.com algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en 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] Student Please Read Frwd This
NIT JAIPUR PRESENTS YOU KAMPUSATTACK.COM http://ampusattack.com/ Biggest Social Platform For Students by Students - Enjoy Spiced up Social Networking With Hot Features! - Get Connected To Constillation Of Young Brains Like You! - Access share useful collection of Ebooks,Notes, Ppt's,Codes,Programs. etc.. - Find Lot Of Humor Fun Inside! - Chat With Spicy Kampus Messenger with new people , Play Amazing Games. *! STAND OUT FROM CROWD !* With Our Useful Resources You Will Never Be Same As Rest Of Crowd - GD 's With Pro's Con's. - INTERVIEW preprations by personal experience of people. - PLACEMENT PAPERS - *College Previous Papers* - *Info About Latest **Technologies Gadgets.* - *Project Ideas help.* - *INTERNSHIP TRANING GUIDANCE.* *! BE CONNECTED AND UPDATED!* - *Connect With Your Pal's , Senior's Alumni's.* - *Exchange Idea's With People Across Kampuses.* *! EXCLUSIVE EXPERT ZONE !* - STEP OUT from other's with our *INDUSTRIAL GUINDANCE* from Adobe , Microsoft, NTPC, BPCL ,Accenture. - Field Experts Career Consultant Inside. Register Today! *WWW.KAMPUSATTACK.COM* http://www.kampusattack.com/ -- Arpit Bhatnagar (MNIT JAIPUR) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Ties The Rope With Minimum Cost ..Interesting For Geeks
The second cost will be 5+23 irrespective of the end. Correct me u think otherwise. On Mon, Mar 28, 2011 at 10:44 PM, Raunak Agrawal raunak.ra...@gmail.comwrote: @Kunal: Eg: Rope 1: Size 10 mtr Rope 2: Size 13 mtr Rope 3: Size 5 mtr Cost of tying rope 1 and rope 2 = 10 +13 = 23 Now we have tow end...one for rope 1 and another for rope 2 which can be tied with rope 3. So tie Rope 3 end with rope 2 end : (Length of rope 2 + 3) = (5 + 13) = 18 So total cost = 23 +18 = 41. So for different combination we can have different costplease let me know in case there is any doubt. On Mon, Mar 28, 2011 at 10:35 PM, Kunal kunal.shrivas...@gmail.comwrote: If you have already tied ropes 1 and 2 then their final length would be 23 now you are left with two ropes o length 23 and 5 which suns out to be 28. This remains the same in each of your two examples. Why did you add 13 twice ? I mean you can tie them in 28 cost if you first tie any two and then tie with the left one. Why use 3 knots when it can be done in 2 !! Sent from my iPhone On Mar 28, 2011, at 8:36 PM, Raunak Agrawal raunak.ra...@gmail.com wrote: I think the possible solution is : *Tie the highest two ropes at the end of the rope.* * * This is because of the following reason: Eg: Rope 1: Size 10 mtr Rope 2: Size 13 mtr Rope 3: Size 5 mtr Rope1-- Rope2-- Rope3 Cost: (10+13) + (13+5) = 41 Rope1--Rope3-- Rope2 Cost: (10+5) + (5+13) = 33 So the optimum cost is : *1st Highest length Rope + 2*(Length of all other ropes other that two having the highest size) + 2nd Highest Rope*. On Mon, Mar 28, 2011 at 7:49 PM, Gunjan Sharma gunjan.khan...@gmail.com gunjan.khan...@gmail.com wrote: The question seems to be correct. Think again On Mon, Mar 28, 2011 at 5:24 PM, kunal srivastav kunal.shrivas...@gmail.com kunal.shrivas...@gmail.com wrote: if you tie all of them and the cost is sum of invidual lengths then in the end the cost will be sum of all lengths irrespective of any order that we tie them in.. i think the ques would req you to say that the cost is the longer of the two..plz check On Mon, Mar 28, 2011 at 12:11 PM, bittu shashank7andr...@gmail.com shashank7andr...@gmail.com wrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks%2bunsubscr...@googlegroups.com algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en. -- http://thezeitgeistmovement.comthezeitgeistmovement.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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks%2bunsubscr...@googlegroups.com algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en. -- Regards Gunjan Sharma Chairman IEEE Students Chapter IIT Roorkee B.Tech IV year CSE Contact No- +91 9997767077 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks%2bunsubscr...@googlegroups.com algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en 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
Re: [algogeeks] Ties The Rope With Minimum Cost ..Interesting For Geeks
sort ropes according to lengths say 1 .2...3...n now tie likeN---1---(N-1)==N+1+1+N-1=2N+1; (N-1)--2--(N-2) ===N-1+2+2+(N-2)=2N+1; N-2---3---N-32n+1; hope i am correct On Mon, Mar 28, 2011 at 10:47 PM, Gunjan Sharma gunjan.khan...@gmail.comwrote: The second cost will be 5+23 irrespective of the end. Correct me u think otherwise. On Mon, Mar 28, 2011 at 10:44 PM, Raunak Agrawal raunak.ra...@gmail.comwrote: @Kunal: Eg: Rope 1: Size 10 mtr Rope 2: Size 13 mtr Rope 3: Size 5 mtr Cost of tying rope 1 and rope 2 = 10 +13 = 23 Now we have tow end...one for rope 1 and another for rope 2 which can be tied with rope 3. So tie Rope 3 end with rope 2 end : (Length of rope 2 + 3) = (5 + 13) = 18 So total cost = 23 +18 = 41. So for different combination we can have different costplease let me know in case there is any doubt. On Mon, Mar 28, 2011 at 10:35 PM, Kunal kunal.shrivas...@gmail.comwrote: If you have already tied ropes 1 and 2 then their final length would be 23 now you are left with two ropes o length 23 and 5 which suns out to be 28. This remains the same in each of your two examples. Why did you add 13 twice ? I mean you can tie them in 28 cost if you first tie any two and then tie with the left one. Why use 3 knots when it can be done in 2 !! Sent from my iPhone On Mar 28, 2011, at 8:36 PM, Raunak Agrawal raunak.ra...@gmail.com wrote: I think the possible solution is : *Tie the highest two ropes at the end of the rope.* * * This is because of the following reason: Eg: Rope 1: Size 10 mtr Rope 2: Size 13 mtr Rope 3: Size 5 mtr Rope1-- Rope2-- Rope3 Cost: (10+13) + (13+5) = 41 Rope1--Rope3-- Rope2 Cost: (10+5) + (5+13) = 33 So the optimum cost is : *1st Highest length Rope + 2*(Length of all other ropes other that two having the highest size) + 2nd Highest Rope*. On Mon, Mar 28, 2011 at 7:49 PM, Gunjan Sharma gunjan.khan...@gmail.com gunjan.khan...@gmail.com wrote: The question seems to be correct. Think again On Mon, Mar 28, 2011 at 5:24 PM, kunal srivastav kunal.shrivas...@gmail.com kunal.shrivas...@gmail.com wrote: if you tie all of them and the cost is sum of invidual lengths then in the end the cost will be sum of all lengths irrespective of any order that we tie them in.. i think the ques would req you to say that the cost is the longer of the two..plz check On Mon, Mar 28, 2011 at 12:11 PM, bittu shashank7andr...@gmail.com shashank7andr...@gmail.com wrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks%2bunsubscr...@googlegroups.com algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en. -- http://thezeitgeistmovement.comthezeitgeistmovement.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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks%2bunsubscr...@googlegroups.com algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en. -- Regards Gunjan Sharma Chairman IEEE Students Chapter IIT Roorkee B.Tech IV year CSE Contact No- +91 9997767077 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks%2bunsubscr...@googlegroups.com algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en 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] Re: Ties The Rope With Minimum Cost ..Interesting For Geeks
@Raunak. Actually, I didn't add up the individual costs to give the total cost. It is 7 + 11 + 18 = 36. Dave On Mar 28, 12:00 pm, Raunak Agrawal raunak.ra...@gmail.com wrote: @Dave: Dude...u didn't count the cost for tying the two ropes i.e. (3 and 4) together with (5 and 6). On Mon, Mar 28, 2011 at 9:19 PM, Dave dave_and_da...@juno.com wrote: @Bittu. The ungreedy algorithm works. Repeatedly tie the two shortest ropes. E.g., suppose the ropes are 3, 4, 5, and 6 units long. Then tie 3 and 4, giving 7. Now 5 and 6 are the two shortest, so tie them, giving 11. Finally, 7 + 11 = 18. Dave On Mar 28, 1:41 am, bittu shashank7andr...@gmail.com wrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] C o/p gud one try
#includestdio.h main() { long x; float t; scanf(%f,t); printf(%d\n,t); x=90; printf(%f\n,x); { x=1; printf(%f\n,x); { x=30; printf(%f\n,x); } printf(%f\n,x); } x==9; printf(%f\n,x); } o/p on gcc compiler 20.3 (i/p given) -1073741824 20.299988 20.299988 20.299988 20.299988 20.299988 plz explain the o/p -- Arpit Bhatnagar (MNIT JAIPUR) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Ties The Rope With Minimum Cost ..Interesting For Geeks
ok raunak i get what you are trying to say On Mon, Mar 28, 2011 at 11:03 PM, Dave dave_and_da...@juno.com wrote: @Raunak. Actually, I didn't add up the individual costs to give the total cost. It is 7 + 11 + 18 = 36. Dave On Mar 28, 12:00 pm, Raunak Agrawal raunak.ra...@gmail.com wrote: @Dave: Dude...u didn't count the cost for tying the two ropes i.e. (3 and 4) together with (5 and 6). On Mon, Mar 28, 2011 at 9:19 PM, Dave dave_and_da...@juno.com wrote: @Bittu. The ungreedy algorithm works. Repeatedly tie the two shortest ropes. E.g., suppose the ropes are 3, 4, 5, and 6 units long. Then tie 3 and 4, giving 7. Now 5 and 6 are the two shortest, so tie them, giving 11. Finally, 7 + 11 = 18. Dave On Mar 28, 1:41 am, bittu shashank7andr...@gmail.com wrote: you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- thezeitgeistmovement.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.
[algogeeks] Re: 28march
7 races. For the first five races, divide the horses into groups of five and record the win, place, and show finishers of each race. For the sixth race, run the winners of the first five races. Now, only six horses remain in contention for the fastest three: The winner of the sixth race and the place and show horses of his first race, The place horse in the sixth race and the place horse in his first race. The show horse in the sixth race. Three of these horses are known to be faster than all other horses. The winner of the sixth race is known to be the fastest horse. Run the other five contenders in race 7 and choose the fastest two. Dave On Mar 28, 2:54 am, Lavesh Rawat lavesh.ra...@gmail.com wrote: *Horse Race Problem Solution* * *Ok, so there are 25 horses and the race track only allows 5 horses to race at a given time. Given that there is no stop watch available your task is to determine the fastest 3 horses. Assume that each horses speed is constant in different races, what is the minimum number of races to determine the fastest 3? Update Your Answers at : Click Herehttp://dailybrainteaser.blogspot.com/2011/03/28march.html?lavesh=lavesh Solution: Will be updated after 1 day -- Never explain yourself. Your friends don’t need it and your enemies won’t believe it . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Virtual classes
can u gv any link for reference...??? On Sat, Mar 26, 2011 at 12:29 PM, D.N.Vishwakarma@IITR deok...@gmail.comwrote: *there is vtable known as virtual table which contains addresses of virtual functions . And there is vptr a pointer that points to vtable of that class space occupied by class having virtual function wil be equal to space occupied by a pointer * number of virtual functions .. I think this if there is any correction please let me know... * On Sat, Mar 26, 2011 at 12:00 PM, himanshu kansal himanshukansal...@gmail.com wrote: wht is the space occupied by a class in c++ whn it contains a virtual fn. How are the virtual fn implemented internally by c++... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *With Regards Deoki Nandan Vishwakarma IITR MCA Mathematics Department * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Virtual classes
hey u can find dat clearly in C++: The complete reference. You can download dat from here http://asaha.com/ebook/DOTA5NDk-/C-The-Complete-Reference,-3rd-Edition.pdf On Tue, Mar 29, 2011 at 12:07 AM, himanshu kansal himanshukansal...@gmail.com wrote: can u gv any link for reference...??? On Sat, Mar 26, 2011 at 12:29 PM, D.N.Vishwakarma@IITR deok...@gmail.comwrote: *there is vtable known as virtual table which contains addresses of virtual functions . And there is vptr a pointer that points to vtable of that class space occupied by class having virtual function wil be equal to space occupied by a pointer * number of virtual functions .. I think this if there is any correction please let me know... * On Sat, Mar 26, 2011 at 12:00 PM, himanshu kansal himanshukansal...@gmail.com wrote: wht is the space occupied by a class in c++ whn it contains a virtual fn. How are the virtual fn implemented internally by c++... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *With Regards Deoki Nandan Vishwakarma IITR MCA Mathematics Department * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- P.V.N.S.S. Krishna Murthy, Contact no:- +919845812996. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] create subgraph
whats ur expected complexity...?? if we represent the graph in linked list form then graph can be easily formed and subgraph can be easily created in O(no. of successors) i think u shud call it connected nodes instead of successors since it is a undirected grpah On Thu, Mar 24, 2011 at 12:04 PM, divya sweetdivya@gmail.com wrote: You have to create a graph in most efficient way from relationship of nodes read from txt file. text file contains information like: node_id weight node_id node_id weight node_id ….. // which means two nodes are connected with some weight. (undirected) There are around 600K such information for about 65000 nodes. Aim is to create a a subgraph for a given node_id. i.e for that node_id find ALL successor nodes with level mentioned i.e form a subgraph for that node. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Aditya Kumar B-tech 3rd year Computer Science Engg. MNNIT, Allahabad. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Interesting combination/permutation puzzle
Folks, here is an interesting puzzle: A Rubick's Cube has owl heads on it, which can be misoriented. How many (times) MORE combinations are there of this cube vs. one that has blank stickers? the major difference between the cube with owl's heads and the one without is you might have the heads in 4 different directions depends on how you rotate the cube. Here is what i have: I figured since the problem is asking how many times, it's asking the relation between two cases. I also realized that the only the axis/ middle piece of the side matters and everything else is fixed because you can only rotate the edges to make the direction of the middle piece changing relatively. Let's say the number of combination of the cube without heads is N. I am thinking since you have 4 possible directions and Y middle pieces and since the pieces are independent, wouldn't that be 4^Y*N combination of the one with heads, which means 4^Y times more than the one without? What do you think? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Virtual classes
Off the top of my head, virtual functions are implemented through v-tables http://en.wikipedia.org/wiki/Virtual_table The size should be the size of a native pointer (4 bytes in 32 machines) but I could be wrong. On Mon, Mar 28, 2011 at 11:37 AM, himanshu kansal himanshukansal...@gmail.com wrote: can u gv any link for reference...??? On Sat, Mar 26, 2011 at 12:29 PM, D.N.Vishwakarma@IITR deok...@gmail.com wrote: there is vtable known as virtual table which contains addresses of virtual functions . And there is vptr a pointer that points to vtable of that class space occupied by class having virtual function wil be equal to space occupied by a pointer * number of virtual functions .. I think this if there is any correction please let me know... On Sat, Mar 26, 2011 at 12:00 PM, himanshu kansal himanshukansal...@gmail.com wrote: wht is the space occupied by a class in c++ whn it contains a virtual fn. How are the virtual fn implemented internally by c++... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Deoki Nandan Vishwakarma IITR MCA Mathematics Department -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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, hammett http://hammett.castleproject.org/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Virtual classes
Theoretically, the vtable conatins pointer to each virtual function of the class. Each object of this class contains a pointer called vptr to this virtual table. But will the space occupied by the v-table be part of the memory occupied by the class? If the memory needed by v-table is part of class, then the class memory size will be increased by 4n, where n is the number of virtual functions in the class and the machine is 32 bit. Please correct me if I am wrong. Would appreciate if someone clarifies if the vtable is created in class memory or in any other memory space. -- Thanks, Amit Kumar Basak On Tue, Mar 29, 2011 at 1:47 AM, hammett hamm...@gmail.com wrote: Off the top of my head, virtual functions are implemented through v-tables http://en.wikipedia.org/wiki/Virtual_table The size should be the size of a native pointer (4 bytes in 32 machines) but I could be wrong. On Mon, Mar 28, 2011 at 11:37 AM, himanshu kansal himanshukansal...@gmail.com wrote: can u gv any link for reference...??? On Sat, Mar 26, 2011 at 12:29 PM, D.N.Vishwakarma@IITR deok...@gmail.com wrote: there is vtable known as virtual table which contains addresses of virtual functions . And there is vptr a pointer that points to vtable of that class space occupied by class having virtual function wil be equal to space occupied by a pointer * number of virtual functions .. I think this if there is any correction please let me know... On Sat, Mar 26, 2011 at 12:00 PM, himanshu kansal himanshukansal...@gmail.com wrote: wht is the space occupied by a class in c++ whn it contains a virtual fn. How are the virtual fn implemented internally by c++... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Deoki Nandan Vishwakarma IITR MCA Mathematics Department -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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, hammett http://hammett.castleproject.org/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Virtual classes
*you can see in test your c skills yeshwant kanetkar * On Tue, Mar 29, 2011 at 2:05 AM, hammett hamm...@gmail.com wrote: Not sure what you mean by class memory. Are you trying to distinguish between class vs instances? If so, yes, I believe the vtable should be per class, since the this pointer is probably the first one to be pushed in non-static members call, it wouldnt make sense to have a separated copy for each instance. I may be wrong here, though... On Mon, Mar 28, 2011 at 1:31 PM, Amit Basak abas...@gmail.com wrote: Theoretically, the vtable conatins pointer to each virtual function of the class. Each object of this class contains a pointer called vptr to this virtual table. But will the space occupied by the v-table be part of the memory occupied by the class? If the memory needed by v-table is part of class, then the class memory size will be increased by 4n, where n is the number of virtual functions in the class and the machine is 32 bit. Please correct me if I am wrong. Would appreciate if someone clarifies if the vtable is created in class memory or in any other memory space. -- Thanks, Amit Kumar Basak On Tue, Mar 29, 2011 at 1:47 AM, hammett hamm...@gmail.com wrote: Off the top of my head, virtual functions are implemented through v-tables http://en.wikipedia.org/wiki/Virtual_table The size should be the size of a native pointer (4 bytes in 32 machines) but I could be wrong. On Mon, Mar 28, 2011 at 11:37 AM, himanshu kansal himanshukansal...@gmail.com wrote: can u gv any link for reference...??? On Sat, Mar 26, 2011 at 12:29 PM, D.N.Vishwakarma@IITR deok...@gmail.com wrote: there is vtable known as virtual table which contains addresses of virtual functions . And there is vptr a pointer that points to vtable of that class space occupied by class having virtual function wil be equal to space occupied by a pointer * number of virtual functions .. I think this if there is any correction please let me know... On Sat, Mar 26, 2011 at 12:00 PM, himanshu kansal himanshukansal...@gmail.com wrote: wht is the space occupied by a class in c++ whn it contains a virtual fn. How are the virtual fn implemented internally by c++... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Deoki Nandan Vishwakarma IITR MCA Mathematics Department -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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, hammett http://hammett.castleproject.org/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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, hammett http://hammett.castleproject.org/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **With Regards Deoki Nandan Vishwakarma IITR MCA Mathematics Department* * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] SPOJ Problem : PALIN
I m getting WA in this question though all the test cases are giving correct output. Link to the problem : https://www.spoj.pl/problems/PALIN/ Can anybdy check out my code . The following is my code : #includestdio.h #includestring.h int compare(char s[], char t[]) { //only check second half int midpoint,i,l; l=strlen(s); midpoint = l / 2; i = l % 2 == 0 ? midpoint : midpoint + 1; for (; i l; i++) { if(s[i] t[i]) { return -1 ; } else if (s[i] t[i]) { return 1; } } return 0; } void fun2(char str[]) { int i,m,midpoint,l; l=strlen(str); midpoint=l/2; i=l%2==0?midpoint:midpoint+1; while (i l) { str[i] = str[midpoint - 1]; i++; midpoint--; } } void fun1(char arr[]) { int n,midpoint,currPoint,found,l; char c,inc; l=strlen(arr); char newarr[l + 1]; midpoint = l / 2; currPoint=l%2==0?midpoint-1:midpoint; found = 0; while (currPoint = 0 found==0) { c = arr[currPoint]; if (c == '9') { inc = '0'; } else { inc = (char) (c + 1); found = 1; } arr[currPoint] = inc; if (found==0) { currPoint--; } } if (found==0) { // we have fallen off the start of the string // example 999 has become 009. Add a one on to give: 1009 newarr[0]= '1'; newarr[1]='\0'; strcat(newarr,arr); strcpy(arr,newarr); } } void fun(char str[]) { char temp[101]; int m,midpoint,i,l; l=strlen(str); strcpy(temp,str); midpoint=(int)(l/2); i=l%2==0?midpoint:midpoint+1; while (i l) { str[i] = str[midpoint - 1]; i++; midpoint--; } if(compare(str,temp)==0 || compare(str,temp)==-1) { fun1(str); fun2(str); } } int main() { int t; char str[102]; scanf(%d,t); while(t0) { scanf(%s,str); fun(str); printf(%s,str); t--; } return 0; } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.