[algogeeks] Re: Mathematics Puzzle
Hi, The puzzle needs to be rephrased as: If the rank of the student who comes out of the classroom is better than ranks of all students who came out before him/her, then he/she gets a lollipop. Rephrased this way, this is a famous puzzle, and the answer is log(69). On Nov 22, 12:44 pm, shiva shivanand.kadwad...@gmail.com wrote: If all the person got his rank increased except the first(he is last know) then 1. if the previous first ranked person stand front in queue then 69 lollipop need to be distributed. 2. other case 68 lollipop need to be distributed. On Nov 21, 9:46 pm, Shiv Shankar Prajapati mca.shivshan...@gmail.com wrote: Its total no. of Student i.e. 69. If all the students ranking is increased then all the student will get the lollipop. But there is one student left who was at top n now on the least ranking and as the condition is given that student may appear first and get the lollipop. So professor need will give 69 lollipop. in this (worst) case. On Sun, Nov 21, 2010 at 8:42 PM, Ashim Kapoor ashimkap...@gmail.com wrote: Do you mean if the rank of a student is better than the rank of the prev student then he/she gets a lollipop? Thank you, Ashim On Sun, Nov 21, 2010 at 6:57 PM, vamsee marpu marpu.vam...@gmail.comwrote: Does anybody know the solution for the following problem : *A headmaster of a primary school performs an activity with the students of a class to encourage them to perform better in academics. He asks them to stand in queue, starts calling the students out one by one and asks them their rank in class. Each one has a unique rank in class. If the rank of a student is better than his/her previous best rank, then he awards him/ her a lollipop (students love lollipops). Note that the first one in the queue will always get a lollipop and the students arrange themselves in random order in the queue. What is the expected number of lollipops the headmaster will have to distribute among students if the total number of students in the class is 69? Note that the answer can be a fractional number.* Thanks and Regards, M. Vamsee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards, Shiv Shankar, -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Mathematics Puzzle
Any explanation of how it works and how you got log(69) as answer. Thanks in advance. On Nov 22, 2:27 pm, Salil Joshi joshi.sali...@gmail.com wrote: Hi, The puzzle needs to be rephrased as: If the rank of the student who comes out of the classroom is better than ranks of all students who came out before him/her, then he/she gets a lollipop. Rephrased this way, this is a famous puzzle, and the answer is log(69). On Nov 22, 12:44 pm, shiva shivanand.kadwad...@gmail.com wrote: If all the person got his rank increased except the first(he is last know) then 1. if the previous first ranked person stand front in queue then 69 lollipop need to be distributed. 2. other case 68 lollipop need to be distributed. On Nov 21, 9:46 pm, Shiv Shankar Prajapati mca.shivshan...@gmail.com wrote: Its total no. of Student i.e. 69. If all the students ranking is increased then all the student will get the lollipop. But there is one student left who was at top n now on the least ranking and as the condition is given that student may appear first and get the lollipop. So professor need will give 69 lollipop. in this (worst) case. On Sun, Nov 21, 2010 at 8:42 PM, Ashim Kapoor ashimkap...@gmail.com wrote: Do you mean if the rank of a student is better than the rank of the prev student then he/she gets a lollipop? Thank you, Ashim On Sun, Nov 21, 2010 at 6:57 PM, vamsee marpu marpu.vam...@gmail.comwrote: Does anybody know the solution for the following problem : *A headmaster of a primary school performs an activity with the students of a class to encourage them to perform better in academics. He asks them to stand in queue, starts calling the students out one by one and asks them their rank in class. Each one has a unique rank in class. If the rank of a student is better than his/her previous best rank, then he awards him/ her a lollipop (students love lollipops). Note that the first one in the queue will always get a lollipop and the students arrange themselves in random order in the queue. What is the expected number of lollipops the headmaster will have to distribute among students if the total number of students in the class is 69? Note that the answer can be a fractional number.* Thanks and Regards, M. Vamsee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards, Shiv Shankar, -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: switch vs if -- which is faster
I was asking you for some examples ..as i dont have any knowledge regarding this assembly code and how to study it . there was no intention of mine to challenge you or disregard you . On 11/22/10, Gene gene.ress...@gmail.com wrote: I'm not sure what you mean by support. If you mean examples, gcc uses several of the techniques I mentioned. Write some switch statements with different distributions of cases. Compile with -S, and inspect the assembly code. If you don't now how to do that, take the time to learn. If you mean justify the truth of what I wrote, it's observation while studying and teaching courses about compilers on and off for over 15 years and building some myself. BTW, u c I won't ansr mor ??s if wrds arnt spld out... On Nov 22, 12:28 am, LALIT SHARMA lks.ru...@gmail.com wrote: @dipankar Can u tell us , sumthng more in support of ur ans...?? On Mon, Nov 22, 2010 at 10:40 AM, DIPANKAR DUTTA dutta.dipanka...@gmail.com wrote: both are same .. because any good optimizing compiler generate same assembly code of them... On Mon, Nov 22, 2010 at 9:38 AM, Gene gene.ress...@gmail.com wrote: A good compiler will never generate a switch that is slower than an if...else chain. It will analyze the switch cases and pick one of several options for code generation. These may include cascaded conditional jumps (like if...else code), simple jump tables, segmented jump tables (cascaded jumps pick one of several jump tables because a single table would be too big), binary searches in a sorted table of case values, and perfect hash functions. These are the ones I've seen. There may be others. On Nov 21, 8:15 am, shiva shivanand.kadwad...@gmail.com wrote: As per my understanding it is compiler depending thing.. what i feel is switch need to evaluate the expression only once but if else if need to evaluate the expression more than once(what if expression stored in variable and then compare...) Does any one please comment difference in speed of switch and if depending on how it is implemented... I heard switch uses jump table for its operation. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- DIPANKAR DUTTA M-TECH,Computer Science Engg. EC Dept,IIT ROORKEE Uttarakhand , India – 247667 --- website:http://people.iitr.ernet.in/shp/09535009/Website/index.html ph no-09045809987 email:dipan...@iitr.ernet.in -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Lalit Kishore Sharma IIIT Allahabad (Amethi Capmus) 5th Sem -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Lalit Kishore Sharma IIIT Allahabad (Amethi Capmus) 5th Sem -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Mathematics Puzzle
Well, Since the students are mixed randomly (as mentioned in the problem), the chances (probability) that the 'i' th student who comes out is ranked best so far is directly (1/i). Since this is an independent Random Variable, the answer thus becomes sum_1^n {1/i} which for large value of n can be approximated to log (n). Hence the answer. On Mon, Nov 22, 2010 at 3:54 PM, shiva shivanand.kadwad...@gmail.comwrote: Any explanation of how it works and how you got log(69) as answer. Thanks in advance. On Nov 22, 2:27 pm, Salil Joshi joshi.sali...@gmail.com wrote: Hi, The puzzle needs to be rephrased as: If the rank of the student who comes out of the classroom is better than ranks of all students who came out before him/her, then he/she gets a lollipop. Rephrased this way, this is a famous puzzle, and the answer is log(69). On Nov 22, 12:44 pm, shiva shivanand.kadwad...@gmail.com wrote: If all the person got his rank increased except the first(he is last know) then 1. if the previous first ranked person stand front in queue then 69 lollipop need to be distributed. 2. other case 68 lollipop need to be distributed. On Nov 21, 9:46 pm, Shiv Shankar Prajapati mca.shivshan...@gmail.com wrote: Its total no. of Student i.e. 69. If all the students ranking is increased then all the student will get the lollipop. But there is one student left who was at top n now on the least ranking and as the condition is given that student may appear first and get the lollipop. So professor need will give 69 lollipop. in this (worst) case. On Sun, Nov 21, 2010 at 8:42 PM, Ashim Kapoor ashimkap...@gmail.com wrote: Do you mean if the rank of a student is better than the rank of the prev student then he/she gets a lollipop? Thank you, Ashim On Sun, Nov 21, 2010 at 6:57 PM, vamsee marpu marpu.vam...@gmail.comwrote: Does anybody know the solution for the following problem : *A headmaster of a primary school performs an activity with the students of a class to encourage them to perform better in academics. He asks them to stand in queue, starts calling the students out one by one and asks them their rank in class. Each one has a unique rank in class. If the rank of a student is better than his/her previous best rank, then he awards him/ her a lollipop (students love lollipops). Note that the first one in the queue will always get a lollipop and the students arrange themselves in random order in the queue. What is the expected number of lollipops the headmaster will have to distribute among students if the total number of students in the class is 69? Note that the answer can be a fractional number.* Thanks and Regards, M. Vamsee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.comalgogeeks%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.comalgogeeks%252bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards, Shiv Shankar, -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards Salil Joshi. CSE MTech II, IITB A-414, Hostel 12 +91.9819.442.865 This is a confidential E-Mail. If it has reached you by mistake or if you are not the intended receiver, please send it back to me. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] for loop performace in terms of speed makes any difference when we run from max to min and min to max
Might be its is due to the comparison operation which takes many cycles i max takes more cycles of cpu than just simply checking i On Sun, Nov 21, 2010 at 6:50 PM, shiva shivanand.kadwad...@gmail.comwrote: I want to know is there any difference between following two loop in terms of speed. 1. for(i=0;imax;i++) { //Some operation } 2. for(i=max; i; i--) { /Some operation } I heard second one is faster but don't have any proof Please comment. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Rahul Patil -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Swap the LSB and MSB within themself of given no.
@dave plz run gene's code for input 0xAD...or send me some link of bitwise programing which involve simultaneous many opearation... like above... i am always confused with bitwise programing... On Sun, Nov 21, 2010 at 11:11 PM, Dave dave_and_da...@juno.com wrote: @Coolfrog$: Don't forget the bitwise logical products. What is the bit patterns in those hexadecimal constants? Work out the whole example and you will see how it works. -- Dave On Nov 21, 8:21 am, coolfrog$ dixit.coolfrog.div...@gmail.com wrote: @gene plz explain .. what is going on... by taking example. i am unable to run a test case 1. x=0xAD (1010 1101) 2. x1 ===01011010 | x1 01010110 x =0100 how we will get answer as ( 0101 1011).?? On Sun, Nov 21, 2010 at 9:59 AM, Gene gene.ress...@gmail.com wrote: if the input is in unsigned char x, then x = ((x 1) 0xAA) | ((x 1) 0x55) x = ((x 2) 0xCC) | ((x 2) 0x33) On Nov 20, 10:41 pm, Divesh Dixit dixit.coolfrog.div...@gmail.com wrote: assuming all are 8bit no. input = 0x46 (0100 0110) output = 0x26 ( 0010 0110 ) input = 0x75 (0111 0101) output = 0xFC (1110 1010 ) Algorithm..??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Divesh* (¨`·.·´¨) Always `·.¸(¨`·.·´¨ ) Keep (¨`·.·´¨)¸.·´Smiling! `·.¸.·´ Life can give u 100's of reason 2cry,but u can give life 1000's of reasons 2Smile- 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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Divesh* (¨`·.·´¨) Always `·.¸(¨`·.·´¨ ) Keep (¨`·.·´¨)¸.·´Smiling! `·.¸.·´ Life can give u 100's of reason 2cry,but u can give life 1000's of reasons 2Smile -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Swap the LSB and MSB within themself of given no.
@Coolfrog$: It will be instructive if you do it for yourself. Perhaps with practice you can work through your confusion. Have you worked out the bit patterns of those hex constants? They are crucial to understanding Gene's algorithm. -- Dave On Nov 22, 6:55 am, coolfrog$ dixit.coolfrog.div...@gmail.com wrote: @dave plz run gene's code for input 0xAD...or send me some link of bitwise programing which involve simultaneous many opearation... like above... i am always confused with bitwise programing... On Sun, Nov 21, 2010 at 11:11 PM, Dave dave_and_da...@juno.com wrote: @Coolfrog$: Don't forget the bitwise logical products. What is the bit patterns in those hexadecimal constants? Work out the whole example and you will see how it works. -- Dave On Nov 21, 8:21 am, coolfrog$ dixit.coolfrog.div...@gmail.com wrote: @gene plz explain .. what is going on... by taking example. i am unable to run a test case 1. x=0xAD (1010 1101) 2. x1 ===01011010 | x1 01010110 x = 0100 how we will get answer as ( 0101 1011).?? On Sun, Nov 21, 2010 at 9:59 AM, Gene gene.ress...@gmail.com wrote: if the input is in unsigned char x, then x = ((x 1) 0xAA) | ((x 1) 0x55) x = ((x 2) 0xCC) | ((x 2) 0x33) On Nov 20, 10:41 pm, Divesh Dixit dixit.coolfrog.div...@gmail.com wrote: assuming all are 8bit no. input = 0x46 (0100 0110) output = 0x26 ( 0010 0110 ) input = 0x75 (0111 0101) output = 0xFC (1110 1010 ) Algorithm..??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Divesh* (¨`·.·´¨) Always `·.¸(¨`·.·´¨ ) Keep (¨`·.·´¨)¸.·´Smiling! `·.¸.·´ Life can give u 100's of reason 2cry,but u can give life 1000's of reasons 2Smile- 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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Divesh* (¨`·.·´¨) Always `·.¸(¨`·.·´¨ ) Keep (¨`·.·´¨)¸.·´Smiling! `·.¸.·´ Life can give u 100's of reason 2cry,but u can give life 1000's of reasons 2Smile- 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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Mathematics Puzzle
@Ashim : Yes @Shiv Shankar : The Question says : *the students arrange themselves in random order in the queue. *69* *is possible only when the students arrange themselves in decreasing order of their rank. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] GOOGLE SUMMER OF CODE
Hi On 22 November 2010 08:14, ankit sablok ankit4...@gmail.com wrote: WHEN IS GOOGLE SUMMER OF CODE 2011 BEGINING AND HOW CAN WE APPLY FOR IT Next year AND WHAT ARE THE ELIGIBILITY CRITERIA FOR THE APPLICATION. you must be a student PLEASE HELP ME OUT WITH THIS APPLICATION PROCEDURE... Kindly refer to the faqs or ask at #gsoc(freenode) for real time feedback THNXX IN ADVANCE ANKIT SABLOK B.TECH COMPUTER SCIENCE AND ENGG -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Siddharth Srivastava When you have learned to snatch the error code from the trap frame, it will be time for you to leave. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Fwd: Ayyamperumal's Research Survey- Spare max. 4 minutes, Thanks -reg
-- Forwarded message -- From: Ayyamperumal Ragupathy ayyamperum...@gmail.com Date: Sun, Nov 21, 2010 at 3:58 PM Subject: Ayyamperumal's Research Survey- Spare max. 4 minutes, Thanks -reg To: a.sarukris...@gmail.com Dear Sir/Madam/Friends/students, As a part of my research i am collecting data.This will be used for academic purpose only. It contains 11 questions out of which 9 are multichoice questions. Max. 4 minutes time. Kindly forward this to your friend/Relatives/collegues so that i can collect the required data by this week end. Thank you for the support extended. Click the below link, *You can click multiple times to be filled by your family members and submit.* http://www.surveygizmo.com/s3/416683/ayyamperumal (or) http://www.surveygizmo.com/s3/416683/052cdb09cdd4 Regards, -- R.Ayyamperumal, Asst. Prof. in Business Administration, VHNSN College, Virudhunagar - 626001. Cell : 9894832987, 9688196789 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.