Why structural recursion should be taught before arrays in CS 1

  • Authors:
  • Kim B. Bruce;Andrea Danyluk;Thomas Murtagh

  • Affiliations:
  • Williams College, Williamstown, MA;Williams College, Williamstown, MA;Williams College, Williamstown, MA

  • Venue:
  • Proceedings of the 36th SIGCSE technical symposium on Computer science education
  • Year:
  • 2005

Quantified Score

Hi-index 0.00

Visualization

Abstract

The approach to teaching recursion in introductory programming courses has changed little during the transition from procedural to object-oriented languages. It is still common to present recursion late in the course and to focus on traditional, procedural examples such as calculating factorials or solving the Towers of Hanoi puzzle. In this paper, we propose that the shift to object-oriented programming techniques calls for a significant shift in our approach to teaching recursion. First, we argue that in the context of object-oriented programming students should be introduced to examples of simple recursive structures such as linked lists and methods that process them, before being introduced to traditional procedural examples. Second, we believe that this material should be presented before students are introduced to structures such as arrays. In our experience, the early presentation of recursive structures provides the opportunity to reinforce the fundamentals of defining and using classes and better prepares students to appreciate the reasons to use classes to encapsulate access to other data structures when they are presented.