Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-sh8wx Total loading time: 0 Render date: 2024-07-23T03:16:29.276Z Has data issue: false hasContentIssue false

1 - Specifying Algorithms

Published online by Cambridge University Press:  05 June 2012

R. D. Tennent
Affiliation:
Queen's University, Ontario
Get access

Summary

Case Study: Searching an Array

Professor Higgins wants his programmer, Eliza Doolittle, to write a code fragment that is to test for the presence or absence of a value x in an array A. Here is the intended application: A is to contain the student numbers of all the students currently enrolled in his course on computational metaphysics, and x might be the student number of a student who is trying to verify that he or she is properly registered.

Exercise 1.1 Before reading on, pretend that you are Eliza Doolittle and try to write the desired code. Also, try to write an application program that uses the code.

As you will quickly discover if you try to write the desired code, or to write a program to use it, the preceding paragraph is an inadequate specification. Here are some of the questions that must be answered before (or during) the development of the desired code or any associated applications.

  1. What is the range of allowed subscript values for A, and what segment of the array should be searched?

  2. What is the type of variable x (also, presumably, the component type of the array), and how should values of this type be compared?

  3. How should the result be recorded?

  4. Is the array segment sorted in, say, ascending order, to allow use of a more efficient search method?

  5. […]

Type
Chapter
Information
Specifying Software
A Hands-On Introduction
, pp. 15 - 30
Publisher: Cambridge University Press
Print publication year: 2002

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Specifying Algorithms
  • R. D. Tennent, Queen's University, Ontario
  • Book: Specifying Software
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139164900.004
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Specifying Algorithms
  • R. D. Tennent, Queen's University, Ontario
  • Book: Specifying Software
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139164900.004
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Specifying Algorithms
  • R. D. Tennent, Queen's University, Ontario
  • Book: Specifying Software
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139164900.004
Available formats
×