Pages

20.8.11

Summary

  1. We discussed forms of data and processes relevant to an electronic till in a supermarket. In particular, we introduced the idea of a sequence of data items.
  2. A number of fundamental forms of data were introduced. We distinguished two types of number: integers (positive or negative whole numbers, or 0), and real numbers (thought of as decimal numbers and approximated in computers as floating point numbers). Characters may be thought of as symbols that may be entered from a computer keyboard by a single keystroke. Each character is associated with an integer code and we introduced one such encoding called the ASCII code. The Boolean values true and false form another fundamental form of data.
    Data may be structured in a collection. Different forms of collection are possible. We looked at two: sets and sequences. In a sequence, the order in which the items appear in the collection is important and an item may appear more than once. In a set, one is only interested in the different items appearing in the collection, and the order in which these items are listed is of no significance, nor is repetition of an item.
    The Cartesian product of sets X and Y is written X × Y , and is the set consisting of all ordered pairs (x, y), where x is in X and y is in Y . An ordered pair is also called a 2-tuple. More generally, an n-tuple is an association of n items, each taken from a specified set. An n-tuple is written in round brackets, and is a member of a Cartesian product set combining n component sets. For example, a member of the set Int × Char × Int × SeqOfChar would be a 4-tuple, such as (121, ‘y’, 6, “Qwerty”).

Exercises on Section 5

Exercise 12

Give a full description of a function (using the infix notation ×) corresponding to multiplication of integers.

Answer

Solution

A suitable description of integer multiplication is given below.
function (infix) (x × y on Int) return in Int
pre   true.
post   The returned value is the result of multiplying x and y.

Exercise 13

With n = 966, evaluate each of:
(a) MOD(n, 10);
(b) DIV (n, 10);
(c) MOD(DIV (n, 10), 10).

Answer

Solution

966 = 96 × 10 + 6. So (a) MOD(966, 10) = 6 (the remainder when 966 is divided by 10), and (b) DIV (966,10) = 96. Then (c) MOD(DIV (966, 10), 10) becomes MOD(96, 10). This evaluates to 6, which is the remainder when 96 is divided by 10.

Exercise 14

The function LAST is described below.
function LAST(s in SeqOfX ) return in X
pre   s is not empty.
post   The returned value is the last element in s. For example, LAST([1, 2, 3]) = 3.
Consider the expression NOT(LAST(s) = Char LAST (t)).
  • (a) What is the value of this expression if s is “the” and t is:
    • (i) “same”;
    • (ii) “different”?
  • (b) Under what circumstances does this expression have the value true?
  • (c) Is this expression valid with s = [1,2] and t = [1,8,4,2]?

Answer

Solution

(a) If s = “the” then LAST(s) = ‘e’. (i) With t = “same”, we have LAST(t) = ‘e’, and the given expression becomes
NOT(‘e’ =Char ‘e’) = NOT (true) = false.
(i) With t = “different”, we have LAST(t) = ‘t’, and the given expression becomes
NOT(‘e’ =Char ‘t’) = NOT (false) = true.
(b) The given expression is true if the strings s and t have different last letters.
(c) With these values of s and t, the given expression becomes NOT(2 =Char 2). Now =Char compares two characters, and 2 is an integer. So this expression is not valid. (For the given expression to be valid, we need s and t to be sequences of characters, and to be non-empty, so that the precondition of LAST is satisfied.)

Objectives for Section 5

After studying this section you should be able to do the following.
  • Recognise and use the terminology: binary operation, infix notation, quotient and remainder (associated with integer division).
  • Use the notation for various binary operations introduced in the text, in particular DIV and MOD on integers; and ∧ (and) and ∨ (or) on Boolean values.
  • Suggest appropriate signatures and preconditions for functions corresponding to binary operations, including comparisons that return Boolean values.
  • Evaluate expressions involving functions and binary operations introduced in the text. Take note of where brackets appear in an expression.
  • Recognise an expression that is invalid because it uses a process in a way inconsistent with its signature or precondition.

5.4 Expressions

In computer code, one may want to formulate an expression to achieve some particular purpose, such as to express some condition about the states of variables involved in the code. For example, suppose that you want to express the condition that a sequence s contains at least two members, and that the second member of s is not the space character (with ASCII code 32). This condition holds when the expression below is true.
(SIZE(s) > Int 1) ∧ (NOT(ASC(AT(2,s)) = Int 32))
When writing expressions involving functions and binary operations, there are some points to be careful about. One needs to be careful to use brackets as necessary to ensure that operations are applied in the desired order. This is particularly important in expressions using infix notation. You also need to apply each process in a way that is consistent with its signature. And you must apply each process in a way that is consistent with any precondition that it has. We say that an expression is not valid if it uses a function in a way that is inconsistent with its signature or its precondition. For example, ‘Q’ = Int 32 is not valid, since = Int compares two integers, and ‘Q’ is a character, while PUT(7, “This”, ‘Q’) is not valid, since 7 does not satisfy the precondition of PUT. (The precondition of PUT requires that 7≤ SIZE(“This”), but SIZE(“This”) is 4.)
The functions SIZE and AT were described in Activity 16, and the function ASC was described in Section 4.3. The binary operations = Int , > Int and ∧ are defined earlier in this section.

5.3 Comparison functions

Another situation where we use infix notation is in writing comparisons, such as x < y, where x and y are numbers. Such a comparison is either true or false. For example, 5 < 9 is true but 5 < 2 is false. To describe a corresponding function, we take the output set to be Bool = {true, false}. Thus the comparison < on integers corresponds to a function, which we can describe as follows.
function (infix) (x < Int y on Int) return in Bool
pre   true.
post   The returned value is true if x < y and is false otherwise.
Equality is also a comparison function. This is normally written using the infix symbol =. If x and y are numbers, then x = y is true if the numbers x and y are the same and is false if they are not. If one is working with real numbers on a computer, then one needs to be very careful with tests of equality. There will be an element of approximation in the way real numbers are stored, and this may result in a computer reporting real numbers as equal when they are only approximately equal. However, we shall confine our attention to integers, where there is no such problem in deciding whether two numbers are the same.
Sometimes we may wish to test to see whether two characters are the same. (This can be done by comparing their ASCII codes, for example.) A computer will need to work in a different way when comparing two integers for equality from that needed when comparing two characters for equality. These are different processes. Equality of numbers is a function with signature Int × IntBool; equality of characters, on the other hand, has signature Char × CharBool. Since these are different functions, we will give them different identifiers. We will write = Int for equality of integers and = Char for equality of characters.

5.2 Operations on Boolean values

The idea of a binary operation, and the use of infix notation, is not confined to numbers. Infix notation may be used for any process with two inputs from the same set. We look now at two binary operations on Boolean values that are often used.
The first of these takes two Boolean values, and returns true if both of the input values are true and returns false otherwise. It is a binary operation, and we shall write it using the infix notation ∧, where the symbol ∧ can be read as “and”. So ab is true only when a and b are both true. We can describe the function corresponding to this operation as below (The operation ∧ is also known as conjunction).
function (infix) (ab on Bool) return in Bool
pre   true.
post   The returned value is true if both a = true and b = true, and is false otherwise.
Alternatively, we could give the semantics of ∧ by listing the returned value in each of four cases, giving the four possible combinations of input values. Using this approach, we could express the postcondition as follows.
post The returned value is c, where

5.1 Arithmetic operations

Processes such as addition of numbers are called binary operations. (The word “binary” here reflects the fact that a binary operation combines two data items.) A binary operation is a particular form of function. To see this, we need to recognise the appropriate signature.
If you add two integers, then the resulting value is also an integer. So addition of integers takes two integers and returns an integer value. Thus adding integers is a function with signature Int × IntInt. We can add any two integers, so addition is a total function (that is, has precondition true). We can describe a function, +, corresponding to addition of integers, as below.
function (infix) (x + y on Int) return in Int
pre   true.
post   The returned value is the result of adding x and y.
Where we use infix notation to write the value returned by a function, we will set out the signature line in the function description in a slightly different way from that used in Section 4, as illustrated above.

5 Operations and comparisons: Seeing processes as functions

Addition of numbers is a process that one would expect a computer to be able to perform. Now we write the result of adding the numbers 5 and 2 as 5 + 2, for example. The symbol +, which represents the process of addition, appears between the two numbers being added. This is known as infix notation. Infix notation may be used for processes that combine two data items of the same type. Addition, subtraction and multiplication of numbers are familiar examples. We also use infix notation when writing a comparison of the size of two numbers, such as 5 < 9.
In this section, we shall show that a process such as addition of numbers is a function. Perhaps more surprisingly, a process such as < can also be seen as a function. This perception is a necessary preliminary to seeing how such a process can be implemented by a computer.

Exercises on Section 4

Exercise 9

For each of the following functions, give the signature and suggest a suitable precondition.
  • (a) TOUPPER, which changes a string, containing only lower-case letters, into the corresponding string consisting of upper-case letters. (So, for example, TOUPPER(“word”) = “WORD”.)
  • (b) REMOVELAST, which, given a sequence, deletes its last member.
  • (c) LAST, which returns the last member of a sequence.

Objectives for Section 4

After studying this section you should be able to do the following.
  • Recognise and use the terminology: function, signature, domain, semantics, input set, output set, precondition, postcondition.
  • Suggest appropriate signatures and preconditions for functions corresponding to a variety of processes on numbers, characters and sequences, including those with more than one input and those that return a Boolean value.
  • For given inputs, give the value returned by various functions described in this section, in particular: AT, PUT, SIZE, ASC, CHR, ADDLAST.

4.4 Functions returning true or false

Consider a function, say ISIN , associated with following process.
Given a character and a string, determine whether the character appears in the string.
This function has two inputs, a character and a string (sequence of characters), so we can take the input set to be Char × SeqOfChar. But what is the output set? If the character does appear in the string, then the function can return the value true, and if the character does not appear in the string, then the function can return the value false. So a suitable output set is Bool. Then ISIN has signature Char × SeqOfCharBool. We can describe the function ISIN as below.
function ISIN (c in Char, s in SeqOfChar) return in Bool
pre   true.
post   The returned value is true if the character c appears in the sequence s at least once, and is false if c does not appear at all in s.
(If s is the empty string, then it contains no characters, and ISIN (c, s) will be false whatever the character c is.)

Activity 20

Suggest a description for a function ISEMPTY corresponding to the following process.
Determine whether or not a given sequence is empty.

4.3 Character code functions

Many programming languages provide two functions associated with the character codes (see Table 2). We shall call these functions ASC and CHR. ASC takes a character as input, and returns the integer giving the ASCII code of the input character. CHR returns the character whose ASCII code is the input integer. These functions are described below. We have set a precondition on CHR to conform to our earlier restriction on the set of characters that we will consider in this unit.
function ASC(c in Char) return in Int
pre   true.
post   The returned value is the ASCII code of c, as given in Table 2.
function CHR(n in Int) return in Char
pre 32 ≤ n ≤ 126.
post The returned value is the character with ASCII code n, as given in Table 2.

4.2 Functions defined through cases

In each of the examples considered so far, the function has had its semantics expressed using a formula or a general rule. Some functions have their semantics expressed simply by listing the output for each possible input. For example, let Days be the set of days of the week, and the function TOMORROW have signature DaysDays, and return the day following the input day. If we represent Days using the strings {“Mon”, “Tues”, “Wed”, “Thurs”, “Fri”, “Sat”, “Sun”}, then we can describe the corresponding representation of the function TOMORROW as below.
function TOMORROW1(d in SeqOfChar) return in SeqOfChar
pre d is in the set {“Mon”,“Tues”,“Wed”,“Thurs”,“Fri”,“Sat”,“Sun”}.
post The returned value is t, where:
  • if d = “Mon” then t = “Tues”
  • if d = “Tues” then t = “Wed”
  • if d = “Wed” then t = “Thurs”
  • if d = “Thurs” then t = “Fri”
  • if d = “Fri” then t = “Sat”
  • if d = “Sat” then t = “Sun”
  • if d = “Sun” then t = “Mon”.
We distinguish the abstraction (the function TOMORROW) from its representation (the function TOMORROW1), because different representations of the set Days will lead to different representations of the function TOMORROW (see, for example, Exercise 2).

4.1 Functions

A function is a process that, when given an input of a specified type, yields a unique output. This is a key idea in providing a precise, mathematical, description of processes in computing.
To describe a particular function, we first give the set from which the input will be drawn and the set from which the output is drawn. This information is called the signature of the function. An example will make this clearer. Example 1(b), on the previous screen, requires an input that is a string, that is, a sequence of characters. The set containing all possible sequences of characters is SeqOfChar. Example 1(b) produces an output that is a character, so this output is in the set Char. We write the signature of this function as SeqOfCharChar. The set to the left of the arrow is called the input set of the function and the set to the right is called the output set. Some texts use source set rather than input set, and target set rather than output set. It is usual to include an identifier for the function itself in the signature. Suppose we call this function FIRSTCAP. Then its full signature is:
FIRSTCAP: SeqOfCharChar.

4 Processes: Processes that can be applied to data

Having looked at some forms of data, we now turn our attention to processes that can be applied to data. Each process that we consider in this section will input data of a specified form, and will result in a corresponding value. For example, one process, which we will call ASC, takes a character as input, and has as its resulting value the integer giving the ASCII code of the input character (as listed in Table 2). Another process, which we will call SIZE, takes a sequence as input, and has as its resulting value the length of the sequence (which will be an integer).
It is important to distinguish between a description of the outcome required when a process is applied to a form of data, and a description of the exact steps to be taken to achieve the desired outcome. Here, we are concerned only with the first of these; that is, with providing an overview of a computing process. You might like to think of this as a “black box” view of the process. We do not, at this stage, care how one obtains the output value.

Exercises on Section 3

Exercise 7

Each of (a)–(c) is a member of one of the sets given in (i)–(iii). Say which item comes from which set.
Sets: (i) SetOfSeqOfChar. (ii) SeqOfSetOfChar. (iii) SeqOfSeqOfChar.
  • (a) {“error1”, “error2”, “error3”}.
  • (b) [“error1”, “error2”, “error3”].
  • (c) [{‘e’,‘1’}, {‘T’}, {‘q’,‘w’,‘e’,‘r’,‘t’,‘y’}].

Answer

Solution

  • (a) This is a set, as shown by the outer curly brackets. Each member of this set is a string, that is, a sequence of characters. So (a) is a set of sequences of characters. It is a member of SetOfSeqOfChar.
  • (b) This is a sequence, as shown by the outer square brackets. It is a sequence of strings. So (b) is a sequence of sequences of characters. It comes from SeqOfSeqOfChar.
  • (c) This is again a sequence. Each member of this sequence is a set of characters. So (c) comes from SeqOfSetOfChar.

Exercise 8

Let Mix be the disjoint union Int Char. What is the length of the following sequence from SeqOfMix?
[555, ‘5’, ‘5’, ‘5’, 11, 1].

Answer

Solution

There are six items in the sequence [555,‘5’,‘5’,‘5’,11,1] (three integers and three characters), so the length of this sequence is 6.

Objectives for Section 3

After studying this section you should be able to do the following.
  • Recognise and use the terminology: disjoint union; power set (of a set); representation (of a data abstraction).
  • Use and interpret the notation:
    • X Y for the disjoint union of the sets X and Y ;
    • SeqOfSetOfInt for the set consisting of all sequences whose members are sets of integers (and similar notations).

3.4 Representing data in applications

Suppose that you are designing software for some application. You will be working with a programming language that enables you to communicate instructions to a computer. In this programming language, certain forms of data will already be represented electronically. These will include common forms of data, such as numbers, characters and sequences. In any particular application, you are likely also to be concerned with forms of data that are peculiar to that application. Having identified some form of data that you need to be able to handle, you will then need to represent this in terms of what is available; that is, in terms of forms of data that have already been represented electronically.
As a simple example, imagine that integers, characters and strings are available forms of data, and that you want to represent the days of the week.
One natural form of representation is as strings: “Monday”, “Tuesday”, “Wednesday”, and so on. But other forms of representation are possible. The full names can be inconvenient because they involve a lot of writing, so one might choose to use shortened versions, such as: “Mon”, “Tues”, “Wed”, etc. We could be awkward (from the viewpoint of an English speaker), and use the strings: “Lundi”, “Mardi”, “Mercredi”, and so on. Or we could use integers, and represent Monday as 1, Tuesday as 2, Wednesday as 3, etc. This might be very convenient at times, but one then needs to remember which number represents which day.
There are times when it is important to distinguish between a form of data derived from an application situation and the concrete representation you have chosen for it. We might refer to the idea of the days of the week as an abstraction, in distinction to their representation, perhaps as the strings “Mon”, “Tues”, “Wed”, etc.

3.3 Mixing different forms of data: disjoint union of sets

At the supermarket checkout, some items need to be weighed (organic courgettes for example) and some do not. Let BarcodedItems be the set of items that do not need to be weighed, and WeighedItems be the set of items that must be weighed. When a weighed item is recorded at the till, we must record both the item type and the weight of the item that has been purchased. Earlier, we saw that such a purchase can be seen as an ordered pair, such as (“WALNUTS”, 335), that comes from the set WeighedItems × Int.
Suppose now that we want to form the set of all items that might appear in a transaction at a till. We might call this set TillItems. Specifying this set TillItems poses a complication, since there are two different types of element that might appear in it. An item from the set TillItems will come either from BarcodedItems or from WeighedItems × Int. We express this relationship by saying that TillItems is the disjoint union of BarcodedItems and WeighedItems × Int. We write this as:
You can read X Y as “X or Y.”
TillItems = BarcodedItems (WeighedItems × Int).
In general, the disjoint union of sets X and Y , written X Y , is the set consisting of all items that are either from X or from Y . The term “disjoint” reflects the fact that an item could not come both from BarcodedItems and from WeighedItems × Int. These sets contain different forms of data and have nothing in common. (We will only use disjoint union to combine sets containing different forms of data.)
As in Section 1, suppose that till1 is a variable representing a transaction in progress at till 1. The state of till1 will give the items recorded so far, in the order in which they were entered into the till, either by reading the barcode, or as a weighed item. So we can describe the state of till1 as a sequence of till items. The set of all possible states of till1 is SeqOfTillItems, where TillItems is BarcodedItems (WeighedItems × Int).
As noted earlier, we usually want to avoid mixing data of different forms in a collection such as a sequence. But if we need to do this, we can first use a disjoint union to combine the different forms of data into a single set. So, for example, if we needed to form a sequence whose members might be either characters or integers, then this sequence would come from a set SeqOfMix, where Mix is the disjoint union Int Char.
Search Amazon.com for Data and processes in computing,

3.2 Combining data structures

Search Amazon.com Books for Data and processes in computing,
In Section 2, we introduced the notation SeqOfX for the set of all sequences whose members come from the set X. In Section 2, we looked only at sequences whose members were of one of the primitive forms of data (integers, characters or Booleans). We can have sequences whose members are themselves data with a more complicated form. For example, suppose that Jo is working at the till T1 and is replaced by Jessica. We might represent this handover by the 3-tuple (Jo, T1, Jessica). Now suppose that we want to give all the handovers that occur during a particular day, in the order in which they occur. We could give this information in a sequence. This sequence would come from the set SeqOfX , where X is the Cartesian product Staff × Tills × Staff.
As another example, one might think of a sentence as a sequence of words, where each word is seen as a sequence of characters. If we did this, then the sentence would be regarded as coming from the set SeqOfSeqOfChar. We can use notations introduced earlier to show when we want to see a sentence in this way, and when it is to be regarded as a single string (from SeqOfChar).

3.1 Sets of sets

In Section 2, all the sets and sequences we considered had primitive forms of data as their elements. However, sets and sequences may contain non-primitive forms of data. Let us look first at a situation in which we may find it useful to have a set whose members are themselves sets.
Think again about a shop with just three members of staff, given in the set Staff = {Jo, Jessica, Wesley}. Now let at WorkStaff be the set of staff currently at work. Clearly, at WorkStaff may take a range of values. If just Jo and Wesley are at work, then at WorkStaff is {Jo, Wesley}. If Jessica were to start work and Jo were to leave, then at WorkStaff becomes {Jessica, Wesley}.
Now any combination of staff from the set Staff = {Jo, Jessica, Wesley} might be at work at the same time. Possibilities include all these staff (when at WorkStaff is {Jo, Jessica, Wesley}), and none of them (in which case at WorkStaff is { }). The full list of possibilities (giving the possible values of at WorkStaff ) is given below.
{ }, {Jo}, {Jessica}, {Wesley}, {Jo, Jessica}, {Jo, Wesley}, {Jessica, Wesley}, {Jo, Jessica, Wesley}
Here, we have written out all the sets with members taken from the set Staff = {Jo, Jessica, Wesley}. We can form a set whose members are these sets. We will denote this set by SetOfStaff . So:
SetOfStaff = {{ }, {Jo}, {Jessica}, {Wesley}, {Jo, Jessica}, {Jo, Wesley}, {Jessica, Wesley}, {Jo, Jessica, Wesley}}.
The outer curly brackets here delimit the members of the set SetOfStaff. Each of these members is itself a set, and the inner curly brackets delimit each of these member sets. We will not often need to list the members of a set of sets like this. But it is useful to be aware that we can form a set in this way. We might have a variable atWorkStaff, giving the set of staff currently at work. The set giving all possible states of this variable is then SetOfStaff.
In general, we will use SetOfX to denote the set consisting of all the sets drawn from some given set, X. SetOfX is also known as the power set of X. Various other notations are used for this, including P(X) and 2 X . The latter is sometimes used since, if X has cardinality n, then SetOfX has cardinality 2 n . For example Staff has cardinality 3 and SetOfStaff has cardinality 8, which is 23.

3 Combining forms of data: Structuring data

In Section 2, we considered integers, characters and truth values. We shall refer to these as primitive forms of data. We also looked at two forms of data collection, sets and sequences, and at the association of different data items in a tuple. In this section, we will look briefly at some other ways in which data may be structured.

Exercises on Section 2

Exercise 4

Let A be the set of integers between 100 and 999 inclusive.
  • (a) Express A in the form A = {x ∈ ?? : condition}
  • (b) What is the cardinality of A?

Answer

Solution

  • (a) A = {xInt : 100 ≤ x and x ≤ 999}. (There are other correct solutions.)
  • (b) There are 999 integers between 1 and 999 inclusive. The set A does not contain the integers between 1 and 99 inclusive, and there are 99 of these. So A has cardinality 999 − 99 = 900.

Exercise 5

If B = {sSeqOfChar : s starts with ‘T’ and s has length 4}, which of the following is a member of the set B?
  • (a) “This”.
  • (b) [‘T’, ‘h’, ‘i’, ‘s’, ‘.’].
  • (c) [“T”, “h”, “i”, “s”].

Objectives for Section 2

After studying this section you should be able to do the following.
  • Recognise and use the terminology: real number; set; element or member of a set; empty set; length of a sequence; empty sequence, ordered pair, n-tuple, Cartesian product.
  • Appreciate that use of precise notation such as the use of different types of bracket conveys important information when using formal notation. For example, square brackets [ and ] denote a sequence, while curly brackets { and } denote a set.
  • Use and interpret various pieces of notation:
    • curly brackets to denote a set;
      – definition of a set by using a condition;
    • { } to denote the empty set;
    • [ ] to denote an empty sequence;
    • SeqOfX to denote the set of all sequences with members from X;
    • (x, y) to denote an ordered pair or 2-tuple; (x, y, z) to denote a 3-tuple, etc.;
    • X × Y to denote the Cartesian product of the sets X and Y .
  • Determine the cardinality of a given set and the length of a given sequence.
  • Given i, determine the ith element of a given sequence.
  • Be aware of the ASCII character codes.
  • Appreciate that some sets are finite and some are not.

2.6 Associations: tuples and Cartesian products

Consider an item of shopping that is weighed at the supermarket checkout, such as 335 grams of walnuts. This item of shopping has two features: the type of item purchased (walnuts), and the weight of that item (335 grams). To record a weighed item of shopping we need to note both these features. This can be done using an ordered pair: (“WALNUTS”, 335).
The first item in this ordered pair gives the type of item purchased. Let WeighedItems be the set of items stocked by the supermarket that need to be weighed. The first item comes from this set, while the second item in the ordered pair comes from the set Int.
We call the set containing all such pairs the Cartesian product of the two sets. (‘Cartesian’ after the famous French philosopher and mathematician René Descartes.) This set of pairs is written as WeighedItems × Int. So the set WeighedItems × Int consists of all pairs (w, n), where w comes from the set WeighedItems, and n comes from the set Int. We refer to (w, n) as an ordered pair. The word pair here indicates that there are two items grouped together. The word ordered indicates that the order in which the two items are given matters. The pair (“WALNUTS”, 335) is not the same as the pair (335, “WALNUTS”). Similarly, the set WeighedItems × Int is different from the set Int × WeighedItems, which consists of pairs giving: first an integer, then a type of weighed item.
Use of the symbol × here has nothing to do with multiplication of numbers!
We can form the Cartesian product of any two sets. The Cartesian product of sets X and Y is written as X × Y , and consists of all ordered pairs (x, y) where x is from the set X and y is from the set Y. X × Y can be read as “ X cross Y”.
An ordered pair gives an association between two items. There are situations where we may want to associate more than two things. Consider items stocked by the supermarket that have barcodes. The supermarket will be interested in a number of features associated with each item of this type. Three such features are:

2.5 Sequences

You have already met sequences briefly, and have seen that a sequence contains items given in a particular order, and that repetitions are of significance.
One might have a sequence containing integers, such as [22, −31, 44, 0, 2, 0, 11] or a sequence containing characters, such as [‘W’,‘o’,‘r’,‘d’]. However, we will aim to avoid mixing the forms of data in a sequence. A sequence of characters may also be referred to as a string, and that “Word” is another notation for the sequence [‘W’,‘o’,‘r’,‘d’].
The items in a sequence are enumerated from the left. Thus in the sequence [‘W’,‘o’,‘r’,‘d’], the first item is ‘W’, the second item is ‘o’, and so on. The items in a sequence may also be referred to as the elements (or sometimes members) of the sequence. The number of items in a sequence is called its length. So, for example, the length of the sequence [‘W’,‘o’,‘r’,‘d’] is 4. An empty sequence, [ ], has no members and so has length 0.
We do count repeated items when calculating the length of a sequence. So, for example, the sequence of numbers [22, −31, 44, 0, 2, 0, 11] has length 7, while the sequence of characters “aardvark” has length 8.
Incidentally, we are only concerned in this unit with finite sequences. If you study mathematics in other contexts, you may meet sequences that “go on forever”, such as the sequence of real numbers: 1, , , , , ... (where the general term is where n is a positive integer). Any form of data stored on a computer as a sequence will contain a finite number of items, so a sequence describing a form of data stored on a computer will be finite. A finite sequence will have a length that is a positive integer.

2.4 Sets

A set is a collection of items, and is a collection of a particular form. The items appearing in a set are referred to as the elements (or members) of the set. Examples of sets mentioned earlier are: Int, Char and Bool.
A set is a collection in which repetition is not significant, nor is the order in which the items are given. For example, the supermarket might sell its own brand of Wheat Flakes in three sizes: large, medium and small. In a situation where we are interested in the types of product that are available, we are interested in the set of sizes. This set of sizes may be written as:
{large, medium, small}.
We might choose to name the set:
Sizes = {large, medium, small}.
The order in which the elements are listed is of no significance, so we might equally well have written Sizes = {small, medium, large}.
Notice the use of curly brackets {and} here. These are used as a signal that the collection is a set (as distinct from some other form of collection, such as a sequence). Note too the commas used to separate the elements.

2.3 Truth values

We will want to distinguish between statements that are true and statements that are false. Another fundamental form of data allows us to do this. This form of data consists of just two values, which we shall write as true and false.
Not all texts use the same notation: some use T and F; others may use 0 for false and 1 for true (or the reverse!).
We may refer to true and false as truth values, or Boolean values. We will denote the collection (set) of truth values as Bool, after the mathematician George Boole. We write:
Bool = {true, false}.


This shows the collection Bool as a set. We have already mentioned the word set in passing, and now want to look at this concept in more detail.

2.2 Characters

Characters are another fundamental form of data. Computers store characters as integers, and system hardware and software translate these integer codes so that monitors and printers can display them.
As well as the familiar characters appearing on a keyboard, the current international standard (UNICODE) includes codes for characters from a variety of languages and alphabets (such as ê and ö). For simplicity, examples in this unit will use only a part of this code, as given in Table 2. This is confined to printable symbols that appear on a standard computer keyboard (for an English-speaking user).
We will denote by Char the set of characters appearing in Table 2. We will call the codes in the table the ASCII codes of the characters.
The original ASCII set (developed by ANSI, the American National Standards Institute) was finalised in 1968, and provides a basic (but by no means complete) character set for English. With the development of the Internet and a more global economy, efforts are being made to create a standard character set, catering more completely for many languages, and bringing together hundreds of incompatible standards from different countries. UNICODE is the result of this development, but it still only represents some of the written characters of our languages, currently standing at about 94,000 symbols. No existing character set caters for all languages.

2 Forms of data: 2.1 Numbers

The supermarket example discussed in Section 1 involves various forms of data that a computer may need to handle. Some of these, such as numbers and characters, are simple but fundamental. Other forms of data, such as sequences, involve more complicated structure. In this section, we will introduce sets, which are a variety of data collection that is different from sequences. But first we will look more carefully at numbers and characters.
When developing software we need to distinguish between different sorts of numbers, not least because computers represent and process them differently. Whole numbers (positive, negative or zero) are called integers. We shall use Int to denote the collection (or set) of all integers. In principle, digital computers can represent integers exactly, no matter how large or small. In practice, however, most programming languages place restrictions on the size of an integer (positive or negative) that can be stored. Many texts use instead of Int.
Sometimes, we need to work with numbers that are not integers. Measured quantities, such as weights or distances, are often presented as non-integer values. More profoundly, even if one starts with whole numbers, some arithmetic processes, such as division or finding a square root, may yield results that are not integers (see Activity 3). The real numbers are a wider collection of numbers used in mathematics. A real number is conveniently thought of as a decimal, such as 435.5218 or –29.333344, but not every real number can be written as a decimal of a finite length. For example, √2 (the square root of 2) and the number (pi) are real numbers that are non-terminating decimals. Such numbers can never be expressed exactly as a finite decimal.
is approximately equal to 3.142. You may have met it in calculating the circumference or area of a circle.

Exercises on Section 1

Exercise 1

  • (a) How many characters are there in the string “This text.”?
  • (b) Which of the following are integers: 3, 0, 98, 4, –22,, ‘7’, [56]?
  • (c) How many integers are there in the sequence [11, 23, 4, 56, 32]?

    Answer

    Solution

    • (a) There are ten characters: four in each word, a space, and a full stop.
    • (b) Each of 3, 0, 98, 4 and −22 is an integer. is not an integer because it is not a whole number. ‘7’ is a character, and is not an integer. [56] is a sequence containing one integer, but is not an integer.
    • (c) There are five integers in the sequence.


    Exercise 2

    Suppose that the variable till2 holds data in the form of a sequence of barcodes. When an item is read at the checkout, the state of till2 is changed by appending the barcode of the item to the end of the sequence giving the state of till2. Suppose that till2 currently has the state [50222, 50345], and that an item with barcode 50111 is read, and then an item with barcode 50456 is read. Write out the state of the variable till2 at each stage.

    Answer

    Solution

    In turn, the state takes the following values:
    [50222, 50345] (at the start).
    [50222, 50345, 50111] (after 50111 is read).
    [50222, 50345, 50111, 50456] (after 50456 is read).

    Exercise 3

    With item prices as given in Table 1, what is the sequence of prices corresponding to the sequence of barcodes [33050, 33050, 77502, 53151, 77502]? What is the total price of the items given by this sequence?

Objectives for Section 1

After studying this section you should be able to do the following.
  • Recognise the terminology: character; string; integer; sequence; element (of a sequence); variable; identifier (of a variable); state (of a variable).
  • Use and interpret the notational conventions:
    • single inverted commas to show a character;
    • double inverted commas to show a string (sequence of characters);
    • ’ to make explicit a space character;
    • the brackets [ and ] to delimit a sequence.

Data and processes in computing: Introduction

This unit provides an introduction to data and processes in software, and provides a basis that enables these fundamental ideas to be developed in a clear and precise way. It has two main aims. The first is to illustrate how we can describe ways in which data may be structured and processed. The second is to introduce you to some vocabulary and concepts that help us to do this. The material is accessible to anyone with a little experience of the use of symbols in presenting ideas.
Section 1 provides a brief introduction to the unit. It contains some new language that will be explained more fully in later sections. Read this section without spending too much time on it. The most important material in this unit is that in Sections 2 and 4. Section 3 includes some ideas that are relatively difficult. You should read this section, but do not spend a great deal of time on it. Section 5 is of a similar length to Sections 2 and 4.
Overall, do not allow yourself to spend too long on any section while you are studying this unit. You can always come back and reread material here if you find later that you need a more thorough understanding of some point.

4 Conclusion

Culture is just one perspective that can help us to understand more about a business. In this Unit we saw how the concept of culture developed from research into differences between cultures at a national level. Many cultural elements of a business are not obvious, but there have been some attempts in the academic literature to develop definitions and identify influencing factors. It is possible to see, or ‘feel’, that one business is different from another, and that this involves more than just how it presents itself to the outside world. Business values and accepted ways of doing things are often reflected in a business's socialisation programmes.

3 Factors influencing culture

Where the culture of a business comes from, and how it develops, is the subject of much discussion within business studies. Every commentator seems to have their own list of key factors. One example is by Drennan (1992), who proposes twelve key factors that shape the culture of a business. These are:

2.2 Symbols within business

How have academics and managers attempted to diagnose these largely hidden aspects of business? One well-known example is provided by Trice and Beyer (1984), who concentrated on the idea of there being symbols within a business. They divided these into, first, high-level symbols, which are the more obvious ones such as company buildings and logos, and, second, low-level symbols. They suggested four categories of low-level symbols: practices, communications, physical forms and a common language. These are explained below.

2 Definitions of organisational culture: 2.1 Culture as socialisation

The cultural perspective has become popular in business studies because it offers a way of explaining performance and understanding difference. It is only one way of analysing business, but it is an interesting one as it focuses particularly on the insider point of view, or on what it is ‘really’ like to work in an organisation. There have been many definitions of organisational culture. One definition that is often cited is:
Culture is a pattern of beliefs and expectations shared by the organisational members. These beliefs and expectations produce norms that powerfully shape the behaviour of individuals and groups within the organisation.
(Schwartz and Davis, 1981, p. 33)

1.2 Working abroad

The extract from a newspaper article in Example 1 provides insight into the problems of working abroad.

Example 1

Working abroad is often considered the chance of a lifetime. Living and working in a foreign country with all expenses paid; what more could anyone want?
In a surprising number of cases the answer is actually: ‘Quite a lot’. Finding yourself adrift in a different culture might seem exciting when you're on holiday, but it's an entirely different proposition when you're living and working. Codes of business practice may be radically different and the expatriate lifestyle can be lonely… yet many multinational companies have made little effort to prepare their employees for the shock.

1 National cultures: 1.1 Hofstede's five Cultural Dimensions

A series of perspectives that we might use to achieve a different insight into business was introduced by Morgan (1986) in his book entitled Images of an Organization. One of these was the business as a culture, a type of micro-society where people work and ‘live’ together on a daily basis, with certain rules and understandings about what is acceptable and what is not. The idea of a business having a culture was developed from the work of Hofstede on national cultures (1980). His research focused on ways of measuring national culture and how these ‘measures’ might work differently in different contexts. The cultural values that are important in a national culture, he suggested, could be reflected in the way businesses within that country are operated and organised.
Hofstede's five dimensions (he developed four in 1980, then added a fifth in 1991) were:
Power distance This concerns the extent to which less powerful members of organisations within a country expect and accept that power is distributed unequally. National cultures that demonstrated what Hofstede called a ‘low power distance’ are ones in which there is a concern to minimise inequalities. Hofstede included Sweden and New Zealand as examples of this. In general, Hofstede found that Latin American and Latin European (France and Spain) countries had higher power distance scores. The less powerful in these societies tend to look to those with power to make decisions, and inequalities within society are more acceptable. This is represented by a tendency for the centralisation of power and the subordination of those with less power within businesses.
Individualism/collectivism In an individualistic society, people are expected to look after themselves and their families. In the case of business this is reflected in, for example, employment contracts based on hiring and firing. Two examples of countries with high scores on this dimension were Australia and Canada. In more collective societies, people are more concerned for others and the culture is based around more cohesive groups, such as the family, which offer protection in exchange for loyalty. This tendency is reflected in businesses as well as elsewhere in society. Hofstede cited Ecuador and Indonesia as examples of more collective societies.

Business cultures

Why are we studying ‘business cultures’? Culture is a metaphor which can be used to explore the identity of a business. It is about how others see the business, but also how the individuals who work there understand it. Culture offers us a powerful insight into the business and what it is like to work within it.

An introduction to business cultures: Introduction

Culture is just one perspective that can help us to understand more about a business. 'Business culture' is not just about how others see a business, but also about how the individuals within an organisation understand it. In this unit we explore how the concept of culture developed from research into differences between cultures at a national level. It is possible to see, or ‘feel’, that one business is different from another, and that this involves more than just how it presents itself to the outside world.

19.8.11

7 Unit summary

7.1 What have you learnt in this unit?

This unit began by exploring some basic issues involving computers:
  • the nature of data and information;
  • why human beings need (and want) computers;
  • the prevalence of computers in modern life.
The unit looked briefly at how a computer-based society affects the average person who (whether he or she knows it or not) has a persona that consists of data about them held by many diverse organisations.
Much of this unit consisted of case studies illustrating the possibilities for computer use. They raised some of the issues posed by computing technologies, such as:
  • the distinction between data and information;
  • what computers can do with data to produce information;
  • how computers can be used to work with data and search for it, control machines, and support commercial operations.
There are a number of themes running through this unit.
  • Data requires encoding.
  • In order to function, a computer requires data which may be stored in databases.
  • Data has to be transmitted from place to place.
  • At the heart of a computer system there are one or more programs.
  • Many current computer systems are distributed, in that they consist of a number of computers which cooperate and communicate with each other in order to function.
  • Information has to be fit-for-purpose.
  • Security and trustworthiness are major concerns with many systems.
  • Computer systems also have drawbacks and adverse effects. They also have social, political, legal and ethical implications.
You should be able to define the following terms in your own words.
case study hit
computer information
computer program internet
computer system keyword
data parameter
database perceptual data
database server search engine
distributed system sensation
gateway sign/symbol
global positioning system (GPS) World Wide Web (the web)

6.3 Summary

This section examined how computers can be used to control machines. It used the household washing machine as a case study and explored how the microcomputer contained in such a machine is programmed to:
  • provide an interface for the user to operate the machine;
  • control the way the machine carries out the operations chosen by the user.
The washing machine case study also illustrated the necessity of building safety features into computer-controlled mechanisms.
Computers are also used to support selling goods and services via the web. A case study of a successful company showed what the information requirements for such a system are, and examined how two or more computers can cooperate as part of a distributed system to satisfy these requirements in a way that is secure.

6.2.3 Security: are my credit card details safe?

Many people now shop regularly on the web. However, many others don't because they fear that an unscrupulous person could obtain their credit card details. They also fear that if they provide their names and addresses to a firm on the web, they will be bombarded with junk mail (or its electronic equivalent, junk email). Some worry that, since anyone can put up a website, the seller may be bogus and no goods will appear after the sale has been completed or won't be as advertised.
Consequently, other important issues raised by this case study are security and trustworthiness. The internet is a remarkably open medium. It does not take too much effort to ‘capture’ the data that flows along communication lines. Someone could theoretically read your credit card details as they are transmitted between your computer and that of the seller. (I use the term ‘theoretically’ because there exist techniques which enable the data to be transformed into a form which would be virtually impossible to read.)
You can be reasonably confident of buying from a website if it displays one of two things.
  1. The address shown in the bar at the top of the screen should start with ‘https’ instead of ‘http’. The letter ‘s’ means you are connected to a secure web server using techniques to protect your details from electronic snoopers.
  2. An icon representing a small key is present. This also indicates that the web server you are connected to is a secure one.
Another safety precaution is to deal only with web sellers you know are reputable. Consumer organisations often have schemes for accrediting web sellers who are legitimate and secure dealers. Friends and neighbours may also be able to recommend reputable and secure web sellers.

SAQ 9

Is web selling, as practised by a firm like Lakeland, an example of a distributed system? Explain.

Answer

Yes, it is a distributed system. It consists of user PCs, web servers, and database servers, with data and information being transferred between them using networks (in this case the internet).

6.2.2 Database servers

To be able to search a website like Lakeland's requires not only a web server but a database server. Like a web server, a database server is a computer that responds to requests from other computers. Its task is to find and extract data from a database.
The web and database servers form part of a distributed system. This means that separate computers exchange data and information across a network (in this case the internet) to produce results for a user. For example, suppose I use the keyword search to ask for ‘kitchen cleaners’. This request is transferred to the web server, which has an index of products which can be categorised as kitchen cleaners. It then sends these product numbers to the database server, which locates the correct items in the product database and returns information about them (pictures, description and price) via the web server to my browser.
Compared with the simple data from which the complex DNA database is built, the data processed by the database servers at a company like Lakeland is complex (text, graphics, pictures).

6.2.1 Using a sales website

A visitor to a sales website is usually able to:
  • browse through the details of the goods for sale;
  • search for a particular product;
  • check on the availability of goods;
  • read reviews of the products by other purchasers;
  • register to receive newsletters which detail new items of interest;
  • buy products using credit or debit cards, and in some cases, other payment methods such as cheques.

6.2 Selling on the weba

The web is fast becoming a medium for selling everything from books to clothes, gardening tools to beauty products, investment advice to travel services. Web-based selling seems to be concentrated in three main categories of company:
  • existing catalogue sales companies which have put their catalogues online to allow customers to buy using the web;
  • existing companies whose products are largely information and which have used the web as a means of providing a personalised service or one with a very quick response;
  • companies which have started from scratch using the web as their only sales medium.

6.1.4 Controlling the machine

The major task of a washing machine microcomputer is to control the actions of the machine in accordance with the wash programme selected. To do this, the computer is electrically attached to a variety of:
  • actuators that cause mechanical parts of the system to work;
  • sensors that sense the state of some aspect of the machine, such as water temperature.
There is an actuator to open or close the water input valve. Another controls the turning of the drum, and another the pumping of water through the machine. There is also one for pumping the water to the drain and one for controlling the water that washes through the tray holding washing powder and fabric softener. Lastly, there is an actuator that turns on a heating coil if the water temperature is below the desired temperature for the wash.
As regards sensors, my machine has one to check water level, and another to check water temperature. It also has a sensor that weighs the dry laundry at the start of the cycle, providing data that the microcomputer program uses to determine how much water to use for each wash. This enables my machine to optimise water use, and hence conserve resources (water and the electricity to heat the water).

6.1.3 Ensuring safety

Ensuring that a user can't choose a wash temperature that's too hot for the ‘hand wash’ programme is an example of ensuring safety. In other words, the washing machine microcomputer is trying to prevent the user making choices that are not sensible. Of course, I could put a load of delicate washing in and choose the ‘cotton’ programme which has a temperature of 90°C. The computer program controlling the machine has no way of knowing that I've put silks or woollens in and not cottons. The worst that would happen, however, is that I would ruin some expensive clothing due to my own negligence.
What about the safety of the user? A washing machine could be dangerous if anyone could put their hand into the drum when it was moving, or when the water was very hot (anything over 40°C can scald), or when the water level is high enough to spill out of the door. The programme on my machine does allow the user to open the door to insert additional items during the cycle, but only when safety conditions are met (drum not moving, water not too hot, water not too high). It is incumbent on the designer of any such system to ensure that basic safety requirements are met. While it may not result in serious harm if, for example, one can open the door when water is above the level of the bottom of the door, customer satisfaction would surely plummet were this to happen.
Some computer-controlled applications (e.g. controlling a flying aircraft) have to go further towards ensuring that an operator doesn't jeopardise situations due to negligence. These are not discussed in this unit, but you should be aware that they exist. They are called safety-critical systems, which means that serious harm or loss of life could occur if these systems break down, or do not function properly.

Exercise 15

It is common in modern cars to have central locking. This usually involves pressing a button on a key fob and sending a signal to the car from a short distance which locks or unlocks all doors simultaneously. A button on the control panel may work in a similar way to lock and unlock all the doors from inside.
  1. Can you identify any safety situations that would affect the lock-control program in the car's microcomputer?
  2. What kind of information might a driver need about the door locks?

    Discussion

    1. It might be dangerous to allow someone to unlock the doors while the car is in motion. For example, a child might press the button on the control panel, unlocking the doors, then accidentally open the door and fall out. With very small children, it might be dangerous for the child to be able to unlock any door (even when the car is stationary) without the driver knowing. Thus one safety consideration might be to ensure that it is not possible to override child-proof locks accidentally or through carelessness.
    2. The driver might simply need a light to tell him or her whether the locks were engaged or not.

6.1.2 Choosing programmes and parameters

Another part of the interface shown in Figure 15 allows the user to select one from a variety of predetermined washing programmes, and to change some of the parameters. If I choose the ‘cotton’ programme, for example, the microcomputer's program assumes that I wish to wash this load of laundry at 60°C, use the main wash programme, and spin the washing at the highest speed. Sometimes this programme is fine, but at other times I may want to select the higher temperature of 90°C in order, say, to sterilise the laundry (e.g. nappies), or a lower temperature (e.g. to prevent dark colours fading).
I may also select the pre-wash if my laundry is especially dirty or the additional rinse if a member of the family has sensitive skin which may react to residues of washing powder.
Finally, the microcomputer's program ensures I don't do anything silly. For example, if I select the ‘hand wash’ programme, it will not allow me to change the temperature to one higher than the pre-programmed 30°C.

Exercise 14

What kind of interface would you expect on a very simple microwave oven (one without predetermined programmes)?

Discussion

Since power level (e.g. defrost, low, medium and high) and time are important when microwaving food, the user needs to be able to select these two parameters.
Typically, a microwave interface will have buttons or a dial for selecting the power level, and a numeric keypad or dial for setting the time in terms of minutes and seconds. The display might indicate the power level chosen, and will certainly show the time remaining.
The interface will also have two other important controls: a ‘Start’ button and an ‘Open door’ button.
You may have said something a bit different, depending on your familiarity with microwave ovens.

6 Controlling things; selling things

6.1 Controlling things

As you learned in Section 1, computers can collect, process, store and distribute information. This section shows that they can also be used to:
  • control machines and simple mechanisms;
  • conduct a special kind of commerce: selling on the web.
Let us examine more closely that common household appliance, the automatic washing machine. Virtually all such machines sold in the last decade or so are controlled using a microcomputer of some type. Before that, such control was provided by mechanical systems. However, because these had moving parts they suffered from wear, and tended to break down frequently or require replacement. Also, the nature of mechanical control systems limited how complex they could be. Consequently, they tended to be quite simple, and therefore less ‘automatic’.
The main tasks of a microcomputer in a modern washing machine are to:
  • present an interface to the users that lets them know what possibilities there are and what the current state of the machine is;
  • allow the user to select one from a variety of predetermined washing programmes;
  • change some of the parameters (such as water temperature) to suit particular conditions;
  • initiate, control and finally halt the actions of the machine in accordance with the wash programme selected;
  • in some machines, ensure that the washing is done efficiently with minimum inputs of water or washing powder, in the interests of reducing resource use and maximising environmental protection;
  • ensure safe operation of the machine.
Let's examine some of these tasks in more detail.

5.3 Summary

This section made an interesting contrast between simple data that generates large and complex structures that require large and complex programs to handle them, and complex data which a complex but easy to use program helps a non-expert handle in some interesting, creative, flexible ways.
The case study on DNA illustrated how simple data (consisting of only four elements) can be combined into very large and complex structures (genes and chromosomes). You learned how such large and complex structures, when stored in databases, present certain computational problems. The difficulty of finding anything in such large databases where data may be very repetitive or partial, or its location not known means that huge computational effort is required, both to build the database in the first place, and then to use it effectively.
In contrast, the second case study examined how complex data, such as the graphical representation of a scene, can be made relatively easy to use by a non-expert. The case study showed how the flexibility of a computer and its ability to make and store multiple copies provides great scope for creativity.

5.2.1 Transforming the natural to the designed

The artist Christine Martell lives in Oregon in the United States and works with beads and visual images. I asked her to describe how she makes use of a computer to create her visual images of flowers and trees. She writes of her work:
I start by finding flowers that are compelling in some way, most often in form and colour. I take photographs with a 35 mm camera having a macro lens.
I'm usually looking for a line that might suggest movement or gesture. I find a place that might be the resting place in the movement, and focus the camera there. Often times the background is out of the focal range.
When I have the film developed, I choose a lab that tends to make the photographs saturated [with little or no admixture of white] and rich. I prefer to bring the colour ‘down’ electronically rather than try to enhance it. I have the prints made in 5 by 7 inch size.
I scan the photograph into the computer, using a simple consumer grade scanner. I copy the image to make a working copy. I keep the original photo scan as a separate file, so I can move back and forth between the images to restore original edges and details.
When I draw into the images electronically using a drawing tablet, I am usually looking to create a dynamic energy; to express a movement and visually emphasise the contrast between that energy and the stillness of the flower. I draw back into the images with my digitising tablet, using Painter software. I hardly ever use filters [standard effects made available by ‘painting’ software, equivalent to using a lens filter on a conventional camera] as the effect is too uniform for my taste. Once in a while, if I need a uniform texture for a background, I'll use a filter… or I might start with a filtered texture, then draw into it.
The computer gives me the freedom to mix the visual effects of media that would not readily combine in traditional media. I also can work through many more ideas electronically.

5.2 Art and the common computer

Art is difficult to define. But all art involves the Exercise of human skill. A natural object, such as a piece of driftwood, a flower, a bird song, can move us to admire it as beautiful or intriguing or comforting, but it isn't art. Artists (be they photographers, painters, sculptors, actors, musicians, authors or dancers) use their skill to transform natural objects, materials or signs (paint, clay, their own body or voice, the sounds of musical instrument, words) into something else: something with value in its own right rather than for the way in which it might be used.
And what, you may ask, do computers have to do with art?
Central to this unit is the idea that a computer is essentially a tool. And because of the flexibility of programming, it is an exceedingly flexible tool. With the right sort of program and appropriate peripheral devices, a computer can be used by artists to produce art. This subsection will examine how computers can be used to produce visual art.
If you examine a photograph, a painting or a view out of your window carefully, you will notice that what you are looking at is, for the most part, incredibly complex. Colours vary across an almost infinite colour spectrum. There are apparent lines or edges, and objects within the view will be clearly or fuzzily defined depending upon lighting conditions and distance from the person viewing the scene.

Screening for genetic defects

Now that scientists have mapped the human genome, computers can be used to detect genetic defects.
Screening for genetic diseases existed before the application of computers. Family histories were used, together with a knowledge of inheritance patterns and statistics, to determine the likelihood of a couple having offspring with genetic disorders such as sickle cell anaemia.
Some genetic disorders such as phenylketonuria have had simple chemical detection tests available for some time. Once detected, careful control of diet prevents mental retardation, demonstrating the value of detecting the presence of a genetic disease before any symptoms have appeared.
What the computer adds to the screening process is the power to compare very long genetic sequences (i.e. sequences of base pairs) against the human genome in a way that would be far too time consuming (and therefore expensive) to be carried out by hand. Once a particular gene and type of defect has been identified, it becomes possible to develop a test to find out whether a patient has that genetic defect well before any signs of it appear.
Genetic tests are used for several reasons, including:

5.1.2 The human genome

All life is ‘encoded’ chemically in genes. What this means is that the structure of an organism, the organs it possesses, its colouring, and so on are all determined by different genes. A very simple organism may have just a few genes, and a complex one tens of thousands. The ‘map’ of an organism's genes is referred to as its genome. It shows, in essence, which genes give rise to which characteristics or traits of the organism. The word ‘template’ would describe the genome better than ‘map’.
Figure 13 shows the 23 pairs of human chromosomes that constitute the structure of the human genome. These chromosomes contain between 30,000 and 40,000 genes in total. For each human characteristic, such as eye or hair colour, the human genome shows where the genes are that control that characteristic.

5.1.1 What is DNA?

DNA (deoxyribonucleic acid) is frequently in the news for four main reasons.
  1. DNA can be used in crime detection to eliminate innocent suspects from enquiries or, conversely, to identify with a very high degree of probability the guilty.
  2. DNA is now used in medicine to detect the possibility that diseases having a genetic origin may occur in an individual. This enables doctors to prescribe preventative treatments.
  3. It is hoped that discoveries about DNA will yield important new treatments for hitherto intractable diseases and conditions.
  4. DNA can be used to identify victims of disasters, and establish whether people are related.

5 Computers as tools for working with data

5.1 Genetic databases and disease

Section 2 looked at data and information from two different perspectives: that of the individual and that of commercial organisation. The type of data you have will dictate both why you want to process it using a computer and, to a large extent, how that is done.
This section contains two short case studies whose unifying theme is that the computer and its programs are tools for working with data. The two studies provide an interesting contrast between:
  • simple data in large and complex structures (which require large and complex programs to handle them), and
  • complex data which a complex program helps a non-expert to handle in some interesting, creative, flexible ways.
This subsection uses a case study to show how simple data (the four bases in DNA) can be combined in different ways to create a huge and complex collection of information.

4.4 Summary

This section described how computers can be used in geographical applications (and in doing so it discussed maps and showed how modern maps are composed of layers of different data).
It discussed the GPS to demonstrate how computers can communicate in order to solve a problem, such as navigation.
It also showed how the geographical data that supports both map-making and the GPS navigation system can be presented in different forms such as a map, a list of directions, a moving graphical display on a navigation device such as a GPS receiver or as spoken directions. The reasons why one form of presentation is preferable over another were discussed: it depends on fitness-for-purpose, i.e. on the requirements of the user and/or the situation in which the information is needed.
Finally the section described how computers can be used to find information on the web. The two activities associated with this section introduced you to gateways and to the simple and advanced use of search engines.

4.2.3 Using a search engine more effectively

The search shown in Figure 9(b) is an example of how to use a search engine in a simple way. However, one of the problems with finding information on the web is that there is so much! And not all of it is relevant to what you want. My search for ‘rugby’ and ‘wales’ using the Google search engine yielded about 420,000 results or ‘hits’ (see the information contained in the blue strip on Figure 9(b)). The first few sites listed will probably tell me what I want to know. But what about all the others? Are they all about the game of rugby in Wales?
The answer is ‘no’. A website about rugby in New South Wales, Australia also appeared as a result of this search. Google didn't make a mistake since the site contains the chosen keywords. However, it wasn't smart enough to distinguish between Wales and New South Wales.
If you are just looking (‘surfing’) for information in a general way, too much information isn't always a problem. Where it becomes irritating and counterproductive is when you are looking for some quite specific information.

Example 4

Suppose you're interested in genealogy, and your surname is Bird. If you search on the web by typing in the keywords ‘bird’ and ‘family’, the web server will return every website it finds with those two words in it, so you'll probably find scientific and hobby sites on bird ‘families’ such as the passerines! It's clearly not what you want, but do you need to examine all the websites returned (which could run into hundreds) to find the one you're looking for?
The answer is that there are ‘tricks’ that you can use to narrow down your search to eliminate at least some of the things you aren't looking for. Each search engine has its own ‘tricks’, though the concepts of making more targeted searches are common to most search engines. Search engine screens will generally have a selectable topic called something like ‘Advanced Search’ or ‘Search Tips’.
One obvious trick is to choose your keywords carefully. The more specific the keywords you choose, the more likely you are to get what you want. For example, if you want to find information on antique chairs, typing in just the keyword ‘antique’ will return all websites that use the word antique, and typing in the keyword ‘chair’ by itself will return all websites that use the word chair. But typing in both keywords will only return websites that use both words. The more keywords you add, the more targeted will be the websites returned to you. So adding ‘British’ to ‘antique’ and ‘chair’ will only return websites that have all three words in them.