Date | November 2019 | Marks available | 5 | Reference code | 19N.1.SL.TZ0.7 |
Level | SL | Paper | 1 | Time zone | no time zone |
Command term | Construct | Question number | 7 | Adapted from | N/A |
Question
Construct a trace table for the following algorithm.
K = 1
N = 1
M = 2
loop while K < 5
output(N,M)
K = K + 1
N = N + 2
M = M * 2
end loop
Markscheme
Award [5 max] as follows:
Award [1] for a trace table with at least three columns (headings K, N, M, K<5 and output);
Award [1] for each correct output up to [4 max]
Examiners report
This question was well answered with the vast majority of candidates gaining some marks, many of whom
achieved full or nearly full marks.
Syllabus sections
-
18M.1.SL.TZ0.12a:
The collection
DATA
contains the following data:2, 4, 1, −2, −4, 1, 0
Consider the following pseudocode:
COUNTER = 0
SUM = 0
DATA.resetNext()
loop for X from 0 to 6
if DATA.getNext() > 0
ARRAY[X] = DATA.getNext()
COUNTER = COUNTER + 1
SUM = SUM + ARRAY[X]
end if
end loop
output SUM/COUNTERTrace the pseudocode using the table below:
-
18M.1.SL.TZ0.8:
Consider the following algorithm.
Determine the outputs that will be produced by this algorithm.
-
20N.1.SL.TZ0.9a:
State the reason for not using a binary search.
-
22M.1.SL.TZ0.14a:
Copy and complete the trace table for Algorithm 1 using
TO_FIND = 39
.The first value of the first row has been done for you.
-
22M.1.SL.TZ0.14c:
Copy and complete the trace table for Algorithm 2 using
TO_FIND = 50
.The first two values of the first row have been done for you.
-
22M.1.HL.TZ0.15a:
Copy and complete the trace table for the algorithm using the RPN collection data:
5 2 + 25 16 − * 3 /
-
21M.1.SL.TZ0.14b:
State the purpose of the algorithm.
-
19M.1.SL.TZ0.16c.ii:
State the type of sort in the algorithm constructed in c(i).
-
19M.1.HL.TZ0.15b.ii:
State the type of sort in the algorithm constructed in b(i).
-
19M.1.HL.TZ0.15a:
Copy and complete the table below to trace the algorithm using the data set:
20, 6, 38, 50, 40 -
19M.2.SL.TZ0.4c.ii:
Using the information above state the change in sea level.
-
18N.1.HL.TZ0.10e:
Construct a system flowchart to represent the process described above.
-
19M.2.SL.TZ0.12c.ii:
Outline two improvements to this code that would make the algorithm more efficient.
-
19M.1.SL.TZ0.16b:
Copy and complete the table below to trace the algorithm using the data set:
20, 6, 38, 50, 40
-
18M.1.HL.TZ0.14c:
The home owner has also installed a control system that waters the flowerbeds in the garden. This system aims to maintain the water content of the flowerbeds between a minimum and a maximum value. However, the system is only activated when the light intensity is below a certain level.
Outline the algorithm involved in controlling the watering system described above.
-
18M.1.SL.TZ0.9:
For an identified application, explain why a binary search would be preferred to a linear search.
-
21N.1.HL.TZ0.3a:
Outline what is meant by a sorting algorithm.
-
22M.1.HL.TZ0.14b:
Without using pseudocode, explain how your algorithms could be altered to also find the area and circumference of a circle.
Note:
Area of circle = 2
Circumference of circle = 2
-
22M.1.SL.TZ0.13b:
Construct an algorithm using pseudocode to take the marks that have been stored in
MARK[]
, convert them into the appropriate grade and store the calculated grades inGRADE[]
. -
22M.1.SL.TZ0.13c:
Outline how the name, mark and grade in the three arrays correspond to the same student.
-
22M.1.SL.TZ0.13d:
Construct an algorithm using pseudocode to output the names and grades of all students who achieve a grade of Merit or Distinction.
-
22M.1.SL.TZ0.13e:
Explain how you would change your algorithm in part (d) to allow a user to choose a grade and output the names and marks of the students who have achieved this grade.
-
22M.1.SL.TZ0.14e:
Evaluate the use of a sequential search and a binary search including the advantages and disadvantages of each.
-
19M.1.HL.TZ0.15b.i:
With reference to the algorithm in the flow chart, construct this algorithm in pseudocode so that it performs the same function.
-
21M.1.SL.TZ0.14a:
Copy and complete the table that traces the algorithm in the flowchart using an input value of 19.
-
21M.1.SL.TZ0.13c:
Describe the process a binary search would follow to find a record in the surname array.
-
21M.1.HL.TZ0.14b:
State the name of the method that could be used to restrict the values that are input.
-
18N.1.SL.TZ0.7:
Construct a trace table for the following algorithm
A = 3
B = 7
loop while B >= A
A = A + 1
output(B − A)
B = B − 1
end loop -
18N.1.SL.TZ0.10a:
State the value of variable
BorisBMI
. -
18N.1.SL.TZ0.10c:
State the name of the person whose height is held in
HEIGHT[3]
. -
18N.1.SL.TZ0.10d.i:
Identify one reason why a binary search algorithm cannot be used to find the name of person whose height is given.
-
18N.1.SL.TZ0.10d.ii:
Describe how the name of person whose height is given could be output.
-
19M.1.HL.TZ0.15c:
Construct an algorithm fragment to output the data in the array
VALUES[]
-
18N.2.SL.TZ0.10e.ii:
Outline one disadvantage of using a binary search.
-
21M.1.HL.TZ0.14a.ii:
Outline how the error in the algorithm identified in part (i) can be corrected.
-
20N.1.HL.TZ0.13b.ii:
Outline why it is more efficient that the loop in the given algorithm fragment executes
(K mod 4)
times instead ofK
times. You may give an appropriate example in your answer. -
19M.1.SL.TZ0.16d:
Construct an algorithm fragment to output the data in the array
VALUES[].
-
21M.1.HL.TZ0.14a.i:
Identify the logic error in the algorithm.
-
20N.1.SL.TZ0.7d:
The inventory of office supplies used in the school is stored on the computer as a single file.
Each of the office supplies in the inventory (such as paper, ink, toner, printers, pens, staplers, pencils and scissors) has a unique ID number, name, maximum quantity, minimum quantity and remaining quantity.
Outline the steps in an algorithm that would output a list of supplies with the quantity to be ordered.
-
21N.1.HL.TZ0.3b:
Outline one difference between a bubble sort algorithm and a selection sort algorithm.
-
20N.1.HL.TZ0.13c:
Construct the algorithm in pseudocode for the method
rotate(N,A)
described above. - 19M.2.SL.TZ0.12c.i: State the name of this sorting algorithm.
-
18M.1.SL.TZ0.10a:
Outline the pseudocode that the processing must follow when the system sends out the text reminders.
-
19M.2.SL.TZ0.4d:
Using the formula, rules and initial data given above, construct the pseudocode that would calculate the year that the area of sea ice will be less than 10 000 km2.
-
21M.1.SL.TZ0.8:
List the output from the given algorithm for the following input.
2, 6, 8, 9, 12, 15, 18, 20
loop for Count from 0 to 7
input NUMBER
if NUMBER div 2 = NUMBER / 2 then
if NUMBER div 3 = NUMBER / 3 then
output NUMBER
end if
end if
end loop -
18M.2.SL.TZ0.4c:
Calculate the selling price of a top brand guitar with a volume of 96 dm3 that was damaged. You should show your working.
-
21M.1.SL.TZ0.14d:
Efficiency is an important consideration when designing algorithms to ensure they don’t waste computer resources such as memory or processing time.
Suggest two design considerations that could be made to an algorithm that would make it more efficient.
-
21M.1.HL.TZ0.14c:
A further change has been requested for the algorithm to enable it to calculate the average of all the numbers entered. The average will be output when the algorithm terminates.
Based on the flowchart, construct this algorithm using pseudocode. You must include the required changes:
- correction of logic error
- only allow input of integers between 0 and 1000
- calculation of average of all numbers entered
- output of final average.
-
20N.1.HL.TZ0.13d:
To avoid inefficient use of memory, a new algorithm for the method
rotate(N,A)
is constructed.The
N × N
two-dimensional arrayA
should be rotated clockwise by 90°, without the use of any additional arrays.One way of rotating the two-dimensional array
A
clockwise by 90° is to transposeA
, and then reverse each row ofA
.The transpose of
A
is formed by turning all the rows ofA
into columns. For example, the value in the first row and third column (A[1][3]
) is swapped with the value in the third row and first column (A[3][1]
).
Construct the new algorithm in pseudocode for the methodrotate(N,A)
described above. -
20N.1.SL.TZ0.5:
Describe the steps involved in using the bubble sort algorithm to sort an array.
-
19M.2.SL.TZ0.4c.i:
Using the information above state the area of the sea ice.
-
19M.1.SL.TZ0.16c.i:
With reference to the algorithm in the flow chart, construct this algorithm in pseudocode so that it performs the same function.
-
18N.2.SL.TZ0.10e.i:
Outline one advantage of using a binary search.
-
18M.2.SL.TZ0.4b.ii:
Describe two items that would have a calculated value of more than $90.
-
18M.2.SL.TZ0.4b.i:
Using the above rules, construct the pseudocode that will help Ralph in deciding whether to buy an item.
-
21M.1.SL.TZ0.13b:
Construct a pseudocode algorithm that will sort the surnames into alphabetical order using the bubble sort method. The order of the first names must also be changed so that they keep the same index as their corresponding surname.
-
18N.1.SL.TZ0.10b:
Use pseudocode to construct an algorithm which accepts a person’s BMI and outputs the weight category the person belongs to.
-
19N.1.SL.TZ0.10a:
Consider the following algorithm.
N = 372
X = N DIV 100
Y = X + 10 * (N MOD 100 DIV 10)
Z = Y + (N MOD 10) * 100
Determine the values of variables X, Y, andZ
after execution of this algorithm. Show your working. -
19M.2.SL.TZ0.4b:
Using the rules and initial values above, construct the pseudocode that would enable the area of the sea ice and the sea level rise to be calculated if there was an increase of 0.04 °C in the ocean surface temperature.