How to Design While Loops

08/21/2020
by   Marco T. Morazán, et al.
0

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.

READ FULL TEXT
research
05/27/2019

Proving Non-Termination via Loop Acceleration

We present the first approach to prove non-termination of integer progra...
research
08/21/2020

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...
research
11/21/2019

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

Addressing students by their names helps a teacher to start building rap...
research
10/25/2019

On the Decidability of Termination for Polynomial Loops

We consider the termination problem for triangular weakly non-linear loo...
research
06/02/2023

(Un)Solvable Loop Analysis

Automatically generating invariants, key to computer-aided analysis of p...
research
05/08/2021

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...
research
09/02/2021

A Reasoning Engine for the Gamification of Loop-Invariant Discovery

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

Please sign up or login with your details

Forgot password? Click here to reset