The development, specification, and use of a loop invariant are useful and underutilized tools in writing code to solve a problem or implement an algorithm.Invariants are especially useful in introductory courses (CS 1 and CS2) but are usually avoided because of the mathematical notation associated with them and because most textbooks have brief, if any, coverage of them. Our intent in this paper is provide several motivating examples of the use of pictures as loop invariant and to provide pointers to literature that more fully explores and develops the ideas of using loop invariants in specifying and developing programs.
For forty years programming has been the foundation of introductory computer science. Despite exponential increases in computational power during this period, examples used in introductory courses have remained largely unchanged. The incredible growth in statistics courses at all levels, in contrast with the decline of students taking computer science courses, points to the potential for introducing computer science at many levels without emphasizing the process of programming: leverage the expertise and role-models provided by high school mathematics teachers by studying topics that arise from social networks and modeling to introduce computer science as an alternative to the traditional programming approach. This new approach may capture the interest of a broad population of students, crossing gender boundaries. We are developing modules that we hope will capture student interest and provide a compelling yet intellectually rich area of study. We plan to incorporate these modules into existing courses in math, statistics, and computer science at a wide variety of schools at all levels.
We have developed an application-based approach to introductory courses in computer science. This approach follows an apprenticeship model of learning, where students begin by reading, studying, and extending programs written by experienced and expert programmers. Applications play a central role since programming constructs are motivated and introduced in the context of applications, not the other way around as is the tradition in most texts and courses. Under our applied approach, (1) students are able to learn from interesting real-world examples, (2) the synthesis of different programming constructs is supported using incremental examples, and (3) good design is stressed vis code and concept reuse. In this paper, we provide several examples of our method as well as pointers to all the material we have developed which is freely available electronically. The philosophy underlying this method transcends a particular programming language, but we present our examples using C++ since that is the language used in the CS 1 and CS 2 courses at Duke. This method has been used with equal success using ISETL at Dickinson.
This paper includes an abstract, a discussion of the usefulness of self-reference in early computer science courses, and some examples to illustrate this usefulness. Most readers will not be troubled by this example of self-referential writing. Why then is self-reference, usually in the form of recursive subprograms, thought to be so onerous as to be placed in its own left-until-the-end-and-often-uncovered chapter in most introductory texts? Self-reference is one of the cornerstones of computer science from the unsolvability of the halting problem, to writing a Pascal compiler in Pascal, to reveling in the beauty of Quicksort. We argue that the notion of self-reference should permeate first courses in computer science. If this is to be the case such courses should take a view far broader than “Wow, I can average 10 numbers with the skills I learned in my first programming course!”
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.
hi@scite.ai
10624 S. Eastern Ave., Ste. A-614
Henderson, NV 89052, USA
Copyright © 2024 scite LLC. All rights reserved.
Made with 💙 for researchers
Part of the Research Solutions Family.