Illustrating the Suitability of Greedy and Dynamic Algorithms Using Economics’s “Opportunity Cost” EUGENE CALLAHAN, Tandon School of Engineering New York University ROBERT MURPHY, Free Market Institute Texas Tech University ANAS ELGHAFARI, Tandon School of Engineering New York University ABSTRACT Students of Computer Science often wonder when, exactly, one can apply a greedy algorithm to a problem, and when one must use the more complicated and time-consuming techniques of dynamic programming. This paper argues that the existing pedagogical literature does not ofer clear guidance on this issue. We suggest improving computer science pedagogy by importing a concept economists use in their own implementations of dynamic programming. That economic concept is "opportunity cost," and we explain how it can aid students in diferentiating "greedy problems" from problems requiring dynamic programming. CCS Concepts: · Social and professional topics Computational thinking; Computer science edu- cation; CS1; Computing literacy; Additional Key Words and Phrases: algorithms, algorithms education, algorithm choice, greedy algorithms, dynamic programming, opportunity cost, static optimization, dynamic optimization, allocation problem ACM Reference Format: Eugene Callahan, Robert Murphy, and Anas Elghafari. 2020. Illustrating the Suitability of Greedy and Dynamic Algorithms Using Economics’s łOpportunity Costž. ACM Transactions on Economics and Computation 1, 1 (November 2020), 6 pages. 1 INTRODUCTION Greedy algorithms simply seize upon the łbestž choice available at every step in the algorithm. When applied to suitable problems, this sequence of locally optimal choices will lead to the global optimum. Dynamic programming, on the other hand, tracks the impact of current choices on the chooser’s ability to make other, future choices, ones that might lead to a global optimum but would be blocked by making the choice that łseems bestž at any one moment. But when can one employ a (simpler and faster) greedy algorithm, and when must one resort to (slower and more complex) dynamic programming? The answer turns on the diference between static and dynamic Authors’ addresses: Eugene Callahan, Tandon School of Engineering New York University, ejc369@nyu.edu; Robert Murphy, Free Market Institute Texas Tech University, robert.p.murphy@ttu.edu; Anas Elghafari, Tandon School of Engineering New York University, anas.elghafari@nyu.edu. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for proft or commercial advantage and that copies bear this notice and the full citation on the frst page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specifc permission and/or a fee. Request permissions from permissions@acm.org. © 2020 Copyright held by the owner/author(s). Publication rights licensed to ACM. XXXX-XXXX/2020/11-ART $15.00 https://doi.org/ ACM Transactions on Economics and Computation, Vol. 1, No. 1, Article . Publication date: November 2020. arXiv:2011.10004v1 [cs.DS] 19 Nov 2020