https://cacm.acm.org/blogs/blog-cacm/264263-not-your-grandmothers-textbook-exercise/fulltext ACM acm-header Sign In [ ] Go * ACM.org * Join ACM * About Communications * ACM Resources * Alerts & Feeds * facebook twitter rss Communications of the ACM * Home * Current Issue Latest issue Current Issue: September 2022 Deconstructing the Bakery to Build a Distributed State Machine Middleware 101 Deploying Decentralized, Privacy-Preserving Proximity Tracing VIEW TABLE OF CONTENTS * News Latest News News Archive * Blogs About the Blogs BLOG@CACM Blogroll Blogs Archive * Opinion Articles Interviews Opinion Archive * Research Latest Research Research Archive * Practice Latest Practice Practice Archive * Careers + Search for Jobs + Post a Resume + Post A Job + Advertise with Us + Contact Us * Archive The magazine archive includes every article published in Communications of the ACM for over the past 50 years. September 2022 (Vol. 65, No. 9) August 2022 (Vol. 65, No. 8) July 2022 (Vol. 65, No. 7) VIEW MORE ISSUES * Videos Home/Blogs/BLOG@CACM/Not your Grandmother's Textbook Exercise/Full Text BLOG@CACM Not your Grandmother's Textbook Exercise --------------------------------------------------------------------- By Bertrand Meyer September 1, 2022 Comments View as: Print Mobile App Share: Send by email Share on reddit Share on StumbleUpon Share on Hacker News Share on Tweeter Share on Facebook Share Bertrand Meyer In my eulogy of Barry Boehm last week in this blog, I mentioned from memory an exercise in his classic Software Engineering Economics textbook (Prentice Hall, 1981). Now I've got my hands on the book itself and found that it is even better than I remembered. So here is the exercise text in its entirety. It is exercise 1.4, page 9. I hope that citing one exercise from a 1981 textbook, even in full, falls under fair use. They do not write textbooks like this anymore! Mary Jones in the Accounting Department tells you that she has a file of personnel records [2022 update: an Excel sheet] and asks you to develop a program to compute the median age of the personnel in the file. Here are four different ways you might respond: (a) Invoke a sort routine which sorts the personnel file by increasing age. Count the number, N, of personnel records in the file. Find record N/2 in the sorted fileextract its value for "age". (b) Note that in The Art of Computer Programming [Knuth, 1973], Vol. III, pp. 209-220, the problem of obtaining the median is a special case of the problem of finding the i^th largest of N numbers, and that R.W. Floyd has formulated a recursive method of obtaining the median in an average of 3/2 N + O (N^2/3 log N) comparisons. Spend a couple of weeks attempting (unsuccessfully) to improve on Floyd's algorithm, a day programming Floyd's algorithm, and then return to Mary Jones with some questions on the size and format of her file. (c) Ask Mary how soon she needs the results, how much she is willing to pay for them, how many records, N, her personnel file has, and how often she will be making such runs. If N is large, and she wants results often, quickly, and cheaply, ask her if she would be satisfied with the mean value, which is much easier and cheaper to calculate. If not, work with Mary to tailor an approach to obtaining the median which is the best compromise between her various objectives. (d) Compute the mean age, and print it out as the median. It's much easier to program, and Mary Jones will probably never notice the difference. Rank the responses in the order of their relative concern with programming considerations, economic considerations, or other important considerations. If you were the programmer, which approach would you prefer? If you were Mary Jones, which approach would you prefer? Bertrand Meyer is professor and provost at the Schaffhausen Institute of Technology (Switzerland) and chief technology officer of Eiffel Software (Goleta, CA). --------------------------------------------------------------------- No entries found Sign In for Full Access User Name [ ] Password [ ] >> Forgot Password? >> Create an ACM Web Account Sign In More News & opinions Oxford High Turned to AI to Detect Weapons After Shooting The Detroit News On the Model of Computation: Point: We Must Extend Our Model of Computation to Account for Cost and Location William Dally The Legacy of Barry Boehm Bertrand Meyer * For Authors * For Advertisers For Advertisers * Privacy Policy * Help * Contact Us * Mobile Site Copyright (c) 2022 by the ACM. All rights reserved.