Login or Create an Account to view the mark scheme, comment, and add to a test
(a).
Using the table below as a guide, trace the following algorithm by filling out the trace table below row by row (left to right).
[4]![Question Image](https://res.cloudinary.com/n7-education/image/upload/v1648877375/user-content/261b3d92-2258-47f6-9232-e6ef72154f43/7e2676d7-10c0-4fa7-8214-9bf36fabb6f9.png)
INPUT = [2, -2, -5, 7, 0] // A collection
A=0
B=0
C=0
loop while INPUT.hasNext()
A = INPUT.getnext()
if (A => 0) then
B = INPUT.getnext()
end if
C = A+B
output C
end loop
(b).
Explain why binary search is almost always more efficient than linear search on ordered values.
[4](c).
In the context of programming, define a flag.
[1](d).
Given two arrays, ALPHA which contains 10 elements and BETA which contains 20 elements, construct an algorithm to determine whether or not ALPHA is a subset of BETA. That is, if all the items in ALPHA are also in BETA then output “SUBSET” otherwise output “NOT SUBSET”
[7]Extended Response16 MarksPremium
55 Uses163 Views5 Likes