DeepAI AI Chat
Log In Sign Up

How to Design While Loops

by   Marco T. Morazán, et al.

Beginning students find the syntactic construct known as a while loop difficult to master. The difficulties revolve around guaranteeing loop termination and around learning how to properly sequence mutations to solve a problem. In fact, both of these are intertwined and students need to be taught a model that helps them reason about how to design while loops. For students that have been introduced to how to design programs using structural recursion, generative recursion, accumulative recursion, and mutation, the task of teaching them how to design while loops is made easier. These students are familiar, for example, with state variables, termination arguments, and accumulator invariants. All of these are fundamental in the design of while loops. This articles presents a novel technique used at Seton Hall University to introduce beginners to the design of while loops. It presents a design recipe that students can follow step-by-step to establish such things as the driver of the loop, the loop invariant, and the proper sequencing of mutations. The article also presents an example of designing a while-loop based function using the new design recipe.


Proving Non-Termination via Loop Acceleration

We present the first approach to prove non-termination of integer progra...

Using Video Game Development to Motivate Program Design and Algebra Among Inner-City High School Students

Introducing inner-city high school students to program design presents u...

NaMemo: Enhancing Lecturers' Interpersonal Competence of Remembering Students' Names

Addressing students by their names helps a teacher to start building rap...

MORA – Automatic Generation of Moment-Based Invariants

We introduce MORA, an automated tool for generating invariants of probab...

FSM Error Messages

Computer Science students, in general, find Automata Theory difficult an...

All Together Now: Teachers as Research Partners in the Design of Search Technology for the Classroom

In the classroom environment, search tools are the means for students to...

A Reasoning Engine for the Gamification of Loop-Invariant Discovery

We describe the design and implementation of a reasoning engine that fac...