&rpsxwlqj - kirkintilloch high school work can focus on small-scale case studies exploring the...

63
&RPSXWLQJ &RPSXWHU3URJUDPPLQJ +LJKHU

Upload: duongkhanh

Post on 04-Apr-2018

220 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

&RPSXWLQJ&RPSXWHU�3URJUDPPLQJ

+LJKHU

Page 2: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving
Page 3: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

$XJXVW�����

&RPSXWLQJ&RPSXWHU�3URJUDPPLQJ

+LJKHU

6XSSRUW�0DWHULDOV *+,-./

+,*+(5�67,//

Page 4: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

CONTENTS

Section 1 Teacher/Lecturer Notes

Section 2 Student Guide

Section 3 Study Materials

Section 4 Additional Review Questions

Section 5 Bibliography

Computing: Computer Programming (H) 1

Page 5: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Computing: Computer Programming (H) 2

Page 6: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Section 1

Teacher/Lecturer Notes

Computing: Computer Programming (H) 3

Page 7: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Computing: Computer Programming (H) 4

Page 8: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

AimThis unit introduces students to the algorithms and data structures used in the processing of more complex, structured data and develops the ability to use a systematic program design methodology to produce complex programs. Students also develop skills in the testing and debugging of computer programs.

Status of this Learning and Teaching PackThese materials are for guidance only. The mandatory content of the unit is detailed in the unit specification of the Arrangements document.

Target AudienceWhile entry is at the discretion of the centre, students would normally be expected to have attained one of the following (or equivalent experience):• Software Development (H) Unit• Computing course at Intermediate 2• Grade 1 or 2 at Standard Grade in Computing Studies.

Pre-knowledge and skillsThese materials assume that the student has:• programming experience in a high level, procedural language• used a structured design methodology such as top-down, stepwise

refinement• knowledge of some form of algorithmic representation (charts, pseudocode)• used a programming environment (editor, debugging tools, translator).

There are revision and consolidation exercises in programming and algorithms at the beginning of the materials that can be used to reinforce what will already be known by some students, and to provide a starting point for those students who have little knowledge of programming. The teacher/lecturer will need to supplement these exercises with further introductory tasks for those students who are not taking the unit within a course and who may not have much experience of programming. Such exercises may be found in the SCCC, Higher Programming materials issued in 1989.

ProgressionKnowledge of file handling, data structures and data types is extended in depth and breadth from that studied at Intermediate2 or Standard Grade. The language studied in both the core unit Software Development and the project at Intermediate 2 will also have a bearing on the progression in programming skills into Higher.

The unit provides a foundation in the study of programming that can be used and built upon at Advanced Higher level within the Project.

Hardware and Software RequirementsAs for Standard Grade programming and Intermediate 2 level projects.

Learning and Teaching approachesThis pack consists of information sheets and activity sheets.

Computing: Computer Programming (H) 5

Page 9: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

The information sheets aim to introduce in summary form new areas of content in the unit. You should note that they are not intended to be used as full and comprehensive course notes. Neither are they a replacement for teacher led classroom activity. Further reading and sources of more in-depth study of topic areas are listed in the bibliography.

Activities are varied (design, investigate, brainstorm, implement, analyse, review etc..) and class organisation ranges from individual to group work and whole class lessons. The teaching and learning route is not prescriptive and serves as a model. It is not prescribed that you either undertake all of the activities in the pack or that you deliver the unit in the manner herein designed. You are free to adjust the content and the delivery of this unit in accordance with local needs and preferences.

Some activities may be completed at home and set as homework exercises. For instance, the design of algorithms, review questions and even to some extent code generation in a particular language - although students should have reference to technical manuals if at all possible in this case.

Pathway Through the UnitThe unit starts with some revision exercises in programming. These revisit the algorithms, data structures and language constructs covered in Standard Grade or at Intermediate 2 level. You may, given the knowledge that you have of your students, prefer to bypass the revision exercises, or to select one or two as refreshers. The choice is entirely yours.

Unit outcomes 1, 2 and 3 extend knowledge and understanding of algorithms, data structures and file handling. A natural progression in learning then is the introduction of new data structures and a study of their uses. Activities include brainstorming in groups, individual design and practical activity. File handling procedures follow with mini-investigations, report writing, design and practical activity. It would be appropriate to schedule assessments 2 and 3 to be taken within or at the end of this lesson sequence.

Having gained considerably more experience in understanding abstract data structures and file handling procedures, and with increased use of a programming environment, the student then meets a study of the aspects of the software development process as detailed in unit Outcome 1. These aspects include knowledge of the purpose and features of editors, translation and debugging tools. Activities involve close reading, review questions and a focused investigation of the tools on offer within a chosen programming environment. The investigation requires the completion of a checklist of features, and there are opportunities within this activity for group or paired work. Assessment 1 could be issued at the end of this study.

Searching and sorting techniques are then covered, with emphasis on efficiency (memory and processor time) of various sort and search methods. There is further opportunity for group work and plenary sessions. Activities also include a comparative study of a range of sorting and searching algorithms, reporting and structured walkthroughs. Students should be encouraged to build a set of module libraries on the search and sort methods outlined in the reference materials, in particular binary search and one sort routine. This will better prepare them for the integrated problem-solving task of Assessment 4.

The practice in small-scale design and implementation, the study of search and sort techniques, and an increased understanding of their function as components of module libraries, will have laid the foundation for the design and implementation of larger scale solutions required in

Computing: Computer Programming (H) 6

Page 10: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Assessment 4. However, it will be necessary to revisit the stages of software development. Group work can focus on small-scale case studies exploring the issues of good and bad programming techniques.

This particular route culminates in the investigation of an aspect of computer programming. There is enough flexibility to introduce the investigation earlier and this is left to your preference. It should be noted that investigations have scope to cover some of the theory and practical activity of the unit outcomes, making it possible to further integrate the teaching and learning of unit outcomes. You may wish to plan your own route through this unit which takes this on board.

Revision & Consolidation

Outcome 2 & 3 Assessments 2, 3

Outcome 1 Assessment 1

Outcome 4 Assessment 4

Outcome 5 Assessment 5

Computing: Computer Programming (H) 7

Page 11: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Computing: Computer Programming (H) 8

Page 12: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Section 2

Student Guide

Computing: Computer Programming (H) 9

Page 13: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Computing: Computer Programming (H) 10

Page 14: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

INTRODUCTION

Welcome to the Programming unit at Higher level.

You will be reading this section because you are interested in finding out what this unit is all about, and whether you need to prepare yourself in any way for what you are about to study.

You may already have experience of programming in a high level language from Standard Grade or Intermediate 2 level. Or you may be a student who is keen on programming, has maybe tinkered with it on a PC at home, but has never really studied it.

Have a look at the questions in the table below. They are designed to help you to think about what you should already know before you study this unit. If you have any doubts about what is written then have a word with your teacher/lecturer.

It may be that if you have little experience of programming you will need to catch up with the rest of the class by taking an accelerated route through the foundation knowledge, understanding and practical skills detailed below. Your teacher/lecturer will be able to give you some tasks that will help you to do this.

Computing: Computer Programming (H) 11

Do I know about? YES/NO

Stages of program development

A design method

Using a translator

Using a source editor

Using debugging tools

Program sequence

Modularity

Simple data types

Structured Data Types - 1D array

Data transfer

Statements

Expressions

Repetition

Complex conditions

Full test data

Readability

User Interface

Page 15: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

HOW CAN YOU ORGANISE YOUR STUDIES?

As you work through this unit you will be given information sheets or textbooks to read, together with activities that you will need to carry out, either on your own, or with some of your classmates.

You will be reading for information, taking notes, preparing a report or giving some feedback on your findings within a mini-investigation. To help you with this nature of work you may wish to have have a copy of:

Learning Skills ToolboxAsk your teacher/lecturer for a copy of this at the start of your unit. You will find the content of this booklet very useful to you throughout your studies.

An outcome of this unit is an investigation that will involve you preparing a report of approximately 800-1000 words in length. Materials have been written to help you with this so make sure that you have a copy of:

Higher Investigation : Guide for CandidatesThis will tell you all that you need to know.

There are a number of assessments that you will also need to carry out within the unit. Your teacher/lecturer will issue these at particular times and he or she may already have a timetable that you can look at. To help you organise yourself in dealing with these assessments you should prepare a grid, like the one below, that you can use to keep track of your progress.

COMPUTER PROGRAMMING (HIGHER)

If you are studying more than one course or unit then it will be a good idea to prepare one for all of your subjects. You will then be able to see ‘busy’ periods of your studies when more than one assessment is coming up in the same week or month, and try to manage your time and preparation.

Computing: Computer Programming (H) 12

Assessment Descript ion Date Issued Date Completed Resul t

1

2

3

4

5

Page 16: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Section 3

Study Materials

Computing: Computer Programming (H) 13

Page 17: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Computing: Computer Programming (H) 14

Page 18: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

LESSON SEQUENCE 1

OverviewIn this sequence of lessons the student will revisit some of the programming language features and constructs used at Standard Grade or Intermediate 2. It would be useful to have to hand a programming folio produced at an earlier stage. This will help remind students on how to use certain language constructs and features.

Suggested Activities• teacher led overview of prior learning, possibly using a checklist

• selection of introductory programming tasks from SCCC Higher Computing Tasks, 1989

• coding of three small algorithms (Activity 1A, 1B, 1C).

Outcomes• use of an array structure• use of iteration techniques• use of selection• use of data types (integer, char, string)• conditions• entering and editing a program• translating and debugging a program• stepwise refinement• software development cycle• pseudocode & structured charts• user interface guidelines.

Teaching Resources (OHPs)• Refer to SCCC, Higher Computing Programming OHPs, 1989 Specifically:

OHPT L&E 3.1, 3.2, 3.3, 3.4(a), 3.4(b), 3.5(a), 3.5(b)

• Software Development (H), Outcome 1.

Computing: Computer Programming (H) 15

Page 19: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 1A

1 . Read closely the following algorithm.

for index = 1 to maxlistsize doset list[index] to null

set listposition to 1repeat

ask for a nameread the name from the keyboardif name <> ‘end’ then

store the name in list[listposition]add one to listposition

until name given = ‘end’display message “names in reverse order”set position to listposition-1repeat

display name at list[position] on screendecrement position

until position = 1

2 . Write down in your own words what you think it does.

3 . What would be the result of applying this algorithm to the list of names below?

JamesRubyGeorgeMandyBrianEdward

4 . Code and test this algorithm - remember to program in a modular style, using meaningful identifiers and internal commentary! Take a printout ofyour work, with the test cases, and keep it in your folder of work.

Computing: Computer Programming (H) 16

Page 20: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 1B

1 . Read closely the following algorithm.

for index = 1 to maxlistsize doset list[index] to null

set listposition to 1repeat

ask for a positive integerread the integer from the keyboardif integer <> -1 then

store the integer in list[listposition]add one to listposition

until integer given = -1display message “the maximum is”set position to 1set maximum to integer at first position in listrepeat

if list[position] > maximum then set maximum to list[position]increment position

until position = listposition-1display maximum value

2 . Write down in your own words what you think it does.

3 . What would be the result of applying this algorithm to the list of integers below?

-2010030-400150-1

4 . Code and test this algorithm - remember to program in a modular style, using meaningful identifiers and internal commentary! Take a printout ofyour work, with the test cases, and keep it in your folder of work.

Computing: Computer Programming (H) 17

Page 21: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 1C

1 . Read closely the following algorithm.

for index = 1 to maxlistsize doset list[index] to null

set listposition to 1repeat

ask for a characterread the character from the keyboardif character <> ‘!” then

store the character in list[listposition]add one to listposition

until character given = ‘!’display message “swapping of letters”set firstposition to 1set lastposition to listposition - 1repeat

temp = list[firstposition]list[firstposition] = list[lastposition]list[lastposition] = tempincrement firstpositiondecrement lastposition

until firstposition = lastposition

2 . Write down in your own words what you think it does.

3 . What would be the result of applying this algorithm to the list of characters below?

c, g, a, b, d

4 . Code and test this algorithm - remember to program in a modular style, using meaningful identifiers and internal commentary! Take a printout ofyour work, with the test cases, and keep it in your folder of work.

Computing: Computer Programming (H) 18

Page 22: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

LESSON SEQUENCE 2

OverviewIn this sequence of lessons the student will learn new data structures and operations that can be carried out on them. Algorithms for manipulating queues, stacks and 2 dimensional arrays will be developed and students will be expected to implement them. File handling will also be introduced and algorithms to support the features explored.

Suggested Activities• teacher led overview of each key learning point

• study of information sheets (2A - 2D) with review questions

• coding and testing of algorithms (Activity 2A, 2B, 2C, 2D, 2E, 2F, 2G).

Outcomes• understanding of records, queues and stacks as abstract data structures• implementation of queues and stacks as a list structure in a programming language• understanding of standard algorithms to manipulate records, queues and stacks• knowledge of list operations insert, delete append• implementation of a frequency count algorithm• knowledge and understanding of 2 dimensional structures and where they can be used• knowledge and understanding of file handling and applicative uses• practical skills in file handling, records, stacks and queues.

Computing: Computer Programming (H) 19

Page 23: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Information 2A - Data Structures (queues and stacks)

Your programming experience thus far has probably introduced you to the most common data types which are:

• numeric (integers or reals e.g. 1256 or 12.56)

• textual (character strings or individual characters e.g. ‘moxey’ or ‘m’)

• boolean (logical values that are either TRUE or FALSE)

These data types are primitive and can be viewed as the atoms of a programming language. Some languages require you to declare these types in advance, such as Pascal, while others try to figure out the type of the data from the nature of the operation that you are trying to carry out (addition, concatenation, comparison) for example hypertalk or visual basic.

Just as very little could be modelled in our universe were we to be restricted to simple atomic elements, the same argument applies to programming. A programming language is as rich as the data types and data structures that it supports. Data types and data structures provide us with the ability to model solutions to problems.

Just as atoms combine to form molecules, primitive data types can combine to form data structures. And just as molecules can combine to form more complex molecules, data structures can combine to form structures of almost any complexity - provided, of course, that the language you use can support this!

Before we examine the need for data structures, let’s revisit a structure that you are already familiar with and have been using in previous exercises.

In activity 1A, 1B and 1C you probably programmed your solution using a onedimensional list structure - an array. This is a data structure, since it combines a list of much simpler data types into a single, identifiable object. You can refer to the array as a single object by using its name, or you can access individual items of the array by using an array subscript.

Array ModellingAn array of type ‘string’ can be modelled as below:

1 2 3 4Julie Martin Chris Millie

As a data structure it is a list. It contains 4 elements of type string.

Array OperationsElements can be added to the list, deleted from it or moved around in it, as you have already seen in section 1.

Computing: Computer Programming (H) 20

Page 24: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Applications of array structuresBy simply working through what the algorithm(s) in section 1 were doing you will have noticed that the array can be used to model many different types of problem. Indeed, you will have identified problems that needed to:

• reverse the order in a list of names• find the maximum value in a list of positive integers• swap elements in a list from the outside in.

The array is therefore a pretty versatile data structure in that it can be used to model many different types of problem.

Other uses to which the array can be put - THE QUEUEImagine that you are trying to write a program that will model the flow of customers at a supermarket checkout. You would be looking perhaps to drawup a model as follows:

checkout customer a customer b customer c

head tailof queue of queue

Queue Operations

• remove a customer from the head of the queue• add a customer to the tail of the queue.

The queue is therefore just another form of array, but with special operations. Elements are removed from the head of the queue first. This is also known asa FIFO (First In First Out) list structure.

Computing: Computer Programming (H) 21

Page 25: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Other uses to which the array can be put - THE STACKImagine that you are trying to write a program that will model the flow of dishes being washed in an hotel kitchen. You would be looking perhaps to drawup a model as follows:

Top

stack of washed stack of unwashedplates sink plates

Stack Operations• remove a plate from the top of the stack - known as a POP operation• add a plate to the top of the stack - known as a PUSH operation.

The stack is also another form of array with its own set of operations. Elements are added to and removed from the top of the stack first. This is also known as a LIFO (Last In First Out) structure.

Computing: Computer Programming (H) 22

Page 26: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Information 2B - Data Structures (arrays in parallel and records)

There will be times when the use of a single array will not be enough to model the solution to a problem.

Consider the following problem:

A postman is given a batch of letters for his area. He sorts the letters into street name and then sorts on the door number within the street. Thus making it easierfor him to deliver the letters to each person.

If we were to model this problem in a programming language then we wouldneed to store both the street name and the door number. We could choose to usea single list as follows

25 Woods Crescent 23 Marton Drive 21 Woods Crescent

putting the door number and the street address together in a single string. However we are just making things awkward when it comes to sorting the lists.Think of how you would sort the information above. Which portions of the stringwould you need to look at?

An alternative is to use two lists and manage the update and sorting of bothin parallel.

Thus we have:

25 23 21 list a

Woods Crescent Marton Drive Woods Crescent list b

During a sort operation when elements of a list need to be interchanged thenthe same elements of the second list will also need to be interchanged. So forexample if we say

list a[2] := list a[3]

then we also need to say

list b[2] := list b[3]

so that the door numbers and the addresses still correspond with one another.This is an example of handling arrays in parallel.

Computing: Computer Programming (H) 23

Page 27: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Handling two data structures in parallel can be expensive in terms of the overallprocessing time and also requires careful management.

• There are at least twice the number of assignments that needto take place which increases the size of the program code and theoverall execution time.

• Mistakes can creep into the coding, where one of the lists is not beingmaintained properly. You can see how easy it would be to ‘forget’to swap over elements of a second list during a sort.

An alternative to using arrays in parallel would be to have a structured datatype within the programming language itself that would allow for the grouping ofelements of different type and size within a single object/structure.

This grouping is known as a record, and you may have met this structure in yourprevious studies of databases.

A number of related items can be grouped together into a single object. If wetake the letters example above, then we would have:

data type

recorddoornumber - integer; Fieldsstreet - string;

Programming languages that support this type of structure will all have differentways of declaring and using it.

The sorting of a list of these objects is more straightforward than the maintenanceof two arrays in parallel.

record list structure

1 2 3

25 23 21Woods Crescent Marton Drive Woods Crescent

This is simply a linear list (1 dimensional array) of records. It has a dimensionof 3.

Computing: Computer Programming (H) 24

Page 28: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Information 2C - File Handling

Many computer applications involve processing data that has already been created and is stored as a file on backing storage. A file is often organised as a sequential collection of records, each one containing information about the subject of the file.

So for instance, a file of stock control records might contain information in each record on:

(a) the stock item(b) the stock code(c) the cost of the item(d) the current stock level.

Another example may be a file of students, each record containing information about:

(a) the student’s name(b) the courses that they take(c) their address(d) their telephone number.

Organisation of information and access methodsIf a file is organised sequentially then the information can only be accessed in the order in which the file was created, whereas randomly organised files can be accessed in any order.

We will concentrate on sequential (serial) access methods.

Serial Files and File Handling The basic operations that we are interested in exploring are:

• assigning a file on disk to an internal file name in a program• opening a file for input• reading from a file• opening a file for output• writing to a file• appending information to a file• closing a file.

How a particular programming language lets you do these will be differentfrom language to language, and so rather than look at concrete examples in a particular environment such as Pascal or Comal, let’s examine logically what is meant to be happening with each of these operations, and you can explore the syntax of a particular programming language for yourself.

Computing: Computer Programming (H) 25

Page 29: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

The table below describes the operation, the need for it and its effect.

operation need effect

assign to set up a mapping between sets up accessan internal program filename and a file on disk

open for input to set the file access pointer opens the fileto the start of the file in order toread from it. Notification giventhat the file is in use.

read to take a copy of data from the reads datafile and hold it in a program variable for processing

open for output opens/creates a file on disk, opens/createssetting the file access pointer to a file/new filethe start of file in order to write

write to save any changes writes datato a file.

append to add information to the end adds dataof a file that already exists

close to close a file so that otherprograms are notified that the fileis no longer in use.

Computing: Computer Programming (H) 26

Page 30: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Information 2D - 2 Dimensional structures

You have already met the use of single dimensional data structures in the form of arrays or lists.

Some problems will require you to model the solution using a more complex structure that will need more than one dimension. Multidimensional arrays can be handled quite easily in some languages. These can be two or three dimensional. We will look at two dimensional arrays.

A two dimensional array is simply a matrix of elements of the same type. As an object it may look like this:

This is a two dimensional array that has 2 entries in one dimension and 6 entries in the other, of type integer.

The declaration and use of this structure will vary from language to language, but to illustrate its use it is declared in Pascal and Comal as:

Pascal Comal2D_array : array[1..2,1..6] of integer DIM 2D_array(1:2,1:6)

We assign values to the positions within the array by saying:

Pascal Comal2D_array[1,1] := 1 2D_array(1,1) = 12D_array[2,3] := 13 2D_array(2,3) = 13

Q . What is stored at array positions:

[1,3]? [1,6]? [2,5]? [2,2] ?

Q . Model on paper what a 2 dimensional array with dimensions 10 x 10 of type string would look like.

We will be looking at algorithms to initialise, insert into and display the full contents of 2 dimensional arrays.

Computing: Computer Programming (H) 27

1 3

5 7

1 1 1 3

1 5 1 9

2 4 3 3

1 1 1 5

1 212345

6

Page 31: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Storage requirements of multidimensional structures.Let us assume that we have a 2D array of dimensions 5x5 of real numbers, and further assume that on our machine a real number is stored making use of 4 bytes of memory - see Computer Systems(H).

The translator will need to reserve 25 x 4 = 100 bytes for this structure. This seems reasonable enough.However, imagine that we wish to model a larger array with 1000 numbers in each dimension then we would be looking at:

1000x1000x4 = 4MBytes of RAM!

Modelling a multidimensional array will be limited by the amount of RAM available on your machine.

Initialising

It is always good programming practice to initialise the contents of data structures before using them. Some systems have quite ‘lazy’ translators that simply grab any available memory for variable storage and do not clear the contents from any previous use. This can cause problems for programmers, and so it is best to initialise everything before you start.

Let us assume that we have an array of dimensions 10x10 of integer as below:

The algorithm below would be used to initialise the contents to 0:

For each element in rows 1 to 10 doFor each element in cols 1 to 10 do

set array position[row,col] to 0

Computing: Computer Programming (H) 28

1 2 3 4 5 6 7 8 9 1 0

1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0

2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0

3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 4 0

4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 5 0

5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 6 0

6 1 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9 7 0

7 1 7 2 7 3 7 4 7 5 7 6 7 7 7 8 7 9 8 0

8 1 8 2 8 3 8 4 8 5 8 6 8 7 8 8 8 9 9 0

9 1 9 2 9 3 9 4 9 5 9 6 9 7 9 8 9 9 100

Page 32: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 2A - The Queue

1. Read information sheet 2A on stacks and queues.

2. In small groups, brainstorm the areas where you can see the need to have a queue structure. The diagram below gives you an idea to start with.

printingin a multi-userenvironment

uses of the queue

Be ready to discuss your ideas with your teacher/lecturer who willbe leading a feedback session.

3. Individually write down the steps you would need to take to:

(a) add an item to a queue - assume a pointer to the tail of the queue(b) remove an item from a queue - assume a pointer to the head.

4.

(i) As a group, design a problem specification for an area that you consider would need to be modelled using a queue. Don’t be too ambitious as your team are going to develop and code the solution!

(ii) Elect a team leader who will carve up the design and programming tasks amongst you. It may be easier to construct an Input/Process/Output chart and delegate programming tasks from that.

Good testing practice would be to nominate an individual who willtake sole charge of testing all of the components and the finishedproduct. They can be busy making up the test cases while the restare doing the coding!

Computing: Computer Programming (H) 29

Page 33: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 2B - The Stack

1. Read information sheet 2A on stacks and queues.

2. In small groups, brainstorm the areas where you can see the need to have a stack structure. The diagram below gives you an idea to start with.

managingreturns from subroutinecalls

uses of the stack

Be ready to discuss your ideas with your teacher/lecturer who willbe leading a feedback session.

3. Individually write down the steps you would need to take to:

(a) add an item to a stack(b) remove an item from a stack.

4.

(i) As a group, design a problem specification for an area that you consider would need to be modelled using a queue. Don’t be too ambitious as you are, as a team, going to develop and code the solution!

(ii) Elect a team leader who will carve up the design and programming tasks amongst you. It may be easier to construct an Input/Process/Output chart and delegate programming tasks from that.

Good testing practice would be to nominate an individual who willtake sole charge of testing all of the components and the finishedproduct. They can be busy making up the test cases while the restare doing the coding!

Computing: Computer Programming (H) 30

Page 34: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 2C - Arrays in Parallel

1 . Read information sheet 2B on parallel arrays and records.

2 . Answer the following questions.

(a) what does it mean to handle arrays in parallel?

(b) identify two situations where you might need to do this?

(c) in what ways can this approach be considered inefficient?

(d) what might be an alternative approach and how would a programming language need to be able support this?

3 . Investigate how to solve the following problem using arrays in parallel in aprogramming language of your choice.

Problem

A program is to be written that will display the names of the month thathave thirty days in it. The names are to be displayed in ascending, alphabetical order.

The program will accept the name of a month, followed by the number ofdays that it has. Both will be typed in at the keyboard.

Next, the program will sort the months into order (remember to perform thesame interchange operations on the days!). Finally the program will findthe occurrence of all thirty day months and display the name of those monthson the screen.

Computing: Computer Programming (H) 31

Page 35: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 2D - The Record

1 . Read information sheet 2B on parallel arrays and records.

2 . Investigate how to solve the following problem using an array of recordsin a programming language of your choice.

Problem

A program is to be written that will display the names of the month thathave thirty days in it. The names are to be displayed in ascending, alphabetical order.

The program will accept the name of a month, followed by the number ofdays that it has. Both will be typed in at the keyboard.

Next, the program will sort the months into order. Finally the program will find the occurrence of all thirty day months and display the name of those months on the screen.

3 . Find out what is meant by fixed length and variable length records.

Investigate whether your programming language allows you to workwith both types of record structure, or only one of them.

Computing: Computer Programming (H) 32

Page 36: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 2E - Sequential File Handling

1 . Read information sheet 2C on file handling.

2 . Choose a programming language that you would normally program in.Investigate and write a short report on this programming environment that allows you to:

1. assign - link the name of the file on backing storewith the name of the file within the program

2. open a file for input

3. read from the file

4. open a file for output

5. write to the file

6. append items to the file.

3 . Try and pair up with someone who looked at a different language fromthe one that you investigated and compare notes.

4 . Do tasks 1, 2 and 3 on activity sheet 2F.

Computing: Computer Programming (H) 33

Page 37: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 2F - (Assign, open, read, write, close, append)

Task 1An ASCII file is held on disk. You have been asked to write a small operatingutility that will duplicate the file. The name of the new file should be the same as the original filename with a .copy extension.

So for example, if the file was called ‘myfile’ then the copy will be called‘myfile.copy’

First design an algorithm that will perform the duplication.

Now code and test your algorithm.

Task 2

A sequential file of student records is held on disk. Each record contains the name of the student and their average exam grade for the year.

You have been asked to find the name of the student with the highest average exam grade.

First design an algorithm that will search the file for the highest exam grade.

Now code and test your algorithm.

Task 3Modify your program in task 1 so that it appends to the original file a message stating the date and time of the last update. You will need to find out how yourprogram can get the system date and time values.

Computing: Computer Programming (H) 34

marie twist 56linda thorn 92martin manson 77wilma smith 84george benson 98graham forest 63

Page 38: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 2G - Having some fun with 2D Arrays!

The Magic SquareA magic square is an NxN matrix of integers, ranging in value from 1 to N2 such that the sum of every row, column and diagonal is the same.

The figure on the right gives an examplewhere N=3 and the sum of every row, columnand diagonal is 15.

One way of generating a magic square where n is odd is to follow the steps in the algorithm given below. The diagrams to the right shows the first six entries in the magic square as each step in the algorithm is carried out.

AlgorithmStart with N=1Put the value N into middle of the top rowRepeat

beginMove one square up and to the leftTry to assign the value N+1 to this squareIf this move takes you outside then

grid wrap around the column and assignIf the square already contains a value then

move down insteadend

Until N=9

TaskTry this algorithm out in your programming environment. You will need to translate the algorithm and also write a routine to display the contents of the array to see yourmagic square

Computing: Computer Programming (H) 35

6 1 8

7 5 3

2 9 4

6+1+8=157+5+3=152+9+4=15

2+5+8=15

1

1

2

1

3

2

1

3

2 4

1

5 3

2 4

6 1

5 3

2 4

Page 39: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Lesson Sequence 3

OverviewHaving gained considerably more experience in understanding structures and file handling procedures and with more practical activity in the use of a programming environment, the student then meets a study of the aspects of the software development process detailed in unit Outcome 1. This involves a study of the purpose and features of editors, translators and debugging tools.

Suggested ActivitiesActivities involve close reading (Information sheet 3A), review questions and a focused investigation of the tools on offer within a selected programming environment (Activity 3A). The investigation requires the completion of a checklist of features, and there are opportunities for group and paired work. Assessment 1 could be issued at the end of this study.

Outcomes• knowledge and understanding of the purpose of an editor• knowledge and understanding of the purpose of debugging• activities that can take place during debugging• knowing the editing and debugging features on offer within a particular environment.

Teaching Resources (OHPs)Refer to SCCC Programming OHPs - Higher Computing 1989Specifically:

OHPT L & E 2.3a, 2.3b

Computing: Computer Programming (H) 36

Page 40: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Information 3A - Editors and Debugging Tools

DebuggingProgram debugging is connected with testing in that it uses the results of test cases to signify the presence of errors. Debugging involves the detection, location and removal of any errors within the program. A large portion of this activity will require the use of a program editor, and this use is discussed below.

The Debugging Process

Detect

Locate

Remove

Locating the errorsErrors can be due to faulty logic within the program, where it does not really carry out the requirements of the original problem specification, and a good test approach can help to highlight any such errors. One approach you may have met in Software Development (H) is to document, in advance of testing, the test cases that are going to be used, together with the expected result and the actual result.

Close examination of this structured listing should follow. A successful approach will be to to find out where exactly in the program the errors are happening be. What module contains the error, is it a particular line of code that is not working correctly? Has a variable been given an incorrect value etc.?

Programmers tend to look at code as if its operation is what it should be doing, rather than what it is doing. It is always a good idea to get a small team together and perform a structured walkthrough of the code logic. It is sometimes easier for someone who has not written the original code to spot any mistakes.

Code inspection on its own is not enough to locate all possible errors in a program. For example, it may be the case where errors in the code do not cause immediate failure of the program, or produce invalid test results. The best way to deal with this nature of error is to use a trace facility. This allows the programmer to inspect the values of variables and follow through the logical execution of the program.

Computing: Computer Programming (H) 37

Test Cases Expected Result Actual Result

Page 41: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

One commonly used technique is to include program statements which print important data values at appropriate places in the program. By looking at the values of, say a variable, at one print statement, and then again later on in the program at another print statement, you can deduce that the error must lie somewhere in the logic between the two prints.

This can be a laborious and time consuming task which involves continuous editing and recompilation of the code. It is probably better to anticipate errors in the code and write these traces into the source as it is being built in the first place. You will need to remember to remove all such traces from your code when it is finally delivered to your clients.

Some systems provide a compiler directive that allows you to switch the output statements on or off. Simply recompile the source with a different directive when you need to produce the final version.

Because of the problems associated with putting traces into your software, some programming environments provide such functions as part of their software development tools.

Memory dumpsThe most crude and primitive aid is the core dump. Not commonly used, but we will refer to it here for the sake of completeness. This is a complete listing of the memory contents at the point when the error manifested itself. They are painful and laborious to read, and as they provide little information with reference to the original source program, they are really of little value in the debugging process to those of you who may have programmed in a high level language.

The second, and more useful tool is the symbolic dump. It can take two forms, interactive and batch. In the batch mode the dump contains a listing of all variable names and their values, either at the end of the program or when the programmer has included a statement at which point a dump is to be taken. A properly structured dump will separate global and local variables, allowing the programmer to focus on particular module behaviour. The symbolic dump is more useful than the core dump, but it still produces an incredible amount of information, most of which is not really relevant to the error that you are trying to trace.

Interactive symbolic dumps allow you to specify the value of particular variables by name, thus allowing you to concentrate upon a trace of one or two values within your program.

Symbolic dumps are useful at providing information on program values once the program has completed execution, but does not give information about the program as it is running. To do this you need to look at more flexible tracking tools. These tools are known as trace packages.

Trace PackagesThis software allows you to track the values of a variable, monitor procedure calls and exits and observe control transfer such as branches executed within an if..then..else construct. The information is dynamic, i.e. it changes as the program is running.

Using such a tool obviously brings with it compromises in memory and speed. They have the potential to generate enormous quantities of information and unless they are switched on and off with care and precision, they can produce unmanageable amounts of output, and simply add to the time required to debug the program.

Computing: Computer Programming (H) 38

Page 42: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 3A - Exploring Editing and Debugging Tools

1 . Ask your teacher/lecturer for the SCCC, Higher Computing materials:

Programming - Languages and Environments (Information)

(i) In small groups read and take notes on the Information bookletpp 2-6.

(ii) Decide as a group whether the language you have been usingwould be considered a special or general purpose language? Why?

(iii) Discuss in your group where on the spectrum of 1st through to 5thgeneration languages your programming language belongs. Justifywhy you think that this is the case.

(iv) Still in your groups, read and take notes from the Information Sheet3A on Editors and Debugging Tools. Answer the following questions: (a) What are the three stages involved in debugging?(b) Name three debugging tools that a programmer can use.(c) Why are core and symbolic dumps not as popular as traces?(d) What do you use an editor for?(e) What is the difference between a screen and a line editor?

2 . Individually, do task 2 on page 2 of the task booklet, Programming - Languages and Environments, writing your report as you go along.

3 . Regroup and discuss your findings. Nominate a group leader who willfeedback a summary of your findings to your teacher/lecturer.

Computing: Computer Programming (H) 39

Page 43: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Lesson Sequence 4

OverviewSearching and sorting techniques are now introduced within the context of analysing the efficiency(memory and order) of various sort and search algorithms. There is opportunity for group activity and group reporting sessions. Students should be encouraged to build module libraries, particularly with binary search and insertion sort, that can be used later in Assessment 4.

You should have available a set of sort routines - see activity 4B which students can benchmark to show timings and number of comparisons for each algorithm.

Suggested ActivitiesActivities include carrying out a comparative study of a range of sorting and searching algorithms, reporting, and practice in structured walkthroughs (Activities 4A and 4B).

To supplement the SCCC, Higher Computing materials on Further Algorithms, two information sheets have been written (Information 4A and 4B). These explain in a little greater detail the complexity of algorithms and how to calculate their memory requirements.

Outcomes• knowledge and understanding of search algorithms on simple lists• comparison of binary and linear search on simple lists• knowledge and understanding of sort algorithms on simple lists• comparison of list sort algorithms in terms of memory use and

processor time• practical experience of establishing module libraries and exploring

how the programming environment supports them.

Teaching Resources (OHPs)Refer to SCCC, Higher Computing Programming OHPs - Higher Computing 1989. Specifically: OHPT FA 1.1 through to 7.1

Computing: Computer Programming (H) 40

Page 44: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 4A - Searching

1. Read SCCC, Higher Computing - Further Algorithms on Linear and Binary Search methods, copying down the algorithms and taking note of how they work.

2. (a) Set-up the following list as an array within your programming environment.

23 46 77 99 101 250 300 310 420

(b) Use a linear search to find the values below. Copy and complete thetable:

(c) What can you say about the number of comparisons as the size of thelist increases? What would you say was the worst case, the best case and the average case?

(d) Do the same task, only this time write a binary search routine.

(e) What can you say about the number of comparisons as the size of thelist increases? What would you say was the worst case, the best case and the average case?

Computing: Computer Programming (H) 41

Value Position in list Number of comparisons

2 3

4 6

7 7

9 9

101

250

300

310

420

- 1

500

Page 45: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 4B - Sorting

1. Read SCCC, Higher Computing - Further Algorithms on the sort methods listed in the table below. You will be using these algorithms at a later stage, but for this task, simply note how they work.

2. In small groups, run the test programs that your teacher/lecturer will provide you with for the four sorting algorithms below and complete the table:

Technique Selection Selection- Exchange Quicksort

Exchange

Completion time (secs)

Memory Required

Number of passes

(N Items)

Total comparison

(N Items)

Simplicity of

Coding

Appropriate to what

size of list?

Computing: Computer Programming (H) 42

Page 46: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Information 4A - Appreciating the order of an algorithm

When you decide to use a particular algorithm then you must be aware of how much time it will take to execute on the machine that you will be using. You may wonder how this can be figured out in advance of actually running the program.

One way to get a measure of this is to step through the algorithm. You will have realised in using sorts and searches that these algorithms have an order i.e. a complexity that is expressed as a mathematical function.

For instance, the algorithm might have an order of log n, or n, or n3. Developers of these algorithms have already worked out their complexity for you and so you needn’t worry about having to do that. But what does it mean to say that an algorithm has a complexity of n3?

The table below maps out for you some common functions that may apply to an algorithm’s complexity. Notice the relationship between the size of the list n and the value that the function returns.

You can see that algorithms which have a complexity of 2n, or n raised to some high power, such as n10 are of little value. It will simply take far too long for the computer to process the information.

Imagine that you have a machine able to carry out one step of the algorithm in a millionth of a second. The last column, where the complexity is 2n and n=32 would take 71.58 minutes to complete.

The size of the list here is relatively small. Increase this to a real-world application and you may be talking of light years of computation time!

Computing: Computer Programming (H) 43

log n n n log n0 1 0 1 1 2

1 2 2 4 8 4

2 4 8 1 6 6 4 1 6

3 8 2 4 6 4 512 256

4 1 6 6 4 256 4096 65536

5 3 2 160 1024 32768 4294967296

n2 n3 2n

Page 47: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Information 4B - Appreciating the memory requirements of an algorithm

When you analyse the performance of an algorithm then you must also take into account not only the order(complexity) of it, but also the amount of memory that it needs. This typically includes the instruction space (i.e. the space for the code), space for simple variables and fixed-sized structured variables (such as arrays), the space for constants, and so on.

Clearly this measurement of memory requirements will be very problem specific, and it is best to illustrate the calculations with reference to particular examples.

Example 1

Algorithm

sum := 0;for index := 1 to n do

sum := sum + list[index]

This simple algorithm adds together all the numbers in a fixed sized list structure which has dimension 1 to n of type integer.

The space needed is:

arraysize : 1 word (it is of type integer)list : n words (since the list can hold n elements to be summed)sum : 1 wordindex : 1 word

Total space requirements = n+3 words.

Q . Work out the space requirements for the binary search algorithm.

Q . How does this compare with the space requirements of the linear searchalgorithm?

Q . What would be the space requirements using an array of floating pointnumbers?

Computing: Computer Programming (H) 44

Page 48: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Lesson Sequence 5

OverviewUp to this point, the practical activities undertaken have been relatively small scale, requiring the student to code small modules or groups of modules.

It is time now to pull together the learning and try to set problems in contexts within which the student(s) will have to follow through all of the necessary stages of software development and integrate their learning from previous outcomes.

It is suggested that the problem-solving activities be carried out by small teams of programmers. This will allow a realistic model of a programming environment to be set up. Students can be encouraged to take on particular responsibilities namely chief programmer, tester, debugger, etc., although all should take part in the initial analysis and design stage as a team.

The qualities of a good HCI can be explored, drawing upon Software Development (H), Outcome 1. Direct experience of software evaluation is carried out in activity 5A.

It would be appropriate to issue assessment 4 at the end of this lesson sequence.

Suggested ActivitiesThis series of activities will be teacher led, working with the class as a whole, but with small groups for investigations and brainstorming sessions. Some ideas are:

(1) Emphasise the key stages in the development of a software solution, drawing from Languages and Environments - Information booklet pp 10-16 and the core unit Software Development (H). Use OHP resources from SCCC Programming pack - Higher Computing, 1989, OHPT 1.1, 1.2, 2.1

• Encourage the use of module libraries already constructed forsorting and searching within Activity 5C. Discuss as a class the effect that precompiled routines have on development time, maintainability and reliability. Refer back to Outcome 1 of Software Development(H).

• Explore the nature of a good HCI. Using Activity 5A.

• Examples of poor developmental practice would bring into focus the need for planning, formal specifications, review, program structure etc. Refer to SCCC Programming OHPs - Higher Computing, 1989 OHPT L&E 2.4, 3.1, 3.2

• Having programmed in a high level language the teams could be encouraged to think about alternative development environments. Pulling in the themes of the Higher course of levels of language, selection according to suitability, objects and operations etc. Students could be encouraged to think of providing alternative solutions in GPPs or another high level language. What would be the immediate advantages? What are the drawbacks, if any? Activity 5B.

• Looking at how software teams can be organised, test strategies that can be used and the development tools required. Encourage teamwork in activities 5C and 5D.

Computing: Computer Programming (H) 45

Page 49: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Depending upon time available, further work could include:

• discussions of current software developments and any issues that have surrounded their development/release/maintenance.

• In relation to project management, teams could draw upon their direct experiences in having to cooperate and work together. The use of systematic test approaches could be emphasised and students encouraged to talk directly about how this influenced the manner in which their team had to work. Current developments in rapid application generators could be introduced, focusing on factors such as rapid prototyping, the HCI and reliability.

• Computer Aided Software Engineering tools (CASE) could be explored and the need for better project management tools highlighted.

Computing: Computer Programming (H) 46

Page 50: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 5A - The Human Computer Interface

1 . In small groups do task 3 in the booklet SCCC Programming - Languages and Environments.

2 . Still working in your groups prepare a talk that will last for 5 minutes onwhat you have discovered in the above software evaluation. You shoulduse the following headings:

Name of Package

Screen Layout

Prompts

On-Line Help

Error Messages

Memory Requirements

Response Time

Nominate a person in the group who will stand up and give the presentationto the rest of the class.

3 . Suggest possible improvements to the HCI under these headings.

4 . How does your group think that the HCI of this package could be changed to suit people with specific learning difficulties or disabilities?

Computing: Computer Programming (H) 47

Page 51: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 5B - Comparison of High Level Languages

1 . In small groups do task 1 in the booklet SCCC Programming - Languages and Environments.

2 . (a) Still working in your groups prepare a talk that will last for 5 minutes onwhat you have discovered in comparing the two languages. Constructa table showing the differences. Your teacher/lecturer will copy this on toan OHP.

(b) Nominate a person in the group who will stand up and give a presentationon your group’s comparison.

3 . Decide as a group whether either of your programming languages would besuitable for the following tasks. Justify your decisions.

(a) A library information system that would log the borrowing andreturn of books.

(b) A computer game, supporting 3D animation and colour.

(c) A CAD package that would allow the user to model integratedcircuits.

(d) A swipe-card system that would monitor student access to securedcomputing areas within your organisation.

(e) A multi-media program that would teach 5 year olds how to speakFrench.

(f) A program that will plot a graph of a mathematical function.

(g) A program to control the room temperature within a distillery.

Computing: Computer Programming (H) 48

Page 52: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 5C - Larger Scale Problem 1

Working as a small programming teamIn this task you will follow through all stages of the software development process, from analysis to testing and debugging. You should document each stage as you develop it, and meet with your teacher/lecturer at regular intervals to check on your progress.

ProblemA manufacturer of household electrical goods is considering the possibility of managing her customer accounts using a computer. She approaches you with the following requirements:

I need a system that will allow me to store at least 100 customers’ details. Icurrently hold information on the name, address, customer order number, amount due, and date of payment.

Each week I would like to make an enquiry on which customers have not settled their account with me. At the moment I simply look through all the customer accounts and compare the day’s date with the date of payment to find out who still owes me money.

I would like to have a simple way of keying-in all of my customer details. It would also be really useful if I could key-in a customer order number and the computer would display all the details on the screen for that customer.

I’m sure that this could be done a lot quicker if I had a computer. Could you write a program for me that would do this?

TaskDevelop a program that will manage these accounts. You will need to look at doing the following:

(a) Allowing the user to key-in a list of customer details(b) Storing customer details in a file on disk(c) Reading these details from the file and storing them internally(d) Finding out which customers have accounts that are unpaid(e) Using a search method that you know of to find details(f) Commenting upon the efficiency of memory use, and the

efficiency of the search algorithm that you have used.

Computing: Computer Programming (H) 49

Page 53: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Activity 5D - Larger Scale Problem 2

Working as a small programming teamIn this task you will follow through all stages of the software development process, from analysis to testing and debugging. You should document each stage as you develop it, and meet with your teacher/lecturer at regular intervals to check on your progress.

ProblemA local newsagent is thinking of using a computer to assist with the arrivals, collation and distribution of newspapers and periodicals which arrive at his shop each day.

I need a system that will allow me to store details on at least 20 different typesof newspapers and magazines. I tend to vary the amount that I order of eachtype, but there should be no more than 100 or so newspapers ordered for each day and around 10 of each periodical.

Each week I would like to setup the rota of delivery for the week ahead. I have3 delivery boys who deal with 6 different newspapers and deliver to around50 customers each.

I would like to have a simple way of keying-in all of my newspaper and periodical details and assigning a newspaper boy a set of newspapers and a list of customers.

I would also like a rota that would change each boy’s schedule every month.

I’m sure that this could be done a lot quicker if I had a computer. Could youwrite a program for me that would do this?

TaskDevelop a program that will manage these accounts. You will need to look at doing the following:

(a) Allowing the user to key-in a list of newspaper and periodical details(b) Storing these details in a file on disk(c) Reading these details from the file and storing them internally(d) Setting up the delivery details for each newspaper boy(e) Working out a rota that can change each month(f) Commenting upon the efficiency of memory use, and the

efficiency of the sort algorithm that you have used.

Computing: Computer Programming (H) 50

Page 54: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Lesson Sequence 6

OverviewThis section of the unit prepares students for the Investigation.

Two support resources have been developed that you will find useful for this section. These are:

Higher Investigation - Guide for Teachers/Lecturers

Higher Investigation - Guide for Candidates

Computing: Computer Programming (H) 51

Page 55: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Computing: Computer Programming (H) 52

Page 56: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Section 4

Additional Review Questions

Computing: Computer Programming (H) 53

Page 57: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Computing: Computer Programming (H) 54

Page 58: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Outcome 1 - Review Questions

1. Explain what is meant by the term debugging and describe the threestages that it involves.

2. State two differences between a line editor and a screen editor.

3. Explain why the use of debugging tools such as traces can help to speedup software development.

4. A linear list is to be created containing 10 elements of type string.

Write down the algorithm to:

(i) add an item to the list(ii) remove an item from the list.

5. On large lists, the linear search method can be slow and inefficient.Suggest an alternative search method and describe how it works.

6. Name two sorting techniques and explain their differences with respect to number of comparisons, time taken to complete and numberof passes (assume a list size of 1000).

7. Suggest two reasons why sort and search algorithms are normallyavailable to programmers within module libraries.

8. How do you work out the memory requirements of an algorithm?

9. What is a dry run and explain why it is a useful method of debugging software?

Computing: Computer Programming (H) 55

Page 59: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Outcome 2 & 3 Review Questions

1. What is a 2 Dimensional array structure?

2. Explain how matrices in mathematics could be modelled quite effectively using 2 Dimensional arrays.

3. Explain the difference between a queue and a stack data structure.

4. Name three file handling operations and explain their purpose.

5. State the difference between sequential and random file access methods.

6. Describe two applications of 1 dimensional arrays in parallel.

7. Suggest a suitable data structure that will model the applications receivedby your local University (look at an UCAS form to see the nature of theinformation supplied).

8. Recommend a suitable file access method for (7) and justify yourchoice.

Computing: Computer Programming (H) 56

Page 60: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Outcome 4 Review Questions

1. List in the correct order the stages of software development.

2. State the purpose of each stage.

3. Describe two methods of representing program design and explainwhy the two methods differ.

4. Explain what is meant by systematic and comprehensive testing.

5. A program has been written to find the maximum in a list of 10 integers.Construct three test cases and explain why you have chosen them.

6. Construct two test cases for the following algorithm:

set found to falseset current position to head of listwhile not end of list and not found do

if list[current position] = item looking for thenset found to true

elseincrement current position

7. Name three high level languages and state one difference between each.

8. State one special purpose language and give an example of where itcan be used.

9. Explain is meant by the terms maintainable, robust and portable.

10. Explain one method of analysing the performance of an algorithm.

Computing: Computer Programming (H) 57

Page 61: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Computing: Computer Programming (H) 58

Page 62: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Section 5

Bibliography

Computing: Computer Programming (H) 59

Page 63: &RPSXWLQJ - Kirkintilloch High School work can focus on small-scale case studies exploring the issues of good and bad ... learning of unit outcomes. ... preparing a report or giving

Further Reading on the Outcomes

Title Author Publisher

Software Engineering (5th Ed)* I, Sommerville Addison-Wesley

Software Engineering for Students Coleman and Pratt Chartwell-Bratt

Software Engineering - A Practitioner’s Pressman McGraw-HillApproach

Computer Algorithms Horowitz Computer SciencePress

Programming Language Woodman (Ed) ThomsonChoice - Practice and Computer PressExperience

Understanding Computer* Bradley StanleyScience (3rd Edition) Thornes

Systems Analysis and Design* Davis Addision-Wesley

The Mind Tool (4th Ed) Graham West PublishingCompany

Problem Solving and* Sprankle Prentice HallProgramming

Introduction to Algorithms Cormen MIT Press

The Social and Interactional Thomas (Ed) Cambridge PressDimensions of Human ComputerInterfaces

* = highly recommended

Computing: Computer Programming (H) 60