香港中學文憑資訊及通訊科技 模擬試卷及多項選擇題
4. David designs an algorithm to change the value in an array of binary digits, A , as shown below: X = FALSE FOR I = 1 to 4 X NOT X If X THEN IF A[I] = 0 THEN A[I] 1 ELSE A[I] 0 ELSE IF A[I] = 1 THEN A[I] 1 ELSE A[I] 0 (a) Suppose that the initial content of A is: A[1] A[2] A[3] A[4] 1 0 1 1 What is the content of A after executing the algorithm? (2 marks) A[1] A[2] A[3] A[4] (b) Suppose that the content of A after executing the algorithm TWICE is: A[1] A[2] A[3] A[4] 0 0 1 0 What is the initial content of A ? (2 marks) A[1] A[2] A[3] A[4]
Made with FlippingBook
RkJQdWJsaXNoZXIy ODY0MTQz