2 research outputs found

    How to Design While Loops

    Full text link
    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.Comment: In Proceedings TFPIE 2019 and 2020, arXiv:2008.0892

    Vector Programming Using Generative Recursion

    Full text link
    Vector programming is an important topic in many Introduction to Computer Science courses. Despite the importance of vectors, learning vector programming is a source of frustration for many students. Much of the frustration is rooted in discovering the source of bugs that are manifested as out-of-bounds indexing. The problem is that such bugs are, sometimes, rooted in incorrectly computing an index. Other times, however, these errors are rooted in mistaken reasoning about how to correctly process a vector. Unfortunately, either way, all too often beginners are left adrift to resolve indexing errors on their own. This article extends the work done on vector programming using vector intervals and structural recursion to using generative recursion. As for problems solved using structural recursion, vector intervals provide beginners with a useful framework for designing code that properly indexes vectors. This article presents the methodology and concrete examples that others may use to build their own CS1 modules involving vector programming using any programming language.Comment: In Proceedings TFPIE 2018, arXiv:1906.10757. arXiv admin note: text overlap with arXiv:1805.0512
    corecore