11 A program has been written to find the location of a requested value in a list, however the program does not return the correct location. The algorithm responsible is shown below. (see paper) a Line 1 the use of a 1-D array to only one line of code required to create multiple values store the list of values, rather than can be traversed using loop structure eight individual variables. Design two parameter passing easily implemented with advantages of using a 1-D array to store one line the list of values. efficiency of code each individual element in the array can be referenced by indexing 1 mark each bullet, max 2 marks 2 b A trace table is being used to record the changes to variables when stepping through the code. (Line 5 does not change a variable’s value and so it not included.) (see paper) i Complete the information in the Line dataset find location above, recording the value assigned to 1 the variable for line 2, 3, 4 and 6. 2 99 3 72 4 1 6 99 4 correct values for three marks, 3 for 2 marks 3 and 2 for 1 mark. ii Explain why the location is never (Line 6) sets the counter to the location correctly given. that will result in the location being given as 99 (1 mark). The loop will also terminate prematurely (because the counter is greater than 6) (1 mark) 2 iii Describe how the algorithm should be Line 6 should be changed to (1 mark) corrected. SET location TO Counter (1 mark) 2 c i The program is halted at line 4 to allow Breakpoints (1 mark) it to be debugged. State the feature of the software development environment Accept on watch value” and other “Break that allows a program’s execution to be similar debugging features. halted. 1 ii Describe how halting the execution of Values of variables can be inspected to the program will assist with finding determine issues. errors in the program. Ability to step-into/step over code to assess effect. Program flow/logic can be inspected. Other valid. 1 mark each bullet, max 2 marks 2
11 A program has been written to find the location of a requested value in a list, however the program does not return the correct location. The algorithm responsible is shown below. (see paper) a Line 1 the use of a 1-D array to store the list of values, rather than eight individual variables. Design two advantages of using a 1-D array to store the list of values. only one line of code required to create multiple values can be traversed using loop structure parameter passing easily implemented with one line efficiency of code each individual element in the array can be referenced by indexing 1 mark each bullet, max 2 marks 2 b A trace table is being used to record the changes to variables when stepping through the code. (Line 5 does not change a variable’s value and so it not included.) (see paper) i Complete the information in the above, recording the value assigned to the variable for line 2, 3, 4 and 6. Line dataset find location 3 1 2 99 3 72 4 1 6 99 4 correct values for three marks, 3 for 2 marks and 2 for 1 mark. ii Explain why the location is never correctly given. (Line 6) sets the counter to the location that will result in the location being given as 99 (1 mark). The loop will also terminate prematurely (because the counter is greater than 6) (1 mark) 2 iii Describe how the algorithm should be corrected. Line 6 should be changed to (1 mark) SET location TO Counter (1 mark) 2 c i The program is halted at line 4 to allow it to be debugged. State the feature of the software development environment that allows a program’s execution to be halted. Breakpoints (1 mark) Accept “Break on watch value” and other similar debugging features. 1 ii Describe how halting the execution of the program will assist with finding errors in the program. Values of variables can be inspected to determine issues. Ability to step-into/step over code to assess effect. Program flow/logic can be inspected. Other valid. 1 mark each bullet, max 2 marks 2