SlideShare a Scribd company logo
1 of 85
Download to read offline
Page 1 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Advantages of designing a solution to a problem by splitting it up into smaller problems (top-
down/modular design)
Produce and describe top-down/modular designs using appropriate techniques, including structure
diagrams, showing stepwise refinement
Top down/modular design
A Top-down design is when a problem is split into smaller sub-problems, which themselves are split into even
smaller sub-problems until each is just one element of the final program.
Benefits and drawbacks of modular programs
Page 2 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Structure diagrams
A structure diagram is a pictorial representation of a modular system.
Stepwise refinement
Stepwise refinement is the process of developing a modular design by splitting a problem into smaller sub-
tasks, which themselves are repeatedly split into even smaller sub-tasks until each is just one element of the
final program.
Page 3 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
produce an algorithm for a given problem either in pseudocode form or the flowchart form
understand algorithms presented in the form of program flowcharts and pseudocode
What is an Algorithm?
An algorithm is a sequence of steps, which perform a specific task. In computing, algorithms are usually
represented as a program flowchart, or in pseudocode.
What is a program flowchart?
A program flowchart is a pictorial representation of an algorithm. Program flowcharts consist of special
symbols:
Page 4 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Here is an example of a flowchart to output the first five squared numbers:
Page 5 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
What is Pseudocode?
Pseudo-code is a simplified form of programming code that uses common programming terminologies, but
does not use the strict syntax rules of a programming language.
An example of a pseudocode algorithm:
{
BEGIN
INPUT CardNumber
REPEAT
INPUT PIN
IF PIN is wrong for this CardNumber THEN
OUTPUT “Wrong Pin”
END IF
UNTIL Pin is correct
INPUT Amount
IF there are enough funds THEN
Dispense Cash
Update customer’s balance
ELSE
OUTPUT “Sorry, insufficient funds”
END IF
END
}
Algorithms should be evaluated using the following criteria:
1. Efficiency
2. Correctness
3. Appropriateness
Efficiency
An algorithm’s efficiency can be judged in terms of:
‱ Speed: How quick the algorithm produces the required output.
‱ Memory requirements: How many lines of code the algorithm contains.
Page 6 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Correctness
Although an algorithm is expected to produce the correct outputs, correctness can still be measured in terms
of:
Accuracy : How many decimal places produce output with greater accuracy (e.g. more decimal
places)
Range: Will the algorithm work with the complete range of inputs? Or can it only deal with positive
numbers, whole numbers, numbers below 1 million, etc.
Reliability: Will the algorithm always produce correct output within the range that it is designed to
work? Or are there values which it will not accept
(e.g. zero).
Appropriateness
Appropriateness can be measured in terms of:
Length: If the problem is simple then a short algorithm would normally be expected.
Speed: if the output needs to be generated quickly, then the algorithm must be able to generate output
quick enough.
Memory requirements: An algorithm controlling a washing machine must not require a lot of
memory!
Page 7 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Flow Charts
Introduction:
This section covers the use of flow diagrams (charts) in the production of algorithms. This topic must not be
confused with “Systems flowcharts” as those are different and these are covered in a different section
(Systems analysis).
This section primarily covers four areas:
1. Common flow chart symbols
2. Writing flowcharts to solve problems
3. Dry running of flowcharts to determine its function and outputs
4. Exercises to test the above concepts
5. Topical past paper questions
Page 8 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
1. Common flowchart symbols
Page 9 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Understand and use assignment statements
What is an Assignment?
An assignment is an instruction in a program that places a value into a specified variable.
Some typical assignments are:
Note that the last example is a common method used to increment the value of a variable. It could be read as:
(The new value of “Counter” is its existing value plus one)
TheLength  20.5
TheUsersName$  “Charlie”
TheArea  TheWidth *
TheLength
TotalCost  LabelledCost + 15
Counter  Counter + 1
Page 10 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Arithmetic operators including operators for integer
Addition, subtraction and multiplication
Powers
Division
A result of a division such as 17 Ă· 4 can be expressed either as a real (4.25) or as two integers
(4 remainder 1).
The integer method, in most programming languages, uses the operators DIV and MOD.
Page 11 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Relational operators, eg. =, <, <=, >, >= and <>
Relational operators are used in the format: [Expression] [Operator] [Expression] and will always return a
Boolean (True or False) value.
Relational operators are typically used with the “IF” selection and also within conditional loops
(REPEAT-UNTIL or WHILE-WEND).
In the following table, the variables “a” and “name$” have the following assignments:
a3+5
name$ “JAMES”
Page 12 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Boolean operators AND, OR and NOT
AND & OR
The AND & OR operators always return a Boolean result and are used in the format:
[Boolean] [Operator] [Boolean]
The following ‘truth’ table summarizes the result of the Boolean operations:
Values Results
NOT
The NOT operator reverses the result of the Boolean expression and is used in the format:
NOT [Boolean]
The following truth table summarizes the NOT operation:
Examples of Boolean ‘logic’
Consider the following algorithm, which is used to monitor a printer and display its output via an
LCD display in the front panel:
IF NOT(PaperTrayEmpty) AND (FilesWaiting > 0) THEN
OUTPUT “PRINTING
”
ELSE
OUTPUT “PLEASE ADD PAPER”
END IF
Page 13 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Validation
Validation checks ensure that data entered into the computer is sensible. Data is checked in accordance with a
set of rules. The computer's software can validate data while it is being entered into the computer. The main
purpose of data validation is to spot an error. This can be done quickly and easily as the process is automated.
1. Range check. A mathematics exam is out of 100. A simple validation rule that the computer can apply to
any data that is input is that the mark must be between 0 and 100 inclusive. Consequently, a mark of 101
would be rejected by this check as being outside the acceptable range.
2. Character check. A person’s name will consist of letters of the alphabet and sometimes a hyphen or
apostrophe. This rule can be applied to input of a person’s name so that dav2d will immediately be rejected as
unacceptable.
3. Format check. A particular application is set up to accept a national insurance number. Each person has a
unique national insurance number, but they all have the same format of characters, 2 letters followed by 6
digits followed by a single letter. If the computer knows this rule then it knows what the format of a NI
number is and would reject ABC12345Z because it is in the wrong format, it breaks the rule.
4. Length check. A NI number has 9 characters, if more or fewer than 9 characters are keyed in then the data
cannot be accurate.
5. Existence check. A bar code is read at a supermarket check-out till. The code is sent to the main computer
which will search for that code on the stock file. As the stock file contains details of all items held in stock, if
it is not there then the item cannot exist, which it obviously does, therefore the code must have been wrongly
read.
Page 14 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Presence check
Code can be added to check that a particular control has not been left empty or un-checked:
If Username = “” Then
Print (“You have not entered a Username”)
End
Range check
Code can be added to check that a particular control has a value between an allowed maximum and minimum:
If Age < 11 OR Age > 70 Then
Print (“The age that you have entered is not within the permitted
range”)
End
Is
Username = “”?
You have not
entered a
Username
No Yes
Is
(Age)< 11
OR
(Age)> 70
The age that you
have entered is
not within the
permitted range
No Yes
Page 15 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Length check
Code can be added to check that a particular control has a value between an allowed maximum and minimum:
If Len(Password) > 12 Then
Print (“The password that you have entered is too long”)
End
Is
Len(Password)> 12?
The password that
you have entered
is too long
No Yes
Page 16 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
2. Writing flowcharts to solve problems
The following five problems are also covered in section 3.2 where the algorithms are constructed using
pseudocode. Candidates may choose to answer questions using either flowcharts or pseudocode but a working
knowledge of both techniques is well advised.
2.1 Example 1
A town contains 5000 houses. Each house owner must pay tax based on the value of the house. Houses over
$200 000 pay 2% of their value in tax, houses over $100 000 pay 1.5% of their value in tax and houses over
$50 000 pay 1% of their value in tax. All others pay no tax. Write an algorithm to solve this problem in the
form of a flowchart.
2.2 Example 2
The following formula is used to calculate n: n = (x * x)/(1 – x). The value x = 0 is used to stop the algorithm.
The calculation is repeated using values of x until the value x = 0 is input. There is also a need to check for
error conditions. The values of n and x should be output. Write an algorithm to show this repeated calculation
in the form of a flowchart.
2.3 Example 3
Write an algorithm in the form of a flowchart which takes temperatures input over a 100 day period (once per
day) and outputs the number of days when the temperature was below 20ÂșC and the number of days when the
temperature was 20ÂșC and above.
2.4 Example 4
Write an algorithm in the form of a flowchart which:
inputs the top speeds (in km/hr) of 5000 cars
outputs the fastest speed and the slowest speed
outputs the average (mean) speed of all the 5000 cars
2.5 Example 5
A shop sells books, maps and magazines. Each item is identified by a unique 4 – digit code. All books have a
code starting with 1, all maps have a code starting with 2 and all magazines have a code starting with 3. The
code 9999 is used to end the algorithm.
Write an algorithm in the form of a flowchart which inputs the codes for all items in stock and outputs the
number of books, number of maps and the number of magazines in stock. Include any validation checks
needed.
Page 17 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Answers to the Examples:
Page 18 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 19 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 20 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 21 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 22 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
3. Dry running of flowcharts
Dry running of flowcharts is basically a technique to:
Determine the output for a known set of data to check it carries out the task correctly.
Check the logic of the algorithm.
Determine the function of the algorithm.
When dry running a flowchart it is advisable to draw up a trace table showing how variables
change their values at each stage in the algorithm.
The advantages of doing this are:
If you make a mistake, it is easier to back track to where the error occurred rather than
starting from the beginning again
There is less chance of an error being made
Encourages a more logical approach
The following three examples show all stages in the dry running for the given set of input data:
3.1 Example 1
This algorithm inputs 3 numbers, each number goes through successive division by 10 until its value is less
than 1. An output is produced which contains the number input and a value generated by the flowchart
processing.
Data to be used: X = 85, 3190, -40
3.2 Example 2
This algorithm inputs 5 values and outputs how many input numbers were negative and how many were
positive.
Data to be used: N = 1, -5, 2, -8, -7
3.3 Example 3
This algorithm inputs the number of hours of sunshine recorded each day for a week (7 days). The output is
the highest value for hours of sunshine and the average (mean) value for the numbers of hours of sunshine per
day.
Data to be used: hours = 9.0, 7.8, 1.2, 4.5, 10.0, 6.4, 3.1
Page 23 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Answers to the Examples:
Page 24 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 25 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 26 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Questions 1 to 7 are problems which require an algorithm to be written in the form of a flowchart. Questions 8
to 10 require a trace table to be written and find the expected output for the given set of data. The answers to
these questions can be found in booklet 6.
1. Regis lives in Brazil and often travels to USA, Europe and Japan. He wants to be able to convert
Brazilian Reais into US dollars, European euros and Japanese yen.
The conversion formula is: Currency value = number of Reais X conversion rate
For example, if Regis is going to USA and wants to take 1000 Reais (and the exchange rate is 0.48) then
he would input USA, 1000 and 0.48 and the output would be: 480 US dollars.
Write an algorithm, using a flowchart, which inputs the country he is visiting, the exchange rate and the
amount in Brazilian Reais he is taking. The output will be value in foreign currency and the name of the
currency.
2. As part of an experiment, a school measured the heights (in meters) of all its 500 students.
Write an algorithm, using a flowchart, which inputs the heights of all 500 students and outputs the height
of the tallest person and the shortest person in the school.
3. A geography class decide to measure daily temperatures and hours of sunshine per day over a 12
month period (365 days)
Write an algorithm, using a flowchart, which inputs the temperatures and hours of sunshine for all 365
days, and finally outputs the average (mean) temperature for the year and the average (mean) number of
hours per day over the year.
4. A small shop sells 280 different items. Each item is identified by a 3 – digit code. All items that start
with a zero (0) are cards, all items that start with a one (1) are sweets, all items that start with a two
(2) are stationery and all items that start with a three (3) are toys.
Write an algorithm, using a flowchart, which inputs the 3 – digit code for all 280 items and outputs the
number of cards, sweets, stationery and toys.
5. A company is carrying out a survey by observing traffic at a road junction. Each time a car, bus or
lorry passed by the road junction it was noted down.
10 000 vehicles were counted during the survey.
Write an algorithm, using an algorithm, which:
inputs all 10000 responses outputs the number of cars, buses and lorries that passed by the junction during
the survey outputs the number of vehicles that weren’t cars, buses or lorries during the survey.
Page 27 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
6. Speed cameras read the time a vehicle passes a point (A) on the road and then reads the time it
passes a second point (B) on the same road (points A and B are 100 metres apart).
The speed of the vehicle is calculated using:
The maximum allowed speed is 100 kilometers per hour. 500 vehicles were monitored using
these cameras over a 1 hour period.
Write an algorithm, using a flowchart, which:
inputs the start time and end time for the 500 vehicles that were monitored
calculate the speed for each vehicle using the formula above
outputs the speed for each vehicle and also a message if the speed exceeded 100 km/hour
output the highest speed of all the 500 vehicles monitored
7. There are ten stations on a railway line:
1 ------ 2 ------ 3 ------ 4 ------ 5 ------ 6 ------ 7 ------ 8 ------ 9 ------ 10
The train travels in both directions (i.e. from 1 to 10 and then from 10 to 1). The fare between
each station is $2.
A passenger inputs the number of the station at the start of his journey and the number of the
destination station and the fare is calculated (e.g if a passenger gets on a station 3 and his
destination is station 9 his fare will be $12). The calculation must take into account the direction
of the train (e.g. a passenger getting on at station 7 and getting off at station 1 will also pay $12
and not a negative value!!).
A discount of 10% is given if 3 or more passengers are travelling together.
Write an algorithm, using a flowchart, which:
inputs the number of passengers travelling
inputs the station number of the starting point and the station number of the destination
calculates the total fare taking into account the direction of travel
calculates any discount due
outputs the cost of the tickets and prints the tickets
Page 28 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
8. Draw the trace table and determine the output from the following flowchart using the following
data:
number = 45, -2, 20.5
Page 29 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
9. Draw the trace table and determine the output from the following flowchart using the following
data (NOTE: input of the word “end” stops the program and outputs results of the survey):
vehicle = car, car, lorry, bus, van, van, car, car, bus, car, end
Page 30 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
10. Draw the trace table and determine the output from the following flowchart using the following
data:
X = 5, -3, 0, -3, 7, 0, 6, -11, -7, 12
Page 31 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Past Papers Questions:
Modular Design/Top-down design:
(Computing 9691 Questions)
May/June 2006
5. (a) Programs can be designed in modular form.
Discuss the advantages and disadvantages of designing programs in modular form.
[5]
(b) A program is to be written which will update the records in a sequential file and then
produce a backup copy.
Describe, using a diagram, the way that this problem can be split into modules to prepare it for
coding. [5]
May/June 2009
A company specialises in creating websites for customers.
8. (a) As part of the process of designing a site, the company will use diagrams in order to make
understanding easier.
Describe two types of diagram that may be used by the company. [4]
May/June 2011. P23
1. (a) Draw a suitable layout for the screen. [5]
3. Kris has written a program that will work out the wages for her staff. The main steps for each
employee are: to work out the hours worked, work out the total earnings, work out tax and finally
print out how much will be taken home.
(a) Complete the structure diagram to show the modules that will be needed.
[3]
(b) The printout will be different for those staff who receives cash and
those who have their earnings paid directly to a bank account. Add the
next level to the print module.
Oct/NOV 2011 P23
Page 32 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
1 Nathan is designing a software solution for stock control in a computer shop. He has a colleague,
called Andre, who will help him write the program. Nathan decides to modularise the solution.
(a) State why modularisation is a good idea. [1]
(b) As the first step in his design he splits the solution into the following main areas:
Initialisation, StockOrdering, Sales, SalesReport.
Complete the following structure diagram.
[1]
(c) SalesReport is made up of two modules, MonthlySalesReport and AnnualSalesReport.
Add them to the structure diagram in (b). [2]
Oct/NOV 2012 P21
1 Soni works for a software house which has been asked to design software for a cycle hire company,
Super Bikes.
Soni decides on the main tasks:
collecting the information about new bikes
entering details of repairs
entering details of hirer
entering details of payment
(a) Complete the structure diagram showing these tasks.
[2]
(b) The collection of information about repairs has three subtasks:
input the repair needed
input the parts list
input the cost of the repair
Add these to the structure diagram in part (a). [1]
(c) State two reasons for dividing the main task into smaller tasks. [2]
Page 33 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Flow Charts:
May/June 2006
9
Trace the flow chart using the numbers 2 and 3. Write down each of the values of N in the order that they are
printed out.
(a) 2 [1]
(b) 3 [2]
Page 34 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2006
17 The following flowchart shows how the bar code written on an item is used to find the price, do stock
control and produce an itemised bill. Select statements from the list below to complete the flowchart.
Page 35 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2007
11 Study the following flowchart very carefully.
(a) Complete the following table showing the expected output from the flowchart for the three sets of input
data:
Page 36 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2007
11) Majid lives in Cairo but often travels to Tokyo, Mumbai and Washington. A flow chart has been written
so he can work out the local time in these three places.
Page 37 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 38 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2008
9) The following flowchart inputs two numbers, carries out a calculation and then outputs the result.
(a) Complete the following table for the three sets of input data.
Page 39 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2008
17) The following flowchart shows how sensors (which can be analogue or digital) and a computer are used to
control the temperature of a greenhouse for plants. Complete the flowchart using the items from the list below.
Page 40 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
19) The manufacturing cost of producing an item depends on its complexity. A company manufactures three
different types of item, with costs based on the following calculations:
Item type 1: item cost = parts cost * 1.5
Item type 2: item cost = parts cost * 2.5
Item type 3: item cost = parts cost * 5.0
The company makes 1000 items per day.
Write an algorithm, using pseudocode, flowchart or otherwise, which
inputs the item type and parts cost of each item
outputs the item cost for each item
calculates and outputs the average (mean) item cost per day (based on 1000 items being made).
[5]
Page 41 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2009
14) Study the flowchart very carefully.
(a) Complete the table to show what outputs you would expect for the two inputs.
Page 42 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
16) The following flowchart shows what happens when a customer uses a credit card to pay for goods at a
supermarket. Ten of the boxes are blank.
Using the items from the list, insert the ten missing statements using the appropriate number only. Each
statement may be used once only.
Page 43 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2009. P11
9) Study the flowchart.
May/June 2010. P11
18) A group of students were monitoring the temperature every day over a one-year period.
Readings were taken ten times every day (you may assume a year contains 365 days).
Write an algorithm, using pseudocode or flowchart, which
inputs all the temperatures (ten per day)
outputs the highest temperature taken over the year
outputs the lowest temperature taken over the year
outputs the average temperature per day
outputs the average temperature for the whole year
Page 44 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2010. P12
13) Study the following flowchart very carefully:
Page 45 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
16 (a) Write an algorithm, using pseudocode or a flowchart, which:
_ inputs 50 numbers
_ outputs how many of the numbers were > 100 [3]
(b) Write an algorithm, using pseudocode or a flowchart, which:
_ inputs 100 numbers
_ finds the average of the input numbers
_ outputs the average [3]
Page 46 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2010. P13
Oct/Nov 2010. P11
4 (a) To log on to a computer, a user needs to type in a user id followed by a password; these should match
up. Only three attempts are allowed.
The flowchart below shows the log on procedure. Several boxes have been left blank.
Complete the flowchart using items from the list.
Page 47 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
17) A school is doing a check on the heights and weights of all its students. The school has 1000 students.
Write an algorithm, using pseudocode or a flowchart, which
‱ inputs the height and weight of all 1000 students
‱ outputs the average (mean) height and weight
‱ includes any necessary error traps for the input of height and weight [5]
Page 48 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2010. P13
15 (a) The following flowchart shows how a burglar alarm system uses light sensors to determine if an
intruder has entered the house and decides to sound an alarm.
Select statements from the list below, using numbers only, to complete the flowchart.
Page 49 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
17 (a) Write an algorithm, using pseudocode or a flowchart, which
_ inputs a set of positive numbers (which end with -1)
_ outputs the average (mean) value of the input numbers
_ outputs the value of the largest (highest) number input [4]
(b) Write an algorithm, using pseudocode or a flowchart, which
_ inputs a whole number (which is > 0)
_ calculates the number of digits in the number
_ outputs the number of digits and the original number
(E.g. 147 would give an output of 3, 147) [4]
Page 50 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2011. P11
5) Study the following flowchart very carefully:
Page 51 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
(b) What is the purpose of this flowchart? [1]
Page 52 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2011. P12
10 The following flowchart inputs ten temperatures and outputs the average (mean) temperature and the
number of temperatures which were negative (i.e. < 0).
Page 53 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 54 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2011. P11
Page 55 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 56 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 57 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2011. P13
Page 58 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 59 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 60 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2012. P11
Page 61 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 62 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 63 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 64 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2012. P12
Page 65 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 66 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2012. P12
Page 67 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 68 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 69 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 70 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2012. P13
Page 71 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 72 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 73 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 74 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2013. P11
Page 75 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 76 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2013. P12
Page 77 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 78 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 79 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
May/June 2013. P12
Page 80 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2013. P12
5 Study the following flowchart very carefully
Page 81 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Complete the trace table for the following two sets of data:
(i) a = 5, b = 4, c = 1, d = 9
(ii) a = 5, b = 9, c = 4, d = 1
Page 82 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
15 A library uses barcodes to identify borrowers and books. A borrower has a card containing a barcode
with an equivalent numerical code. Each book also has a barcode with an equivalent numerical code.
The flowchart on the facing page shows what happens when book(s) are taken out by a borrower.
However, several stages are missing.
Using item numbers only, complete the flowchart by selecting stages from the item list below.
Page 83 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Page 84 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design
Oct/Nov 2013. P13
14 A microprocessor controls the opening and closing of automatic doors to a supermarket. Customers are
detected using pressure sensors.
The flowchart on the next page shows how the sensors and microprocessor interact to control the opening and
closing of the doors. However, several of the stages in the process have been missed out.
Using item number only, complete the flowchart using items from the following list:
Page 85 of 85
2.1 Algorithm design and
problem-solving
2.1.1 Problem-solving and design

More Related Content

What's hot

Quran para 6 for Kindle
Quran para 6 for KindleQuran para 6 for Kindle
Quran para 6 for Kindleharoobnabbas
 
Week- 08 - Feeder protection and Bus–Bar Protection.
Week- 08 - Feeder protection and  Bus–Bar Protection.Week- 08 - Feeder protection and  Bus–Bar Protection.
Week- 08 - Feeder protection and Bus–Bar Protection.PremanandDesai
 
064 teks viler - karavan nade
064   teks viler - karavan nade064   teks viler - karavan nade
064 teks viler - karavan nadezoran radovic
 
Python Programming ADP VTU CSE 18CS55 Module 4 Chapter 3
Python Programming ADP VTU CSE 18CS55 Module 4 Chapter 3Python Programming ADP VTU CSE 18CS55 Module 4 Chapter 3
Python Programming ADP VTU CSE 18CS55 Module 4 Chapter 3Demian Antony DMello
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1Emmanuel Alimpolos
 
La civilizacion industrial y el hombre
La civilizacion industrial y el hombreLa civilizacion industrial y el hombre
La civilizacion industrial y el hombrecarol2202
 
Si Cr Zm - Hor 01 - VB
Si Cr Zm - Hor 01 - VBSi Cr Zm - Hor 01 - VB
Si Cr Zm - Hor 01 - VBStripovi Klub
 
Quran para 3 for Kindle
Quran para 3 for Kindle Quran para 3 for Kindle
Quran para 3 for Kindle haroobnabbas
 
Fukushima Cognitron
Fukushima CognitronFukushima Cognitron
Fukushima CognitronESCOM
 
Week-08 - Transformer Assembly-Threephase
Week-08 - Transformer Assembly-ThreephaseWeek-08 - Transformer Assembly-Threephase
Week-08 - Transformer Assembly-ThreephasePremanandDesai
 
CatĂĄlogo Giannini 1950
CatĂĄlogo Giannini 1950CatĂĄlogo Giannini 1950
CatĂĄlogo Giannini 1950Roberto Fontanezi
 
Aasan Tarjuma Quran (Tauzeeh ul-quran) ŰąŰłŰ§Ù† ŰȘŰ±ŰŹÙ…Û Ù‚Ű±ŰąÙ† (ŰȘÙˆŰ¶ÛŒŰ­ Ű§Ù„Ù‚Ű±ŰąÙ†) ۔
Aasan Tarjuma Quran (Tauzeeh ul-quran) ŰąŰłŰ§Ù† ŰȘŰ±ŰŹÙ…Û Ù‚Ű±ŰąÙ† (ŰȘÙˆŰ¶ÛŒŰ­ Ű§Ù„Ù‚Ű±ŰąÙ†) ۔Aasan Tarjuma Quran (Tauzeeh ul-quran) ŰąŰłŰ§Ù† ŰȘŰ±ŰŹÙ…Û Ù‚Ű±ŰąÙ† (ŰȘÙˆŰ¶ÛŒŰ­ Ű§Ù„Ù‚Ű±ŰąÙ†) ۔
Aasan Tarjuma Quran (Tauzeeh ul-quran) ŰąŰłŰ§Ù† ŰȘŰ±ŰŹÙ…Û Ù‚Ű±ŰąÙ† (ŰȘÙˆŰ¶ÛŒŰ­ Ű§Ù„Ù‚Ű±ŰąÙ†) ۔Asad-Mughal
 
Jim mc kee why the .22 squirrel - scn fall 2007
Jim mc kee   why the .22 squirrel - scn fall 2007Jim mc kee   why the .22 squirrel - scn fall 2007
Jim mc kee why the .22 squirrel - scn fall 2007L L
 
Quran para 20 for Kindle
Quran para 20 for KindleQuran para 20 for Kindle
Quran para 20 for Kindleharoobnabbas
 
0396 Tajanstveni Jahač
0396  Tajanstveni Jahač0396  Tajanstveni Jahač
0396 Tajanstveni JahačTompa *
 

What's hot (20)

Lycklama a Nijeholt in Nederlandsche Leeuw 2017
Lycklama a Nijeholt in Nederlandsche Leeuw 2017Lycklama a Nijeholt in Nederlandsche Leeuw 2017
Lycklama a Nijeholt in Nederlandsche Leeuw 2017
 
Quran para 6 for Kindle
Quran para 6 for KindleQuran para 6 for Kindle
Quran para 6 for Kindle
 
Week- 08 - Feeder protection and Bus–Bar Protection.
Week- 08 - Feeder protection and  Bus–Bar Protection.Week- 08 - Feeder protection and  Bus–Bar Protection.
Week- 08 - Feeder protection and Bus–Bar Protection.
 
064 teks viler - karavan nade
064   teks viler - karavan nade064   teks viler - karavan nade
064 teks viler - karavan nade
 
Python Programming ADP VTU CSE 18CS55 Module 4 Chapter 3
Python Programming ADP VTU CSE 18CS55 Module 4 Chapter 3Python Programming ADP VTU CSE 18CS55 Module 4 Chapter 3
Python Programming ADP VTU CSE 18CS55 Module 4 Chapter 3
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
La civilizacion industrial y el hombre
La civilizacion industrial y el hombreLa civilizacion industrial y el hombre
La civilizacion industrial y el hombre
 
Si Cr Zm - Hor 01 - VB
Si Cr Zm - Hor 01 - VBSi Cr Zm - Hor 01 - VB
Si Cr Zm - Hor 01 - VB
 
Quran para 3 for Kindle
Quran para 3 for Kindle Quran para 3 for Kindle
Quran para 3 for Kindle
 
Quran with Tajwid Surah 63 ïŽŸŰ§Ù„Ù‚Ű±ŰąÙ† ŰłÙˆŰ±Ûƒ Ű§Ù„Ù…Ù†Ű§ÙÙ‚ÙˆÙ†ïŽż Al-Munafiqun đŸ™Ș PDF
Quran with Tajwid Surah 63 ïŽŸŰ§Ù„Ù‚Ű±ŰąÙ† ŰłÙˆŰ±Ûƒ Ű§Ù„Ù…Ù†Ű§ÙÙ‚ÙˆÙ†ïŽż Al-Munafiqun đŸ™Ș PDFQuran with Tajwid Surah 63 ïŽŸŰ§Ù„Ù‚Ű±ŰąÙ† ŰłÙˆŰ±Ûƒ Ű§Ù„Ù…Ù†Ű§ÙÙ‚ÙˆÙ†ïŽż Al-Munafiqun đŸ™Ș PDF
Quran with Tajwid Surah 63 ïŽŸŰ§Ù„Ù‚Ű±ŰąÙ† ŰłÙˆŰ±Ûƒ Ű§Ù„Ù…Ù†Ű§ÙÙ‚ÙˆÙ†ïŽż Al-Munafiqun đŸ™Ș PDF
 
Fukushima Cognitron
Fukushima CognitronFukushima Cognitron
Fukushima Cognitron
 
Masters Degree Front
Masters Degree FrontMasters Degree Front
Masters Degree Front
 
Week-08 - Transformer Assembly-Threephase
Week-08 - Transformer Assembly-ThreephaseWeek-08 - Transformer Assembly-Threephase
Week-08 - Transformer Assembly-Threephase
 
Quran with Tajwid Surah 93 ïŽŸŰ§Ù„Ù‚Ű±ŰąÙ† ŰłÙˆŰ±Ûƒ Ű§Ù„Ű¶Ű­Ù‰ïŽż Ad-Dhuha đŸ™Ș PDF
Quran with Tajwid Surah 93 ïŽŸŰ§Ù„Ù‚Ű±ŰąÙ† ŰłÙˆŰ±Ûƒ Ű§Ù„Ű¶Ű­Ù‰ïŽż Ad-Dhuha đŸ™Ș PDFQuran with Tajwid Surah 93 ïŽŸŰ§Ù„Ù‚Ű±ŰąÙ† ŰłÙˆŰ±Ûƒ Ű§Ù„Ű¶Ű­Ù‰ïŽż Ad-Dhuha đŸ™Ș PDF
Quran with Tajwid Surah 93 ïŽŸŰ§Ù„Ù‚Ű±ŰąÙ† ŰłÙˆŰ±Ûƒ Ű§Ù„Ű¶Ű­Ù‰ïŽż Ad-Dhuha đŸ™Ș PDF
 
Verification of Ohm's Law
Verification of Ohm's LawVerification of Ohm's Law
Verification of Ohm's Law
 
CatĂĄlogo Giannini 1950
CatĂĄlogo Giannini 1950CatĂĄlogo Giannini 1950
CatĂĄlogo Giannini 1950
 
Aasan Tarjuma Quran (Tauzeeh ul-quran) ŰąŰłŰ§Ù† ŰȘŰ±ŰŹÙ…Û Ù‚Ű±ŰąÙ† (ŰȘÙˆŰ¶ÛŒŰ­ Ű§Ù„Ù‚Ű±ŰąÙ†) ۔
Aasan Tarjuma Quran (Tauzeeh ul-quran) ŰąŰłŰ§Ù† ŰȘŰ±ŰŹÙ…Û Ù‚Ű±ŰąÙ† (ŰȘÙˆŰ¶ÛŒŰ­ Ű§Ù„Ù‚Ű±ŰąÙ†) ۔Aasan Tarjuma Quran (Tauzeeh ul-quran) ŰąŰłŰ§Ù† ŰȘŰ±ŰŹÙ…Û Ù‚Ű±ŰąÙ† (ŰȘÙˆŰ¶ÛŒŰ­ Ű§Ù„Ù‚Ű±ŰąÙ†) ۔
Aasan Tarjuma Quran (Tauzeeh ul-quran) ŰąŰłŰ§Ù† ŰȘŰ±ŰŹÙ…Û Ù‚Ű±ŰąÙ† (ŰȘÙˆŰ¶ÛŒŰ­ Ű§Ù„Ù‚Ű±ŰąÙ†) ۔
 
Jim mc kee why the .22 squirrel - scn fall 2007
Jim mc kee   why the .22 squirrel - scn fall 2007Jim mc kee   why the .22 squirrel - scn fall 2007
Jim mc kee why the .22 squirrel - scn fall 2007
 
Quran para 20 for Kindle
Quran para 20 for KindleQuran para 20 for Kindle
Quran para 20 for Kindle
 
0396 Tajanstveni Jahač
0396  Tajanstveni Jahač0396  Tajanstveni Jahač
0396 Tajanstveni Jahač
 

Similar to problem solving and design By ZAK

As Level Computer Science Book -2
As Level Computer Science  Book -2As Level Computer Science  Book -2
As Level Computer Science Book -2DIGDARSHAN KUNWAR
 
Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software developmentHattori Sidek
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdfMIT,Imphal
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challengesDhanu Srikar
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartSachin Goyani
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing TechniquesAppili Vamsi Krishna
 
Fundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptxFundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptxEyasu46
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchartRohit Shrivastava
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review ProcessDr. Syed Hassan Amin
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithmmshoaib15
 
Chapter 2(1)
Chapter 2(1)Chapter 2(1)
Chapter 2(1)TejaswiB4
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptxTadiwaMawere
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptxssuser586772
 
Software develop....
Software develop.... Software develop....
Software develop.... GCWUS
 
GE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfGE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfAsst.prof M.Gokilavani
 
COM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptxCOM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptxAnasYunusa
 
Qat09 presentations dxw07u
Qat09 presentations dxw07uQat09 presentations dxw07u
Qat09 presentations dxw07uShubham Sharma
 

Similar to problem solving and design By ZAK (20)

As Level Computer Science Book -2
As Level Computer Science  Book -2As Level Computer Science  Book -2
As Level Computer Science Book -2
 
Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software development
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Practical 01 (detailed)
Practical 01 (detailed)Practical 01 (detailed)
Practical 01 (detailed)
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
 
Fundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptxFundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptx
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
Module 1 python.pptx
Module 1 python.pptxModule 1 python.pptx
Module 1 python.pptx
 
Chapter 2(1)
Chapter 2(1)Chapter 2(1)
Chapter 2(1)
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx
 
Software develop....
Software develop.... Software develop....
Software develop....
 
GE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfGE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdf
 
COM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptxCOM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptx
 
Qat09 presentations dxw07u
Qat09 presentations dxw07uQat09 presentations dxw07u
Qat09 presentations dxw07u
 

More from Tabsheer Hasan

Lab Network Settings And Testing
Lab Network Settings And TestingLab Network Settings And Testing
Lab Network Settings And TestingTabsheer Hasan
 
How to train cortana to respond to your voice
How to train cortana to respond to your voiceHow to train cortana to respond to your voice
How to train cortana to respond to your voiceTabsheer Hasan
 
How to turn on hey cortana on windows 10
How to turn on hey cortana on windows 10How to turn on hey cortana on windows 10
How to turn on hey cortana on windows 10Tabsheer Hasan
 
How to pin cortana to your taskbar on
How to pin cortana to your taskbar on How to pin cortana to your taskbar on
How to pin cortana to your taskbar on Tabsheer Hasan
 
Introduction To Computer
Introduction To ComputerIntroduction To Computer
Introduction To ComputerTabsheer Hasan
 
How to set up cortana on windows 10
How to set up cortana on windows 10How to set up cortana on windows 10
How to set up cortana on windows 10Tabsheer Hasan
 
2210 s15 qp_ms_er_12
2210 s15 qp_ms_er_122210 s15 qp_ms_er_12
2210 s15 qp_ms_er_12Tabsheer Hasan
 
Databases By ZAK
Databases By ZAKDatabases By ZAK
Databases By ZAKTabsheer Hasan
 
Data structures; arrays By ZAK
Data structures; arrays By ZAKData structures; arrays By ZAK
Data structures; arrays By ZAKTabsheer Hasan
 
Programming concepts By ZAK
Programming concepts By ZAKProgramming concepts By ZAK
Programming concepts By ZAKTabsheer Hasan
 
Pseudocode By ZAK
Pseudocode By ZAKPseudocode By ZAK
Pseudocode By ZAKTabsheer Hasan
 
operating systems By ZAK
operating systems By ZAKoperating systems By ZAK
operating systems By ZAKTabsheer Hasan
 
memory, storage devices and media By ZAK
memory, storage devices and media By ZAKmemory, storage devices and media By ZAK
memory, storage devices and media By ZAKTabsheer Hasan
 
input devices By ZAK
input devices By ZAKinput devices By ZAK
input devices By ZAKTabsheer Hasan
 
1.3.2 computer architecture and the fetch execute cycle By ZAK
1.3.2 computer architecture and the fetch execute cycle By ZAK1.3.2 computer architecture and the fetch execute cycle By ZAK
1.3.2 computer architecture and the fetch execute cycle By ZAKTabsheer Hasan
 
computer architecture and the fetch execute cycle By ZAK
computer architecture and the fetch execute cycle By ZAKcomputer architecture and the fetch execute cycle By ZAK
computer architecture and the fetch execute cycle By ZAKTabsheer Hasan
 
logic gates By ZAK
logic gates By ZAKlogic gates By ZAK
logic gates By ZAKTabsheer Hasan
 
internet principles of operation By ZAK
internet principles of operation By ZAKinternet principles of operation By ZAK
internet principles of operation By ZAKTabsheer Hasan
 

More from Tabsheer Hasan (20)

Lab Network Settings And Testing
Lab Network Settings And TestingLab Network Settings And Testing
Lab Network Settings And Testing
 
How to train cortana to respond to your voice
How to train cortana to respond to your voiceHow to train cortana to respond to your voice
How to train cortana to respond to your voice
 
How to turn on hey cortana on windows 10
How to turn on hey cortana on windows 10How to turn on hey cortana on windows 10
How to turn on hey cortana on windows 10
 
How to pin cortana to your taskbar on
How to pin cortana to your taskbar on How to pin cortana to your taskbar on
How to pin cortana to your taskbar on
 
Introduction To Computer
Introduction To ComputerIntroduction To Computer
Introduction To Computer
 
How to set up cortana on windows 10
How to set up cortana on windows 10How to set up cortana on windows 10
How to set up cortana on windows 10
 
2210 s15 qp_ms_er_12
2210 s15 qp_ms_er_122210 s15 qp_ms_er_12
2210 s15 qp_ms_er_12
 
Databases By ZAK
Databases By ZAKDatabases By ZAK
Databases By ZAK
 
Data structures; arrays By ZAK
Data structures; arrays By ZAKData structures; arrays By ZAK
Data structures; arrays By ZAK
 
Programming concepts By ZAK
Programming concepts By ZAKProgramming concepts By ZAK
Programming concepts By ZAK
 
Pseudocode By ZAK
Pseudocode By ZAKPseudocode By ZAK
Pseudocode By ZAK
 
Ethics By ZAK
Ethics By ZAKEthics By ZAK
Ethics By ZAK
 
security By ZAK
security By ZAKsecurity By ZAK
security By ZAK
 
operating systems By ZAK
operating systems By ZAKoperating systems By ZAK
operating systems By ZAK
 
memory, storage devices and media By ZAK
memory, storage devices and media By ZAKmemory, storage devices and media By ZAK
memory, storage devices and media By ZAK
 
input devices By ZAK
input devices By ZAKinput devices By ZAK
input devices By ZAK
 
1.3.2 computer architecture and the fetch execute cycle By ZAK
1.3.2 computer architecture and the fetch execute cycle By ZAK1.3.2 computer architecture and the fetch execute cycle By ZAK
1.3.2 computer architecture and the fetch execute cycle By ZAK
 
computer architecture and the fetch execute cycle By ZAK
computer architecture and the fetch execute cycle By ZAKcomputer architecture and the fetch execute cycle By ZAK
computer architecture and the fetch execute cycle By ZAK
 
logic gates By ZAK
logic gates By ZAKlogic gates By ZAK
logic gates By ZAK
 
internet principles of operation By ZAK
internet principles of operation By ZAKinternet principles of operation By ZAK
internet principles of operation By ZAK
 

Recently uploaded

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

problem solving and design By ZAK

  • 1. Page 1 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Advantages of designing a solution to a problem by splitting it up into smaller problems (top- down/modular design) Produce and describe top-down/modular designs using appropriate techniques, including structure diagrams, showing stepwise refinement Top down/modular design A Top-down design is when a problem is split into smaller sub-problems, which themselves are split into even smaller sub-problems until each is just one element of the final program. Benefits and drawbacks of modular programs
  • 2. Page 2 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Structure diagrams A structure diagram is a pictorial representation of a modular system. Stepwise refinement Stepwise refinement is the process of developing a modular design by splitting a problem into smaller sub- tasks, which themselves are repeatedly split into even smaller sub-tasks until each is just one element of the final program.
  • 3. Page 3 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design produce an algorithm for a given problem either in pseudocode form or the flowchart form understand algorithms presented in the form of program flowcharts and pseudocode What is an Algorithm? An algorithm is a sequence of steps, which perform a specific task. In computing, algorithms are usually represented as a program flowchart, or in pseudocode. What is a program flowchart? A program flowchart is a pictorial representation of an algorithm. Program flowcharts consist of special symbols:
  • 4. Page 4 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Here is an example of a flowchart to output the first five squared numbers:
  • 5. Page 5 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design What is Pseudocode? Pseudo-code is a simplified form of programming code that uses common programming terminologies, but does not use the strict syntax rules of a programming language. An example of a pseudocode algorithm: { BEGIN INPUT CardNumber REPEAT INPUT PIN IF PIN is wrong for this CardNumber THEN OUTPUT “Wrong Pin” END IF UNTIL Pin is correct INPUT Amount IF there are enough funds THEN Dispense Cash Update customer’s balance ELSE OUTPUT “Sorry, insufficient funds” END IF END } Algorithms should be evaluated using the following criteria: 1. Efficiency 2. Correctness 3. Appropriateness Efficiency An algorithm’s efficiency can be judged in terms of: ‱ Speed: How quick the algorithm produces the required output. ‱ Memory requirements: How many lines of code the algorithm contains.
  • 6. Page 6 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Correctness Although an algorithm is expected to produce the correct outputs, correctness can still be measured in terms of: Accuracy : How many decimal places produce output with greater accuracy (e.g. more decimal places) Range: Will the algorithm work with the complete range of inputs? Or can it only deal with positive numbers, whole numbers, numbers below 1 million, etc. Reliability: Will the algorithm always produce correct output within the range that it is designed to work? Or are there values which it will not accept (e.g. zero). Appropriateness Appropriateness can be measured in terms of: Length: If the problem is simple then a short algorithm would normally be expected. Speed: if the output needs to be generated quickly, then the algorithm must be able to generate output quick enough. Memory requirements: An algorithm controlling a washing machine must not require a lot of memory!
  • 7. Page 7 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Flow Charts Introduction: This section covers the use of flow diagrams (charts) in the production of algorithms. This topic must not be confused with “Systems flowcharts” as those are different and these are covered in a different section (Systems analysis). This section primarily covers four areas: 1. Common flow chart symbols 2. Writing flowcharts to solve problems 3. Dry running of flowcharts to determine its function and outputs 4. Exercises to test the above concepts 5. Topical past paper questions
  • 8. Page 8 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 1. Common flowchart symbols
  • 9. Page 9 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Understand and use assignment statements What is an Assignment? An assignment is an instruction in a program that places a value into a specified variable. Some typical assignments are: Note that the last example is a common method used to increment the value of a variable. It could be read as: (The new value of “Counter” is its existing value plus one) TheLength  20.5 TheUsersName$  “Charlie” TheArea  TheWidth * TheLength TotalCost  LabelledCost + 15 Counter  Counter + 1
  • 10. Page 10 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Arithmetic operators including operators for integer Addition, subtraction and multiplication Powers Division A result of a division such as 17 Ă· 4 can be expressed either as a real (4.25) or as two integers (4 remainder 1). The integer method, in most programming languages, uses the operators DIV and MOD.
  • 11. Page 11 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Relational operators, eg. =, <, <=, >, >= and <> Relational operators are used in the format: [Expression] [Operator] [Expression] and will always return a Boolean (True or False) value. Relational operators are typically used with the “IF” selection and also within conditional loops (REPEAT-UNTIL or WHILE-WEND). In the following table, the variables “a” and “name$” have the following assignments: a3+5 name$ “JAMES”
  • 12. Page 12 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Boolean operators AND, OR and NOT AND & OR The AND & OR operators always return a Boolean result and are used in the format: [Boolean] [Operator] [Boolean] The following ‘truth’ table summarizes the result of the Boolean operations: Values Results NOT The NOT operator reverses the result of the Boolean expression and is used in the format: NOT [Boolean] The following truth table summarizes the NOT operation: Examples of Boolean ‘logic’ Consider the following algorithm, which is used to monitor a printer and display its output via an LCD display in the front panel: IF NOT(PaperTrayEmpty) AND (FilesWaiting > 0) THEN OUTPUT “PRINTING
” ELSE OUTPUT “PLEASE ADD PAPER” END IF
  • 13. Page 13 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Validation Validation checks ensure that data entered into the computer is sensible. Data is checked in accordance with a set of rules. The computer's software can validate data while it is being entered into the computer. The main purpose of data validation is to spot an error. This can be done quickly and easily as the process is automated. 1. Range check. A mathematics exam is out of 100. A simple validation rule that the computer can apply to any data that is input is that the mark must be between 0 and 100 inclusive. Consequently, a mark of 101 would be rejected by this check as being outside the acceptable range. 2. Character check. A person’s name will consist of letters of the alphabet and sometimes a hyphen or apostrophe. This rule can be applied to input of a person’s name so that dav2d will immediately be rejected as unacceptable. 3. Format check. A particular application is set up to accept a national insurance number. Each person has a unique national insurance number, but they all have the same format of characters, 2 letters followed by 6 digits followed by a single letter. If the computer knows this rule then it knows what the format of a NI number is and would reject ABC12345Z because it is in the wrong format, it breaks the rule. 4. Length check. A NI number has 9 characters, if more or fewer than 9 characters are keyed in then the data cannot be accurate. 5. Existence check. A bar code is read at a supermarket check-out till. The code is sent to the main computer which will search for that code on the stock file. As the stock file contains details of all items held in stock, if it is not there then the item cannot exist, which it obviously does, therefore the code must have been wrongly read.
  • 14. Page 14 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Presence check Code can be added to check that a particular control has not been left empty or un-checked: If Username = “” Then Print (“You have not entered a Username”) End Range check Code can be added to check that a particular control has a value between an allowed maximum and minimum: If Age < 11 OR Age > 70 Then Print (“The age that you have entered is not within the permitted range”) End Is Username = “”? You have not entered a Username No Yes Is (Age)< 11 OR (Age)> 70 The age that you have entered is not within the permitted range No Yes
  • 15. Page 15 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Length check Code can be added to check that a particular control has a value between an allowed maximum and minimum: If Len(Password) > 12 Then Print (“The password that you have entered is too long”) End Is Len(Password)> 12? The password that you have entered is too long No Yes
  • 16. Page 16 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 2. Writing flowcharts to solve problems The following five problems are also covered in section 3.2 where the algorithms are constructed using pseudocode. Candidates may choose to answer questions using either flowcharts or pseudocode but a working knowledge of both techniques is well advised. 2.1 Example 1 A town contains 5000 houses. Each house owner must pay tax based on the value of the house. Houses over $200 000 pay 2% of their value in tax, houses over $100 000 pay 1.5% of their value in tax and houses over $50 000 pay 1% of their value in tax. All others pay no tax. Write an algorithm to solve this problem in the form of a flowchart. 2.2 Example 2 The following formula is used to calculate n: n = (x * x)/(1 – x). The value x = 0 is used to stop the algorithm. The calculation is repeated using values of x until the value x = 0 is input. There is also a need to check for error conditions. The values of n and x should be output. Write an algorithm to show this repeated calculation in the form of a flowchart. 2.3 Example 3 Write an algorithm in the form of a flowchart which takes temperatures input over a 100 day period (once per day) and outputs the number of days when the temperature was below 20ÂșC and the number of days when the temperature was 20ÂșC and above. 2.4 Example 4 Write an algorithm in the form of a flowchart which: inputs the top speeds (in km/hr) of 5000 cars outputs the fastest speed and the slowest speed outputs the average (mean) speed of all the 5000 cars 2.5 Example 5 A shop sells books, maps and magazines. Each item is identified by a unique 4 – digit code. All books have a code starting with 1, all maps have a code starting with 2 and all magazines have a code starting with 3. The code 9999 is used to end the algorithm. Write an algorithm in the form of a flowchart which inputs the codes for all items in stock and outputs the number of books, number of maps and the number of magazines in stock. Include any validation checks needed.
  • 17. Page 17 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Answers to the Examples:
  • 18. Page 18 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 19. Page 19 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 20. Page 20 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 21. Page 21 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 22. Page 22 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 3. Dry running of flowcharts Dry running of flowcharts is basically a technique to: Determine the output for a known set of data to check it carries out the task correctly. Check the logic of the algorithm. Determine the function of the algorithm. When dry running a flowchart it is advisable to draw up a trace table showing how variables change their values at each stage in the algorithm. The advantages of doing this are: If you make a mistake, it is easier to back track to where the error occurred rather than starting from the beginning again There is less chance of an error being made Encourages a more logical approach The following three examples show all stages in the dry running for the given set of input data: 3.1 Example 1 This algorithm inputs 3 numbers, each number goes through successive division by 10 until its value is less than 1. An output is produced which contains the number input and a value generated by the flowchart processing. Data to be used: X = 85, 3190, -40 3.2 Example 2 This algorithm inputs 5 values and outputs how many input numbers were negative and how many were positive. Data to be used: N = 1, -5, 2, -8, -7 3.3 Example 3 This algorithm inputs the number of hours of sunshine recorded each day for a week (7 days). The output is the highest value for hours of sunshine and the average (mean) value for the numbers of hours of sunshine per day. Data to be used: hours = 9.0, 7.8, 1.2, 4.5, 10.0, 6.4, 3.1
  • 23. Page 23 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Answers to the Examples:
  • 24. Page 24 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 25. Page 25 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 26. Page 26 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Questions 1 to 7 are problems which require an algorithm to be written in the form of a flowchart. Questions 8 to 10 require a trace table to be written and find the expected output for the given set of data. The answers to these questions can be found in booklet 6. 1. Regis lives in Brazil and often travels to USA, Europe and Japan. He wants to be able to convert Brazilian Reais into US dollars, European euros and Japanese yen. The conversion formula is: Currency value = number of Reais X conversion rate For example, if Regis is going to USA and wants to take 1000 Reais (and the exchange rate is 0.48) then he would input USA, 1000 and 0.48 and the output would be: 480 US dollars. Write an algorithm, using a flowchart, which inputs the country he is visiting, the exchange rate and the amount in Brazilian Reais he is taking. The output will be value in foreign currency and the name of the currency. 2. As part of an experiment, a school measured the heights (in meters) of all its 500 students. Write an algorithm, using a flowchart, which inputs the heights of all 500 students and outputs the height of the tallest person and the shortest person in the school. 3. A geography class decide to measure daily temperatures and hours of sunshine per day over a 12 month period (365 days) Write an algorithm, using a flowchart, which inputs the temperatures and hours of sunshine for all 365 days, and finally outputs the average (mean) temperature for the year and the average (mean) number of hours per day over the year. 4. A small shop sells 280 different items. Each item is identified by a 3 – digit code. All items that start with a zero (0) are cards, all items that start with a one (1) are sweets, all items that start with a two (2) are stationery and all items that start with a three (3) are toys. Write an algorithm, using a flowchart, which inputs the 3 – digit code for all 280 items and outputs the number of cards, sweets, stationery and toys. 5. A company is carrying out a survey by observing traffic at a road junction. Each time a car, bus or lorry passed by the road junction it was noted down. 10 000 vehicles were counted during the survey. Write an algorithm, using an algorithm, which: inputs all 10000 responses outputs the number of cars, buses and lorries that passed by the junction during the survey outputs the number of vehicles that weren’t cars, buses or lorries during the survey.
  • 27. Page 27 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 6. Speed cameras read the time a vehicle passes a point (A) on the road and then reads the time it passes a second point (B) on the same road (points A and B are 100 metres apart). The speed of the vehicle is calculated using: The maximum allowed speed is 100 kilometers per hour. 500 vehicles were monitored using these cameras over a 1 hour period. Write an algorithm, using a flowchart, which: inputs the start time and end time for the 500 vehicles that were monitored calculate the speed for each vehicle using the formula above outputs the speed for each vehicle and also a message if the speed exceeded 100 km/hour output the highest speed of all the 500 vehicles monitored 7. There are ten stations on a railway line: 1 ------ 2 ------ 3 ------ 4 ------ 5 ------ 6 ------ 7 ------ 8 ------ 9 ------ 10 The train travels in both directions (i.e. from 1 to 10 and then from 10 to 1). The fare between each station is $2. A passenger inputs the number of the station at the start of his journey and the number of the destination station and the fare is calculated (e.g if a passenger gets on a station 3 and his destination is station 9 his fare will be $12). The calculation must take into account the direction of the train (e.g. a passenger getting on at station 7 and getting off at station 1 will also pay $12 and not a negative value!!). A discount of 10% is given if 3 or more passengers are travelling together. Write an algorithm, using a flowchart, which: inputs the number of passengers travelling inputs the station number of the starting point and the station number of the destination calculates the total fare taking into account the direction of travel calculates any discount due outputs the cost of the tickets and prints the tickets
  • 28. Page 28 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 8. Draw the trace table and determine the output from the following flowchart using the following data: number = 45, -2, 20.5
  • 29. Page 29 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 9. Draw the trace table and determine the output from the following flowchart using the following data (NOTE: input of the word “end” stops the program and outputs results of the survey): vehicle = car, car, lorry, bus, van, van, car, car, bus, car, end
  • 30. Page 30 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 10. Draw the trace table and determine the output from the following flowchart using the following data: X = 5, -3, 0, -3, 7, 0, 6, -11, -7, 12
  • 31. Page 31 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Past Papers Questions: Modular Design/Top-down design: (Computing 9691 Questions) May/June 2006 5. (a) Programs can be designed in modular form. Discuss the advantages and disadvantages of designing programs in modular form. [5] (b) A program is to be written which will update the records in a sequential file and then produce a backup copy. Describe, using a diagram, the way that this problem can be split into modules to prepare it for coding. [5] May/June 2009 A company specialises in creating websites for customers. 8. (a) As part of the process of designing a site, the company will use diagrams in order to make understanding easier. Describe two types of diagram that may be used by the company. [4] May/June 2011. P23 1. (a) Draw a suitable layout for the screen. [5] 3. Kris has written a program that will work out the wages for her staff. The main steps for each employee are: to work out the hours worked, work out the total earnings, work out tax and finally print out how much will be taken home. (a) Complete the structure diagram to show the modules that will be needed. [3] (b) The printout will be different for those staff who receives cash and those who have their earnings paid directly to a bank account. Add the next level to the print module. Oct/NOV 2011 P23
  • 32. Page 32 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 1 Nathan is designing a software solution for stock control in a computer shop. He has a colleague, called Andre, who will help him write the program. Nathan decides to modularise the solution. (a) State why modularisation is a good idea. [1] (b) As the first step in his design he splits the solution into the following main areas: Initialisation, StockOrdering, Sales, SalesReport. Complete the following structure diagram. [1] (c) SalesReport is made up of two modules, MonthlySalesReport and AnnualSalesReport. Add them to the structure diagram in (b). [2] Oct/NOV 2012 P21 1 Soni works for a software house which has been asked to design software for a cycle hire company, Super Bikes. Soni decides on the main tasks: collecting the information about new bikes entering details of repairs entering details of hirer entering details of payment (a) Complete the structure diagram showing these tasks. [2] (b) The collection of information about repairs has three subtasks: input the repair needed input the parts list input the cost of the repair Add these to the structure diagram in part (a). [1] (c) State two reasons for dividing the main task into smaller tasks. [2]
  • 33. Page 33 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Flow Charts: May/June 2006 9 Trace the flow chart using the numbers 2 and 3. Write down each of the values of N in the order that they are printed out. (a) 2 [1] (b) 3 [2]
  • 34. Page 34 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2006 17 The following flowchart shows how the bar code written on an item is used to find the price, do stock control and produce an itemised bill. Select statements from the list below to complete the flowchart.
  • 35. Page 35 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2007 11 Study the following flowchart very carefully. (a) Complete the following table showing the expected output from the flowchart for the three sets of input data:
  • 36. Page 36 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2007 11) Majid lives in Cairo but often travels to Tokyo, Mumbai and Washington. A flow chart has been written so he can work out the local time in these three places.
  • 37. Page 37 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 38. Page 38 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2008 9) The following flowchart inputs two numbers, carries out a calculation and then outputs the result. (a) Complete the following table for the three sets of input data.
  • 39. Page 39 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2008 17) The following flowchart shows how sensors (which can be analogue or digital) and a computer are used to control the temperature of a greenhouse for plants. Complete the flowchart using the items from the list below.
  • 40. Page 40 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 19) The manufacturing cost of producing an item depends on its complexity. A company manufactures three different types of item, with costs based on the following calculations: Item type 1: item cost = parts cost * 1.5 Item type 2: item cost = parts cost * 2.5 Item type 3: item cost = parts cost * 5.0 The company makes 1000 items per day. Write an algorithm, using pseudocode, flowchart or otherwise, which inputs the item type and parts cost of each item outputs the item cost for each item calculates and outputs the average (mean) item cost per day (based on 1000 items being made). [5]
  • 41. Page 41 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2009 14) Study the flowchart very carefully. (a) Complete the table to show what outputs you would expect for the two inputs.
  • 42. Page 42 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 16) The following flowchart shows what happens when a customer uses a credit card to pay for goods at a supermarket. Ten of the boxes are blank. Using the items from the list, insert the ten missing statements using the appropriate number only. Each statement may be used once only.
  • 43. Page 43 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2009. P11 9) Study the flowchart. May/June 2010. P11 18) A group of students were monitoring the temperature every day over a one-year period. Readings were taken ten times every day (you may assume a year contains 365 days). Write an algorithm, using pseudocode or flowchart, which inputs all the temperatures (ten per day) outputs the highest temperature taken over the year outputs the lowest temperature taken over the year outputs the average temperature per day outputs the average temperature for the whole year
  • 44. Page 44 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2010. P12 13) Study the following flowchart very carefully:
  • 45. Page 45 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 16 (a) Write an algorithm, using pseudocode or a flowchart, which: _ inputs 50 numbers _ outputs how many of the numbers were > 100 [3] (b) Write an algorithm, using pseudocode or a flowchart, which: _ inputs 100 numbers _ finds the average of the input numbers _ outputs the average [3]
  • 46. Page 46 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2010. P13 Oct/Nov 2010. P11 4 (a) To log on to a computer, a user needs to type in a user id followed by a password; these should match up. Only three attempts are allowed. The flowchart below shows the log on procedure. Several boxes have been left blank. Complete the flowchart using items from the list.
  • 47. Page 47 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 17) A school is doing a check on the heights and weights of all its students. The school has 1000 students. Write an algorithm, using pseudocode or a flowchart, which ‱ inputs the height and weight of all 1000 students ‱ outputs the average (mean) height and weight ‱ includes any necessary error traps for the input of height and weight [5]
  • 48. Page 48 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2010. P13 15 (a) The following flowchart shows how a burglar alarm system uses light sensors to determine if an intruder has entered the house and decides to sound an alarm. Select statements from the list below, using numbers only, to complete the flowchart.
  • 49. Page 49 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 17 (a) Write an algorithm, using pseudocode or a flowchart, which _ inputs a set of positive numbers (which end with -1) _ outputs the average (mean) value of the input numbers _ outputs the value of the largest (highest) number input [4] (b) Write an algorithm, using pseudocode or a flowchart, which _ inputs a whole number (which is > 0) _ calculates the number of digits in the number _ outputs the number of digits and the original number (E.g. 147 would give an output of 3, 147) [4]
  • 50. Page 50 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2011. P11 5) Study the following flowchart very carefully:
  • 51. Page 51 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design (b) What is the purpose of this flowchart? [1]
  • 52. Page 52 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2011. P12 10 The following flowchart inputs ten temperatures and outputs the average (mean) temperature and the number of temperatures which were negative (i.e. < 0).
  • 53. Page 53 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 54. Page 54 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2011. P11
  • 55. Page 55 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 56. Page 56 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 57. Page 57 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2011. P13
  • 58. Page 58 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 59. Page 59 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 60. Page 60 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2012. P11
  • 61. Page 61 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 62. Page 62 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 63. Page 63 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 64. Page 64 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2012. P12
  • 65. Page 65 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 66. Page 66 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2012. P12
  • 67. Page 67 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 68. Page 68 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 69. Page 69 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 70. Page 70 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2012. P13
  • 71. Page 71 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 72. Page 72 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 73. Page 73 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 74. Page 74 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2013. P11
  • 75. Page 75 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 76. Page 76 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2013. P12
  • 77. Page 77 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 78. Page 78 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 79. Page 79 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design May/June 2013. P12
  • 80. Page 80 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2013. P12 5 Study the following flowchart very carefully
  • 81. Page 81 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Complete the trace table for the following two sets of data: (i) a = 5, b = 4, c = 1, d = 9 (ii) a = 5, b = 9, c = 4, d = 1
  • 82. Page 82 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design 15 A library uses barcodes to identify borrowers and books. A borrower has a card containing a barcode with an equivalent numerical code. Each book also has a barcode with an equivalent numerical code. The flowchart on the facing page shows what happens when book(s) are taken out by a borrower. However, several stages are missing. Using item numbers only, complete the flowchart by selecting stages from the item list below.
  • 83. Page 83 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design
  • 84. Page 84 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design Oct/Nov 2013. P13 14 A microprocessor controls the opening and closing of automatic doors to a supermarket. Customers are detected using pressure sensors. The flowchart on the next page shows how the sensors and microprocessor interact to control the opening and closing of the doors. However, several of the stages in the process have been missed out. Using item number only, complete the flowchart using items from the following list:
  • 85. Page 85 of 85 2.1 Algorithm design and problem-solving 2.1.1 Problem-solving and design