{
  "schema": "cie-topical-past-papers/answers-v1",
  "subject": "9618",
  "subject_name": "Computer Science",
  "generated": "2026-08-14",
  "coverage": {
    "question_records": 407,
    "available_mark_scheme_entries": 407,
    "unavailable_mark_scheme_entries": 0
  },
  "records": [
    {
      "id": "9618-2021-mj-31-q01",
      "question_id": "9618-2021-mj-31-q01",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 14,
      "status": "available",
      "reason": null,
      "text": "1(a) Working: one mark for calculation of the mantissa and one mark for 3\ncalculation or use of the exponent\nExponent: one from:\n= 0.11101 × 23 // 0.11101 × 211 // 0.11101 × 103 // 0.11101 × 1011\n= 1.00011 × 23 // 1.00011 × 211 // 1.00011 × 103 // 1.00011 × 1011\n= appropriate shifting of binary point for +7.25\nMantissa: one from:\n= 111.01 (conversion to binary +7.25 – 10 bits)\n= 0111010000 (mantissa 10 bits for +7.25\n= 1000101111(one’s complement mantissa for –7.25)\n= 1000110000 (two’s complement mantissa for –7.25)\nCorrect Answer (Max 1)\nMantissa Exponent\n\n1 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1\n\n1(b) One mark for working out the exponent 3\nOne mark for working out the mantissa\nOne mark for the correct answer\nExample answers\n• =1.011000111 × 27 (exponent is 7)\n• =10110001.11 // –128 + 32 + 16 + 1 + 0.5 + 0.25 // convert to positive\n01001110.01 (and add a minus sign to the answer)\n• –78.25\n\n1(c) One mark for working 3\nOne mark for correct mantissa\nOne mark for correct exponent\nExample answers\nNumber of places added to exponent for normalisation −6 for number to\nretain its value // mantissa moved 6 places left\nMantissa\n0 1 1 1 0 0 0 0 0 0\nExponent\n\n1 0 0 0 0 1\n\n1(d)(i) One mark for each correct marking point (Max 3) 3\n• Requires 11 bits / more than 10 bits to store (accurately) / reference to\nmaximum (positive) number that can be stored = 511\n• Denary 513 in binary is 1000000001 // Normalised: 0.1000000001\n• Results in overflow\n© UCLES 2021 Page 3 of 10\n\n1(d)(ii) One mark for each correct marking point (Max 2) 2\n• The number of bits for the mantissa must be increased\n• 11/12 bits mantissa and 5/4 bits exponent\nQuestion Answer Marks",
      "source_pages": [
        3,
        4
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_31.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_31-p03.png",
        "../answer-assets/9618_s21_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2021-mj-31-q02",
      "question_id": "9618-2021-mj-31-q02",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 2,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark for each correct marking point (Max 2) 2\n• To create a new data type (from existing data types)\n• To allow data types not available in a programming language to be\nconstructed // To extend the flexibility of the programming language\n\n2(b)(i) TYPE SchoolDay = (Monday, Tuesday, Wednesday, Thursday, 1\nFriday)\n\n2(b)(ii) TYPE WeekEnd = (Saturday, Sunday) 1\n\n2(c) One mark for each marking point (Max 4) 4\n• TYPE ClubMeet and ENDTYPE correct\n• DECLARE FirstName and DECLARE LastName included with correct\ndata types\n• DECLARE Schoolday included with correct data types from part 2(b)(i)\n• DECLARE Weekend included with correct data types from part 2(b)(ii)\nExample answer\nTYPE ClubMeet\nDECLARE FirstName : STRING\nDECLARE LastName : STRING\nDECLARE Schoolday : SchoolDay\nDECLARE Weekend : WeekEnd\nENDTYPE\n© UCLES 2021 Page 4 of 10",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2021-mj-31-q03",
      "question_id": "9618-2021-mj-31-q03",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 3,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark for each correct line from Operating System Term to Description 5\nManaging the execution of many programs\nthat appear to run at the same time\n\n3(b) One mark for each correct statement (Max 4) 4\n• An interpreter examines source code one statement at a time\n• Check each statement for errors\n• …If no error is found the statement is executed\n• …If an error is found this is reported and the interpreter halts\n• Interpretation is repeated for every iteration in repeated sections of\ncode/in loops\n• Interpretation has to be repeated every time the program is run\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_31-p05.png"
      ]
    },
    {
      "id": "9618-2021-mj-31-q04",
      "question_id": "9618-2021-mj-31-q04",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 4,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "4(a)(i) One mark for each correct marking point (Max 2) 2\n• Reverse Polish Notation provides an unambiguous method of\nrepresenting an expression\n• … reading from left to right\n• …without the need to use brackets\n• …with no need for rules of precedence / BODMAS\n© UCLES 2021 Page 5 of 10\n\n4(a)(ii) One mark for identification of the data structure, 2\nOne mark for a sensible reason\nEither:\nStructure: stack\nThe operands are popped from the stack in the reverse order to how they\nwere pushed\nOr:\nStructure: Binary tree\nA (binary) tree allows both infix and postfix to be evaluated (tree traversal)\n\n4(b) a b - a c + * 7 / 1\n\n4(c) a / b * 4 – (a + b) 1\n\n4(d) 1 mark for correct structure 2\n1 mark for correct substitution\n(a + b) / (c / d)\n(17 + 3) / (48 / 12)\nQuestion Answer Marks",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_31-p05.png",
        "../answer-assets/9618_s21_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2021-mj-31-q05",
      "question_id": "9618-2021-mj-31-q05",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 5,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "5(a) Working (Max 3) 5\nMay be seen on diagram\n• Initialisation: setting Base to 0\n• … and the rest of the towns to ∞\n• Evidence to show values at nodes being updated\n• Evidence to show ‘visited node(s)’\nMay be seen in working section of paper\n• Evidence to show calculation of at least one route\n• Evidence to show more than one route has been calculated for at least\none town\nCorrect Answer (Max 2)\nOne mark for four correct values…\n… One mark for all values correct\nTown 1 Town 2 Town 3 Town 4 Town 5 Town 6\n3 5 2 9 3 8\n© UCLES 2021 Page 6 of 10\n\n5(b) One mark for each correct marking point (Max 3) 3\n• Artificial Neural Networks can be represented using graphs\n• Graphs provide structures for relationships // graphs provide\nrelationships between nodes\n• AI problems can be defined/solved as finding a path in a graph\n• Graphs may be analysed/ingested by a range of algorithms\n• …e.g. A* / Dijksta’s algorithm\n• …used in machine learning.\n• Example of method e.g. Back propagation of errors / regression\nmethods\nQuestion Answer Marks",
      "source_pages": [
        6,
        7
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_31.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_31-p06.png",
        "../answer-assets/9618_s21_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2021-mj-31-q06",
      "question_id": "9618-2021-mj-31-q06",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 6,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "6 One mark for each correct benefit (Max 2) 4\n• Accuracy – Ensures accurate delivery of the message\n• Completeness – Missing packets can be easily detected and a re-send\nrequest sent so the message arrives complete\n• Resilience – if a network changes the router can detect this and send\nthe data another way to ensure it arrives\n• Path also available to other users // Doesn’t use whole bandwidth //\nallows simultaneous use of channel by multiple users\n• Better security as packets hashed and sent by different routes.\nOne mark for each correct drawback (Max 2)\n• Time delays to correct errors // Network problems may introduce errors\nin packets\n• Requires complex protocols for delivery\n• Unsuitable for real time transmission applications\n© UCLES 2021 Page 7 of 10",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2021-mj-31-q07",
      "question_id": "9618-2021-mj-31-q07",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark for working, (all three columns P, Q and R) 3\nOne mark for each correct column Y, Z\nA B C P Q R Y Z\n0 0 0 0 0 0 0 0\n0 0 1 0 0 0 1 0\n0 1 0 1 0 0 1 0\n0 1 1 1 0 1 0 1\n1 0 0 1 0 0 1 0\n1 0 1 1 0 1 0 1\n1 1 0 0 1 0 0 1\n1 1 1 0 1 0 1 1\n\n7(b) Full adder 1\n\n7(c) One mark for each point 4\n_ _ _ _ _ _\nY = A B C + A B C + A B C + A B C\nPurpose: Sum bit\n_ _ _\nZ = A B C + A B C + A B C + A B C\nPurpose: Carry output\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_31-p08.png"
      ]
    },
    {
      "id": "9618-2021-mj-31-q08",
      "question_id": "9618-2021-mj-31-q08",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 8,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correct marking point (Max 2) 2\n• The initial order of the data\n• The number of data items to be sorted\n• The efficiency of the sorting algorithm\n© UCLES 2021 Page 8 of 10\n\n8(b) One mark for each marking point (max 6) 6\nMP1 Use of FOR loop to cycle through the whole year group\nMP2 Temporary storage of the score being ‘inserted’\nMP3 Temporary storage of the corresponding name elements\nMP4 Use of WHILE loop with correct exit clause\nMP5 Moving of all three elements of data to next array elements\nMP6 Correct updating of counter variable\nMP7 Final insertion of all three data elements\nExample algorithm\nYearSize ← 249\nFOR Student ← 2 to YearSize\nTemp1 ← Score[Student]\nTemp2 ← Name[Student,1]\nTemp3 ← Name[Student,2]\nCounter ← Student\nWHILE Counter > 1 AND Score[Counter - 1] < Temp1\nScore[Counter] ← Score[Counter - 1]\nName[Counter,1] ← Name[Counter - 1,1]\nName[Counter,2] ← Name[Counter - 1,2]\nCounter ← Counter – 1\nENDWHILE\nScore[Counter] ← Temp1\nName[Counter,1] ← Temp2\nName[Counter,2] ← Temp3\nNEXT Student\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_31-p08.png",
        "../answer-assets/9618_s21_ms_31-p09.png"
      ]
    },
    {
      "id": "9618-2021-mj-31-q09",
      "question_id": "9618-2021-mj-31-q09",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 9,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark for each correct marking point (Max 2) 2\n• Imperative languages use variables\n• … which are changed using (assignment) statements\n• … they rely on a method of repetition / iteration.\n• The statements provide a sequence of commands for the computer to\nperform\n• … in the order written / given\n• … each line of code changes something in the program run.\n\n9(b) One mark for each correct marking point (Max 2) 2\n• Instructs a program on what needs to be done instead of how to do it\n• ... using facts and rules\n• … using queries to satisfy goals.\n• Can be logical or functional\n• Logical - states a program as a set of logical relations\n• Functional – constructed by applying functions to arguments / uses a\nmathematical style\n© UCLES 2021 Page 9 of 10\n\n9(c) One mark for each correct programming paradigm (Max 4) 4\nProgram code example Programming paradigm\nmale(john).\nfemale(ethel). Declarative\nparent(john, ethel).\nFOR Counter = 1 TO 20\nX = X * Counter Procedural / imperative\nNEXT Counter\nStart: LDD Counter\nINC ACC Low-level / assembly\nSTO Counter\npublic class Vehicle\n{\nprivate speed;\npublic Vehicle()\nObject oriented / (OOP)\n{\nspeed = 0;\n}\n}\n© UCLES 2021 Page 10 of 10",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_31-p09.png",
        "../answer-assets/9618_s21_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2021-mj-32-q01",
      "question_id": "9618-2021-mj-32-q01",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 14,
      "status": "available",
      "reason": null,
      "text": "1(a) Working: one mark for calculation of the mantissa and one mark for 3\ncalculation or use of the exponent\nExponent: one from:\n= 0.11101 × 23 // 0.11101 × 211 // 0.11101 × 103 // 0.11101 × 1011\n= 1.00011 × 23 // 1.00011 × 211 // 1.00011 × 103 // 1.00011 × 1011\n= appropriate shifting of binary point for +7.25\nMantissa: one from:\n= 111.01 (conversion to binary +7.25 – 10 bits)\n= 0111010000 (mantissa 10 bits for +7.25\n= 1000101111(one’s complement mantissa for –7.25)\n= 1000110000 (two’s complement mantissa for –7.25)\nCorrect Answer (Max 1)\nMantissa Exponent\n\n1 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1\n\n1(b) One mark for working out the exponent 3\nOne mark for working out the mantissa\nOne mark for the correct answer\nExample answers\n• =1.011000111 × 27 (exponent is 7)\n• =10110001.11 // –128 + 32 + 16 + 1 + 0.5 + 0.25 // convert to positive\n01001110.01 (and add a minus sign to the answer)\n• –78.25\n\n1(c) One mark for working 3\nOne mark for correct mantissa\nOne mark for correct exponent\nExample answers\nNumber of places added to exponent for normalisation −6 for number to\nretain its value // mantissa moved 6 places left\nMantissa\n0 1 1 1 0 0 0 0 0 0\nExponent\n\n1 0 0 0 0 1\n\n1(d)(i) One mark for each correct marking point (Max 3) 3\n• Requires 11 bits / more than 10 bits to store (accurately) / reference to\nmaximum (positive) number that can be stored = 511\n• Denary 513 in binary is 1000000001 // Normalised: 0.1000000001\n• Results in overflow\n© UCLES 2021 Page 3 of 10\n\n1(d)(ii) One mark for each correct marking point (Max 2) 2\n• The number of bits for the mantissa must be increased\n• 11/12 bits mantissa and 5/4 bits exponent\nQuestion Answer Marks",
      "source_pages": [
        3,
        4
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_32.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_32-p03.png",
        "../answer-assets/9618_s21_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2021-mj-32-q02",
      "question_id": "9618-2021-mj-32-q02",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 2,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark for each correct marking point (Max 2) 2\n• To create a new data type (from existing data types)\n• To allow data types not available in a programming language to be\nconstructed // To extend the flexibility of the programming language\n\n2(b)(i) TYPE SchoolDay = (Monday, Tuesday, Wednesday, Thursday, 1\nFriday)\n\n2(b)(ii) TYPE WeekEnd = (Saturday, Sunday) 1\n\n2(c) One mark for each marking point (Max 4) 4\n• TYPE ClubMeet and ENDTYPE correct\n• DECLARE FirstName and DECLARE LastName included with correct\ndata types\n• DECLARE Schoolday included with correct data types from part 2(b)(i)\n• DECLARE Weekend included with correct data types from part 2(b)(ii)\nExample answer\nTYPE ClubMeet\nDECLARE FirstName : STRING\nDECLARE LastName : STRING\nDECLARE Schoolday : SchoolDay\nDECLARE Weekend : WeekEnd\nENDTYPE\n© UCLES 2021 Page 4 of 10",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2021-mj-32-q03",
      "question_id": "9618-2021-mj-32-q03",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 3,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark for each correct line from Operating System Term to Description 5\nManaging the execution of many programs\nthat appear to run at the same time\n\n3(b) One mark for each correct statement (Max 4) 4\n• An interpreter examines source code one statement at a time\n• Check each statement for errors\n• …If no error is found the statement is executed\n• …If an error is found this is reported and the interpreter halts\n• Interpretation is repeated for every iteration in repeated sections of\ncode/in loops\n• Interpretation has to be repeated every time the program is run\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2021-mj-32-q04",
      "question_id": "9618-2021-mj-32-q04",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 4,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "4(a)(i) One mark for each correct marking point (Max 2) 2\n• Reverse Polish Notation provides an unambiguous method of\nrepresenting an expression\n• … reading from left to right\n• …without the need to use brackets\n• …with no need for rules of precedence / BODMAS\n© UCLES 2021 Page 5 of 10\n\n4(a)(ii) One mark for identification of the data structure, 2\nOne mark for a sensible reason\nEither:\nStructure: stack\nThe operands are popped from the stack in the reverse order to how they\nwere pushed\nOr:\nStructure: Binary tree\nA (binary) tree allows both infix and postfix to be evaluated (tree traversal)\n\n4(b) a b - a c + * 7 / 1\n\n4(c) a / b * 4 – (a + b) 1\n\n4(d) 1 mark for correct structure 2\n1 mark for correct substitution\n(a + b) / (c / d)\n(17 + 3) / (48 / 12)\nQuestion Answer Marks",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_32-p05.png",
        "../answer-assets/9618_s21_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2021-mj-32-q05",
      "question_id": "9618-2021-mj-32-q05",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 5,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "5(a) Working (Max 3) 5\nMay be seen on diagram\n• Initialisation: setting Base to 0\n• … and the rest of the towns to ∞\n• Evidence to show values at nodes being updated\n• Evidence to show ‘visited node(s)’\nMay be seen in working section of paper\n• Evidence to show calculation of at least one route\n• Evidence to show more than one route has been calculated for at least\none town\nCorrect Answer (Max 2)\nOne mark for four correct values…\n… One mark for all values correct\nTown 1 Town 2 Town 3 Town 4 Town 5 Town 6\n3 5 2 9 3 8\n© UCLES 2021 Page 6 of 10\n\n5(b) One mark for each correct marking point (Max 3) 3\n• Artificial Neural Networks can be represented using graphs\n• Graphs provide structures for relationships // graphs provide\nrelationships between nodes\n• AI problems can be defined/solved as finding a path in a graph\n• Graphs may be analysed/ingested by a range of algorithms\n• …e.g. A* / Dijksta’s algorithm\n• …used in machine learning.\n• Example of method e.g. Back propagation of errors / regression\nmethods\nQuestion Answer Marks",
      "source_pages": [
        6,
        7
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_32.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_32-p06.png",
        "../answer-assets/9618_s21_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2021-mj-32-q06",
      "question_id": "9618-2021-mj-32-q06",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 6,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "6 One mark for each correct benefit (Max 2) 4\n• Accuracy – Ensures accurate delivery of the message\n• Completeness – Missing packets can be easily detected and a re-send\nrequest sent so the message arrives complete\n• Resilience – if a network changes the router can detect this and send\nthe data another way to ensure it arrives\n• Path also available to other users // Doesn’t use whole bandwidth //\nallows simultaneous use of channel by multiple users\n• Better security as packets hashed and sent by different routes.\nOne mark for each correct drawback (Max 2)\n• Time delays to correct errors // Network problems may introduce errors\nin packets\n• Requires complex protocols for delivery\n• Unsuitable for real time transmission applications\n© UCLES 2021 Page 7 of 10",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2021-mj-32-q07",
      "question_id": "9618-2021-mj-32-q07",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark for working, (all three columns P, Q and R) 3\nOne mark for each correct column Y, Z\nA B C P Q R Y Z\n0 0 0 0 0 0 0 0\n0 0 1 0 0 0 1 0\n0 1 0 1 0 0 1 0\n0 1 1 1 0 1 0 1\n1 0 0 1 0 0 1 0\n1 0 1 1 0 1 0 1\n1 1 0 0 1 0 0 1\n1 1 1 0 1 0 1 1\n\n7(b) Full adder 1\n\n7(c) One mark for each point 4\n_ _ _ _ _ _\nY = A B C + A B C + A B C + A B C\nPurpose: Sum bit\n_ _ _\nZ = A B C + A B C + A B C + A B C\nPurpose: Carry output\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_32-p08.png"
      ]
    },
    {
      "id": "9618-2021-mj-32-q08",
      "question_id": "9618-2021-mj-32-q08",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 8,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correct marking point (Max 2) 2\n• The initial order of the data\n• The number of data items to be sorted\n• The efficiency of the sorting algorithm\n© UCLES 2021 Page 8 of 10\n\n8(b) One mark for each marking point (max 6) 6\nMP1 Use of FOR loop to cycle through the whole year group\nMP2 Temporary storage of the score being ‘inserted’\nMP3 Temporary storage of the corresponding name elements\nMP4 Use of WHILE loop with correct exit clause\nMP5 Moving of all three elements of data to next array elements\nMP6 Correct updating of counter variable\nMP7 Final insertion of all three data elements\nExample algorithm\nYearSize ← 249\nFOR Student ← 2 to YearSize\nTemp1 ← Score[Student]\nTemp2 ← Name[Student,1]\nTemp3 ← Name[Student,2]\nCounter ← Student\nWHILE Counter > 1 AND Score[Counter - 1] < Temp1\nScore[Counter] ← Score[Counter - 1]\nName[Counter,1] ← Name[Counter - 1,1]\nName[Counter,2] ← Name[Counter - 1,2]\nCounter ← Counter – 1\nENDWHILE\nScore[Counter] ← Temp1\nName[Counter,1] ← Temp2\nName[Counter,2] ← Temp3\nNEXT Student\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_32-p08.png",
        "../answer-assets/9618_s21_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2021-mj-32-q09",
      "question_id": "9618-2021-mj-32-q09",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 9,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark for each correct marking point (Max 2) 2\n• Imperative languages use variables\n• … which are changed using (assignment) statements\n• … they rely on a method of repetition / iteration.\n• The statements provide a sequence of commands for the computer to\nperform\n• … in the order written / given\n• … each line of code changes something in the program run.\n\n9(b) One mark for each correct marking point (Max 2) 2\n• Instructs a program on what needs to be done instead of how to do it\n• ... using facts and rules\n• … using queries to satisfy goals.\n• Can be logical or functional\n• Logical - states a program as a set of logical relations\n• Functional – constructed by applying functions to arguments / uses a\nmathematical style\n© UCLES 2021 Page 9 of 10\n\n9(c) One mark for each correct programming paradigm (Max 4) 4\nProgram code example Programming paradigm\nmale(john).\nfemale(ethel). Declarative\nparent(john, ethel).\nFOR Counter = 1 TO 20\nX = X * Counter Procedural / imperative\nNEXT Counter\nStart: LDD Counter\nINC ACC Low-level / assembly\nSTO Counter\npublic class Vehicle\n{\nprivate speed;\npublic Vehicle()\nObject oriented / (OOP)\n{\nspeed = 0;\n}\n}\n© UCLES 2021 Page 10 of 10",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_32-p09.png",
        "../answer-assets/9618_s21_ms_32-p10.png"
      ]
    },
    {
      "id": "9618-2021-mj-33-q01",
      "question_id": "9618-2021-mj-33-q01",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 14,
      "status": "available",
      "reason": null,
      "text": "1(a) Working: one mark for calculation of the mantissa and one mark for 3\ncalculation or use of the exponent\nExponent: one from:\n= 0.11101 × 23 // 0.11101 × 211 // 0.11101 × 103 // 0.11101 × 1011\n= 1.00011 × 23 // 1.00011 × 211 // 1.00011 × 103 // 1.00011 × 1011\n= appropriate shifting of binary point for +7.25\nMantissa: one from:\n= 111.01 (conversion to binary +7.25 – 10 bits)\n= 0111010000 (mantissa 10 bits for +7.25\n= 1000101111(one’s complement mantissa for –7.25)\n= 1000110000 (two’s complement mantissa for –7.25)\nCorrect Answer (Max 1)\nMantissa Exponent\n\n1 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1\n\n1(b) One mark for working out the exponent 3\nOne mark for working out the mantissa\nOne mark for the correct answer\nExample answers\n• =1.011000111 × 27 (exponent is 7)\n• =10110001.11 // –128 + 32 + 16 + 1 + 0.5 + 0.25 // convert to positive\n01001110.01 (and add a minus sign to the answer)\n• –78.25\n\n1(c) One mark for working 3\nOne mark for correct mantissa\nOne mark for correct exponent\nExample answers\nNumber of places added to exponent for normalisation −6 for number to\nretain its value // mantissa moved 6 places left\nMantissa\n0 1 1 1 0 0 0 0 0 0\nExponent\n\n1 0 0 0 0 1\n\n1(d)(i) One mark for each correct marking point (Max 3) 3\n• Requires 11 bits / more than 10 bits to store (accurately) / reference to\nmaximum (positive) number that can be stored = 511\n• Denary 513 in binary is 1000000001 // Normalised: 0.1000000001\n• Results in overflow\n© UCLES 2021 Page 3 of 10\n\n1(d)(ii) One mark for each correct marking point (Max 2) 2\n• The number of bits for the mantissa must be increased\n• 11/12 bits mantissa and 5/4 bits exponent\nQuestion Answer Marks",
      "source_pages": [
        3,
        4
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_33.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_33-p03.png",
        "../answer-assets/9618_s21_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2021-mj-33-q02",
      "question_id": "9618-2021-mj-33-q02",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 2,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark for each correct marking point (Max 2) 2\n• To create a new data type (from existing data types)\n• To allow data types not available in a programming language to be\nconstructed // To extend the flexibility of the programming language\n\n2(b)(i) TYPE SchoolDay = (Monday, Tuesday, Wednesday, Thursday, 1\nFriday)\n\n2(b)(ii) TYPE WeekEnd = (Saturday, Sunday) 1\n\n2(c) One mark for each marking point (Max 4) 4\n• TYPE ClubMeet and ENDTYPE correct\n• DECLARE FirstName and DECLARE LastName included with correct\ndata types\n• DECLARE Schoolday included with correct data types from part 2(b)(i)\n• DECLARE Weekend included with correct data types from part 2(b)(ii)\nExample answer\nTYPE ClubMeet\nDECLARE FirstName : STRING\nDECLARE LastName : STRING\nDECLARE Schoolday : SchoolDay\nDECLARE Weekend : WeekEnd\nENDTYPE\n© UCLES 2021 Page 4 of 10",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2021-mj-33-q03",
      "question_id": "9618-2021-mj-33-q03",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 3,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark for each correct line from Operating System Term to Description 5\nManaging the execution of many programs\nthat appear to run at the same time\n\n3(b) One mark for each correct statement (Max 4) 4\n• An interpreter examines source code one statement at a time\n• Check each statement for errors\n• …If no error is found the statement is executed\n• …If an error is found this is reported and the interpreter halts\n• Interpretation is repeated for every iteration in repeated sections of\ncode/in loops\n• Interpretation has to be repeated every time the program is run\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_33-p05.png"
      ]
    },
    {
      "id": "9618-2021-mj-33-q04",
      "question_id": "9618-2021-mj-33-q04",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 4,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "4(a)(i) One mark for each correct marking point (Max 2) 2\n• Reverse Polish Notation provides an unambiguous method of\nrepresenting an expression\n• … reading from left to right\n• …without the need to use brackets\n• …with no need for rules of precedence / BODMAS\n© UCLES 2021 Page 5 of 10\n\n4(a)(ii) One mark for identification of the data structure, 2\nOne mark for a sensible reason\nEither:\nStructure: stack\nThe operands are popped from the stack in the reverse order to how they\nwere pushed\nOr:\nStructure: Binary tree\nA (binary) tree allows both infix and postfix to be evaluated (tree traversal)\n\n4(b) a b - a c + * 7 / 1\n\n4(c) a / b * 4 – (a + b) 1\n\n4(d) 1 mark for correct structure 2\n1 mark for correct substitution\n(a + b) / (c / d)\n(17 + 3) / (48 / 12)\nQuestion Answer Marks",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_33-p05.png",
        "../answer-assets/9618_s21_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2021-mj-33-q05",
      "question_id": "9618-2021-mj-33-q05",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 5,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "5(a) Working (Max 3) 5\nMay be seen on diagram\n• Initialisation: setting Base to 0\n• … and the rest of the towns to ∞\n• Evidence to show values at nodes being updated\n• Evidence to show ‘visited node(s)’\nMay be seen in working section of paper\n• Evidence to show calculation of at least one route\n• Evidence to show more than one route has been calculated for at least\none town\nCorrect Answer (Max 2)\nOne mark for four correct values…\n… One mark for all values correct\nTown 1 Town 2 Town 3 Town 4 Town 5 Town 6\n3 5 2 9 3 8\n© UCLES 2021 Page 6 of 10\n\n5(b) One mark for each correct marking point (Max 3) 3\n• Artificial Neural Networks can be represented using graphs\n• Graphs provide structures for relationships // graphs provide\nrelationships between nodes\n• AI problems can be defined/solved as finding a path in a graph\n• Graphs may be analysed/ingested by a range of algorithms\n• …e.g. A* / Dijksta’s algorithm\n• …used in machine learning.\n• Example of method e.g. Back propagation of errors / regression\nmethods\nQuestion Answer Marks",
      "source_pages": [
        6,
        7
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_33.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_33-p06.png",
        "../answer-assets/9618_s21_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2021-mj-33-q06",
      "question_id": "9618-2021-mj-33-q06",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 6,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "6 One mark for each correct benefit (Max 2) 4\n• Accuracy – Ensures accurate delivery of the message\n• Completeness – Missing packets can be easily detected and a re-send\nrequest sent so the message arrives complete\n• Resilience – if a network changes the router can detect this and send\nthe data another way to ensure it arrives\n• Path also available to other users // Doesn’t use whole bandwidth //\nallows simultaneous use of channel by multiple users\n• Better security as packets hashed and sent by different routes.\nOne mark for each correct drawback (Max 2)\n• Time delays to correct errors // Network problems may introduce errors\nin packets\n• Requires complex protocols for delivery\n• Unsuitable for real time transmission applications\n© UCLES 2021 Page 7 of 10",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2021-mj-33-q07",
      "question_id": "9618-2021-mj-33-q07",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark for working, (all three columns P, Q and R) 3\nOne mark for each correct column Y, Z\nA B C P Q R Y Z\n0 0 0 0 0 0 0 0\n0 0 1 0 0 0 1 0\n0 1 0 1 0 0 1 0\n0 1 1 1 0 1 0 1\n1 0 0 1 0 0 1 0\n1 0 1 1 0 1 0 1\n1 1 0 0 1 0 0 1\n1 1 1 0 1 0 1 1\n\n7(b) Full adder 1\n\n7(c) One mark for each point 4\n_ _ _ _ _ _\nY = A B C + A B C + A B C + A B C\nPurpose: Sum bit\n_ _ _\nZ = A B C + A B C + A B C + A B C\nPurpose: Carry output\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_33-p08.png"
      ]
    },
    {
      "id": "9618-2021-mj-33-q08",
      "question_id": "9618-2021-mj-33-q08",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 8,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correct marking point (Max 2) 2\n• The initial order of the data\n• The number of data items to be sorted\n• The efficiency of the sorting algorithm\n© UCLES 2021 Page 8 of 10\n\n8(b) One mark for each marking point (max 6) 6\nMP1 Use of FOR loop to cycle through the whole year group\nMP2 Temporary storage of the score being ‘inserted’\nMP3 Temporary storage of the corresponding name elements\nMP4 Use of WHILE loop with correct exit clause\nMP5 Moving of all three elements of data to next array elements\nMP6 Correct updating of counter variable\nMP7 Final insertion of all three data elements\nExample algorithm\nYearSize ← 249\nFOR Student ← 2 to YearSize\nTemp1 ← Score[Student]\nTemp2 ← Name[Student,1]\nTemp3 ← Name[Student,2]\nCounter ← Student\nWHILE Counter > 1 AND Score[Counter - 1] < Temp1\nScore[Counter] ← Score[Counter - 1]\nName[Counter,1] ← Name[Counter - 1,1]\nName[Counter,2] ← Name[Counter - 1,2]\nCounter ← Counter – 1\nENDWHILE\nScore[Counter] ← Temp1\nName[Counter,1] ← Temp2\nName[Counter,2] ← Temp3\nNEXT Student\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_33-p08.png",
        "../answer-assets/9618_s21_ms_33-p09.png"
      ]
    },
    {
      "id": "9618-2021-mj-33-q09",
      "question_id": "9618-2021-mj-33-q09",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 9,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark for each correct marking point (Max 2) 2\n• Imperative languages use variables\n• … which are changed using (assignment) statements\n• … they rely on a method of repetition / iteration.\n• The statements provide a sequence of commands for the computer to\nperform\n• … in the order written / given\n• … each line of code changes something in the program run.\n\n9(b) One mark for each correct marking point (Max 2) 2\n• Instructs a program on what needs to be done instead of how to do it\n• ... using facts and rules\n• … using queries to satisfy goals.\n• Can be logical or functional\n• Logical - states a program as a set of logical relations\n• Functional – constructed by applying functions to arguments / uses a\nmathematical style\n© UCLES 2021 Page 9 of 10\n\n9(c) One mark for each correct programming paradigm (Max 4) 4\nProgram code example Programming paradigm\nmale(john).\nfemale(ethel). Declarative\nparent(john, ethel).\nFOR Counter = 1 TO 20\nX = X * Counter Procedural / imperative\nNEXT Counter\nStart: LDD Counter\nINC ACC Low-level / assembly\nSTO Counter\npublic class Vehicle\n{\nprivate speed;\npublic Vehicle()\nObject oriented / (OOP)\n{\nspeed = 0;\n}\n}\n© UCLES 2021 Page 10 of 10",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_33-p09.png",
        "../answer-assets/9618_s21_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2021-mj-41-q01",
      "question_id": "9618-2021-mj-41-q01",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 24,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per bullet point 2\n• Declaring record/class with name node…\n• …declaring data and next node (both as Integers)\nExample code:\nVisual Basic\nStructure node\nDim Data As Integer\nDim nextNode As Integer\nEnd Structure\nPython\nclass node:\ndef __init__(self, theData, nextNodeNumber):\nself. Data = theData\nself.nextNode = nextNodeNumber\nJava\nclass node{\nprivate Integer Data;\nprivate Integer nextNode;\npublic node(Integer dataP, Integer nextNodeP){\nthis.Data = dataP;\nthis.nextNode = nextNodeP;\n}\n}\n© UCLES 2021 Page 4 of 30\n\n1(b) 1 mark per bullet point 4\n• Declaring array named linkedList with data type node\n• Assigning all nodes correctly as record/object nodes …\n• …with correct values stored\n• declaring startPointer as 0, emptyList as 5\nExample code:\nVisual Basic\nDim linkedList(9) As node\nlinkedList(0).data = 1\nlinkedList(0).nextNode = 1\nlinkedList(1).data = 5\nlinkedList(1).nextNode = 4\nlinkedList(2).data = 6\nlinkedList(2).nextNode = 7\nlinkedList(3).data = 7\nlinkedList(3).nextNode = -1\nlinkedList(4).data = 2\nlinkedList(4).nextNode = 2\nlinkedList(5).data = 0\nlinkedList(5).nextNode = 6\nlinkedList(6).data = 0\nlinkedList(6).nextNode = 8\nlinkedList(7).data = 56\nlinkedList(7).nextNode = 3\nlinkedList(8).data = 0\nlinkedList(8).nextNode = 9\nlinkedList(9).data = 0\nlinkedList(9).nextNode = -1\nDim startPointer As Integer = 0\nDim emptyList As Integer = 5\n© UCLES 2021 Page 5 of 30\n\n1(b) Python\nlinkedList = [node(1,1),node(5,4),node(6,7),node(7,-1),node(2,2),node(0,6),\nnode(0,8),node(56,3),node(0,9),node(0,-1)]\nstartPointer = 0\nemptyList = 5\nJava\npublic static void main(String[] args){\nnode[] linkedList = new node[10];\nlinkedList[0] = new node(1,1);\nlinkedList[1] = new node(5, 4);\nlinkedList[2] = new node(6, 7);\nlinkedList[3] = new node(7,-1);\nlinkedList[4] = new node(2,2);\nlinkedList[5] = new node(0,6);\nlinkedList[6] = new node(0,8);\nlinkedList[7] = new node(56, 3);\nlinkedList[8] = new node(0,9);\nlinkedList[9] = new node(0,-1);\nInteger startPointer = 0;\nInteger emptyList = 5;\n}\n© UCLES 2021 Page 6 of 30\n\n1(c)(i) 1 mark per bullet point 6\n• Procedure outputNodes …\n• …taking linked list and start pointer as parameters\n• Looping until nextNode/pointer is –1\n• Outputting the node data in the correct order, i.e. following pointers\n• Updating pointer to current node’s nextNode\n• Using the correct record/class field/properties throughout\nExample code:\nVisual Basic\nSub outputNodes(ByRef linkedList, ByVal currentPointer)\nWhile (currentPointer <> -1)\nConsole.WriteLine(linkedList(currentPointer).data)\ncurrentPointer = linkedList(currentPointer).nextNode\nEnd While\nEnd Sub\nPython\ndef outputNodes(linkedList, currentPointer):\nwhile(currentPointer != -1):\nprint(str(linkedList[currentPointer].data))\ncurrentPointer = linkedList[currentPointer].nextNode\nJava\npublic static void outputNodes(node[] linkedList, Integer currentPointer){\nwhile(currentPointer != -1){\nSystem.out.println(linkedList[currentPointer].data);\ncurrentPointer = linkedList[currentPointer].nextNode;\n}\n}\n© UCLES 2021 Page 7 of 30\n\n1(c)(ii) Screenshot showing: 1\n\n1\n5",
      "source_pages": [
        4,
        5,
        6,
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_41-p04.png",
        "../answer-assets/9618_s21_ms_41-p05.png",
        "../answer-assets/9618_s21_ms_41-p06.png",
        "../answer-assets/9618_s21_ms_41-p07.png",
        "../answer-assets/9618_s21_ms_41-p08.png"
      ]
    },
    {
      "id": "9618-2021-mj-41-q02",
      "question_id": "9618-2021-mj-41-q02",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 20,
      "status": "available",
      "reason": null,
      "text": "2\n6\n56\n7\n1(d)(i) 1 mark per bullet point to max 7 7\n• Function taking list and both pointers as parameters\n• Taking (integer) data as input\n• Checking if list is full …\n• … and returning False\n• Insert the input data to the empty list node’s data\n• Following pointers to find last node in Linked List …\n• …and updating last node’s pointer to empty list/location where new node is added\n• Updating empty list to it’s first elements pointer\n• Returning true when added successfully\nExample code:\nVisual Basic\nFunction addNode(ByRef linkedList() As node, ByVal currentPointer As Integer, ByRef\nemptyList As Integer)\nConsole.WriteLine(\"Enter the data to add\")\nDim dataToAdd As Integer = Console.ReadLine()\nDim previousPointer As Integer = 0\nDim newNode As node\nIf emptyList < 0 Or emptyList > 9 Then\nReturn False\nElse\nnewNode.data = dataToAdd\nnewNode.nextNode = -1\n© UCLES 2021 Page 8 of 30\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(i) linkedList(emptyList) = newNode\npreviousPointer = 0\nWhile (currentPointer <> -1)\npreviousPointer = currentPointer\ncurrentPointer = linkedList(currentPointer).nextNode\nEnd While\nDim valueToWrite As Integer = emptyList\nlinkedList(previousPointer).nextNode = valueToWrite\nemptyList = linkedList(emptyList).nextNode\nReturn True\nEnd If\nEnd Function\nPython\ndef addNode(linkedList, currentPointer, emptyList):\ndataToAdd = input(\"Enter the data to add\")\nif emptyList <0 or emptyList > 9:\nreturn False\nelse:\nnewNode = node(int(dataToAdd), -1)\nlinkedList[emptyList] = (newNode)\npreviousPointer = 0\nwhile(currentPointer != -1):\npreviousPointer = currentPointer\ncurrentPointer = linkedList[currentPointer].nextNode\nlinkedList[previousPointer].nextNode = emptyList\nemptyList = linkedList[emptyList].nextNode\nreturn True\n© UCLES 2021 Page 9 of 30\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(i) Java\npublic static Boolean addNode(node[] linkedList, Integer currentPointer,\nInteger emptyList){\nInteger dataToAdd;\nInteger previousPointer;\nnode newNode;\nScanner in = new Scanner(System.in);\nSystem.out.println(\"Enter the data to add\");\ndataToAdd = in.nextInt();\nif(emptyList < 0 || emptyList > 9){\nreturn false;\n}else{\nnewNode = new node(dataToAdd, -1);\nlinkedList[emptyList] = newNode;\npreviousPointer = 0;\nwhile(currentPointer != -1){\npreviousPointer = currentPointer;\ncurrentPointer = linkedList[currentPointer].nextNode;\n}\nlinkedList[previousPointer].nextNode = emptyList;\nemptyList = linkedList[emptyList].nextNode;\nreturn true;\n}\n}\n© UCLES 2021 Page 10 of 30\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(ii) 1 mark per bullet point 3\n• Call addNode() with list, start and empty pointers and store/check return value …\n• …output appropriate message if True returned and if False returned\n• Calling outputNodes() with list and start pointer before and after addNode()\nExample code:\nVisual Basic\nSub Main()\nDim linkedList(10) As node\nlinkedList(0).data = 1\nlinkedList(0).nextNode = 1\nlinkedList(1).data = 5\nlinkedList(1).nextNode = 4\nlinkedList(2).data = 6\nlinkedList(2).nextNode = 7\nlinkedList(3).data = 7\nlinkedList(3).nextNode = -1\nlinkedList(4).data = 2\nlinkedList(4).nextNode = 2\nlinkedList(5).data = -1\nlinkedList(5).nextNode = 6\nlinkedList(6).data = -1\nlinkedList(6).nextNode = 7\nlinkedList(7).data = 56\nlinkedList(7).nextNode = 3\nlinkedList(8).data = -1\nlinkedList(8).nextNode = 9\nlinkedList(9).data = -1\nlinkedList(9).nextNode = -1\nDim startPointer As Integer = 0\nDim emptyList As Integer = 5\noutputNodes(linkedList, startPointer)\nDim returnValue As Boolean\nreturnValue = addNode(linkedList, startPointer,\nemptyList)\n© UCLES 2021 Page 11 of 30\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(ii) If returnValue = True Then\nConsole.WriteLine(\"Item successfully added\")\nElse\nConsole.WriteLine(\"Item not added, list full\")\nEnd If\noutputNodes(linkedList, startPointer)\nConsole.ReadLine()\nEnd Sub\nPython\nlinkedList = [node(1,1),node(5,4),node(6,7),node(7,-1),node(2,2),node(-1,6),\nnode(-1,7),node(56,3),node(-1,9),node(-1,-1)]\nstartPointer = 0\nemptyList = 5\noutputNodes(linkedList, startPointer)\nreturnValue = addNode(linkedList, startPointer, emptyList)\nif returnValue == True:\nprint(\"Item successfully added\")\nelse:\nprint(\"Item not added, list full\")\noutputNodes(linkedList, startPointer)\nJava\npublic static void main(String[] args){\nnode[] linkedList = new node[10];\nlinkedList[0] = new node(1,1);\nlinkedList[1] = new node(5, 4);\nlinkedList[2] = new node(6, 7);\nlinkedList[3] = new node(7,-1);\nlinkedList[4] = new node(2,2);\nlinkedList[5] = new node(-1,6);\nlinkedList[6] = new node(-1,7);\nlinkedList[7] = new node(56, 3);\nlinkedList[8] = new node(-1,9);\n© UCLES 2021 Page 12 of 30\n\n2\n6\n56\n7\n5 (being input)\n1\n5\n\n2\n6\n56\n7\n5\n© UCLES 2021 Page 13 of 30\n\n2(a) 1 mark per bullet point 2\n• Array with identifier arrayData\n• correct 10 data items added\nExample code:\nVisual Basic\nDim arrayData(9) As Integer\nSub Main()\narrayData(0) = 10\narrayData(1) = 5\narrayData(2) = 6\narrayData(3) = 7\narrayData(4) = 1\narrayData(5) = 12\narrayData(6) = 13\narrayData(7) = 15\narrayData(8) = 21\narrayData(9) = 8\nEnd Sub\nPython\narrayData = [10, 5, 6, 7, 1, 12, 13, 15, 21, 8]\nJava\nint[] arrayData = new int[];\npublic static void main(String[] args){\narrayData[0] = 10;\narrayData[1] = 5;\narrayData[2] = 6;\narrayData[3] = 7;\narrayData[4] = 1;\narrayData[5] = 12;\narrayData[6] = 13;\n© UCLES 2021 Page 14 of 30\n\n2(a) arrayData[7] = 15;\narrayData[8] = 21;\narrayData[9] = 8;\n}\n\n2(b)(i) 1 mark per bullet point 6\n• function linearSearch with correct identifier\n• …taking integer search value as a parameter\n• Searching 10 times/through all array elements …\n• …comparing each element to search value\n• returning True if found\n• returning False if not found\nExample code:\nVisual Basic\nFunction linearSearch(ByRef searchValue As Integer)\nFor x = 0 To 9\nIf arrayData(x) = searchValue Then\nReturn True\nEnd If\nNext\nReturn False\nEnd Function\n© UCLES 2021 Page 15 of 30\n\n2(b)(i) Python\ndef linearSearch(searchValue):\nfor x in range(0, 10):\nif arrayData[x] == searchValue:\nreturn True\nreturn False\nJava\npublic static Boolean linearSearch(Integer searchValue){\nfor (int x = 0; x < 10; x++){\nif(arrayData[x] == searchValue){\nreturn true;\n}\n}\nreturn false;\n}\n© UCLES 2021 Page 16 of 30\n\n2(b)(ii) 1 mark per bullet point to max 4 4\n• Taking value as input…\n• …checking/casting to Integer\n• Calling linearSearch and sending input as parameter\n• Storing and checking return value…\n• …outputting appropriate message if found and if not found\nExample code:\nVisual Basic\nDim arrayData(10) As Integer\nSub Main()\narrayData(0) = 10\narrayData(1) = 5\narrayData(2) = 6\narrayData(3) = 7\narrayData(4) = 1\narrayData(5) = 12\narrayData(6) = 13\narrayData(7) = 15\narrayData(8) = 12\narrayData(9) = 8\nConsole.WriteLine(\"Enter a number to search for\")\nDim searchValue As Integer = Console.ReadLine()\nDim returnValue As Boolean = linearSearch(searchValue)\nIf returnValue = True Then\nConsole.WriteLine(\"Found it\")\nElse\nConsole.WriteLine(\"Didn't find it\")\nEnd If\nEnd Sub\n© UCLES 2021 Page 17 of 30\n\n2(b)(ii) Python\narrayData = [10, 5, 6, 7, 1, 12, 13, 15, 21, 8]\nsearchValue = int(input(\"Enter the number to search for\"))\nreturnValue = linearSearch(searchValue)\nif returnValue == True:\nprint(\"It was found\")\nelse:\nprint(\"It was not found\")\nJava\nInteger[] arrayData = new Integer[10];\npublic static void main(String[] args){\narrayData[0] = 10;\narrayData[1] = 5;\narrayData[2] = 6;\narrayData[3] = 7;\narrayData[4] = 1;\narrayData[5] = 12;\narrayData[6] = 13;\narrayData[7] = 15;\narrayData[8] = 12;\narrayData[9] = 8;\nSystem.out.println(\"Enter the number to search for\");\nInteger searchValue;\nScanner in = new Scanner(System.in);\nsearchValue = in.nextInt();\nBoolean returnValue;\nreturnValue = linearSearch(searchValue);\nif (returnValue == true){\nSystem.out.println(\"It was found\");\n}else{\nSystem.out.println(\"It was not found\");\n}\n}\n© UCLES 2021 Page 18 of 30\n\n2(b)(iii) 1 mark for screenshot showing input and output for number found 2\n1 mark for screenshot showing input and output for number not found\n\n2(c) 1 mark per bullet point 6\n• Correct outer loop stop\n• Correct inner loop stop\n• Correct < in the IF\n• Correct theArray(y + 1)\n• Correct temp\n• Remainder matching pseudocode\nExample code:\nVisual Basic\nSub bubbleSort()\nDim temp As Integer = 0\nFor x = 0 To 9\nFor y = 0 To 8\nIf theArray(y) < theArray(y + 1) Then\ntemp = theArray(y)\ntheArray(y) = theArray(y + 1)\ntheArray(y + 1) = temp\nEnd If\nNext\nNext\nEnd Sub\n© UCLES 2021 Page 19 of 30\n\n2(c) Python\ndef bubbleSort():\nfor x in range (0, 10):\nfor y in range(0, 9):\nif theArray[y] < theArray[y + 1]:\ntemp = theArray[y]\ntheArray[y] = theArray[y + 1]\ntheArray[y + 1] = temp\nJava\npublic static void bubbleSort(){\nint temp;\nfor (int x = 0; x < 10; x++){\nfor (int y = 0; y < 9; y++){\nif(theArray[y] < theArray[y+1]){\ntemp = theArray[y];\ntheArray[y] = theArray[y+1];\ntheArray[y+1] = temp;\n}\n}\n}\n}\n© UCLES 2021 Page 20 of 30",
      "source_pages": [
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_41-p08.png",
        "../answer-assets/9618_s21_ms_41-p09.png",
        "../answer-assets/9618_s21_ms_41-p10.png",
        "../answer-assets/9618_s21_ms_41-p11.png",
        "../answer-assets/9618_s21_ms_41-p12.png",
        "../answer-assets/9618_s21_ms_41-p13.png",
        "../answer-assets/9618_s21_ms_41-p14.png",
        "../answer-assets/9618_s21_ms_41-p15.png",
        "../answer-assets/9618_s21_ms_41-p16.png",
        "../answer-assets/9618_s21_ms_41-p17.png",
        "../answer-assets/9618_s21_ms_41-p18.png",
        "../answer-assets/9618_s21_ms_41-p19.png",
        "../answer-assets/9618_s21_ms_41-p20.png"
      ]
    },
    {
      "id": "9618-2021-mj-41-q03",
      "question_id": "9618-2021-mj-41-q03",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 31,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per bullet point 5\n• Class named treasureChest and end\n• Question declared as string as a class attribute\n• Answer declared as integer as a class attribute\n• Points declared as integer as a class attribute\n• All 3 attributes are private\nExample code:\nVisual Basic\nClass treasureChest\nPrivate question As String\nPrivate answer As Integer\nPrivate points As Integer\nSub New(questionP, answerP, pointsP)\nquestion = questionP\nanswer = answerP\npoints = pointsP\nEnd Sub\nEnd Class\nPython\nclass treasureChest:\n#Private question : String\n#Private answer : Integer\n#Private points : Integer\ndef __init__(self, questionP, answerP, pointsP):\nself.__question = questionP\nself.__answer = answerP\nself.__points = points\n© UCLES 2021 Page 21 of 30\n\n3(a) Java\nimport java.util.Scanner;\nclass treasureChest{\nprivate String question;\nprivate Integer answer;\nprivate Integer points;\npublic treasureChest(String questionP, Integer answerP, Integer pointsP){\nquestion = questionP;\nanswer = answerP;\npoints = pointsP;\n}\n}\n\n3(b) 1 mark per bullet point to max 8 8\n• procedure declared as readData\n• declare array arrayTreasure with 4 elements type treasureChest\n• opening correct file for read\n• looping until EOF/5 questions …\n• …reading in and storing each group of 3 lines appropriately\n• creating object of type treasureChest …\n• …with question, answer and points from file as parameters\n• ..adding to next array element/appending\n• … repeatedly for all 5 questions in correct order\n• Use of appropriate exception handler…\n• …appropriate output if file not found\n• Closing correct file\n© UCLES 2021 Page 22 of 30\n\n3(b) Example code:\nVisual Basic\nSub readData()\nDim arrayTreasure(4) as treasureChest\nDim filename As String = \"treasureChestData.txt\"\nTry\nDim fileReader As New System.IO.StreamReader(filename)\nDim question As String\nDim answer, points As Integer\nDim numberQuestions as Integer = 0\nWhile fileReader.Peek <> -1\nquestion = fileReader.ReadLine()\nanswer = fileReader.ReadLine()\npoints = fileReader.ReadLine()\narrayTreasure(numberQuestions) = New treasureChest(question, answer, points)\nnumberQuestions += 1\nEnd While\nfileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\nPython\n# arrayTreasure(5) as treasureChest\ndef readData():\nfilename = \"treasureChestData.txt\"\ntry:\nfile= open(filename,\"r\")\ndataFetched = (file.readline()).strip()\nwhile(dataFetched != \"\" ):\nquestion = dataFetched\nanswer = (file.readline()).strip()\n© UCLES 2021 Page 23 of 30\n\n3(b) points = (file.readline()).strip()\narrayTreasure.append(treasureChest(question, answer, points))\ndataFetched = (file.readline()).strip()\nfile.close()\nexcept IOError:\nprint(\"Could not find file\")\nJava\npublic static void readData(){\ntreasureChest[] arrayTreasure = new treasureChest[5]:\nString filename = \"treasureChestData.txt\";\nString dataRead;\nString question;\nString answer;\nString points;\nInteger numberQuestions = 0;\ntry{\nFileReader f = new FileReader(filename);\nBufferedReader reader = new BufferedReader(f);\ndataRead = reader.readLine();\nwhile (dataRead != null){\nquestion = dataRead;\nanswer = reader.readLine();\npoints = reader.readLine();\narrayTreasure[numberQuestions] = new treasureChest(question,\nInteger.parseInt(answer), Integer.parseInt(points));\nnumberQuestions++;\ndataRead = reader.readLine();\n}\nreader.close();\n}\n© UCLES 2021 Page 24 of 30\n\n3(b) catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No file found\");\n}\n}\n\n3(c)(i) 1 mark for getQuestion returning the value of question 1\nExample code:\nVisual Basic\nFunction getQuestion()\nReturn question\nEnd Function\nPython\ndef getQuestion(self):\nreturn self.__question\nJava\npublic String getQuestion(){\nreturn question;\n}\n© UCLES 2021 Page 25 of 30\n\n3(c)(ii) 1 mark per bullet point 3\n• Function checkAnswer taking in the parameter, returning Boolean\n• Comparing parameter to that object’s answer…\n• …returning True if correct and False otherwise\nExample code:\nVisual Basic\nFunction checkAnswer(answerP)\nIf answer = answerP Then\nReturn True\nElse\nReturn False\nEnd If\nEnd Function\nPython\ndef checkAnswer(self, answerP):\nif int(self.__answer) == answerP:\nreturn True\nelse:\nreturn False\nJava\npublic Boolean checkAnswer(Integer answerP){\nif (answer == answerP){\nreturn true;\n}else{\nreturn false;\n}\n}\n© UCLES 2021 Page 26 of 30\n\n3(c)(iii) 1 mark per bullet point 5\n• Function getPoints taking attempts as parameter and returning integer\n• If attempts is 1 returning points\n• If attempts is 2 returns points DIV 2\n• If attempts is 3 or 4 returns points DIV 4\n• otherwise returns 0\nExample code:\nVisual Basic\nFunction getPoints(attempts)\nIf attempts = 1 Then\nReturn points\nElseIf attempts = 2 Then\nReturn points \\ 2\nElseIf attempts = 3 Or attempts = 4 Then\nReturn points \\ 4\nElse\nReturn 0\nEnd If\nEnd Function\nPython\ndef getPoints(self, attempts):\nif attempts == 1:\nreturn int(self.__points)\nelif attempts == 2:\nreturn int(self.__points) // 2\nelif attempts == 3 or attempts == 4:\nreturn int(self.__points) // 4\nelse:\nreturn 0\n© UCLES 2021 Page 27 of 30\n\n3(c)(iii) Java\npublic Integer getPoints(Integer attempts){\nif (attempts == 1){\nreturn points;\n}else if(attempts == 2){\nreturn Math.round(points/2);\n}else if(attempts == 3 || attempts == 4){\nreturn Math.round(points/4);\n}else{\nreturn 0;\n}\n}\n\n3(c)(iv) 1 mark per bullet point to max 7 7\n• Call the procedure readData()\n• Take the question number as input from user\n• ..validated between 1 and 5\n• Output the question stored at user’s input value\n• Read answer from user\n• Check the answer input against question’s answer\n• …looping until the answer is correct\n• Keeping track of the number of attempts using a variable\n• Using getPoints() and sending the number of attempts as a parameter …\n• …outputting the number of points returned\n• Using .getQuestion and .checkAnswer to access question number input by user and answer input by used\n© UCLES 2021 Page 28 of 30\n\n3(c)(iv) Example code:\nVisual Basic\nSub Main()\nreadData()\nConsole.WriteLine(\"Pick a treasure chest to open\")\nDim choice As Integer = Console.ReadLine()\nDim result As Boolean\nDim answer As Integer\nDim attempts As Integer = 0\nIf choice > 0 And choice < 6 Then\nresult = False\nattempts = 0\nWhile result = False\nConsole.WriteLine(arrayTreasure(choice - 1).getQuestion())\nanswer = Console.ReadLine\nresult = arrayTreasure(choice - 1).checkAnswer(answer)\nattempts = attempts + 1\nEnd While\nConsole.WriteLine(arrayTreasure(choice - 1).getPoints(attempts))\nEnd If\nEnd Sub\nPython\nreadData()\nchoice = int(input(\"Pick a treasure chest to open\"))\nif choice > 0 and choice < 6:\nresult = False\nattempts = 0\nwhile result == False:\nanswer = int(input(arrayTreasure[choice-1].getQuestion()))\nresult = arrayTreasure[choice-1].checkAnswer(answer)\nattempts = attempts + 1\nprint(int(arrayTreasure[choice-1].getPoints(attempts)))\n© UCLES 2021 Page 29 of 30\n\n3(c)(iv) Java\npublic static void main(String[] args){\nreadData();\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Pick a treasure chest to open\");\nInteger answer;\nInteger choice;\nchoice= Integer.parseInt(scanner.nextLine());\nInteger attempts;\nif (choice> 0 && choice < 6){\nBoolean result = false;\nattempts = 0;\nwhile (result == false){\nSystem.out.println(arrayTreasure[choice-1].getQuestion());\nanswer = Integer.parseInt(scanner.nextLine());\nresult = arrayTreasure[choice-1].checkAnswer(answer);\nattempts++;\n}\nSystem.out.println(arrayTreasure[choice-1].getPoints(attempts));\n}\n}\n\n3(c)(v) 1 mark per screenshot 2\n• Screenshot:\noutputting 2*2\nentering 4\noutputting 10\n• Screenshot:\noutputting 3000+4000\nentering an incorrect value\nentering 7000\noutputting 9\n© UCLES 2021 Page 30 of 30",
      "source_pages": [
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_41-p21.png",
        "../answer-assets/9618_s21_ms_41-p22.png",
        "../answer-assets/9618_s21_ms_41-p23.png",
        "../answer-assets/9618_s21_ms_41-p24.png",
        "../answer-assets/9618_s21_ms_41-p25.png",
        "../answer-assets/9618_s21_ms_41-p26.png",
        "../answer-assets/9618_s21_ms_41-p27.png",
        "../answer-assets/9618_s21_ms_41-p28.png",
        "../answer-assets/9618_s21_ms_41-p29.png",
        "../answer-assets/9618_s21_ms_41-p30.png"
      ]
    },
    {
      "id": "9618-2021-mj-42-q01",
      "question_id": "9618-2021-mj-42-q01",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 24,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per bullet point 2\n• Declaring record/class with name node…\n• …declaring data and next node (both as Integers)\nExample code:\nVisual Basic\nStructure node\nDim Data As Integer\nDim nextNode As Integer\nEnd Structure\nPython\nclass node:\ndef __init__(self, theData, nextNodeNumber):\nself. Data = theData\nself.nextNode = nextNodeNumber\nJava\nclass node{\nprivate Integer Data;\nprivate Integer nextNode;\npublic node(Integer dataP, Integer nextNodeP){\nthis.Data = dataP;\nthis.nextNode = nextNodeP;\n}\n}\n© UCLES 2021 Page 4 of 30\n\n1(b) 1 mark per bullet point 4\n• Declaring array named linkedList with data type node\n• Assigning all nodes correctly as record/object nodes …\n• …with correct values stored\n• declaring startPointer as 0, emptyList as 5\nExample code:\nVisual Basic\nDim linkedList(9) As node\nlinkedList(0).data = 1\nlinkedList(0).nextNode = 1\nlinkedList(1).data = 5\nlinkedList(1).nextNode = 4\nlinkedList(2).data = 6\nlinkedList(2).nextNode = 7\nlinkedList(3).data = 7\nlinkedList(3).nextNode = -1\nlinkedList(4).data = 2\nlinkedList(4).nextNode = 2\nlinkedList(5).data = 0\nlinkedList(5).nextNode = 6\nlinkedList(6).data = 0\nlinkedList(6).nextNode = 8\nlinkedList(7).data = 56\nlinkedList(7).nextNode = 3\nlinkedList(8).data = 0\nlinkedList(8).nextNode = 9\nlinkedList(9).data = 0\nlinkedList(9).nextNode = -1\nDim startPointer As Integer = 0\nDim emptyList As Integer = 5\n© UCLES 2021 Page 5 of 30\n\n1(b) Python\nlinkedList = [node(1,1),node(5,4),node(6,7),node(7,-1),node(2,2),node(0,6),\nnode(0,8),node(56,3),node(0,9),node(0,-1)]\nstartPointer = 0\nemptyList = 5\nJava\npublic static void main(String[] args){\nnode[] linkedList = new node[10];\nlinkedList[0] = new node(1,1);\nlinkedList[1] = new node(5, 4);\nlinkedList[2] = new node(6, 7);\nlinkedList[3] = new node(7,-1);\nlinkedList[4] = new node(2,2);\nlinkedList[5] = new node(0,6);\nlinkedList[6] = new node(0,8);\nlinkedList[7] = new node(56, 3);\nlinkedList[8] = new node(0,9);\nlinkedList[9] = new node(0,-1);\nInteger startPointer = 0;\nInteger emptyList = 5;\n}\n© UCLES 2021 Page 6 of 30\n\n1(c)(i) 1 mark per bullet point 6\n• Procedure outputNodes …\n• …taking linked list and start pointer as parameters\n• Looping until nextNode/pointer is –1\n• Outputting the node data in the correct order, i.e. following pointers\n• Updating pointer to current node’s nextNode\n• Using the correct record/class field/properties throughout\nExample code:\nVisual Basic\nSub outputNodes(ByRef linkedList, ByVal currentPointer)\nWhile (currentPointer <> -1)\nConsole.WriteLine(linkedList(currentPointer).data)\ncurrentPointer = linkedList(currentPointer).nextNode\nEnd While\nEnd Sub\nPython\ndef outputNodes(linkedList, currentPointer):\nwhile(currentPointer != -1):\nprint(str(linkedList[currentPointer].data))\ncurrentPointer = linkedList[currentPointer].nextNode\nJava\npublic static void outputNodes(node[] linkedList, Integer currentPointer){\nwhile(currentPointer != -1){\nSystem.out.println(linkedList[currentPointer].data);\ncurrentPointer = linkedList[currentPointer].nextNode;\n}\n}\n© UCLES 2021 Page 7 of 30\n\n1(c)(ii) Screenshot showing: 1\n\n1\n5",
      "source_pages": [
        4,
        5,
        6,
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_42-p04.png",
        "../answer-assets/9618_s21_ms_42-p05.png",
        "../answer-assets/9618_s21_ms_42-p06.png",
        "../answer-assets/9618_s21_ms_42-p07.png",
        "../answer-assets/9618_s21_ms_42-p08.png"
      ]
    },
    {
      "id": "9618-2021-mj-42-q02",
      "question_id": "9618-2021-mj-42-q02",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 20,
      "status": "available",
      "reason": null,
      "text": "2\n6\n56\n7\n1(d)(i) 1 mark per bullet point to max 7 7\n• Function taking list and both pointers as parameters\n• Taking (integer) data as input\n• Checking if list is full …\n• … and returning False\n• Insert the input data to the empty list node’s data\n• Following pointers to find last node in Linked List …\n• …and updating last node’s pointer to empty list/location where new node is added\n• Updating empty list to it’s first elements pointer\n• Returning true when added successfully\nExample code:\nVisual Basic\nFunction addNode(ByRef linkedList() As node, ByVal currentPointer As Integer, ByRef\nemptyList As Integer)\nConsole.WriteLine(\"Enter the data to add\")\nDim dataToAdd As Integer = Console.ReadLine()\nDim previousPointer As Integer = 0\nDim newNode As node\nIf emptyList < 0 Or emptyList > 9 Then\nReturn False\nElse\nnewNode.data = dataToAdd\nnewNode.nextNode = -1\n© UCLES 2021 Page 8 of 30\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(i) linkedList(emptyList) = newNode\npreviousPointer = 0\nWhile (currentPointer <> -1)\npreviousPointer = currentPointer\ncurrentPointer = linkedList(currentPointer).nextNode\nEnd While\nDim valueToWrite As Integer = emptyList\nlinkedList(previousPointer).nextNode = valueToWrite\nemptyList = linkedList(emptyList).nextNode\nReturn True\nEnd If\nEnd Function\nPython\ndef addNode(linkedList, currentPointer, emptyList):\ndataToAdd = input(\"Enter the data to add\")\nif emptyList <0 or emptyList > 9:\nreturn False\nelse:\nnewNode = node(int(dataToAdd), -1)\nlinkedList[emptyList] = (newNode)\npreviousPointer = 0\nwhile(currentPointer != -1):\npreviousPointer = currentPointer\ncurrentPointer = linkedList[currentPointer].nextNode\nlinkedList[previousPointer].nextNode = emptyList\nemptyList = linkedList[emptyList].nextNode\nreturn True\n© UCLES 2021 Page 9 of 30\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(i) Java\npublic static Boolean addNode(node[] linkedList, Integer currentPointer,\nInteger emptyList){\nInteger dataToAdd;\nInteger previousPointer;\nnode newNode;\nScanner in = new Scanner(System.in);\nSystem.out.println(\"Enter the data to add\");\ndataToAdd = in.nextInt();\nif(emptyList < 0 || emptyList > 9){\nreturn false;\n}else{\nnewNode = new node(dataToAdd, -1);\nlinkedList[emptyList] = newNode;\npreviousPointer = 0;\nwhile(currentPointer != -1){\npreviousPointer = currentPointer;\ncurrentPointer = linkedList[currentPointer].nextNode;\n}\nlinkedList[previousPointer].nextNode = emptyList;\nemptyList = linkedList[emptyList].nextNode;\nreturn true;\n}\n}\n© UCLES 2021 Page 10 of 30\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(ii) 1 mark per bullet point 3\n• Call addNode() with list, start and empty pointers and store/check return value …\n• …output appropriate message if True returned and if False returned\n• Calling outputNodes() with list and start pointer before and after addNode()\nExample code:\nVisual Basic\nSub Main()\nDim linkedList(10) As node\nlinkedList(0).data = 1\nlinkedList(0).nextNode = 1\nlinkedList(1).data = 5\nlinkedList(1).nextNode = 4\nlinkedList(2).data = 6\nlinkedList(2).nextNode = 7\nlinkedList(3).data = 7\nlinkedList(3).nextNode = -1\nlinkedList(4).data = 2\nlinkedList(4).nextNode = 2\nlinkedList(5).data = -1\nlinkedList(5).nextNode = 6\nlinkedList(6).data = -1\nlinkedList(6).nextNode = 7\nlinkedList(7).data = 56\nlinkedList(7).nextNode = 3\nlinkedList(8).data = -1\nlinkedList(8).nextNode = 9\nlinkedList(9).data = -1\nlinkedList(9).nextNode = -1\nDim startPointer As Integer = 0\nDim emptyList As Integer = 5\noutputNodes(linkedList, startPointer)\nDim returnValue As Boolean\nreturnValue = addNode(linkedList, startPointer,\nemptyList)\n© UCLES 2021 Page 11 of 30\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(ii) If returnValue = True Then\nConsole.WriteLine(\"Item successfully added\")\nElse\nConsole.WriteLine(\"Item not added, list full\")\nEnd If\noutputNodes(linkedList, startPointer)\nConsole.ReadLine()\nEnd Sub\nPython\nlinkedList = [node(1,1),node(5,4),node(6,7),node(7,-1),node(2,2),node(-1,6),\nnode(-1,7),node(56,3),node(-1,9),node(-1,-1)]\nstartPointer = 0\nemptyList = 5\noutputNodes(linkedList, startPointer)\nreturnValue = addNode(linkedList, startPointer, emptyList)\nif returnValue == True:\nprint(\"Item successfully added\")\nelse:\nprint(\"Item not added, list full\")\noutputNodes(linkedList, startPointer)\nJava\npublic static void main(String[] args){\nnode[] linkedList = new node[10];\nlinkedList[0] = new node(1,1);\nlinkedList[1] = new node(5, 4);\nlinkedList[2] = new node(6, 7);\nlinkedList[3] = new node(7,-1);\nlinkedList[4] = new node(2,2);\nlinkedList[5] = new node(-1,6);\nlinkedList[6] = new node(-1,7);\nlinkedList[7] = new node(56, 3);\nlinkedList[8] = new node(-1,9);\n© UCLES 2021 Page 12 of 30\n\n2\n6\n56\n7\n5 (being input)\n1\n5\n\n2\n6\n56\n7\n5\n© UCLES 2021 Page 13 of 30\n\n2(a) 1 mark per bullet point 2\n• Array with identifier arrayData\n• correct 10 data items added\nExample code:\nVisual Basic\nDim arrayData(9) As Integer\nSub Main()\narrayData(0) = 10\narrayData(1) = 5\narrayData(2) = 6\narrayData(3) = 7\narrayData(4) = 1\narrayData(5) = 12\narrayData(6) = 13\narrayData(7) = 15\narrayData(8) = 21\narrayData(9) = 8\nEnd Sub\nPython\narrayData = [10, 5, 6, 7, 1, 12, 13, 15, 21, 8]\nJava\nint[] arrayData = new int[];\npublic static void main(String[] args){\narrayData[0] = 10;\narrayData[1] = 5;\narrayData[2] = 6;\narrayData[3] = 7;\narrayData[4] = 1;\narrayData[5] = 12;\narrayData[6] = 13;\n© UCLES 2021 Page 14 of 30\n\n2(a) arrayData[7] = 15;\narrayData[8] = 21;\narrayData[9] = 8;\n}\n\n2(b)(i) 1 mark per bullet point 6\n• function linearSearch with correct identifier\n• …taking integer search value as a parameter\n• Searching 10 times/through all array elements …\n• …comparing each element to search value\n• returning True if found\n• returning False if not found\nExample code:\nVisual Basic\nFunction linearSearch(ByRef searchValue As Integer)\nFor x = 0 To 9\nIf arrayData(x) = searchValue Then\nReturn True\nEnd If\nNext\nReturn False\nEnd Function\n© UCLES 2021 Page 15 of 30\n\n2(b)(i) Python\ndef linearSearch(searchValue):\nfor x in range(0, 10):\nif arrayData[x] == searchValue:\nreturn True\nreturn False\nJava\npublic static Boolean linearSearch(Integer searchValue){\nfor (int x = 0; x < 10; x++){\nif(arrayData[x] == searchValue){\nreturn true;\n}\n}\nreturn false;\n}\n© UCLES 2021 Page 16 of 30\n\n2(b)(ii) 1 mark per bullet point to max 4 4\n• Taking value as input…\n• …checking/casting to Integer\n• Calling linearSearch and sending input as parameter\n• Storing and checking return value…\n• …outputting appropriate message if found and if not found\nExample code:\nVisual Basic\nDim arrayData(10) As Integer\nSub Main()\narrayData(0) = 10\narrayData(1) = 5\narrayData(2) = 6\narrayData(3) = 7\narrayData(4) = 1\narrayData(5) = 12\narrayData(6) = 13\narrayData(7) = 15\narrayData(8) = 12\narrayData(9) = 8\nConsole.WriteLine(\"Enter a number to search for\")\nDim searchValue As Integer = Console.ReadLine()\nDim returnValue As Boolean = linearSearch(searchValue)\nIf returnValue = True Then\nConsole.WriteLine(\"Found it\")\nElse\nConsole.WriteLine(\"Didn't find it\")\nEnd If\nEnd Sub\n© UCLES 2021 Page 17 of 30\n\n2(b)(ii) Python\narrayData = [10, 5, 6, 7, 1, 12, 13, 15, 21, 8]\nsearchValue = int(input(\"Enter the number to search for\"))\nreturnValue = linearSearch(searchValue)\nif returnValue == True:\nprint(\"It was found\")\nelse:\nprint(\"It was not found\")\nJava\nInteger[] arrayData = new Integer[10];\npublic static void main(String[] args){\narrayData[0] = 10;\narrayData[1] = 5;\narrayData[2] = 6;\narrayData[3] = 7;\narrayData[4] = 1;\narrayData[5] = 12;\narrayData[6] = 13;\narrayData[7] = 15;\narrayData[8] = 12;\narrayData[9] = 8;\nSystem.out.println(\"Enter the number to search for\");\nInteger searchValue;\nScanner in = new Scanner(System.in);\nsearchValue = in.nextInt();\nBoolean returnValue;\nreturnValue = linearSearch(searchValue);\nif (returnValue == true){\nSystem.out.println(\"It was found\");\n}else{\nSystem.out.println(\"It was not found\");\n}\n}\n© UCLES 2021 Page 18 of 30\n\n2(b)(iii) 1 mark for screenshot showing input and output for number found 2\n1 mark for screenshot showing input and output for number not found\n\n2(c) 1 mark per bullet point 6\n• Correct outer loop stop\n• Correct inner loop stop\n• Correct < in the IF\n• Correct theArray(y + 1)\n• Correct temp\n• Remainder matching pseudocode\nExample code:\nVisual Basic\nSub bubbleSort()\nDim temp As Integer = 0\nFor x = 0 To 9\nFor y = 0 To 8\nIf theArray(y) < theArray(y + 1) Then\ntemp = theArray(y)\ntheArray(y) = theArray(y + 1)\ntheArray(y + 1) = temp\nEnd If\nNext\nNext\nEnd Sub\n© UCLES 2021 Page 19 of 30\n\n2(c) Python\ndef bubbleSort():\nfor x in range (0, 10):\nfor y in range(0, 9):\nif theArray[y] < theArray[y + 1]:\ntemp = theArray[y]\ntheArray[y] = theArray[y + 1]\ntheArray[y + 1] = temp\nJava\npublic static void bubbleSort(){\nint temp;\nfor (int x = 0; x < 10; x++){\nfor (int y = 0; y < 9; y++){\nif(theArray[y] < theArray[y+1]){\ntemp = theArray[y];\ntheArray[y] = theArray[y+1];\ntheArray[y+1] = temp;\n}\n}\n}\n}\n© UCLES 2021 Page 20 of 30",
      "source_pages": [
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_42-p08.png",
        "../answer-assets/9618_s21_ms_42-p09.png",
        "../answer-assets/9618_s21_ms_42-p10.png",
        "../answer-assets/9618_s21_ms_42-p11.png",
        "../answer-assets/9618_s21_ms_42-p12.png",
        "../answer-assets/9618_s21_ms_42-p13.png",
        "../answer-assets/9618_s21_ms_42-p14.png",
        "../answer-assets/9618_s21_ms_42-p15.png",
        "../answer-assets/9618_s21_ms_42-p16.png",
        "../answer-assets/9618_s21_ms_42-p17.png",
        "../answer-assets/9618_s21_ms_42-p18.png",
        "../answer-assets/9618_s21_ms_42-p19.png",
        "../answer-assets/9618_s21_ms_42-p20.png"
      ]
    },
    {
      "id": "9618-2021-mj-42-q03",
      "question_id": "9618-2021-mj-42-q03",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 31,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per bullet point 5\n• Class named treasureChest and end\n• Question declared as string as a class attribute\n• Answer declared as integer as a class attribute\n• Points declared as integer as a class attribute\n• All 3 attributes are private\nExample code:\nVisual Basic\nClass treasureChest\nPrivate question As String\nPrivate answer As Integer\nPrivate points As Integer\nSub New(questionP, answerP, pointsP)\nquestion = questionP\nanswer = answerP\npoints = pointsP\nEnd Sub\nEnd Class\nPython\nclass treasureChest:\n#Private question : String\n#Private answer : Integer\n#Private points : Integer\ndef __init__(self, questionP, answerP, pointsP):\nself.__question = questionP\nself.__answer = answerP\nself.__points = points\n© UCLES 2021 Page 21 of 30\n\n3(a) Java\nimport java.util.Scanner;\nclass treasureChest{\nprivate String question;\nprivate Integer answer;\nprivate Integer points;\npublic treasureChest(String questionP, Integer answerP, Integer pointsP){\nquestion = questionP;\nanswer = answerP;\npoints = pointsP;\n}\n}\n\n3(b) 1 mark per bullet point to max 8 8\n• procedure declared as readData\n• declare array arrayTreasure with 4 elements type treasureChest\n• opening correct file for read\n• looping until EOF/5 questions …\n• …reading in and storing each group of 3 lines appropriately\n• creating object of type treasureChest …\n• …with question, answer and points from file as parameters\n• ..adding to next array element/appending\n• … repeatedly for all 5 questions in correct order\n• Use of appropriate exception handler…\n• …appropriate output if file not found\n• Closing correct file\n© UCLES 2021 Page 22 of 30\n\n3(b) Example code:\nVisual Basic\nSub readData()\nDim arrayTreasure(4) as treasureChest\nDim filename As String = \"treasureChestData.txt\"\nTry\nDim fileReader As New System.IO.StreamReader(filename)\nDim question As String\nDim answer, points As Integer\nDim numberQuestions as Integer = 0\nWhile fileReader.Peek <> -1\nquestion = fileReader.ReadLine()\nanswer = fileReader.ReadLine()\npoints = fileReader.ReadLine()\narrayTreasure(numberQuestions) = New treasureChest(question, answer, points)\nnumberQuestions += 1\nEnd While\nfileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\nPython\n# arrayTreasure(5) as treasureChest\ndef readData():\nfilename = \"treasureChestData.txt\"\ntry:\nfile= open(filename,\"r\")\ndataFetched = (file.readline()).strip()\nwhile(dataFetched != \"\" ):\nquestion = dataFetched\nanswer = (file.readline()).strip()\n© UCLES 2021 Page 23 of 30\n\n3(b) points = (file.readline()).strip()\narrayTreasure.append(treasureChest(question, answer, points))\ndataFetched = (file.readline()).strip()\nfile.close()\nexcept IOError:\nprint(\"Could not find file\")\nJava\npublic static void readData(){\ntreasureChest[] arrayTreasure = new treasureChest[5]:\nString filename = \"treasureChestData.txt\";\nString dataRead;\nString question;\nString answer;\nString points;\nInteger numberQuestions = 0;\ntry{\nFileReader f = new FileReader(filename);\nBufferedReader reader = new BufferedReader(f);\ndataRead = reader.readLine();\nwhile (dataRead != null){\nquestion = dataRead;\nanswer = reader.readLine();\npoints = reader.readLine();\narrayTreasure[numberQuestions] = new treasureChest(question,\nInteger.parseInt(answer), Integer.parseInt(points));\nnumberQuestions++;\ndataRead = reader.readLine();\n}\nreader.close();\n}\n© UCLES 2021 Page 24 of 30\n\n3(b) catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No file found\");\n}\n}\n\n3(c)(i) 1 mark for getQuestion returning the value of question 1\nExample code:\nVisual Basic\nFunction getQuestion()\nReturn question\nEnd Function\nPython\ndef getQuestion(self):\nreturn self.__question\nJava\npublic String getQuestion(){\nreturn question;\n}\n© UCLES 2021 Page 25 of 30\n\n3(c)(ii) 1 mark per bullet point 3\n• Function checkAnswer taking in the parameter, returning Boolean\n• Comparing parameter to that object’s answer…\n• …returning True if correct and False otherwise\nExample code:\nVisual Basic\nFunction checkAnswer(answerP)\nIf answer = answerP Then\nReturn True\nElse\nReturn False\nEnd If\nEnd Function\nPython\ndef checkAnswer(self, answerP):\nif int(self.__answer) == answerP:\nreturn True\nelse:\nreturn False\nJava\npublic Boolean checkAnswer(Integer answerP){\nif (answer == answerP){\nreturn true;\n}else{\nreturn false;\n}\n}\n© UCLES 2021 Page 26 of 30\n\n3(c)(iii) 1 mark per bullet point 5\n• Function getPoints taking attempts as parameter and returning integer\n• If attempts is 1 returning points\n• If attempts is 2 returns points DIV 2\n• If attempts is 3 or 4 returns points DIV 4\n• otherwise returns 0\nExample code:\nVisual Basic\nFunction getPoints(attempts)\nIf attempts = 1 Then\nReturn points\nElseIf attempts = 2 Then\nReturn points \\ 2\nElseIf attempts = 3 Or attempts = 4 Then\nReturn points \\ 4\nElse\nReturn 0\nEnd If\nEnd Function\nPython\ndef getPoints(self, attempts):\nif attempts == 1:\nreturn int(self.__points)\nelif attempts == 2:\nreturn int(self.__points) // 2\nelif attempts == 3 or attempts == 4:\nreturn int(self.__points) // 4\nelse:\nreturn 0\n© UCLES 2021 Page 27 of 30\n\n3(c)(iii) Java\npublic Integer getPoints(Integer attempts){\nif (attempts == 1){\nreturn points;\n}else if(attempts == 2){\nreturn Math.round(points/2);\n}else if(attempts == 3 || attempts == 4){\nreturn Math.round(points/4);\n}else{\nreturn 0;\n}\n}\n\n3(c)(iv) 1 mark per bullet point to max 7 7\n• Call the procedure readData()\n• Take the question number as input from user\n• ..validated between 1 and 5\n• Output the question stored at user’s input value\n• Read answer from user\n• Check the answer input against question’s answer\n• …looping until the answer is correct\n• Keeping track of the number of attempts using a variable\n• Using getPoints() and sending the number of attempts as a parameter …\n• …outputting the number of points returned\n• Using .getQuestion and .checkAnswer to access question number input by user and answer input by used\n© UCLES 2021 Page 28 of 30\n\n3(c)(iv) Example code:\nVisual Basic\nSub Main()\nreadData()\nConsole.WriteLine(\"Pick a treasure chest to open\")\nDim choice As Integer = Console.ReadLine()\nDim result As Boolean\nDim answer As Integer\nDim attempts As Integer = 0\nIf choice > 0 And choice < 6 Then\nresult = False\nattempts = 0\nWhile result = False\nConsole.WriteLine(arrayTreasure(choice - 1).getQuestion())\nanswer = Console.ReadLine\nresult = arrayTreasure(choice - 1).checkAnswer(answer)\nattempts = attempts + 1\nEnd While\nConsole.WriteLine(arrayTreasure(choice - 1).getPoints(attempts))\nEnd If\nEnd Sub\nPython\nreadData()\nchoice = int(input(\"Pick a treasure chest to open\"))\nif choice > 0 and choice < 6:\nresult = False\nattempts = 0\nwhile result == False:\nanswer = int(input(arrayTreasure[choice-1].getQuestion()))\nresult = arrayTreasure[choice-1].checkAnswer(answer)\nattempts = attempts + 1\nprint(int(arrayTreasure[choice-1].getPoints(attempts)))\n© UCLES 2021 Page 29 of 30\n\n3(c)(iv) Java\npublic static void main(String[] args){\nreadData();\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Pick a treasure chest to open\");\nInteger answer;\nInteger choice;\nchoice= Integer.parseInt(scanner.nextLine());\nInteger attempts;\nif (choice> 0 && choice < 6){\nBoolean result = false;\nattempts = 0;\nwhile (result == false){\nSystem.out.println(arrayTreasure[choice-1].getQuestion());\nanswer = Integer.parseInt(scanner.nextLine());\nresult = arrayTreasure[choice-1].checkAnswer(answer);\nattempts++;\n}\nSystem.out.println(arrayTreasure[choice-1].getPoints(attempts));\n}\n}\n\n3(c)(v) 1 mark per screenshot 2\n• Screenshot:\noutputting 2*2\nentering 4\noutputting 10\n• Screenshot:\noutputting 3000+4000\nentering an incorrect value\nentering 7000\noutputting 9\n© UCLES 2021 Page 30 of 30",
      "source_pages": [
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_42-p21.png",
        "../answer-assets/9618_s21_ms_42-p22.png",
        "../answer-assets/9618_s21_ms_42-p23.png",
        "../answer-assets/9618_s21_ms_42-p24.png",
        "../answer-assets/9618_s21_ms_42-p25.png",
        "../answer-assets/9618_s21_ms_42-p26.png",
        "../answer-assets/9618_s21_ms_42-p27.png",
        "../answer-assets/9618_s21_ms_42-p28.png",
        "../answer-assets/9618_s21_ms_42-p29.png",
        "../answer-assets/9618_s21_ms_42-p30.png"
      ]
    },
    {
      "id": "9618-2021-mj-43-q01",
      "question_id": "9618-2021-mj-43-q01",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 24,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per bullet point 2\n• Declaring record/class with name node…\n• …declaring data and next node (both as Integers)\nExample code:\nVisual Basic\nStructure node\nDim Data As Integer\nDim nextNode As Integer\nEnd Structure\nPython\nclass node:\ndef __init__(self, theData, nextNodeNumber):\nself. Data = theData\nself.nextNode = nextNodeNumber\nJava\nclass node{\nprivate Integer Data;\nprivate Integer nextNode;\npublic node(Integer dataP, Integer nextNodeP){\nthis.Data = dataP;\nthis.nextNode = nextNodeP;\n}\n}\n© UCLES 2021 Page 4 of 30\n\n1(b) 1 mark per bullet point 4\n• Declaring array named linkedList with data type node\n• Assigning all nodes correctly as record/object nodes …\n• …with correct values stored\n• declaring startPointer as 0, emptyList as 5\nExample code:\nVisual Basic\nDim linkedList(9) As node\nlinkedList(0).data = 1\nlinkedList(0).nextNode = 1\nlinkedList(1).data = 5\nlinkedList(1).nextNode = 4\nlinkedList(2).data = 6\nlinkedList(2).nextNode = 7\nlinkedList(3).data = 7\nlinkedList(3).nextNode = -1\nlinkedList(4).data = 2\nlinkedList(4).nextNode = 2\nlinkedList(5).data = 0\nlinkedList(5).nextNode = 6\nlinkedList(6).data = 0\nlinkedList(6).nextNode = 8\nlinkedList(7).data = 56\nlinkedList(7).nextNode = 3\nlinkedList(8).data = 0\nlinkedList(8).nextNode = 9\nlinkedList(9).data = 0\nlinkedList(9).nextNode = -1\nDim startPointer As Integer = 0\nDim emptyList As Integer = 5\n© UCLES 2021 Page 5 of 30\n\n1(b) Python\nlinkedList = [node(1,1),node(5,4),node(6,7),node(7,-1),node(2,2),node(0,6),\nnode(0,8),node(56,3),node(0,9),node(0,-1)]\nstartPointer = 0\nemptyList = 5\nJava\npublic static void main(String[] args){\nnode[] linkedList = new node[10];\nlinkedList[0] = new node(1,1);\nlinkedList[1] = new node(5, 4);\nlinkedList[2] = new node(6, 7);\nlinkedList[3] = new node(7,-1);\nlinkedList[4] = new node(2,2);\nlinkedList[5] = new node(0,6);\nlinkedList[6] = new node(0,8);\nlinkedList[7] = new node(56, 3);\nlinkedList[8] = new node(0,9);\nlinkedList[9] = new node(0,-1);\nInteger startPointer = 0;\nInteger emptyList = 5;\n}\n© UCLES 2021 Page 6 of 30\n\n1(c)(i) 1 mark per bullet point 6\n• Procedure outputNodes …\n• …taking linked list and start pointer as parameters\n• Looping until nextNode/pointer is –1\n• Outputting the node data in the correct order, i.e. following pointers\n• Updating pointer to current node’s nextNode\n• Using the correct record/class field/properties throughout\nExample code:\nVisual Basic\nSub outputNodes(ByRef linkedList, ByVal currentPointer)\nWhile (currentPointer <> -1)\nConsole.WriteLine(linkedList(currentPointer).data)\ncurrentPointer = linkedList(currentPointer).nextNode\nEnd While\nEnd Sub\nPython\ndef outputNodes(linkedList, currentPointer):\nwhile(currentPointer != -1):\nprint(str(linkedList[currentPointer].data))\ncurrentPointer = linkedList[currentPointer].nextNode\nJava\npublic static void outputNodes(node[] linkedList, Integer currentPointer){\nwhile(currentPointer != -1){\nSystem.out.println(linkedList[currentPointer].data);\ncurrentPointer = linkedList[currentPointer].nextNode;\n}\n}\n© UCLES 2021 Page 7 of 30\n\n1(c)(ii) Screenshot showing: 1\n\n1\n5",
      "source_pages": [
        4,
        5,
        6,
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_43-p04.png",
        "../answer-assets/9618_s21_ms_43-p05.png",
        "../answer-assets/9618_s21_ms_43-p06.png",
        "../answer-assets/9618_s21_ms_43-p07.png",
        "../answer-assets/9618_s21_ms_43-p08.png"
      ]
    },
    {
      "id": "9618-2021-mj-43-q02",
      "question_id": "9618-2021-mj-43-q02",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 20,
      "status": "available",
      "reason": null,
      "text": "2\n6\n56\n7\n1(d)(i) 1 mark per bullet point to max 7 7\n• Function taking list and both pointers as parameters\n• Taking (integer) data as input\n• Checking if list is full …\n• … and returning False\n• Insert the input data to the empty list node’s data\n• Following pointers to find last node in Linked List …\n• …and updating last node’s pointer to empty list/location where new node is added\n• Updating empty list to it’s first elements pointer\n• Returning true when added successfully\nExample code:\nVisual Basic\nFunction addNode(ByRef linkedList() As node, ByVal currentPointer As Integer, ByRef\nemptyList As Integer)\nConsole.WriteLine(\"Enter the data to add\")\nDim dataToAdd As Integer = Console.ReadLine()\nDim previousPointer As Integer = 0\nDim newNode As node\nIf emptyList < 0 Or emptyList > 9 Then\nReturn False\nElse\nnewNode.data = dataToAdd\nnewNode.nextNode = -1\n© UCLES 2021 Page 8 of 30\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(i) linkedList(emptyList) = newNode\npreviousPointer = 0\nWhile (currentPointer <> -1)\npreviousPointer = currentPointer\ncurrentPointer = linkedList(currentPointer).nextNode\nEnd While\nDim valueToWrite As Integer = emptyList\nlinkedList(previousPointer).nextNode = valueToWrite\nemptyList = linkedList(emptyList).nextNode\nReturn True\nEnd If\nEnd Function\nPython\ndef addNode(linkedList, currentPointer, emptyList):\ndataToAdd = input(\"Enter the data to add\")\nif emptyList <0 or emptyList > 9:\nreturn False\nelse:\nnewNode = node(int(dataToAdd), -1)\nlinkedList[emptyList] = (newNode)\npreviousPointer = 0\nwhile(currentPointer != -1):\npreviousPointer = currentPointer\ncurrentPointer = linkedList[currentPointer].nextNode\nlinkedList[previousPointer].nextNode = emptyList\nemptyList = linkedList[emptyList].nextNode\nreturn True\n© UCLES 2021 Page 9 of 30\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(i) Java\npublic static Boolean addNode(node[] linkedList, Integer currentPointer,\nInteger emptyList){\nInteger dataToAdd;\nInteger previousPointer;\nnode newNode;\nScanner in = new Scanner(System.in);\nSystem.out.println(\"Enter the data to add\");\ndataToAdd = in.nextInt();\nif(emptyList < 0 || emptyList > 9){\nreturn false;\n}else{\nnewNode = new node(dataToAdd, -1);\nlinkedList[emptyList] = newNode;\npreviousPointer = 0;\nwhile(currentPointer != -1){\npreviousPointer = currentPointer;\ncurrentPointer = linkedList[currentPointer].nextNode;\n}\nlinkedList[previousPointer].nextNode = emptyList;\nemptyList = linkedList[emptyList].nextNode;\nreturn true;\n}\n}\n© UCLES 2021 Page 10 of 30\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(ii) 1 mark per bullet point 3\n• Call addNode() with list, start and empty pointers and store/check return value …\n• …output appropriate message if True returned and if False returned\n• Calling outputNodes() with list and start pointer before and after addNode()\nExample code:\nVisual Basic\nSub Main()\nDim linkedList(10) As node\nlinkedList(0).data = 1\nlinkedList(0).nextNode = 1\nlinkedList(1).data = 5\nlinkedList(1).nextNode = 4\nlinkedList(2).data = 6\nlinkedList(2).nextNode = 7\nlinkedList(3).data = 7\nlinkedList(3).nextNode = -1\nlinkedList(4).data = 2\nlinkedList(4).nextNode = 2\nlinkedList(5).data = -1\nlinkedList(5).nextNode = 6\nlinkedList(6).data = -1\nlinkedList(6).nextNode = 7\nlinkedList(7).data = 56\nlinkedList(7).nextNode = 3\nlinkedList(8).data = -1\nlinkedList(8).nextNode = 9\nlinkedList(9).data = -1\nlinkedList(9).nextNode = -1\nDim startPointer As Integer = 0\nDim emptyList As Integer = 5\noutputNodes(linkedList, startPointer)\nDim returnValue As Boolean\nreturnValue = addNode(linkedList, startPointer,\nemptyList)\n© UCLES 2021 Page 11 of 30\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2021\nPUBLISHED\nQuestion Answer Marks\n1(d)(ii) If returnValue = True Then\nConsole.WriteLine(\"Item successfully added\")\nElse\nConsole.WriteLine(\"Item not added, list full\")\nEnd If\noutputNodes(linkedList, startPointer)\nConsole.ReadLine()\nEnd Sub\nPython\nlinkedList = [node(1,1),node(5,4),node(6,7),node(7,-1),node(2,2),node(-1,6),\nnode(-1,7),node(56,3),node(-1,9),node(-1,-1)]\nstartPointer = 0\nemptyList = 5\noutputNodes(linkedList, startPointer)\nreturnValue = addNode(linkedList, startPointer, emptyList)\nif returnValue == True:\nprint(\"Item successfully added\")\nelse:\nprint(\"Item not added, list full\")\noutputNodes(linkedList, startPointer)\nJava\npublic static void main(String[] args){\nnode[] linkedList = new node[10];\nlinkedList[0] = new node(1,1);\nlinkedList[1] = new node(5, 4);\nlinkedList[2] = new node(6, 7);\nlinkedList[3] = new node(7,-1);\nlinkedList[4] = new node(2,2);\nlinkedList[5] = new node(-1,6);\nlinkedList[6] = new node(-1,7);\nlinkedList[7] = new node(56, 3);\nlinkedList[8] = new node(-1,9);\n© UCLES 2021 Page 12 of 30\n\n2\n6\n56\n7\n5 (being input)\n1\n5\n\n2\n6\n56\n7\n5\n© UCLES 2021 Page 13 of 30\n\n2(a) 1 mark per bullet point 2\n• Array with identifier arrayData\n• correct 10 data items added\nExample code:\nVisual Basic\nDim arrayData(9) As Integer\nSub Main()\narrayData(0) = 10\narrayData(1) = 5\narrayData(2) = 6\narrayData(3) = 7\narrayData(4) = 1\narrayData(5) = 12\narrayData(6) = 13\narrayData(7) = 15\narrayData(8) = 21\narrayData(9) = 8\nEnd Sub\nPython\narrayData = [10, 5, 6, 7, 1, 12, 13, 15, 21, 8]\nJava\nint[] arrayData = new int[];\npublic static void main(String[] args){\narrayData[0] = 10;\narrayData[1] = 5;\narrayData[2] = 6;\narrayData[3] = 7;\narrayData[4] = 1;\narrayData[5] = 12;\narrayData[6] = 13;\n© UCLES 2021 Page 14 of 30\n\n2(a) arrayData[7] = 15;\narrayData[8] = 21;\narrayData[9] = 8;\n}\n\n2(b)(i) 1 mark per bullet point 6\n• function linearSearch with correct identifier\n• …taking integer search value as a parameter\n• Searching 10 times/through all array elements …\n• …comparing each element to search value\n• returning True if found\n• returning False if not found\nExample code:\nVisual Basic\nFunction linearSearch(ByRef searchValue As Integer)\nFor x = 0 To 9\nIf arrayData(x) = searchValue Then\nReturn True\nEnd If\nNext\nReturn False\nEnd Function\n© UCLES 2021 Page 15 of 30\n\n2(b)(i) Python\ndef linearSearch(searchValue):\nfor x in range(0, 10):\nif arrayData[x] == searchValue:\nreturn True\nreturn False\nJava\npublic static Boolean linearSearch(Integer searchValue){\nfor (int x = 0; x < 10; x++){\nif(arrayData[x] == searchValue){\nreturn true;\n}\n}\nreturn false;\n}\n© UCLES 2021 Page 16 of 30\n\n2(b)(ii) 1 mark per bullet point to max 4 4\n• Taking value as input…\n• …checking/casting to Integer\n• Calling linearSearch and sending input as parameter\n• Storing and checking return value…\n• …outputting appropriate message if found and if not found\nExample code:\nVisual Basic\nDim arrayData(10) As Integer\nSub Main()\narrayData(0) = 10\narrayData(1) = 5\narrayData(2) = 6\narrayData(3) = 7\narrayData(4) = 1\narrayData(5) = 12\narrayData(6) = 13\narrayData(7) = 15\narrayData(8) = 12\narrayData(9) = 8\nConsole.WriteLine(\"Enter a number to search for\")\nDim searchValue As Integer = Console.ReadLine()\nDim returnValue As Boolean = linearSearch(searchValue)\nIf returnValue = True Then\nConsole.WriteLine(\"Found it\")\nElse\nConsole.WriteLine(\"Didn't find it\")\nEnd If\nEnd Sub\n© UCLES 2021 Page 17 of 30\n\n2(b)(ii) Python\narrayData = [10, 5, 6, 7, 1, 12, 13, 15, 21, 8]\nsearchValue = int(input(\"Enter the number to search for\"))\nreturnValue = linearSearch(searchValue)\nif returnValue == True:\nprint(\"It was found\")\nelse:\nprint(\"It was not found\")\nJava\nInteger[] arrayData = new Integer[10];\npublic static void main(String[] args){\narrayData[0] = 10;\narrayData[1] = 5;\narrayData[2] = 6;\narrayData[3] = 7;\narrayData[4] = 1;\narrayData[5] = 12;\narrayData[6] = 13;\narrayData[7] = 15;\narrayData[8] = 12;\narrayData[9] = 8;\nSystem.out.println(\"Enter the number to search for\");\nInteger searchValue;\nScanner in = new Scanner(System.in);\nsearchValue = in.nextInt();\nBoolean returnValue;\nreturnValue = linearSearch(searchValue);\nif (returnValue == true){\nSystem.out.println(\"It was found\");\n}else{\nSystem.out.println(\"It was not found\");\n}\n}\n© UCLES 2021 Page 18 of 30\n\n2(b)(iii) 1 mark for screenshot showing input and output for number found 2\n1 mark for screenshot showing input and output for number not found\n\n2(c) 1 mark per bullet point 6\n• Correct outer loop stop\n• Correct inner loop stop\n• Correct < in the IF\n• Correct theArray(y + 1)\n• Correct temp\n• Remainder matching pseudocode\nExample code:\nVisual Basic\nSub bubbleSort()\nDim temp As Integer = 0\nFor x = 0 To 9\nFor y = 0 To 8\nIf theArray(y) < theArray(y + 1) Then\ntemp = theArray(y)\ntheArray(y) = theArray(y + 1)\ntheArray(y + 1) = temp\nEnd If\nNext\nNext\nEnd Sub\n© UCLES 2021 Page 19 of 30\n\n2(c) Python\ndef bubbleSort():\nfor x in range (0, 10):\nfor y in range(0, 9):\nif theArray[y] < theArray[y + 1]:\ntemp = theArray[y]\ntheArray[y] = theArray[y + 1]\ntheArray[y + 1] = temp\nJava\npublic static void bubbleSort(){\nint temp;\nfor (int x = 0; x < 10; x++){\nfor (int y = 0; y < 9; y++){\nif(theArray[y] < theArray[y+1]){\ntemp = theArray[y];\ntheArray[y] = theArray[y+1];\ntheArray[y+1] = temp;\n}\n}\n}\n}\n© UCLES 2021 Page 20 of 30",
      "source_pages": [
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_43-p08.png",
        "../answer-assets/9618_s21_ms_43-p09.png",
        "../answer-assets/9618_s21_ms_43-p10.png",
        "../answer-assets/9618_s21_ms_43-p11.png",
        "../answer-assets/9618_s21_ms_43-p12.png",
        "../answer-assets/9618_s21_ms_43-p13.png",
        "../answer-assets/9618_s21_ms_43-p14.png",
        "../answer-assets/9618_s21_ms_43-p15.png",
        "../answer-assets/9618_s21_ms_43-p16.png",
        "../answer-assets/9618_s21_ms_43-p17.png",
        "../answer-assets/9618_s21_ms_43-p18.png",
        "../answer-assets/9618_s21_ms_43-p19.png",
        "../answer-assets/9618_s21_ms_43-p20.png"
      ]
    },
    {
      "id": "9618-2021-mj-43-q03",
      "question_id": "9618-2021-mj-43-q03",
      "subject": "9618",
      "year": 2021,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 31,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per bullet point 5\n• Class named treasureChest and end\n• Question declared as string as a class attribute\n• Answer declared as integer as a class attribute\n• Points declared as integer as a class attribute\n• All 3 attributes are private\nExample code:\nVisual Basic\nClass treasureChest\nPrivate question As String\nPrivate answer As Integer\nPrivate points As Integer\nSub New(questionP, answerP, pointsP)\nquestion = questionP\nanswer = answerP\npoints = pointsP\nEnd Sub\nEnd Class\nPython\nclass treasureChest:\n#Private question : String\n#Private answer : Integer\n#Private points : Integer\ndef __init__(self, questionP, answerP, pointsP):\nself.__question = questionP\nself.__answer = answerP\nself.__points = points\n© UCLES 2021 Page 21 of 30\n\n3(a) Java\nimport java.util.Scanner;\nclass treasureChest{\nprivate String question;\nprivate Integer answer;\nprivate Integer points;\npublic treasureChest(String questionP, Integer answerP, Integer pointsP){\nquestion = questionP;\nanswer = answerP;\npoints = pointsP;\n}\n}\n\n3(b) 1 mark per bullet point to max 8 8\n• procedure declared as readData\n• declare array arrayTreasure with 4 elements type treasureChest\n• opening correct file for read\n• looping until EOF/5 questions …\n• …reading in and storing each group of 3 lines appropriately\n• creating object of type treasureChest …\n• …with question, answer and points from file as parameters\n• ..adding to next array element/appending\n• … repeatedly for all 5 questions in correct order\n• Use of appropriate exception handler…\n• …appropriate output if file not found\n• Closing correct file\n© UCLES 2021 Page 22 of 30\n\n3(b) Example code:\nVisual Basic\nSub readData()\nDim arrayTreasure(4) as treasureChest\nDim filename As String = \"treasureChestData.txt\"\nTry\nDim fileReader As New System.IO.StreamReader(filename)\nDim question As String\nDim answer, points As Integer\nDim numberQuestions as Integer = 0\nWhile fileReader.Peek <> -1\nquestion = fileReader.ReadLine()\nanswer = fileReader.ReadLine()\npoints = fileReader.ReadLine()\narrayTreasure(numberQuestions) = New treasureChest(question, answer, points)\nnumberQuestions += 1\nEnd While\nfileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\nPython\n# arrayTreasure(5) as treasureChest\ndef readData():\nfilename = \"treasureChestData.txt\"\ntry:\nfile= open(filename,\"r\")\ndataFetched = (file.readline()).strip()\nwhile(dataFetched != \"\" ):\nquestion = dataFetched\nanswer = (file.readline()).strip()\n© UCLES 2021 Page 23 of 30\n\n3(b) points = (file.readline()).strip()\narrayTreasure.append(treasureChest(question, answer, points))\ndataFetched = (file.readline()).strip()\nfile.close()\nexcept IOError:\nprint(\"Could not find file\")\nJava\npublic static void readData(){\ntreasureChest[] arrayTreasure = new treasureChest[5]:\nString filename = \"treasureChestData.txt\";\nString dataRead;\nString question;\nString answer;\nString points;\nInteger numberQuestions = 0;\ntry{\nFileReader f = new FileReader(filename);\nBufferedReader reader = new BufferedReader(f);\ndataRead = reader.readLine();\nwhile (dataRead != null){\nquestion = dataRead;\nanswer = reader.readLine();\npoints = reader.readLine();\narrayTreasure[numberQuestions] = new treasureChest(question,\nInteger.parseInt(answer), Integer.parseInt(points));\nnumberQuestions++;\ndataRead = reader.readLine();\n}\nreader.close();\n}\n© UCLES 2021 Page 24 of 30\n\n3(b) catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No file found\");\n}\n}\n\n3(c)(i) 1 mark for getQuestion returning the value of question 1\nExample code:\nVisual Basic\nFunction getQuestion()\nReturn question\nEnd Function\nPython\ndef getQuestion(self):\nreturn self.__question\nJava\npublic String getQuestion(){\nreturn question;\n}\n© UCLES 2021 Page 25 of 30\n\n3(c)(ii) 1 mark per bullet point 3\n• Function checkAnswer taking in the parameter, returning Boolean\n• Comparing parameter to that object’s answer…\n• …returning True if correct and False otherwise\nExample code:\nVisual Basic\nFunction checkAnswer(answerP)\nIf answer = answerP Then\nReturn True\nElse\nReturn False\nEnd If\nEnd Function\nPython\ndef checkAnswer(self, answerP):\nif int(self.__answer) == answerP:\nreturn True\nelse:\nreturn False\nJava\npublic Boolean checkAnswer(Integer answerP){\nif (answer == answerP){\nreturn true;\n}else{\nreturn false;\n}\n}\n© UCLES 2021 Page 26 of 30\n\n3(c)(iii) 1 mark per bullet point 5\n• Function getPoints taking attempts as parameter and returning integer\n• If attempts is 1 returning points\n• If attempts is 2 returns points DIV 2\n• If attempts is 3 or 4 returns points DIV 4\n• otherwise returns 0\nExample code:\nVisual Basic\nFunction getPoints(attempts)\nIf attempts = 1 Then\nReturn points\nElseIf attempts = 2 Then\nReturn points \\ 2\nElseIf attempts = 3 Or attempts = 4 Then\nReturn points \\ 4\nElse\nReturn 0\nEnd If\nEnd Function\nPython\ndef getPoints(self, attempts):\nif attempts == 1:\nreturn int(self.__points)\nelif attempts == 2:\nreturn int(self.__points) // 2\nelif attempts == 3 or attempts == 4:\nreturn int(self.__points) // 4\nelse:\nreturn 0\n© UCLES 2021 Page 27 of 30\n\n3(c)(iii) Java\npublic Integer getPoints(Integer attempts){\nif (attempts == 1){\nreturn points;\n}else if(attempts == 2){\nreturn Math.round(points/2);\n}else if(attempts == 3 || attempts == 4){\nreturn Math.round(points/4);\n}else{\nreturn 0;\n}\n}\n\n3(c)(iv) 1 mark per bullet point to max 7 7\n• Call the procedure readData()\n• Take the question number as input from user\n• ..validated between 1 and 5\n• Output the question stored at user’s input value\n• Read answer from user\n• Check the answer input against question’s answer\n• …looping until the answer is correct\n• Keeping track of the number of attempts using a variable\n• Using getPoints() and sending the number of attempts as a parameter …\n• …outputting the number of points returned\n• Using .getQuestion and .checkAnswer to access question number input by user and answer input by used\n© UCLES 2021 Page 28 of 30\n\n3(c)(iv) Example code:\nVisual Basic\nSub Main()\nreadData()\nConsole.WriteLine(\"Pick a treasure chest to open\")\nDim choice As Integer = Console.ReadLine()\nDim result As Boolean\nDim answer As Integer\nDim attempts As Integer = 0\nIf choice > 0 And choice < 6 Then\nresult = False\nattempts = 0\nWhile result = False\nConsole.WriteLine(arrayTreasure(choice - 1).getQuestion())\nanswer = Console.ReadLine\nresult = arrayTreasure(choice - 1).checkAnswer(answer)\nattempts = attempts + 1\nEnd While\nConsole.WriteLine(arrayTreasure(choice - 1).getPoints(attempts))\nEnd If\nEnd Sub\nPython\nreadData()\nchoice = int(input(\"Pick a treasure chest to open\"))\nif choice > 0 and choice < 6:\nresult = False\nattempts = 0\nwhile result == False:\nanswer = int(input(arrayTreasure[choice-1].getQuestion()))\nresult = arrayTreasure[choice-1].checkAnswer(answer)\nattempts = attempts + 1\nprint(int(arrayTreasure[choice-1].getPoints(attempts)))\n© UCLES 2021 Page 29 of 30\n\n3(c)(iv) Java\npublic static void main(String[] args){\nreadData();\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Pick a treasure chest to open\");\nInteger answer;\nInteger choice;\nchoice= Integer.parseInt(scanner.nextLine());\nInteger attempts;\nif (choice> 0 && choice < 6){\nBoolean result = false;\nattempts = 0;\nwhile (result == false){\nSystem.out.println(arrayTreasure[choice-1].getQuestion());\nanswer = Integer.parseInt(scanner.nextLine());\nresult = arrayTreasure[choice-1].checkAnswer(answer);\nattempts++;\n}\nSystem.out.println(arrayTreasure[choice-1].getPoints(attempts));\n}\n}\n\n3(c)(v) 1 mark per screenshot 2\n• Screenshot:\noutputting 2*2\nentering 4\noutputting 10\n• Screenshot:\noutputting 3000+4000\nentering an incorrect value\nentering 7000\noutputting 9\n© UCLES 2021 Page 30 of 30",
      "source_pages": [
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30
      ],
      "source_pdf": "_source-pdfs/2021-may-june/ms/9618_s21_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-May-June/9618_s21_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s21_ms_43-p21.png",
        "../answer-assets/9618_s21_ms_43-p22.png",
        "../answer-assets/9618_s21_ms_43-p23.png",
        "../answer-assets/9618_s21_ms_43-p24.png",
        "../answer-assets/9618_s21_ms_43-p25.png",
        "../answer-assets/9618_s21_ms_43-p26.png",
        "../answer-assets/9618_s21_ms_43-p27.png",
        "../answer-assets/9618_s21_ms_43-p28.png",
        "../answer-assets/9618_s21_ms_43-p29.png",
        "../answer-assets/9618_s21_ms_43-p30.png"
      ]
    },
    {
      "id": "9618-2021-on-31-q01",
      "question_id": "9618-2021-on-31-q01",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) One mark for each correct marking point (Max 2) 2\n• 010111000110 (correct mantissa)\n• 0111 (correct exponent)\n\n1(a)(ii) One mark for each correct consequence 2\nOne mark for each correct justification\nConsequence\n• The precision/accuracy of the number would be reduced\nJustification\n• … because the least significant bits of the original number have been\ntruncated/lost // the original number had 13 bits / 14 bits with sign but the\nmantissa can only store 12 bits\n\n1(b) One mark for each correct marking point (Max 3) 3\n• To store the maximum range of numbers in the minimum number of bytes\n/ bits\n• Normalisation minimises the number of leading zeros/ones represented\n• Maximising the number of significant bits // maximising the (potential)\nprecision / accuracy of the number for the given number of bits\n• … enables very large / small numbers to be stored with accuracy.\n• Avoids the possibility of many numbers having multiple representations.\n© UCLES 2021 Page 3 of 10",
      "source_pages": [
        3
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_31.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_31-p03.png"
      ]
    },
    {
      "id": "9618-2021-on-31-q02",
      "question_id": "9618-2021-on-31-q02",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 2,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "2 One mark for each single correct line from Programming Paradigm to 4\nDescription\nProgramming Paradigm Description\nPrograms using the instruction set of a\nprocessor\nDeclarative\nPrograms based on events such as\nuser actions or sensor outputs\nImperative\nPrograms using the concepts of class,\ninheritance, encapsulation and\nLow-level polymorphism\nPrograms with an explicit sequence of\ncommands that update the program\nObject oriented state, with or without procedure calls\nPrograms that specify the desired\nresult rather than how to get to it\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2021-on-31-q03",
      "question_id": "9618-2021-on-31-q03",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 3,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark for each marking point (Max 2) 2\n• TYPE Parts =\n• (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard,\nMouse)\nComplete answer\nTYPE Parts = (Monitor, CPU, SSD, HDD, LaserPrinter,\nKeyboard, Mouse)\n\n3(b) One mark for each marking point (Max 2) 2\n• TYPE SelectParts = ^\n• correct data type chosen Parts\nComplete answer\nTYPE SelectParts = ^Parts\n© UCLES 2021 Page 4 of 10",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2021-on-31-q04",
      "question_id": "9618-2021-on-31-q04",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 4,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark for each marking point (Max 2) 2\n• <character>::=\n• $|%|&|*|#\nComplete answer\n<character>::= $|%|&|*|#\n\n4(b)(i) For example: $A9E3 1\n\n4(b)(ii) One mark for each marking point (Max 4) 4\n• <password>::=<character> …\n• … <code>\n• <code>::= …\n• … <digit>|<capital_letter>\n• … |<digit><code>|<capital_letter><code>\nComplete answer\n<password>::=<character><code>\n<code>::=<digit>|<capital_letter>|<digit><code>|<capital_\nletter><code>\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_31-p05.png"
      ]
    },
    {
      "id": "9618-2021-on-31-q05",
      "question_id": "9618-2021-on-31-q05",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 5,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark for each correct marking point (Max 4) 4\n• In both serial and sequential files records are stored one after the other …\n• … and need to be accessed one after the other\n• Serial files are stored in chronological order\n• Sequential files are stored with ordered records\n• … and stored in the order of the key field\n• In serial files, new records are added in the next available space / records\nare appended to the file\n• In sequential files, new records are inserted in the correct position.\n\n5(b) Direct (access) 1\n\n5(c) Sequential (access) 1\n© UCLES 2021 Page 5 of 10",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_31-p05.png"
      ]
    },
    {
      "id": "9618-2021-on-31-q06",
      "question_id": "9618-2021-on-31-q06",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 6,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for each correct marking point (Max 5) 5\n• A large message is divided up into a group of smaller chunks of the same\nsize called packets\n• The packet has a header and a payload\n• The header contains a source IP address, destination IP address (and\nsequence number)\n• Each packet is dispatched independently\n• … and may travel along different routes / paths\n• The packets may arrive out of order\n• … and are reassembled into the original message at the destination\n• If packets are missing / corrupted a re-transmission request is sent.\n\n6(b) One mark for each correct marking point (Max 3) 3\n• The router examines the packet’s header\n• It reads the IP address of the destination (from the packet header)\n• A router has access to a routing table\n• …containing information about, e.g., available hops / netmask / gateway\nused\n• … and the status of the routes along the route\n• … the router decides on the next hop / best route\n• … and sends the packet on its next hop.\n© UCLES 2021 Page 6 of 10",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2021-on-31-q07",
      "question_id": "9618-2021-on-31-q07",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark per two correct products (Max 3) 3\n_ _ _ _ _ _\n(Z =) A B C D + A B C D + A B C D + A B C D +\n_\nA B C D + A B C D\n\n7(b)(i) One mark for every two correct rows or columns (Max 2) 2\nAB\n00 01 11 10\n00 0 0 1 0\n01 0 0 1 1\nCD\n11 0 0 1 1\n10 0 0 1 0\n\n7(b)(ii) One mark for correct loop (Max 2) 2\nAB\n00 01 11 10\n0 1\n00 0 0\n01 0 0 1 1\nCD\n11 0 0 1 1\n01 0 0 1 0\n\n7(b)(iii) One mark per correct marking point (Max 2) 2\n• A B // A D\n• + A D // + A B\n(Z =) A B + A D // A D + A B\n\n7(b)(iv) (Z =) A (B + D) // A (D + B) 1\n© UCLES 2021 Page 7 of 10",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2021-on-31-q08",
      "question_id": "9618-2021-on-31-q08",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 8,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correct marking point (Max 2) 2\n• The SSL and TLS protocols provide communications security over the\ninternet / network\n• … they provide encryption\n• They enable two parties to identify and authenticate each other\n• … and communicate with confidentiality and integrity.\n\n8(b) One mark for each correct marking point (Max 4) 4\n• An SSL/TLS connection is initiated by an application\n• … which becomes the client\n• The application which receives the connection becomes the server\n• Every new session begins with a handshake (as defined by the\n(SSL/TLS) protocols)\n• The client requests the digital certificate from the server // the server\nsends the digital certificate to the client\n• The client verifies the server’s digital certificate\n• …and obtains the server’s public key\n• The encryption algorithms are agreed\n• The symmetric\n• … session keys are generated / defined\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_31.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_31-p08.png"
      ]
    },
    {
      "id": "9618-2021-on-31-q09",
      "question_id": "9618-2021-on-31-q09",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 9,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "9(a)(i) One mark for correct statement (Max 1) 1\n• Enables deep learning to take place\n• Where the problem you are trying to solve has a higher level of\ncomplexity it requires more layers to solve\n• To enable the neural network to learn and make decisions on its own\n• To improve the accuracy of the result.\n\n9(a)(ii) One mark for each correct marking point (Max 4) 4\n• Artificial neural networks are intended to replicate the way human brains\nwork\n• Weights / values are assigned for each connection between nodes\n• The data are input at the input layer and are passed into the system\n• They are analysed at each subsequent (hidden) layer where\ncharacteristics are extracted / outputs are calculated\n• … this process of training / learning is repeated many times to achieve\noptimum outputs // reinforcement learning takes place\n• Decisions can be made without being specifically programmed\n• The deep learning net will have created complex feature detectors\n• The output layer provides the results\n• Back propagation (of errors) will be used to correct any errors that have\nbeen made.\n© UCLES 2021 Page 8 of 10\n\n9(b) One mark for each correct calculation as follows (Max 4) 5\n• Node B (from Home) (Line 3 in table)\n• Node C (from Home) (Line 4 in table)\n• Node B and Node E (from A) (Lines 5 and 6 in table)\n• Node F and Node School (from E) (Lines 7 and 8 in table)\n• Node School (from F) (Line 9 in table)\nOne mark for correct path (Max 1):\n• Home  A  E  F  School\nNode Cost from Home Heuristic Total\nNode (g) (h) (f = g + h)\n1 Home 0 14 14\n2 A 1 10 11\n3 B 5 7 12\n4 C 4 9 13\n5 B 1 + 3 = 4 7 11\n6 E 1 + 6 = 7 3 10\n7 F 7 + 1 = 8 3 11\n8 School 7 + 5 = 12 0 12\n\n9 School 8 + 3 = 11 0 11\nFinal Path Home  A  E  F  School\n© UCLES 2021 Page 9 of 10",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_31.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_31-p08.png",
        "../answer-assets/9618_w21_ms_31-p09.png"
      ]
    },
    {
      "id": "9618-2021-on-31-q10",
      "question_id": "9618-2021-on-31-q10",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 10,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 13,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark for each correct marking point (Max 3) 3\n• Must have a base case/stopping condition\n• Must have a general case\n• … which calls itself (recursively) // Defined in terms of itself\n• … which changes its state and moves towards the base case\nUnwinding can occur once the base case is reached.\n\n10(b) One mark for each correct marking point (Max 3) 3\n• A stack is a LIFO data structure\n• Each recursive call is pushed onto the stack\n• …. and is then popped as the function ends\n• Enables backtracking/unwinding\n… to maintain the required order.\n\n10(c) One mark for each marking point (Max 2) 2\n• Linked List\n• Queue\nBinary Tree\n\n10(d) One mark for each marking point (Max 5) 5\n• Checking if stack is full / empty using IF … THEN … (ELSE) … ENDIF\n• … correctly using StackFull() function\n• RETURN suitable message if stack is full\n• RETURN message if space available on stack\n• Incrementing TopOfStack pointer if space available\n• Assigning new data using correct NewInteger variable\n• … to correct the array element in ArrayStack[] array.\nExample algorithm\nFUNCTION AddInteger(NewInteger : INTEGER) RETURNS STRING\nIF StackFull() THEN\nRETURN \"The stack is full\"\nELSE\nTopOfStack ← TopOfStack + 1\nArrayStack[TopOfStack] ← NewInteger\nRETURN \"Item added\"\nENDIF\nENDFUNCTION\n© UCLES 2021 Page 10 of 10",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2021-on-32-q01",
      "question_id": "9618-2021-on-32-q01",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) One mark for each correct marking point (Max 2) 2\n• 010111000110 (correct mantissa)\n• 0111 (correct exponent)\n\n1(a)(ii) One mark for each correct consequence 2\nOne mark for each correct justification\nConsequence\n• The precision/accuracy of the number would be reduced\nJustification\n• … because the least significant bits of the original number have been\ntruncated/lost // the original number had 13 bits / 14 bits with sign but the\nmantissa can only store 12 bits\n\n1(b) One mark for each correct marking point (Max 3) 3\n• To store the maximum range of numbers in the minimum number of bytes\n/ bits\n• Normalisation minimises the number of leading zeros/ones represented\n• Maximising the number of significant bits // maximising the (potential)\nprecision / accuracy of the number for the given number of bits\n• … enables very large / small numbers to be stored with accuracy.\n• Avoids the possibility of many numbers having multiple representations.\n© UCLES 2021 Page 3 of 10",
      "source_pages": [
        3
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_32.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_32-p03.png"
      ]
    },
    {
      "id": "9618-2021-on-32-q02",
      "question_id": "9618-2021-on-32-q02",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 2,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "2 One mark for each single correct line from Programming Paradigm to 4\nDescription\nProgramming Paradigm Description\nPrograms using the instruction set of a\nprocessor\nDeclarative\nPrograms based on events such as\nuser actions or sensor outputs\nImperative\nPrograms using the concepts of class,\ninheritance, encapsulation and\nLow-level polymorphism\nPrograms with an explicit sequence of\ncommands that update the program\nObject oriented state, with or without procedure calls\nPrograms that specify the desired\nresult rather than how to get to it\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2021-on-32-q03",
      "question_id": "9618-2021-on-32-q03",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 3,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark for each marking point (Max 2) 2\n• TYPE Parts =\n• (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard,\nMouse)\nComplete answer\nTYPE Parts = (Monitor, CPU, SSD, HDD, LaserPrinter,\nKeyboard, Mouse)\n\n3(b) One mark for each marking point (Max 2) 2\n• TYPE SelectParts = ^\n• correct data type chosen Parts\nComplete answer\nTYPE SelectParts = ^Parts\n© UCLES 2021 Page 4 of 10",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2021-on-32-q04",
      "question_id": "9618-2021-on-32-q04",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 4,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark for each marking point (Max 2) 2\n• <character>::=\n• $|%|&|*|#\nComplete answer\n<character>::= $|%|&|*|#\n\n4(b)(i) For example: $A9E3 1\n\n4(b)(ii) One mark for each marking point (Max 4) 4\n• <password>::=<character> …\n• … <code>\n• <code>::= …\n• … <digit>|<capital_letter>\n• … |<digit><code>|<capital_letter><code>\nComplete answer\n<password>::=<character><code>\n<code>::=<digit>|<capital_letter>|<digit><code>|<capital_\nletter><code>\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2021-on-32-q05",
      "question_id": "9618-2021-on-32-q05",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 5,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark for each correct marking point (Max 4) 4\n• In both serial and sequential files records are stored one after the other …\n• … and need to be accessed one after the other\n• Serial files are stored in chronological order\n• Sequential files are stored with ordered records\n• … and stored in the order of the key field\n• In serial files, new records are added in the next available space / records\nare appended to the file\n• In sequential files, new records are inserted in the correct position.\n\n5(b) Direct (access) 1\n\n5(c) Sequential (access) 1\n© UCLES 2021 Page 5 of 10",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2021-on-32-q06",
      "question_id": "9618-2021-on-32-q06",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 6,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for each correct marking point (Max 5) 5\n• A large message is divided up into a group of smaller chunks of the same\nsize called packets\n• The packet has a header and a payload\n• The header contains a source IP address, destination IP address (and\nsequence number)\n• Each packet is dispatched independently\n• … and may travel along different routes / paths\n• The packets may arrive out of order\n• … and are reassembled into the original message at the destination\n• If packets are missing / corrupted a re-transmission request is sent.\n\n6(b) One mark for each correct marking point (Max 3) 3\n• The router examines the packet’s header\n• It reads the IP address of the destination (from the packet header)\n• A router has access to a routing table\n• …containing information about, e.g., available hops / netmask / gateway\nused\n• … and the status of the routes along the route\n• … the router decides on the next hop / best route\n• … and sends the packet on its next hop.\n© UCLES 2021 Page 6 of 10",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2021-on-32-q07",
      "question_id": "9618-2021-on-32-q07",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark per two correct products (Max 3) 3\n_ _ _ _ _ _\n(Z =) A B C D + A B C D + A B C D + A B C D +\n_\nA B C D + A B C D\n\n7(b)(i) One mark for every two correct rows or columns (Max 2) 2\nAB\n00 01 11 10\n00 0 0 1 0\n01 0 0 1 1\nCD\n11 0 0 1 1\n10 0 0 1 0\n\n7(b)(ii) One mark for correct loop (Max 2) 2\nAB\n00 01 11 10\n0 1\n00 0 0\n01 0 0 1 1\nCD\n11 0 0 1 1\n01 0 0 1 0\n\n7(b)(iii) One mark per correct marking point (Max 2) 2\n• A B // A D\n• + A D // + A B\n(Z =) A B + A D // A D + A B\n\n7(b)(iv) (Z =) A (B + D) // A (D + B) 1\n© UCLES 2021 Page 7 of 10",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2021-on-32-q08",
      "question_id": "9618-2021-on-32-q08",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 8,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correct marking point (Max 2) 2\n• The SSL and TLS protocols provide communications security over the\ninternet / network\n• … they provide encryption\n• They enable two parties to identify and authenticate each other\n• … and communicate with confidentiality and integrity.\n\n8(b) One mark for each correct marking point (Max 4) 4\n• An SSL/TLS connection is initiated by an application\n• … which becomes the client\n• The application which receives the connection becomes the server\n• Every new session begins with a handshake (as defined by the\n(SSL/TLS) protocols)\n• The client requests the digital certificate from the server // the server\nsends the digital certificate to the client\n• The client verifies the server’s digital certificate\n• …and obtains the server’s public key\n• The encryption algorithms are agreed\n• The symmetric\n• … session keys are generated / defined\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_32.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_32-p08.png"
      ]
    },
    {
      "id": "9618-2021-on-32-q09",
      "question_id": "9618-2021-on-32-q09",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 9,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "9(a)(i) One mark for correct statement (Max 1) 1\n• Enables deep learning to take place\n• Where the problem you are trying to solve has a higher level of\ncomplexity it requires more layers to solve\n• To enable the neural network to learn and make decisions on its own\n• To improve the accuracy of the result.\n\n9(a)(ii) One mark for each correct marking point (Max 4) 4\n• Artificial neural networks are intended to replicate the way human brains\nwork\n• Weights / values are assigned for each connection between nodes\n• The data are input at the input layer and are passed into the system\n• They are analysed at each subsequent (hidden) layer where\ncharacteristics are extracted / outputs are calculated\n• … this process of training / learning is repeated many times to achieve\noptimum outputs // reinforcement learning takes place\n• Decisions can be made without being specifically programmed\n• The deep learning net will have created complex feature detectors\n• The output layer provides the results\n• Back propagation (of errors) will be used to correct any errors that have\nbeen made.\n© UCLES 2021 Page 8 of 10\n\n9(b) One mark for each correct calculation as follows (Max 4) 5\n• Node B (from Home) (Line 3 in table)\n• Node C (from Home) (Line 4 in table)\n• Node B and Node E (from A) (Lines 5 and 6 in table)\n• Node F and Node School (from E) (Lines 7 and 8 in table)\n• Node School (from F) (Line 9 in table)\nOne mark for correct path (Max 1):\n• Home  A  E  F  School\nNode Cost from Home Heuristic Total\nNode (g) (h) (f = g + h)\n1 Home 0 14 14\n2 A 1 10 11\n3 B 5 7 12\n4 C 4 9 13\n5 B 1 + 3 = 4 7 11\n6 E 1 + 6 = 7 3 10\n7 F 7 + 1 = 8 3 11\n8 School 7 + 5 = 12 0 12\n\n9 School 8 + 3 = 11 0 11\nFinal Path Home  A  E  F  School\n© UCLES 2021 Page 9 of 10",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_32.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_32-p08.png",
        "../answer-assets/9618_w21_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2021-on-32-q10",
      "question_id": "9618-2021-on-32-q10",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 10,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 13,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark for each correct marking point (Max 3) 3\n• Must have a base case/stopping condition\n• Must have a general case\n• … which calls itself (recursively) // Defined in terms of itself\n• … which changes its state and moves towards the base case\nUnwinding can occur once the base case is reached.\n\n10(b) One mark for each correct marking point (Max 3) 3\n• A stack is a LIFO data structure\n• Each recursive call is pushed onto the stack\n• …. and is then popped as the function ends\n• Enables backtracking/unwinding\n… to maintain the required order.\n\n10(c) One mark for each marking point (Max 2) 2\n• Linked List\n• Queue\nBinary Tree\n\n10(d) One mark for each marking point (Max 5) 5\n• Checking if stack is full / empty using IF … THEN … (ELSE) … ENDIF\n• … correctly using StackFull() function\n• RETURN suitable message if stack is full\n• RETURN message if space available on stack\n• Incrementing TopOfStack pointer if space available\n• Assigning new data using correct NewInteger variable\n• … to correct the array element in ArrayStack[] array.\nExample algorithm\nFUNCTION AddInteger(NewInteger : INTEGER) RETURNS STRING\nIF StackFull() THEN\nRETURN \"The stack is full\"\nELSE\nTopOfStack ← TopOfStack + 1\nArrayStack[TopOfStack] ← NewInteger\nRETURN \"Item added\"\nENDIF\nENDFUNCTION\n© UCLES 2021 Page 10 of 10",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_32-p10.png"
      ]
    },
    {
      "id": "9618-2021-on-41-q01",
      "question_id": "9618-2021-on-41-q01",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 17,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per bullet point 3\n• function with correct name and parameters\n• correct Div operator (or equivalent) used\n• code matches pseudocode\nExample program code:\nPython\ndef Unknown(X, Y):\nif X < Y:\nprint(str(X + Y))\nreturn Unknown(X + 1, Y) * 2\nelif X == Y:\nreturn 1\nelse:\nprint(str(X + Y))\nreturn int(Unknown(X - 1, Y) / 2)\nVB.NET\nFunction Unknown(X, Y)\nIf X < Y Then\nConsole.WriteLine(X + Y)\nReturn Unknown(X + 1, Y) * 2\nElseIf X = Y Then\nReturn 1\nElse\nConsole.WriteLine(X + Y)\nReturn Unknown(X - 1, Y) \\ 2\nEnd If\nEnd Function\nJava\npublic static Integer Unknown(Integer X, Integer Y){\nif(X < Y){\nSystem.out.println(X+Y);\nreturn Unknown(X + 1, Y) * 2;\n}else if(X == Y){\nreturn 1;\n}else{\nSystem.out.println(X + Y);\nInteger ReturnValue = Unknown(X-1,Y) / 2;\nreturn ReturnValue;\n}\n}\n© UCLES 2021 Page 3 of 23\n\n1(b)(i) 1 mark per bullet point 3\n• Suitable output identifying parameters for each call\n• All three correct function calls …\n• …outputting the return value for each call\nExample program code:\nPython\nprint(\"10 and 15\")\nprint(str(Unknown(10, 15)))\nprint(\"10 and 10\")\nprint(str(Unknown(10, 10)))\nprint(\"15 and 10\")\nprint(str(Unknown(15, 10)))\nVB.NET\nConsole.WriteLine(\"10 and 15\")\nConsole.WriteLine(Unknown(10, 15))\nConsole.WriteLine(\"10, 10\")\nConsole.WriteLine(Unknown(10, 10))\nConsole.WriteLine(\"15, 10\")\nConsole.WriteLine(Unknown(15, 10))\nJava\npublic static void main(String[] args){\nSystem.out.println(\"10 and 15\");\nSystem.out.println(Unknown(10,15));\nSystem.out.println(\"10 and 10\");\nSystem.out.println(Unknown(10, 10));\nSystem.out.println(\"15 and 10\");\nSystem.out.println(Unknown(15, 10));\n}\n© UCLES 2021 Page 4 of 23\n\n1(b)(ii) 1 mark for 1 function with correct output 2\n\n1 mark for remaining 2 function calls with correct output\nFor example:\n10 and 15\n25\n26\n27\n28\n29\n32\n10 and 10\n\n1\n15 and 10\n25\n24\n23\n22\n21\n0\n© UCLES 2021 Page 5 of 23\n\n1(c) 1 mark per bullet point 7\n• Iterative function, taking 2 parameters\n• Starting with return value (Total) as 1\n• Looping while X <> Y // might be 1 loop or two separate // returning when X =\nY // looping until X==Y\n• Within each loop, outputting (X+Y) correctly when X<Y and Y<X\n• Each time X < Y, Total * 2 and X++\n• Each time Y < X Total DIV 2 and X--\n• Returning the Total after correct calculations\nExample program code:\nPython\ndef IterativeUnknown(X,Y):\nTotal = 1\nwhile X != Y:\nprint(str(X + Y))\nif X < Y:\nX = X + 1\nTotal = Total * 2\nelse:\nX = X - 1\nTotal = int(Total / 2)\nreturn Total\nVB.NET\nFunction IterativeUnknown(X, Y)\nDim Total As Integer = 1\nWhile X <> Y\nConsole.WriteLine(X + Y)\nIf X < Y Then\nX = X + 1\nTotal = Total * 2\nElse\nX = X - 1\nTotal = Total \\ 2\nEnd If\nEnd While\nReturn Total\nEnd Function\n© UCLES 2021 Page 6 of 23\n\n1(c) Java\npublic static Integer IterativeUnknown(Integer X, Integer\nY){\nInteger Total = 1;\nwhile (X != Y){\nSystem.out.println(X+Y);\nif(X<Y){\nX = X + 1;\nTotal = Total * 2;\n}else{\nX = X - 1;\nTotal = Total / 2;\n}\n}\nreturn Total;\n}\n\n1(d)(i) Calling function 3 times with correct Data and outputting 1\nExample program code:\nPython\nprint(\"10 and 15\")\nprint(str(IterativeUnknown(10, 15)))\nprint(\"10 and 10\")\nprint(str(IterativeUnknown(10, 10)))\nprint(\"15 and 10\")\nprint(str(IterativeUnknown(15, 10)))\nVB.NET\nConsole.WriteLine(\"10 and 15\")\nConsole.WriteLine(IterativeUnknown(10, 15))\nConsole.WriteLine(\"10, 10\")\nConsole.WriteLine(IterativeUnknown(10, 10))\nConsole.WriteLine(\"15, 10\")\nConsole.WriteLine(IterativeUnknown(15, 10))\nJava\nSystem.out.println(\"10 and 15\");\nSystem.out.println(IterativeUnknown(10, 15));\nSystem.out.println(\"10 and 10\");\nSystem.out.println(IterativeUnknown(10, 10));\nSystem.out.println(\"15 and 10\");\nSystem.out.println(IterativeUnknown(15, 10));\n© UCLES 2021 Page 7 of 23\n\n1(d)(ii) 1 mark for screenshot showing correct output for both functions 1\nQuestion Answer Marks",
      "source_pages": [
        3,
        4,
        5,
        6,
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_41-p03.png",
        "../answer-assets/9618_w21_ms_41-p04.png",
        "../answer-assets/9618_w21_ms_41-p05.png",
        "../answer-assets/9618_w21_ms_41-p06.png",
        "../answer-assets/9618_w21_ms_41-p07.png",
        "../answer-assets/9618_w21_ms_41-p08.png"
      ]
    },
    {
      "id": "9618-2021-on-41-q02",
      "question_id": "9618-2021-on-41-q02",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 30,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark per bullet point 5\n• class declared (with appropriate close) with identifier Picture\n• correct attribute declarations with Data types (Description, Frame colour =\nstring, Width, Height = integer.)\n• …as private\n• correct constructor (with appropriate close) with four parameters…\n• …parameters assigned to attributes\nExample program code:\nPython\nclass Picture:\ndef __init__(self, DescriptionP, WidthSizeP,\nHeightSizeP, FrameColourP):\nself.__Description = DescriptionP # string\nself.__Width = int(WidthSizeP) #integer\nself.__Height = int(HeightSizeP) #integer\nself.__FrameColour = FrameColourP #string\nJava\nclass Picture{\nprivate String Description;\nprivate Integer Width;\nprivate Integer Height;\nprivate String FrameColour;\npublic Picture(String DescriptionP, Integer WidthP,\nInteger HeightP, String FrameColourP){\nDescription = DescriptionP;\nWidth = WidthP;\nHeight = HeightP;\nFrameColour = FrameColourP;\n}\n}\n© UCLES 2021 Page 8 of 23\n\n2(a) VB.NET\nClass Picture\nPrivate Description As String\nPrivate Width As Integer\nPrivate Height As Integer\nPrivate FrameColour As String\nPublic Sub New(DescriptionP, WidthP, HeightP,FrameColourP)\nDescription = DescriptionP\nWidth = WidthP\nHeight = HeightP\nFrameColour = FrameColourP\nEnd Sub\nEnd Class\n© UCLES 2021 Page 9 of 23\n\n2(b) 1 mark per bullet point 3\n• 1 Get method taking no parameter…\n• …returning correct attribute\n• remaining 3 correct methods\nExample program code:\nPython\ndef GetDescription(self):\nreturn self.__Description\ndef GetWidth(self):\nreturn self.__Width\ndef GetHeight(self):\nreturn self.__Height\ndef GetColour(self):\nreturn self.__FrameColour\nJava\npublic String GetDescription(){\nreturn Description;\n}\npublic Integer GetWidth(){\nreturn Width;\n}\npublic Integer GetHeight(){\nreturn Height;\n}\npublic String GetFrameColour(){\nreturn FrameColour;\n}\nVB.NET\nFunction GetDescription()\nReturn Description\nEnd Function\nFunction GetWidth()\nReturn Width\nEnd Function\nFunction GetHeight()\nReturn Height\nEnd Function\nFunction GetFrameColour()\nReturn FrameColour\nEnd Function\n© UCLES 2021 Page 10 of 23\n\n2(c) 1 mark per bullet point 2\n• Set method (procedure) taking parameter (no return) …\n• …assigning parameter to correct attribute\nExample program code:\nPython\ndef SetDescription(self, DescriptionP):\nself.__Description = DescriptionP\nJava\npublic void SetDescription(String DescriptionP){\nDescription = DescriptionP;\n}\nVB.NET\nPublic Sub SetDescription(DescriptionP)\nDescription = DescriptionP\nEnd Sub\n\n2(d) 1 mark for declaring array of type Picture with 100 elements 1\nExample program code:\nPython\nPictureArray = []\nfor i in range(100):\nPictureArray.append(Picture(\"\",0,0,\"\"))\nJava\npublic static void main(String[] args){\nPicture[] PictureArray = new Picture[100];}\nVB.NET\nDim PictureArray(0 to 99) As Picture\n© UCLES 2021 Page 11 of 23\n\n2(e) 1 mark per bullet point: 8\n• Exception with opening the file inside...\n• ..appropriate catch and output\n1 mark per bullet point to Max 7\n• Function/procedure declared with correct name (and close, passing array by\nreference or global array declared)\n• opening Pictures.txt for Read\n• looping until EOF / or equivalent\n• …reading each set of 4 lines from the file within loop\n• creating object of type Picture\n• …with Description, Width, Height, Frame colour from File as parameters\n• ..adding to next array element/appending\n• closing the File (in an appropriate place)\n• counts and returns number of pictures in array\nExample program code:\nPython\ndef ReadData(PictureArray):\nFilename = \"Pictures.txt\"\nCounter = 0\ntry:\nFile = open(Filename,\"r\")\nDescription = (File.readline()).strip().lower()\nwhile(Description != \"\"):\nWidth = int((File.readline()).strip())\nHeight = int((File.readline()).strip())\nFrame = ((File.readline()).strip()).lower()\nPictureArray[Counter] = Picture(Description,\nWidth, Height, Frame)\nDescription =((File.readline()).strip()).lower()\nCounter = Counter + 1\nFile.close()\nexcept IOError:\nprint(\"Could not find File\")\nreturn Counter, PictureArray\n© UCLES 2021 Page 12 of 23\n\n2(e) VB.NET\nFunction ReadData(ByRef PictureArray, ByRef NumberPictures)\nAs Integer\nDim Counter As Integer = 0\nTry\nDim Filename As String = \"Pictures.txt\"\nDim FileReader As New System.IO.StreamReader(Filename)\nDim Description, FrameColour As String\nDim Height, Width As Integer\nWhile FileReader.Peek <> -1\nDescription = FileReader.ReadLine()\nWidth = FileReader.ReadLine()\nHeight = FileReader.ReadLine()\nFrameColour = FileReader.ReadLine()\nPictureArray(NumberPictures) =\nNew Picture(Description, Width, Height, FrameColour)\nNumberPictures = NumberPictures + 1\nCounter = Counter + 1\nEnd While\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid File\")\nEnd Try\nReturn Counter\nEnd Function\n© UCLES 2021 Page 13 of 23\n\n2(e) Java\npublic static Integer ReadData(Picture[] PictureArray){\nString Filename = \"Pictures.txt\";\nString DataRead;\nString Description;\nString Width;\nString Height;\nString FrameColour;\nInteger NumberPictures = 0;\ntry{\nFileReader f = new FileReader(Filename);\nBufferedReader Reader = new BufferedReader(f);\nDataRead = Reader.readLine();\nwhile(DataRead != null){\nDescription = DataRead;\nWidth = Reader.readLine();\nHeight = Reader.readLine();\nFrameColour = Reader.readLine();\nPictureArray[NumberPictures] =\nnew Picture(Description, Integer.parseInt(Width),\nInteger.parseInt(Height), FrameColour);\nNumberPictures++;\nDataRead = Reader.readLine();\n}\nReader.close();\n}\ncatch(FileNotFoundException ex){\nSystem.out.println(\"No File found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No File found\");\n}\nreturn NumberPictures;\n}\n\n2(f) 1 mark per bullet point 2\n• calling function ReadData() …\n• …store/use the Number of elements returned/by reference based on answer\nto part 2e\nExample program code:\nPython\nNumberPicturesInArray, PictureArray = ReadData(PictureArray)\nJava\nInteger NumberPicturesInArray = ReadData(PictureArray);\nVB.NET\nDim NumberPicturesInArray As Integer = ReadData()\n© UCLES 2021 Page 14 of 23\n\n2(g) 1 mark per bullet point to Max 7 7\n• taking as input all three values (colour, width, height)\n• … converting colour to lowercase // uppercase\n• looping through array …\n• …using returned value from part 2(f) as max index\n• …within loop, checking if Array[index].FrameColour matches input\n• …and checking if Array[index].FrameWidth <= input Width\n• …and checking if Array[index].FrameHeight <= input Height\n• …all using Get methods\n• outputting the Picture Description, Width and Height for all/any matching\nPictures\nExample program code:\nPython\nFrameColour = input(\"Input the Frame colour \").lower()\nMaxWidth = int(input(\"Input the Maximum Width \"))\nMaxHeight = int(input(\"Input the Maximum Height \"))\nprint(\"Matches Frames shown\")\nfor Z in range(0, NumberPicturesInArray):\nif PictureArray[Z].GetColour() == FrameColour:\nif(PictureArray[Z].GetWidth() <= MaxWidth):\nif (PictureArray[Z].GetHeight() <= MaxHeight):\nprint(PictureArray[Z].GetDescription(), \" \" ,\nstr(PictureArray[Z].GetWidth()), \" \",\nstr(PictureArray[Z].GetHeight()))\nVB.NET\nSub Main()\nDim PictureArray(0 To 99) As Picture\nDim NumberPictures As Integer = 0\nDim FrameColour As String\nDim MaxWidth, MaxHeight As Integer\nReadData(PictureArray, NumberPictures)\nConsole.WriteLine(\"Input the Frame colour\")\nFrameColour = (Console.ReadLine()).ToLower()\nConsole.WriteLine(\"Input the Maximum Width\")\nMaxWidth = Console.ReadLine()\nConsole.WriteLine(\"Input the Maximum Height\")\nMaxHeight = Console.ReadLine()\nConsole.WriteLine(\"Matching Frames shown\")\nFor X = 0 To NumberPictures - 1\nIf PictureArray(X).GetFrameColour() = FrameColour And\nPictureArray(X).GetWidth <= MaxWidth And\nPictureArray(X).GetHeight <= MaxHeight Then\n© UCLES 2021 Page 15 of 23\n\n2(g) Console.WriteLine(PictureArray(X).GetDescription() & \" \"\n& PictureArray(X).GetWidth() & \" \" &\nPictureArray(X).GetHeight)\nEnd If\nNext\nConsole.ReadLine()\nEnd Sub\nJava\npublic static void main(String[] args){\nPicture[] PictureArray = new Picture[100];\nInteger NumberPicturesInArray = ReadData(PictureArray);\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Enter the Frame colour\");\nString FrameColour = scanner.nextLine();\nSystem.out.println(\"Enter the Maximum Width\");\nInteger MaxWidth = Integer.parseInt(scanner.nextLine());\nSystem.out.println(\"Enter the Maximum Height\");\nInteger MaxHeight = Integer.parseInt(scanner.nextLine());\nFrameColour = FrameColour.toLowerCase();\nfor(int X = 0; X < NumberPicturesInArray; X++){\nif(PictureArray[X].GetFrameColour().equals(FrameColour) &&\nPictureArray[X].GetWidth() <= MaxWidth &&\nPictureArray[X].GetHeight() <= MaxHeight){\nSystem.out.println(PictureArray[X].GetDescription() +\n\" \" + PictureArray[X].GetWidth() + \" \" +\nPictureArray[X].GetHeight());\n}\n}\n}\n\n2(h) 1 mark for screenshot showing output for BLACK, 100, 100 2\n1 mark for showing no outputs for silver, 25, 25\nInput the Frame colour BLACK\nInput the Maximum Width 100\nInput the Maximum Height 100\nMatches Frames shown\nflowers 45 50\npeople 20 20\nlandscape 30 45\nlandscape 25 37\npeople 50 40\nInput the Frame colour silver\nInput the Maximum Width 25\nInput the Maximum Height 25\nMatches Frames shown\n© UCLES 2021 Page 16 of 23",
      "source_pages": [
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_41-p08.png",
        "../answer-assets/9618_w21_ms_41-p09.png",
        "../answer-assets/9618_w21_ms_41-p10.png",
        "../answer-assets/9618_w21_ms_41-p11.png",
        "../answer-assets/9618_w21_ms_41-p12.png",
        "../answer-assets/9618_w21_ms_41-p13.png",
        "../answer-assets/9618_w21_ms_41-p14.png",
        "../answer-assets/9618_w21_ms_41-p15.png",
        "../answer-assets/9618_w21_ms_41-p16.png"
      ]
    },
    {
      "id": "9618-2021-on-41-q03",
      "question_id": "9618-2021-on-41-q03",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 34,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per bullet point 4\n• Declaring array named ArrayNodes of type integer\n• …with 20 by 3 elements\n• RootPointer declared as integer and assigned -1\n• FreeNode declared as integer and assigned 0\nExample program code:\nPython\nArrayNodes=[[0 for X in range(3)] for Y in range(20)]\nRootPointer = -1\nFreeNode = 0\nVB.NET\nSub Main()\nDim ArrayNodes(19, 2) As Integer\nDim RootPointer As Integer = -1\nDim FreeNode As Integer = 0\nEnd Sub\nJava\npublic static Integer[][] ArrayNodes = new Integer[20][3];\npublic static Integer RootPointer = -1;\npublic static Integer FreeNode = 0;\n© UCLES 2021 Page 17 of 23\n\n3(b) 1 mark for each completed statement to Max 6 8\n1 mark per bullet point\n• Function/procedure declaration either :\ntaking parameters by reference\nreturning the three amended values (Python)\nusing global instead\n• remainder of function/procedure matches the pseudocode\nExample program code:\nPython\ndef AddNode(ArrayNodes, RootPointer, FreeNode):\nNodeData = int(input(\"Enter the Data\"))\nif FreeNode <= 19:\nArrayNodes[FreeNode][0] = -1\nArrayNodes[FreeNode][1] = NodeData\nArrayNodes[FreeNode][2] = -1\nif RootPointer == -1: # Add to start\nRootPointer = 0\nelse:\nPlaced = False\nCurrentNode = RootPointer\nwhile Placed == False:\nif NodeData < ArrayNodes[CurrentNode][1]:\nif ArrayNodes[CurrentNode][0] == -1:\nArrayNodes[CurrentNode][0] = FreeNode\nPlaced = True\nelse:\nCurrentNode = ArrayNodes[CurrentNode][0]\nelse:\nif ArrayNodes[CurrentNode][2] == -1:\nArrayNodes[CurrentNode][2] = FreeNode\nPlaced = True\nelse:\nCurrentNode = ArrayNodes[CurrentNode][2]\nFreeNode = FreeNode + 1\nelse:\nprint(\"Tree is full\")\nreturn ArrayNodes, RootPointer, FreeNode\n© UCLES 2021 Page 18 of 23\n\n3(b) VB.NET\nSub AddNode(ByRef ArrayNodes, ByRef RootPointer,\nByRef FreeNode)\nConsole.WriteLine(\"Enter the Data\")\nDim NodeData As Integer = Console.ReadLine\nIf FreeNode <= 19 Then\nArrayNodes(FreeNode, 0) = -1\nArrayNodes(FreeNode, 1) = NodeData\nArrayNodes(FreeNode, 2) = -1\nIf RootPointer = -1 Then\nRootPointer = 0\nElse\nDim Placed As Boolean = False\nDim CurrentNode As Integer = RootPointer\nWhile Placed = False\nIf NodeData < ArrayNodes(CurrentNode, 1) Then\nIf ArrayNodes(CurrentNode, 0) = -1 Then\nArrayNodes(CurrentNode, 0) = FreeNode\nPlaced = True\nElse\nCurrentNode = ArrayNodes(CurrentNode, 0)\nEnd If\nElse\nIf ArrayNodes(CurrentNode, 2) = -1 Then\nArrayNodes(CurrentNode, 2) = FreeNode\nPlaced = True\nElse\nCurrentNode = ArrayNodes(CurrentNode, 2)\nEnd If\nEnd If\nEnd While\nEndif\nFreeNode = FreeNode + 1\nElse\nConsole.WriteLine(\"Tree is full\")\nEnd If\nEnd Sub\n© UCLES 2021 Page 19 of 23\n\n3(b) Java\npublic static void AddNode(){\nSystem.out.println(\"Enter the Data\");\nInteger NodeData;\nScanner in = new Scanner(System.in);\nNodeData = in.nextInt();\nif(FreeNode <= 19){\nArrayNodes[FreeNode][0] = -1;\nArrayNodes[FreeNode][1] = NodeData;\nArrayNodes[FreeNode][2] = -1;\nif (RootPointer == -1){\nRootPointer = 0;\n}else{\nBoolean Placed = false;\nInteger CurrentNode = RootPointer;\nwhile(Placed == false){\nif (NodeData < ArrayNodes[CurrentNode][1]){\nif (ArrayNodes[CurrentNode][0] == -1){\nArrayNodes[CurrentNode][0] = FreeNode;\nPlaced = true;\n}else{\nCurrentNode = ArrayNodes[CurrentNode][0];\n}\n}else{\nif (ArrayNodes[CurrentNode][2] == -1){\nArrayNodes[CurrentNode][2] = FreeNode;\nPlaced = true;\n}else{\nCurrentNode = ArrayNodes[CurrentNode][2];\n}\n}\n}\n}\nFreeNode = FreeNode + 1;\n}else{\nSystem.out.println(\"Tree is full\");\n}\n}\n© UCLES 2021 Page 20 of 23\n\n3(c) 1 mark per bullet point 4\n• procedure header (and end, take array as parameter)\n• Loops through all array elements // loops 20 times\n• Prints data in index 0, 1, 2 in each array element…\n• … in the correct order and format (spaces between)\nExample program code:\nPython\ndef PrintAll(ArrayNodes):\nfor X in range(0, 20):\nprint(str(ArrayNodes[X][0]), \" \", str(ArrayNodes[X][1]),\n\" \", str(ArrayNodes[X][2]))\nVB.NET\nSub PrintAll(ByRef ArrayNodes)\nFor X = 0 To 19\nConsole.WriteLine(ArrayNodes(X, 0) & \" \" & ArrayNodes(X,\n1) & \" \" & ArrayNodes(X, 2))\nNext\nEnd Sub\nJava\npublic static void PrintAll(){\nfor(int X = 0; X < 20; X++){\nSystem.out.println(ArrayNodes[X][0] + \" \" +\nArrayNodes[X][1] + \" \" + ArrayNodes[X][2]);\n}\n}\n\n3(d)(i) 1 mark per bullet point 3\n• looping 10 times\n• calling AddNode 10 times (check parameters in 3b)\n• calling PrintAll outside of loop (check parameters in 3c)\nExample program code:\nPython\nfor X in range(0,10):\nArrayNodes, RootPointer, FreeNode =\nAddNode(ArrayNodes,RootPointer,FreeNode)\nPrintAll(ArrayNodes)\nVB.NET\nFor X = 0 To 9\nAddNode(ArrayNodes, RootPointer, FreeNode)\nNext\nprintall(ArrayNodes)\nJava\nfor (int X = 0; X < 10; X++){\nAddNode();\n}\nPrintAll();\n© UCLES 2021 Page 21 of 23\n\n3(d)(ii) 1 mark for screenshot showing the following output: 1\n1 10 2\n9 5 3\n4 15 6\n5 8 8\n7 12 −1\n−1 6 −1\n−1 20 −1\n−1 11 −1\n−1 9 −1\n−1 4 −1\n\n3(e)(i) 1 mark per bullet point 7\n• procedure name InOrder taking a parameter (for current node being\naccessed)\n• Checking if left Node is empty (−1)\n• ….(if not) calling procedure recursively with [Current Node][0] as parameter\n• outputting the [Current Node][1]\n• checking if right Node is empty (−1)\n• …(if not) calling procedure recursively with [Current Node][2] as a parameter\n• Order is correct, left, root, right\nExample program code:\nPython\ndef InOrder(ArrayNodes, RootNode):\nif ArrayNodes[RootNode][0] != -1:\nInOrder(ArrayNodes, ArrayNodes[RootNode][0])\nprint(str(ArrayNodes[RootNode][1]))\nif ArrayNodes[RootNode][2] != -1:\nInOrder(ArrayNodes, ArrayNodes[RootNode][2])\nVB.NET\nSub InOrder(ArrayNodes, RootNode)\nIf ArrayNodes(RootNode, 0) <> -1 Then\nInOrder(ArrayNodes, ArrayNodes(RootNode, 0))\nEnd If\nConsole.WriteLine(ArrayNodes(RootNode, 1))\nIf ArrayNodes(RootNode, 2) <> -1 Then\nInOrder(ArrayNodes, ArrayNodes(RootNode, 2))\nEnd If\nEnd Sub\nJava\npublic static void InOrder(Integer Root){\nif (ArrayNodes[Root][0] != -1){\nInOrder(ArrayNodes[Root][0]);\n}\nSystem.out.println(ArrayNodes[Root][1]);\nif(ArrayNodes[Root][2] != -1){\nInOrder(ArrayNodes[Root][2]);\n}\n}\n© UCLES 2021 Page 22 of 23\n\n3(e)(ii) 1 mark showing output: 1\n4\n5\n6\n8\n9\n10\n11\n12\n15\n20\n© UCLES 2021 Page 23 of 23",
      "source_pages": [
        17,
        18,
        19,
        20,
        21,
        22,
        23
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_41-p17.png",
        "../answer-assets/9618_w21_ms_41-p18.png",
        "../answer-assets/9618_w21_ms_41-p19.png",
        "../answer-assets/9618_w21_ms_41-p20.png",
        "../answer-assets/9618_w21_ms_41-p21.png",
        "../answer-assets/9618_w21_ms_41-p22.png",
        "../answer-assets/9618_w21_ms_41-p23.png"
      ]
    },
    {
      "id": "9618-2021-on-42-q01",
      "question_id": "9618-2021-on-42-q01",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 17,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per bullet point 3\n• function with correct name and parameters\n• correct Div operator (or equivalent) used\n• code matches pseudocode\nExample program code:\nPython\ndef Unknown(X, Y):\nif X < Y:\nprint(str(X + Y))\nreturn Unknown(X + 1, Y) * 2\nelif X == Y:\nreturn 1\nelse:\nprint(str(X + Y))\nreturn int(Unknown(X - 1, Y) / 2)\nVB.NET\nFunction Unknown(X, Y)\nIf X < Y Then\nConsole.WriteLine(X + Y)\nReturn Unknown(X + 1, Y) * 2\nElseIf X = Y Then\nReturn 1\nElse\nConsole.WriteLine(X + Y)\nReturn Unknown(X - 1, Y) \\ 2\nEnd If\nEnd Function\nJava\npublic static Integer Unknown(Integer X, Integer Y){\nif(X < Y){\nSystem.out.println(X+Y);\nreturn Unknown(X + 1, Y) * 2;\n}else if(X == Y){\nreturn 1;\n}else{\nSystem.out.println(X + Y);\nInteger ReturnValue = Unknown(X-1,Y) / 2;\nreturn ReturnValue;\n}\n}\n© UCLES 2021 Page 3 of 23\n\n1(b)(i) 1 mark per bullet point 3\n• Suitable output identifying parameters for each call\n• All three correct function calls …\n• …outputting the return value for each call\nExample program code:\nPython\nprint(\"10 and 15\")\nprint(str(Unknown(10, 15)))\nprint(\"10 and 10\")\nprint(str(Unknown(10, 10)))\nprint(\"15 and 10\")\nprint(str(Unknown(15, 10)))\nVB.NET\nConsole.WriteLine(\"10 and 15\")\nConsole.WriteLine(Unknown(10, 15))\nConsole.WriteLine(\"10, 10\")\nConsole.WriteLine(Unknown(10, 10))\nConsole.WriteLine(\"15, 10\")\nConsole.WriteLine(Unknown(15, 10))\nJava\npublic static void main(String[] args){\nSystem.out.println(\"10 and 15\");\nSystem.out.println(Unknown(10,15));\nSystem.out.println(\"10 and 10\");\nSystem.out.println(Unknown(10, 10));\nSystem.out.println(\"15 and 10\");\nSystem.out.println(Unknown(15, 10));\n}\n© UCLES 2021 Page 4 of 23\n\n1(b)(ii) 1 mark for 1 function with correct output 2\n\n1 mark for remaining 2 function calls with correct output\nFor example:\n10 and 15\n25\n26\n27\n28\n29\n32\n10 and 10\n\n1\n15 and 10\n25\n24\n23\n22\n21\n0\n© UCLES 2021 Page 5 of 23\n\n1(c) 1 mark per bullet point 7\n• Iterative function, taking 2 parameters\n• Starting with return value (Total) as 1\n• Looping while X <> Y // might be 1 loop or two separate // returning when X =\nY // looping until X==Y\n• Within each loop, outputting (X+Y) correctly when X<Y and Y<X\n• Each time X < Y, Total * 2 and X++\n• Each time Y < X Total DIV 2 and X--\n• Returning the Total after correct calculations\nExample program code:\nPython\ndef IterativeUnknown(X,Y):\nTotal = 1\nwhile X != Y:\nprint(str(X + Y))\nif X < Y:\nX = X + 1\nTotal = Total * 2\nelse:\nX = X - 1\nTotal = int(Total / 2)\nreturn Total\nVB.NET\nFunction IterativeUnknown(X, Y)\nDim Total As Integer = 1\nWhile X <> Y\nConsole.WriteLine(X + Y)\nIf X < Y Then\nX = X + 1\nTotal = Total * 2\nElse\nX = X - 1\nTotal = Total \\ 2\nEnd If\nEnd While\nReturn Total\nEnd Function\n© UCLES 2021 Page 6 of 23\n\n1(c) Java\npublic static Integer IterativeUnknown(Integer X, Integer\nY){\nInteger Total = 1;\nwhile (X != Y){\nSystem.out.println(X+Y);\nif(X<Y){\nX = X + 1;\nTotal = Total * 2;\n}else{\nX = X - 1;\nTotal = Total / 2;\n}\n}\nreturn Total;\n}\n\n1(d)(i) Calling function 3 times with correct Data and outputting 1\nExample program code:\nPython\nprint(\"10 and 15\")\nprint(str(IterativeUnknown(10, 15)))\nprint(\"10 and 10\")\nprint(str(IterativeUnknown(10, 10)))\nprint(\"15 and 10\")\nprint(str(IterativeUnknown(15, 10)))\nVB.NET\nConsole.WriteLine(\"10 and 15\")\nConsole.WriteLine(IterativeUnknown(10, 15))\nConsole.WriteLine(\"10, 10\")\nConsole.WriteLine(IterativeUnknown(10, 10))\nConsole.WriteLine(\"15, 10\")\nConsole.WriteLine(IterativeUnknown(15, 10))\nJava\nSystem.out.println(\"10 and 15\");\nSystem.out.println(IterativeUnknown(10, 15));\nSystem.out.println(\"10 and 10\");\nSystem.out.println(IterativeUnknown(10, 10));\nSystem.out.println(\"15 and 10\");\nSystem.out.println(IterativeUnknown(15, 10));\n© UCLES 2021 Page 7 of 23\n\n1(d)(ii) 1 mark for screenshot showing correct output for both functions 1\nQuestion Answer Marks",
      "source_pages": [
        3,
        4,
        5,
        6,
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_42-p03.png",
        "../answer-assets/9618_w21_ms_42-p04.png",
        "../answer-assets/9618_w21_ms_42-p05.png",
        "../answer-assets/9618_w21_ms_42-p06.png",
        "../answer-assets/9618_w21_ms_42-p07.png",
        "../answer-assets/9618_w21_ms_42-p08.png"
      ]
    },
    {
      "id": "9618-2021-on-42-q02",
      "question_id": "9618-2021-on-42-q02",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 30,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark per bullet point 5\n• class declared (with appropriate close) with identifier Picture\n• correct attribute declarations with Data types (Description, Frame colour =\nstring, Width, Height = integer.)\n• …as private\n• correct constructor (with appropriate close) with four parameters…\n• …parameters assigned to attributes\nExample program code:\nPython\nclass Picture:\ndef __init__(self, DescriptionP, WidthSizeP,\nHeightSizeP, FrameColourP):\nself.__Description = DescriptionP # string\nself.__Width = int(WidthSizeP) #integer\nself.__Height = int(HeightSizeP) #integer\nself.__FrameColour = FrameColourP #string\nJava\nclass Picture{\nprivate String Description;\nprivate Integer Width;\nprivate Integer Height;\nprivate String FrameColour;\npublic Picture(String DescriptionP, Integer WidthP,\nInteger HeightP, String FrameColourP){\nDescription = DescriptionP;\nWidth = WidthP;\nHeight = HeightP;\nFrameColour = FrameColourP;\n}\n}\n© UCLES 2021 Page 8 of 23\n\n2(a) VB.NET\nClass Picture\nPrivate Description As String\nPrivate Width As Integer\nPrivate Height As Integer\nPrivate FrameColour As String\nPublic Sub New(DescriptionP, WidthP, HeightP,FrameColourP)\nDescription = DescriptionP\nWidth = WidthP\nHeight = HeightP\nFrameColour = FrameColourP\nEnd Sub\nEnd Class\n© UCLES 2021 Page 9 of 23\n\n2(b) 1 mark per bullet point 3\n• 1 Get method taking no parameter…\n• …returning correct attribute\n• remaining 3 correct methods\nExample program code:\nPython\ndef GetDescription(self):\nreturn self.__Description\ndef GetWidth(self):\nreturn self.__Width\ndef GetHeight(self):\nreturn self.__Height\ndef GetColour(self):\nreturn self.__FrameColour\nJava\npublic String GetDescription(){\nreturn Description;\n}\npublic Integer GetWidth(){\nreturn Width;\n}\npublic Integer GetHeight(){\nreturn Height;\n}\npublic String GetFrameColour(){\nreturn FrameColour;\n}\nVB.NET\nFunction GetDescription()\nReturn Description\nEnd Function\nFunction GetWidth()\nReturn Width\nEnd Function\nFunction GetHeight()\nReturn Height\nEnd Function\nFunction GetFrameColour()\nReturn FrameColour\nEnd Function\n© UCLES 2021 Page 10 of 23\n\n2(c) 1 mark per bullet point 2\n• Set method (procedure) taking parameter (no return) …\n• …assigning parameter to correct attribute\nExample program code:\nPython\ndef SetDescription(self, DescriptionP):\nself.__Description = DescriptionP\nJava\npublic void SetDescription(String DescriptionP){\nDescription = DescriptionP;\n}\nVB.NET\nPublic Sub SetDescription(DescriptionP)\nDescription = DescriptionP\nEnd Sub\n\n2(d) 1 mark for declaring array of type Picture with 100 elements 1\nExample program code:\nPython\nPictureArray = []\nfor i in range(100):\nPictureArray.append(Picture(\"\",0,0,\"\"))\nJava\npublic static void main(String[] args){\nPicture[] PictureArray = new Picture[100];}\nVB.NET\nDim PictureArray(0 to 99) As Picture\n© UCLES 2021 Page 11 of 23\n\n2(e) 1 mark per bullet point: 8\n• Exception with opening the file inside...\n• ..appropriate catch and output\n1 mark per bullet point to Max 7\n• Function/procedure declared with correct name (and close, passing array by\nreference or global array declared)\n• opening Pictures.txt for Read\n• looping until EOF / or equivalent\n• …reading each set of 4 lines from the file within loop\n• creating object of type Picture\n• …with Description, Width, Height, Frame colour from File as parameters\n• ..adding to next array element/appending\n• closing the File (in an appropriate place)\n• counts and returns number of pictures in array\nExample program code:\nPython\ndef ReadData(PictureArray):\nFilename = \"Pictures.txt\"\nCounter = 0\ntry:\nFile = open(Filename,\"r\")\nDescription = (File.readline()).strip().lower()\nwhile(Description != \"\"):\nWidth = int((File.readline()).strip())\nHeight = int((File.readline()).strip())\nFrame = ((File.readline()).strip()).lower()\nPictureArray[Counter] = Picture(Description,\nWidth, Height, Frame)\nDescription =((File.readline()).strip()).lower()\nCounter = Counter + 1\nFile.close()\nexcept IOError:\nprint(\"Could not find File\")\nreturn Counter, PictureArray\n© UCLES 2021 Page 12 of 23\n\n2(e) VB.NET\nFunction ReadData(ByRef PictureArray, ByRef NumberPictures)\nAs Integer\nDim Counter As Integer = 0\nTry\nDim Filename As String = \"Pictures.txt\"\nDim FileReader As New System.IO.StreamReader(Filename)\nDim Description, FrameColour As String\nDim Height, Width As Integer\nWhile FileReader.Peek <> -1\nDescription = FileReader.ReadLine()\nWidth = FileReader.ReadLine()\nHeight = FileReader.ReadLine()\nFrameColour = FileReader.ReadLine()\nPictureArray(NumberPictures) =\nNew Picture(Description, Width, Height, FrameColour)\nNumberPictures = NumberPictures + 1\nCounter = Counter + 1\nEnd While\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid File\")\nEnd Try\nReturn Counter\nEnd Function\n© UCLES 2021 Page 13 of 23\n\n2(e) Java\npublic static Integer ReadData(Picture[] PictureArray){\nString Filename = \"Pictures.txt\";\nString DataRead;\nString Description;\nString Width;\nString Height;\nString FrameColour;\nInteger NumberPictures = 0;\ntry{\nFileReader f = new FileReader(Filename);\nBufferedReader Reader = new BufferedReader(f);\nDataRead = Reader.readLine();\nwhile(DataRead != null){\nDescription = DataRead;\nWidth = Reader.readLine();\nHeight = Reader.readLine();\nFrameColour = Reader.readLine();\nPictureArray[NumberPictures] =\nnew Picture(Description, Integer.parseInt(Width),\nInteger.parseInt(Height), FrameColour);\nNumberPictures++;\nDataRead = Reader.readLine();\n}\nReader.close();\n}\ncatch(FileNotFoundException ex){\nSystem.out.println(\"No File found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No File found\");\n}\nreturn NumberPictures;\n}\n\n2(f) 1 mark per bullet point 2\n• calling function ReadData() …\n• …store/use the Number of elements returned/by reference based on answer\nto part 2e\nExample program code:\nPython\nNumberPicturesInArray, PictureArray = ReadData(PictureArray)\nJava\nInteger NumberPicturesInArray = ReadData(PictureArray);\nVB.NET\nDim NumberPicturesInArray As Integer = ReadData()\n© UCLES 2021 Page 14 of 23\n\n2(g) 1 mark per bullet point to Max 7 7\n• taking as input all three values (colour, width, height)\n• … converting colour to lowercase // uppercase\n• looping through array …\n• …using returned value from part 2(f) as max index\n• …within loop, checking if Array[index].FrameColour matches input\n• …and checking if Array[index].FrameWidth <= input Width\n• …and checking if Array[index].FrameHeight <= input Height\n• …all using Get methods\n• outputting the Picture Description, Width and Height for all/any matching\nPictures\nExample program code:\nPython\nFrameColour = input(\"Input the Frame colour \").lower()\nMaxWidth = int(input(\"Input the Maximum Width \"))\nMaxHeight = int(input(\"Input the Maximum Height \"))\nprint(\"Matches Frames shown\")\nfor Z in range(0, NumberPicturesInArray):\nif PictureArray[Z].GetColour() == FrameColour:\nif(PictureArray[Z].GetWidth() <= MaxWidth):\nif (PictureArray[Z].GetHeight() <= MaxHeight):\nprint(PictureArray[Z].GetDescription(), \" \" ,\nstr(PictureArray[Z].GetWidth()), \" \",\nstr(PictureArray[Z].GetHeight()))\nVB.NET\nSub Main()\nDim PictureArray(0 To 99) As Picture\nDim NumberPictures As Integer = 0\nDim FrameColour As String\nDim MaxWidth, MaxHeight As Integer\nReadData(PictureArray, NumberPictures)\nConsole.WriteLine(\"Input the Frame colour\")\nFrameColour = (Console.ReadLine()).ToLower()\nConsole.WriteLine(\"Input the Maximum Width\")\nMaxWidth = Console.ReadLine()\nConsole.WriteLine(\"Input the Maximum Height\")\nMaxHeight = Console.ReadLine()\nConsole.WriteLine(\"Matching Frames shown\")\nFor X = 0 To NumberPictures - 1\nIf PictureArray(X).GetFrameColour() = FrameColour And\nPictureArray(X).GetWidth <= MaxWidth And\nPictureArray(X).GetHeight <= MaxHeight Then\n© UCLES 2021 Page 15 of 23\n\n2(g) Console.WriteLine(PictureArray(X).GetDescription() & \" \"\n& PictureArray(X).GetWidth() & \" \" &\nPictureArray(X).GetHeight)\nEnd If\nNext\nConsole.ReadLine()\nEnd Sub\nJava\npublic static void main(String[] args){\nPicture[] PictureArray = new Picture[100];\nInteger NumberPicturesInArray = ReadData(PictureArray);\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Enter the Frame colour\");\nString FrameColour = scanner.nextLine();\nSystem.out.println(\"Enter the Maximum Width\");\nInteger MaxWidth = Integer.parseInt(scanner.nextLine());\nSystem.out.println(\"Enter the Maximum Height\");\nInteger MaxHeight = Integer.parseInt(scanner.nextLine());\nFrameColour = FrameColour.toLowerCase();\nfor(int X = 0; X < NumberPicturesInArray; X++){\nif(PictureArray[X].GetFrameColour().equals(FrameColour) &&\nPictureArray[X].GetWidth() <= MaxWidth &&\nPictureArray[X].GetHeight() <= MaxHeight){\nSystem.out.println(PictureArray[X].GetDescription() +\n\" \" + PictureArray[X].GetWidth() + \" \" +\nPictureArray[X].GetHeight());\n}\n}\n}\n\n2(h) 1 mark for screenshot showing output for BLACK, 100, 100 2\n1 mark for showing no outputs for silver, 25, 25\nInput the Frame colour BLACK\nInput the Maximum Width 100\nInput the Maximum Height 100\nMatches Frames shown\nflowers 45 50\npeople 20 20\nlandscape 30 45\nlandscape 25 37\npeople 50 40\nInput the Frame colour silver\nInput the Maximum Width 25\nInput the Maximum Height 25\nMatches Frames shown\n© UCLES 2021 Page 16 of 23",
      "source_pages": [
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_42-p08.png",
        "../answer-assets/9618_w21_ms_42-p09.png",
        "../answer-assets/9618_w21_ms_42-p10.png",
        "../answer-assets/9618_w21_ms_42-p11.png",
        "../answer-assets/9618_w21_ms_42-p12.png",
        "../answer-assets/9618_w21_ms_42-p13.png",
        "../answer-assets/9618_w21_ms_42-p14.png",
        "../answer-assets/9618_w21_ms_42-p15.png",
        "../answer-assets/9618_w21_ms_42-p16.png"
      ]
    },
    {
      "id": "9618-2021-on-42-q03",
      "question_id": "9618-2021-on-42-q03",
      "subject": "9618",
      "year": 2021,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 34,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per bullet point 4\n• Declaring array named ArrayNodes of type integer\n• …with 20 by 3 elements\n• RootPointer declared as integer and assigned -1\n• FreeNode declared as integer and assigned 0\nExample program code:\nPython\nArrayNodes=[[0 for X in range(3)] for Y in range(20)]\nRootPointer = -1\nFreeNode = 0\nVB.NET\nSub Main()\nDim ArrayNodes(19, 2) As Integer\nDim RootPointer As Integer = -1\nDim FreeNode As Integer = 0\nEnd Sub\nJava\npublic static Integer[][] ArrayNodes = new Integer[20][3];\npublic static Integer RootPointer = -1;\npublic static Integer FreeNode = 0;\n© UCLES 2021 Page 17 of 23\n\n3(b) 1 mark for each completed statement to Max 6 8\n1 mark per bullet point\n• Function/procedure declaration either :\ntaking parameters by reference\nreturning the three amended values (Python)\nusing global instead\n• remainder of function/procedure matches the pseudocode\nExample program code:\nPython\ndef AddNode(ArrayNodes, RootPointer, FreeNode):\nNodeData = int(input(\"Enter the Data\"))\nif FreeNode <= 19:\nArrayNodes[FreeNode][0] = -1\nArrayNodes[FreeNode][1] = NodeData\nArrayNodes[FreeNode][2] = -1\nif RootPointer == -1: # Add to start\nRootPointer = 0\nelse:\nPlaced = False\nCurrentNode = RootPointer\nwhile Placed == False:\nif NodeData < ArrayNodes[CurrentNode][1]:\nif ArrayNodes[CurrentNode][0] == -1:\nArrayNodes[CurrentNode][0] = FreeNode\nPlaced = True\nelse:\nCurrentNode = ArrayNodes[CurrentNode][0]\nelse:\nif ArrayNodes[CurrentNode][2] == -1:\nArrayNodes[CurrentNode][2] = FreeNode\nPlaced = True\nelse:\nCurrentNode = ArrayNodes[CurrentNode][2]\nFreeNode = FreeNode + 1\nelse:\nprint(\"Tree is full\")\nreturn ArrayNodes, RootPointer, FreeNode\n© UCLES 2021 Page 18 of 23\n\n3(b) VB.NET\nSub AddNode(ByRef ArrayNodes, ByRef RootPointer,\nByRef FreeNode)\nConsole.WriteLine(\"Enter the Data\")\nDim NodeData As Integer = Console.ReadLine\nIf FreeNode <= 19 Then\nArrayNodes(FreeNode, 0) = -1\nArrayNodes(FreeNode, 1) = NodeData\nArrayNodes(FreeNode, 2) = -1\nIf RootPointer = -1 Then\nRootPointer = 0\nElse\nDim Placed As Boolean = False\nDim CurrentNode As Integer = RootPointer\nWhile Placed = False\nIf NodeData < ArrayNodes(CurrentNode, 1) Then\nIf ArrayNodes(CurrentNode, 0) = -1 Then\nArrayNodes(CurrentNode, 0) = FreeNode\nPlaced = True\nElse\nCurrentNode = ArrayNodes(CurrentNode, 0)\nEnd If\nElse\nIf ArrayNodes(CurrentNode, 2) = -1 Then\nArrayNodes(CurrentNode, 2) = FreeNode\nPlaced = True\nElse\nCurrentNode = ArrayNodes(CurrentNode, 2)\nEnd If\nEnd If\nEnd While\nEndif\nFreeNode = FreeNode + 1\nElse\nConsole.WriteLine(\"Tree is full\")\nEnd If\nEnd Sub\n© UCLES 2021 Page 19 of 23\n\n3(b) Java\npublic static void AddNode(){\nSystem.out.println(\"Enter the Data\");\nInteger NodeData;\nScanner in = new Scanner(System.in);\nNodeData = in.nextInt();\nif(FreeNode <= 19){\nArrayNodes[FreeNode][0] = -1;\nArrayNodes[FreeNode][1] = NodeData;\nArrayNodes[FreeNode][2] = -1;\nif (RootPointer == -1){\nRootPointer = 0;\n}else{\nBoolean Placed = false;\nInteger CurrentNode = RootPointer;\nwhile(Placed == false){\nif (NodeData < ArrayNodes[CurrentNode][1]){\nif (ArrayNodes[CurrentNode][0] == -1){\nArrayNodes[CurrentNode][0] = FreeNode;\nPlaced = true;\n}else{\nCurrentNode = ArrayNodes[CurrentNode][0];\n}\n}else{\nif (ArrayNodes[CurrentNode][2] == -1){\nArrayNodes[CurrentNode][2] = FreeNode;\nPlaced = true;\n}else{\nCurrentNode = ArrayNodes[CurrentNode][2];\n}\n}\n}\n}\nFreeNode = FreeNode + 1;\n}else{\nSystem.out.println(\"Tree is full\");\n}\n}\n© UCLES 2021 Page 20 of 23\n\n3(c) 1 mark per bullet point 4\n• procedure header (and end, take array as parameter)\n• Loops through all array elements // loops 20 times\n• Prints data in index 0, 1, 2 in each array element…\n• … in the correct order and format (spaces between)\nExample program code:\nPython\ndef PrintAll(ArrayNodes):\nfor X in range(0, 20):\nprint(str(ArrayNodes[X][0]), \" \", str(ArrayNodes[X][1]),\n\" \", str(ArrayNodes[X][2]))\nVB.NET\nSub PrintAll(ByRef ArrayNodes)\nFor X = 0 To 19\nConsole.WriteLine(ArrayNodes(X, 0) & \" \" & ArrayNodes(X,\n1) & \" \" & ArrayNodes(X, 2))\nNext\nEnd Sub\nJava\npublic static void PrintAll(){\nfor(int X = 0; X < 20; X++){\nSystem.out.println(ArrayNodes[X][0] + \" \" +\nArrayNodes[X][1] + \" \" + ArrayNodes[X][2]);\n}\n}\n\n3(d)(i) 1 mark per bullet point 3\n• looping 10 times\n• calling AddNode 10 times (check parameters in 3b)\n• calling PrintAll outside of loop (check parameters in 3c)\nExample program code:\nPython\nfor X in range(0,10):\nArrayNodes, RootPointer, FreeNode =\nAddNode(ArrayNodes,RootPointer,FreeNode)\nPrintAll(ArrayNodes)\nVB.NET\nFor X = 0 To 9\nAddNode(ArrayNodes, RootPointer, FreeNode)\nNext\nprintall(ArrayNodes)\nJava\nfor (int X = 0; X < 10; X++){\nAddNode();\n}\nPrintAll();\n© UCLES 2021 Page 21 of 23\n\n3(d)(ii) 1 mark for screenshot showing the following output: 1\n1 10 2\n9 5 3\n4 15 6\n5 8 8\n7 12 −1\n−1 6 −1\n−1 20 −1\n−1 11 −1\n−1 9 −1\n−1 4 −1\n\n3(e)(i) 1 mark per bullet point 7\n• procedure name InOrder taking a parameter (for current node being\naccessed)\n• Checking if left Node is empty (−1)\n• ….(if not) calling procedure recursively with [Current Node][0] as parameter\n• outputting the [Current Node][1]\n• checking if right Node is empty (−1)\n• …(if not) calling procedure recursively with [Current Node][2] as a parameter\n• Order is correct, left, root, right\nExample program code:\nPython\ndef InOrder(ArrayNodes, RootNode):\nif ArrayNodes[RootNode][0] != -1:\nInOrder(ArrayNodes, ArrayNodes[RootNode][0])\nprint(str(ArrayNodes[RootNode][1]))\nif ArrayNodes[RootNode][2] != -1:\nInOrder(ArrayNodes, ArrayNodes[RootNode][2])\nVB.NET\nSub InOrder(ArrayNodes, RootNode)\nIf ArrayNodes(RootNode, 0) <> -1 Then\nInOrder(ArrayNodes, ArrayNodes(RootNode, 0))\nEnd If\nConsole.WriteLine(ArrayNodes(RootNode, 1))\nIf ArrayNodes(RootNode, 2) <> -1 Then\nInOrder(ArrayNodes, ArrayNodes(RootNode, 2))\nEnd If\nEnd Sub\nJava\npublic static void InOrder(Integer Root){\nif (ArrayNodes[Root][0] != -1){\nInOrder(ArrayNodes[Root][0]);\n}\nSystem.out.println(ArrayNodes[Root][1]);\nif(ArrayNodes[Root][2] != -1){\nInOrder(ArrayNodes[Root][2]);\n}\n}\n© UCLES 2021 Page 22 of 23\n\n3(e)(ii) 1 mark showing output: 1\n4\n5\n6\n8\n9\n10\n11\n12\n15\n20\n© UCLES 2021 Page 23 of 23",
      "source_pages": [
        17,
        18,
        19,
        20,
        21,
        22,
        23
      ],
      "source_pdf": "_source-pdfs/2021-oct-nov/ms/9618_w21_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2021-Oct-Nov/9618_w21_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w21_ms_42-p17.png",
        "../answer-assets/9618_w21_ms_42-p18.png",
        "../answer-assets/9618_w21_ms_42-p19.png",
        "../answer-assets/9618_w21_ms_42-p20.png",
        "../answer-assets/9618_w21_ms_42-p21.png",
        "../answer-assets/9618_w21_ms_42-p22.png",
        "../answer-assets/9618_w21_ms_42-p23.png"
      ]
    },
    {
      "id": "9618-2022-mj-31-q01",
      "question_id": "9618-2022-mj-31-q01",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 1,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "1(a) LibraryBook.Title  \"A Level Computer Science\" 2\nLibraryBook.Fiction  FALSE\n\n1(b)(i) DECLARE NumberOfCopies : 1 .. 10 1\n\n1(b)(ii) DECLARE AccessionNumber : ARRAY[1:NumberOfCopies] OF INTEGER 2\n\n1(c) Any two from 3\n A data type constructed by a programmer // not a primitive data type\n A data type that references at least one other data type…\n … the data types can be primitive, or user defined\nOne mark for an example\n Class / object / set\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2022-mj-31-q02",
      "question_id": "9618-2022-mj-31-q02",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 2,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) type(caracal, wild). 2\nhair(caracal, short).\n\n2(b) persian 1\n\n2(c)(i) type(Pet, domestic). 1\n\n2(c)(ii) spots(WildSpotty, yes) 2\n,type(WildSpotty, wild).\n© UCLES 2022 Page 4 of 11",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2022-mj-31-q03",
      "question_id": "9618-2022-mj-31-q03",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "3 Circuit switching max four marks 8\nAny two from\n a dedicated circuit\n circuit is established before transmission starts //\ncircuit is released after transmission ends\n data is transferred using the whole bandwidth\n all data is transferred over the same route\nTwo from\n Advantage – data /frames arrive in order and do not need to be reassembled\n Disadvantage – nobody else can use the same circuit even if it is idle //less secure as only one route used\nPacket switching max four marks\nAny two from\n data is split into packets\n each packet is given its own route\n the routing for a packet depends on the congestion\n packets may not arrive in the order sent\nTwo from\n Advantage – packets can be rerouted if there are problems// more secure as harder to intercept messages\n Disadvantage – time taken to reassemble packets at the destination\n© UCLES 2022 Page 5 of 11",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_31-p05.png"
      ]
    },
    {
      "id": "9618-2022-mj-31-q04",
      "question_id": "9618-2022-mj-31-q04",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 4,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "4(a) RISC max 2 any two from: 4\n Uses simple instructions\n Uses fixed length instructions\n Instructions only require one clock cycle\n Uses many registers\n Makes use of pipelining\n Hardwired CU\nCISC max 2 any two from:\n Uses many instruction formats\n Uses variable length instructions\n Makes use of different addressing modes\n Uses few registers\n Has a large instruction set\n Requires complex circuits\n Frequently uses cache\n Instructions (converted to sub-instructions that) may require many clock cycles\n Programmable CU\n\n4(b) One mark for each difference max 2 from: 2\n RISC has fewer instructions // CISC has more instructions\n RISC has many registers // CISC has few registers\n RISC’s instructions are simpler // CISC’s instructions are more complex\n RISC has a few instruction formats / CISC has many instruction formats\n RISC usually uses single-cycle instructions// CISC uses multi-cycle instructions\n RISC uses fixed-length instructions // CISC uses variable-length instructions\n RISC has better pipelineability // CISC has poorer pipelineability\n RISC requires less complex circuits// CISC requires more complex circuits\n RISC has fewer addressing modes // CISC has more addressing modes\n RISC makes more use of RAM// CISC makes more use of cache/less use of RAM\n RISC has a hard-wired control unit // CISC has a programmable control unit\n RISC only uses load and store instructions to address memory // CISC has many types of instructions to address\nmemory\n© UCLES 2022 Page 6 of 11",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2022-mj-31-q05",
      "question_id": "9618-2022-mj-31-q05",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 12,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark for each in order jk+jk-/ 2\njk+\njk-/\n\n5(b)(i) 1 mark per ring 4\nDo not allow operators in stacks\n2\n3 3 6\n10 10 10 10 4\n10 10 10 10 10 10 40\n\n5(b)(ii) Any four from Max 4 4\nMax 3 generic answer only\n Working from left to right in the expression\n PUSH 10/m onto the stack\n PUSH the following numbers (10/m, 3/j, 2/k) onto the stack\n When the first operator ,*, is reached\n … POP the top two numbers, 2/k and 3/j\n … apply the operation\n PUSH result back onto stack\n Continue to the end of the expression\n\n5(c) Any two from 2\n recursion\n implementation of ADTs e.g. linked lists\n procedure calls\n interrupt handling (storing contents of registers etc)\n© UCLES 2022 Page 7 of 11",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2022-mj-31-q06",
      "question_id": "9618-2022-mj-31-q06",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "6 Two marks each benefit description max 4 6\nNew system can be tried on different virtual hardware (1)\nwithout need to purchase the hardware (1)\nEasier to recover if software emulating the new computer causes system crash (1) as VM provides protection to other\nsoftware (1)\nEmulate programs for the new computer system that are not compatible with the host computer / operating system (1) by\nusing the guest operating system on the old computer (1)\nMore than one new computer system can be emulated (1) this allows multiple operating systems to coexist on a single\ncomputer(1)\nTwo marks each limitation description max 2 from:\nVirtual machines may not be able to emulate the new hardware (1) because this hardware may have been developed since\nthe virtual machine was developed (1)\nUsing virtual machine means execution of extra code // A virtual machine might not be as efficient // resources e.g. memory\nor processor time are shared (1) processing time increased // performance degrades (1)\nUse of a virtual machine increases the maintenance overheads (1) because both host system and the virtual machine must\nbe maintained (1)\n© UCLES 2022 Page 8 of 11",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_31-p08.png"
      ]
    },
    {
      "id": "9618-2022-mj-31-q07",
      "question_id": "9618-2022-mj-31-q07",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 7,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 11,
      "status": "available",
      "reason": null,
      "text": "7(a) 1 mark per point 5\nAcrylic has attribute Soft of type BOOLEAN\nWool has attribute WoolType with suitable data type\nAcrylic and Wool have method YarnInfo()\nAcrylic, Wool and Mix at least one inherit (one arrow correct) from Yarn …\n… Acrylic, Wool and Mix all inherit (all arrows correct) from Yarn\nYarn\nName: STRING\nColour: STRING\nBatchCode: STRING\nWeight: INTEGER\nNumberBalls: INTEGER\nType: STRING\nConstructor()\nEditNumberBalls()\nYarnInfo()\nAcrylic Wool Mix\nWoolType: STRING Percentage: INTEGER\nSoft: BOOLEAN\nConstructor() Constructor()\nConstructor() YarnInfo() YarnInfo()\nYarnInfo()\n© UCLES 2022 Page 9 of 11\n\n7(b) Properties max 2: 6\n the data items / attributes\n the data types // characteristics\n defined in a class\nMethods max 2:\n the procedures/ functions / programmed instructions in a\nclass / super class / base class\n … implementing the behaviours\n … that act on the properties / attributes\nInheritance max 2:\n Methods and properties / attributes contained in one class/ super class / base class\n Are made available to / reused by another class/ derived class\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_31-p09.png",
        "../answer-assets/9618_s22_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2022-mj-31-q08",
      "question_id": "9618-2022-mj-31-q08",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 8,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a)(i) Any two from 2\n To ensure the message is authentic // came from a trusted source\n To ensure that only the intended receiver is able to understand the message\n To ensure the message has not been altered during transmission\n Non-repudiation, neither the sender or receiver can deny the transmission occurred\n\n8(a)(ii) Symmetric 2\nAsymmetric\n\n8(b)(i) Any two from 2\n Any eavesdropping can be identified (as the state will be changed)\n Integrity of the key once transferred can be guaranteed (cannot be copied and decrypted at a later date)\n Longer/more secure keys can be exchanged\n\n8(b)(ii) Any two from 2\n Limited range\n requires dedicated fibre (optic) line and specialist hardware\n cost of dedicated fibre (optic) line and specialist hardware is expensive\n polarisation of light may be altered whilst travelling down fibre optic cables\n© UCLES 2022 Page 10 of 11",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_31.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2022-mj-31-q09",
      "question_id": "9618-2022-mj-31-q09",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 9,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "9(a) LDM #500: Immediate 500 3\nLDD 500: Direct 100\nLDI 500: Indirect 20\n\n9(b) 7\nInstruction\nLabel Opcode Operand\nLDM #20\nSTO Twenty\nLDI Y\nADD Twenty\nSTO Z\nTwenty: #20\nY:\nZ:\nOne mark for LDM #20 seen\nOne mark for storing 20 at any address\nOne mark for labelling that address e.g. Twenty away from the program code\nOne mark for labelling addresses away from the program code as Y and Z\nOne mark for correct use of LDI Y\nOne mark for correct use of STO Z\nOne mark for correct use of ADD with labelled address\n© UCLES 2022 Page 11 of 11",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_31-p11.png"
      ]
    },
    {
      "id": "9618-2022-mj-32-q01",
      "question_id": "9618-2022-mj-32-q01",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 1,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "1(a) BuildingRegister.BuildingID  1067 2\nBuildingRegister.BuildingGroup  \"house\"\n\n1(b)(i) One mark: TYPE BuildingType = 2\nOne mark: (house, bungalow, apartment, farm)\nTYPE BuildingType = (house, bungalow, apartment, farm)\n\n1(b)(ii) DECLARE BuildingGroup : BuildingType 1\n\n1(b)(iii) BuildingRegister.BuildingGroup  house 1\n\n1(c)(i) PRIVATE OwnerName : STRING 1\n\n1(c)(ii) To ensure that attributes can only be accessed by the class’s own methods 2\nTo enforce encapsulation // ensure they are hidden\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2022-mj-32-q02",
      "question_id": "9618-2022-mj-32-q02",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 2,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "2(a) studies(sam, history). 2\ntutors(nina, sam).\n\n2(b) freya, hua // hua, freya 1\n\n2(c) one mark for correct use of X 4\none mark for two other variables in correct positions\none mark for three correct clauses in any order\none mark for correct syntax\nteaches(R, S),\nstudies(X, S),\ntutors(R, X).\n© UCLES 2022 Page 4 of 9",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2022-mj-32-q03",
      "question_id": "9618-2022-mj-32-q03",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "3(a) Protocol one mark, description one mark, max four 4\nAny two from\n HTTP(S) (1) for sending and receiving web pages / hypertext documents (1)\n FTP (1) for sending and receiving files over a network / between devices (1)\n SMTP (1) for sending/uploading emails /push protocol (1)\n POP(3) (1) for receiving/downloading emails /pull protocol (1)\n IMAP (1) for receiving/downloading emails /pull protocol (1)\n\n3(b) Layer one mark, matching function one mark, max four 4\nAny two from\n Transport (1) handles packets (1)\n Internet (1) handles transmission of data using\nIP addresses // provides (optimal) route (1)\n Network Access (Interface) // (Data) Link // Physical (1) Handles how data is physically sent (1)\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2022-mj-32-q04",
      "question_id": "9618-2022-mj-32-q04",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 4,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 13,
      "status": "available",
      "reason": null,
      "text": "4(a)  An unsigned integer,12, is used instead of the last variable 2\n// 12 is not a valid variable\n The variable Z is not a valid variable / missing an unsigned integer after the Z\n\n4(b) One mark per bullet point 5\n <variable> ::= <letter><unsigned_integer>\n <unsigned_integer> ::= <digit>|<digit><digit>\n <digit> ::= 1 | 2 | 3\nand <operator> ::= + | - | *\n <assignment_statement> ::= <variable> =\n <variable><operator><variable>\n© UCLES 2022 Page 5 of 9\n\n4(c)(i) 3\nOne mark adding both boxes… unsigned integer unsigned integer\nOne mark for correct position(s) and connector(s) …\nOne mark … rest correct\n(assignment statement)\nunsigned integer unsigned integer\nvariable = variable operator variable\n\n4(c)(ii) Max three 3\nOne mark for\n<assignment_statement>::=<variable>=\nOne mark two or three correct options or two marks if all four options correct\n<variable><operator><variable>\n|<variable><operator><unsigned_integer>\n|<unsigned_integer><operator><variable>\n|<unsigned_integer><operator><unsigned_integer>\n<assignment_statement>::=<variable>= <variable><operator><variable>|<variable><operator>\n<unsigned_integer>|<unsigned_integer><operator><variable>\n|<unsigned_integer><operator><unsigned_integer>\nor\nOne mark for each section\n<operand>::=<variable>|<unsigned_integer>\n<assignment_statement>::=<variable>=\n<operand><operator><operand>\n<operand>::=<variable>|<unsigned_integer>\n<assignment_statement>::=<variable>=<operand><operator><operand>\n© UCLES 2022 Page 6 of 9",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_32-p05.png",
        "../answer-assets/9618_s22_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2022-mj-32-q05",
      "question_id": "9618-2022-mj-32-q05",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 5,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "5 SIMD (1) many/array processors execute the same instruction using different data sets (1) 6\nMISD (1) many processors (using different instructions) use the same data set (1)\nMIMD (1) many processors (using different instructions) using different data sets (1)\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2022-mj-32-q06",
      "question_id": "9618-2022-mj-32-q06",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "6(a) 1 mark per correct output column 2\nINPUT OUTPUT\nA B E F\n0 0 0 0\n0 1 1 0\n1 0 1 0\n1 1 0 1\n\n6(b)(i) Half adder 1\n\n6(b)(ii) Purpose of E: Sum 2\nPurpose of F: Carry\n© UCLES 2022 Page 7 of 9",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2022-mj-32-q07",
      "question_id": "9618-2022-mj-32-q07",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 7,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "7(a) Any three from 3\nMP1 enquiry made to Certificate Authority (CA)\nMP2 enquirer’s details checked by CA\nMP3 if enquirer details verified by CA then public key is agreed\nMP4 CA creates/issues certificate that includes the enquirers public key\nMP5 encrypting data sent to/by CA with the CA’s public/private key\n\n7(b)(i) MP1 The message is hashed with (the agreed hashing algorithm)… 3\nMP2 … to produce a message digest\nMP3 The message digest is then encrypted with the sender’s private key to form the digital signature\n\n7(b)(ii) Any four from 4\nMP1 The message together with the digital signature is decrypted using the receiver’s private key\nMP2 The digital signature received is decrypted with the sender’s public key to recover the message digest sent\nMP3 The decrypted message received is hashed with the agreed hashing algorithm to reproduce the message digest\nof the message received\nMP4 The two message digests are compared\nMP5 … if they are the same the message has not been altered // if they are different the message has been altered\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_32.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_32-p08.png"
      ]
    },
    {
      "id": "9618-2022-mj-32-q08",
      "question_id": "9618-2022-mj-32-q08",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 8,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 13,
      "status": "available",
      "reason": null,
      "text": "8(a) INTEGER 4",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_32-p08.png"
      ]
    },
    {
      "id": "9618-2022-mj-32-q09",
      "question_id": "9618-2022-mj-32-q09",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 9,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "9 // LENGTH(MyList) - 1\nIndex + 1\n\"Value not found\" (or any similar phrase)\n8(b)(i) The list to be searched must be ordered/sorted 1\n© UCLES 2022 Page 8 of 9\n\n9 To trap (some) runtime errors 4\nTo prevent a program halting unexpectedly\nTo produce meaningful error messages for these errors\nExample divide by zero // end of file // file not found\n© UCLES 2022 Page 9 of 9",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_32-p08.png",
        "../answer-assets/9618_s22_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2022-mj-33-q01",
      "question_id": "9618-2022-mj-33-q01",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 1,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "1(a) LibraryBook.Title  \"A Level Computer Science\" 2\nLibraryBook.Fiction  FALSE\n\n1(b)(i) DECLARE NumberOfCopies : 1 .. 10 1\n\n1(b)(ii) DECLARE AccessionNumber : ARRAY[1:NumberOfCopies] OF INTEGER 2\n\n1(c) Any two from 3\n A data type constructed by a programmer // not a primitive data type\n A data type that references at least one other data type…\n … the data types can be primitive, or user defined\nOne mark for an example\n Class / object / set\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2022-mj-33-q02",
      "question_id": "9618-2022-mj-33-q02",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 2,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) type(caracal, wild). 2\nhair(caracal, short).\n\n2(b) persian 1\n\n2(c)(i) type(Pet, domestic). 1\n\n2(c)(ii) spots(WildSpotty, yes) 2\n,type(WildSpotty, wild).\n© UCLES 2022 Page 4 of 11",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2022-mj-33-q03",
      "question_id": "9618-2022-mj-33-q03",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "3 Circuit switching max four marks 8\nAny two from\n a dedicated circuit\n circuit is established before transmission starts //\ncircuit is released after transmission ends\n data is transferred using the whole bandwidth\n all data is transferred over the same route\nTwo from\n Advantage – data /frames arrive in order and do not need to be reassembled\n Disadvantage – nobody else can use the same circuit even if it is idle //less secure as only one route used\nPacket switching max four marks\nAny two from\n data is split into packets\n each packet is given its own route\n the routing for a packet depends on the congestion\n packets may not arrive in the order sent\nTwo from\n Advantage – packets can be rerouted if there are problems// more secure as harder to intercept messages\n Disadvantage – time taken to reassemble packets at the destination\n© UCLES 2022 Page 5 of 11",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_33-p05.png"
      ]
    },
    {
      "id": "9618-2022-mj-33-q04",
      "question_id": "9618-2022-mj-33-q04",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 4,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "4(a) RISC max 2 any two from: 4\n Uses simple instructions\n Uses fixed length instructions\n Instructions only require one clock cycle\n Uses many registers\n Makes use of pipelining\n Hardwired CU\nCISC max 2 any two from:\n Uses many instruction formats\n Uses variable length instructions\n Makes use of different addressing modes\n Uses few registers\n Has a large instruction set\n Requires complex circuits\n Frequently uses cache\n Instructions (converted to sub-instructions that) may require many clock cycles\n Programmable CU\n\n4(b) One mark for each difference max 2 from: 2\n RISC has fewer instructions // CISC has more instructions\n RISC has many registers // CISC has few registers\n RISC’s instructions are simpler // CISC’s instructions are more complex\n RISC has a few instruction formats / CISC has many instruction formats\n RISC usually uses single-cycle instructions// CISC uses multi-cycle instructions\n RISC uses fixed-length instructions // CISC uses variable-length instructions\n RISC has better pipelineability // CISC has poorer pipelineability\n RISC requires less complex circuits// CISC requires more complex circuits\n RISC has fewer addressing modes // CISC has more addressing modes\n RISC makes more use of RAM// CISC makes more use of cache/less use of RAM\n RISC has a hard-wired control unit // CISC has a programmable control unit\n RISC only uses load and store instructions to address memory // CISC has many types of instructions to address\nmemory\n© UCLES 2022 Page 6 of 11",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2022-mj-33-q05",
      "question_id": "9618-2022-mj-33-q05",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 12,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark for each in order jk+jk-/ 2\njk+\njk-/\n\n5(b)(i) 1 mark per ring 4\nDo not allow operators in stacks\n2\n3 3 6\n10 10 10 10 4\n10 10 10 10 10 10 40\n\n5(b)(ii) Any four from Max 4 4\nMax 3 generic answer only\n Working from left to right in the expression\n PUSH 10/m onto the stack\n PUSH the following numbers (10/m, 3/j, 2/k) onto the stack\n When the first operator ,*, is reached\n … POP the top two numbers, 2/k and 3/j\n … apply the operation\n PUSH result back onto stack\n Continue to the end of the expression\n\n5(c) Any two from 2\n recursion\n implementation of ADTs e.g. linked lists\n procedure calls\n interrupt handling (storing contents of registers etc)\n© UCLES 2022 Page 7 of 11",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2022-mj-33-q06",
      "question_id": "9618-2022-mj-33-q06",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "6 Two marks each benefit description max 4 6\nNew system can be tried on different virtual hardware (1)\nwithout need to purchase the hardware (1)\nEasier to recover if software emulating the new computer causes system crash (1) as VM provides protection to other\nsoftware (1)\nEmulate programs for the new computer system that are not compatible with the host computer / operating system (1) by\nusing the guest operating system on the old computer (1)\nMore than one new computer system can be emulated (1) this allows multiple operating systems to coexist on a single\ncomputer(1)\nTwo marks each limitation description max 2 from:\nVirtual machines may not be able to emulate the new hardware (1) because this hardware may have been developed since\nthe virtual machine was developed (1)\nUsing virtual machine means execution of extra code // A virtual machine might not be as efficient // resources e.g. memory\nor processor time are shared (1) processing time increased // performance degrades (1)\nUse of a virtual machine increases the maintenance overheads (1) because both host system and the virtual machine must\nbe maintained (1)\n© UCLES 2022 Page 8 of 11",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_33-p08.png"
      ]
    },
    {
      "id": "9618-2022-mj-33-q07",
      "question_id": "9618-2022-mj-33-q07",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 7,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 11,
      "status": "available",
      "reason": null,
      "text": "7(a) 1 mark per point 5\nAcrylic has attribute Soft of type BOOLEAN\nWool has attribute WoolType with suitable data type\nAcrylic and Wool have method YarnInfo()\nAcrylic, Wool and Mix at least one inherit (one arrow correct) from Yarn …\n… Acrylic, Wool and Mix all inherit (all arrows correct) from Yarn\nYarn\nName: STRING\nColour: STRING\nBatchCode: STRING\nWeight: INTEGER\nNumberBalls: INTEGER\nType: STRING\nConstructor()\nEditNumberBalls()\nYarnInfo()\nAcrylic Wool Mix\nWoolType: STRING Percentage: INTEGER\nSoft: BOOLEAN\nConstructor() Constructor()\nConstructor() YarnInfo() YarnInfo()\nYarnInfo()\n© UCLES 2022 Page 9 of 11\n\n7(b) Properties max 2: 6\n the data items / attributes\n the data types // characteristics\n defined in a class\nMethods max 2:\n the procedures/ functions / programmed instructions in a\nclass / super class / base class\n … implementing the behaviours\n … that act on the properties / attributes\nInheritance max 2:\n Methods and properties / attributes contained in one class/ super class / base class\n Are made available to / reused by another class/ derived class\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_33-p09.png",
        "../answer-assets/9618_s22_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2022-mj-33-q08",
      "question_id": "9618-2022-mj-33-q08",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 8,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a)(i) Any two from 2\n To ensure the message is authentic // came from a trusted source\n To ensure that only the intended receiver is able to understand the message\n To ensure the message has not been altered during transmission\n Non-repudiation, neither the sender or receiver can deny the transmission occurred\n\n8(a)(ii) Symmetric 2\nAsymmetric\n\n8(b)(i) Any two from 2\n Any eavesdropping can be identified (as the state will be changed)\n Integrity of the key once transferred can be guaranteed (cannot be copied and decrypted at a later date)\n Longer/more secure keys can be exchanged\n\n8(b)(ii) Any two from 2\n Limited range\n requires dedicated fibre (optic) line and specialist hardware\n cost of dedicated fibre (optic) line and specialist hardware is expensive\n polarisation of light may be altered whilst travelling down fibre optic cables\n© UCLES 2022 Page 10 of 11",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_33.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2022-mj-33-q09",
      "question_id": "9618-2022-mj-33-q09",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 9,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "9(a) LDM #500: Immediate 500 3\nLDD 500: Direct 100\nLDI 500: Indirect 20\n\n9(b) 7\nInstruction\nLabel Opcode Operand\nLDM #20\nSTO Twenty\nLDI Y\nADD Twenty\nSTO Z\nTwenty: #20\nY:\nZ:\nOne mark for LDM #20 seen\nOne mark for storing 20 at any address\nOne mark for labelling that address e.g. Twenty away from the program code\nOne mark for labelling addresses away from the program code as Y and Z\nOne mark for correct use of LDI Y\nOne mark for correct use of STO Z\nOne mark for correct use of ADD with labelled address\n© UCLES 2022 Page 11 of 11",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_33-p11.png"
      ]
    },
    {
      "id": "9618-2022-mj-41-q01",
      "question_id": "9618-2022-mj-41-q01",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 29,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per mark point 2\n declaration of at least 1 array with appropriate identifier\n … 11 elements (and appropriate data type(s))\nExample program code:\nJava\nPublic static String[][] FileData = new String[10][2];\nVB.NET\nDim FileData(0 To 9, 0 To 1) As String\nPython\nFileData = [[\"\"] *2 for i in range(11)] #string\n© UCLES 2022 Page 4 of 34\n\n1(b) 1 mark per mark point to max 6 6\n procedure declaration (and end)\n Opening the text file (to read)\n Looping 10 times // looping until end of file (e.g. 10 pairs of data)\n Reading in each pair of lines …\n … storing player name and score in data structure(s)\n closing the file\n Try and catch on file handling …\n … with suitable output\nExample program code:\nJava\npublic static void ReadHighScores(){\nString Filename = \"HighScore.txt\";\ntry{\nFileReader F = new FileReader(Filename);\nBufferedReader Reader = new BufferedReader(F);\nfor(Integer x = 0; x < 10; x++){\nFileData[x][0] = Reader.readLine();\nFileData[x][1] = Reader.readLine();\n}\nReader.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No file found\");\n}\n}\n© UCLES 2022 Page 5 of 34\n\n1(b) Python\ndef ReadHighScores():\nFilename = \"HighScore.txt\"\nFile = open(Filename, 'r')\nfor x in range(0, 10):\nFileData[x][0] = File.readline()[:3]\nFileData[x][1] = File.readline()\nFile.close\nVB.NET\nSub ReadHighScores()\nDim Textfile As String = \"HighScore.txt\"\nDim FileReader As New System.IO.StreamReader(textfile)\nDim DataEntered As Integer = 0\nWhile FileReader.Peek <> -1 and DataEntered < 10\nFileData(DataEntered, 0) = FileReader.ReadLine()\nFileData(DataEntered, 1) = FileReader.ReadLine()\nDataEntered = DataEntered + 1\nEnd While\nFileReader.Close()\nEnd Sub\n© UCLES 2022 Page 6 of 34\n\n1(c) 1 mark per mark point 3\n procedure heading and end\n looping through all data structure elements\n outputting player name, space, score. Each player must start on a new line\nExample program code:\nJava\npublic static void OutputHighScores(){\nfor(Integer x = 0; x < 11; x++){\nSystem.out.println(FileData[x][0] + \" \" + FileData[x][1]);\n}\n}\nPython\ndef OutputHighScores ():\nfor x in range(0, 11):\nOutput = FileData[x][0] + \" \" + FileData[x][1]\nprint(Output)\nVB.NET\nSub OutputHighScores ()\nFor x = 0 To 10\nConsole.WriteLine(FileData(x, 0) & \" \" & FileData(x,1))\nNext\nEnd Sub\n© UCLES 2022 Page 7 of 34\n\n1(d)(i) 1 mark per mark point 2\n (Main program) calls ReadHighScores()\n … then calls OutputHighScores()\nExample program code:\nJava\npublic static void main(String[] args){\nReadHighScores();\nOutputHighScores();\n}\nPython\nReadHighScores()\nOutputHighScore()\nVB.NET\nSub Main()\nReadHighScores()\nOutputHighScore()\nConsole.ReadLine()\nEnd Sub\n© UCLES 2022 Page 8 of 34\n\n1(d)(ii) 1 mark for screenshot showing the 10 names and scores from the file (and one extra blank space may, or may not be 1\nincluded)\ne.g.\n© UCLES 2022 Page 9 of 34\n\n1(e)(i) 1 mark per mark point 3\n Read in a username and score\n Validate username input (3-characters, or just selecting the first 3 characters if there are definitely 3 characters)\n Validate score input (integer (cast) between 1 and 100 000 inclusive)\nExample program code:\nJava\npublic static void main(String[] args){\nScanner scanner = new Scanner(System.in);\nReadHighScores();\nOutputHighScores();\nString Username = \"ABCD\"\ndo{\nSystem.out.println(\"Enter your Username\");\nUsername = scanner.nextLine();\n}while(Username.length != 3)\nString Score = \"-1\";\ndo{\nSystem.out.println(\"Enter your score\");\nScore = scanner.nextLine();\n}while(Integer.parseInt(Score) < 1 || Integer.parseInt(Score) > 100000);\n}\nPython\nUsername = \"ABCD\"\nwhile len(Username) != 3:\nUsername = input(\"Enter your Username\")\nscore = -1\nwhile Score < 1 or Score > 100000:\nScore = int(input(\"Enter score\"))\n© UCLES 2022 Page 10 of 34\n\n1(e)(i) VB.NET\nConsole.WriteLine(\"Enter Username\")\nUsername = \"ABCD\"\nWhile Username.length <> 3\nUsername = Console.ReadLine()\nEnd While\nScore = -1\nWhile Score < 1 Or Score > 100000\nConsole.WriteLine(\"Enter score\")\nScore = Console.ReadLine()\nEnd While\n© UCLES 2022 Page 11 of 34\n\n1(e)(ii) 1 mark per mark point 5\n procedure declaration (and close where appropriate) taking 1 string and 1 integer parameter\n looping through each array element\n … finding the position to input the score\n storing the array data in the correct position\n storing the name and score in the correct position\nExample program code:\nJava\npublic static void Arrange(String Username, String Score){\nString Temp1; String Temp2; String Second1; String Second2;\nfor(Integer x = 0; x < 10; x++){\nif (Integer.parseInt(Score) > Integer.parseInt(FileData[x][1])){\nTemp1 = FileData[x][0];\nTemp2 = FileData[x][1];\nFileData[x][0] = Username;\nFileData[x][1] = Score;\nfor(Integer Count = x+1; Count < 10; Count++){\nsecond1 = FileData[count][0];\nsecond2 = FileData[count][1];\nFileData[Count][0] = Temp1;\nFileData[Count][1] = Temp2;\nTemp1 = Second1;\nTemp2 = Second2;\nx = 11;\n}\n}\n}\n}\n© UCLES 2022 Page 12 of 34\n\n1(e)(ii) Python\ndef Arrange(Username, Score):\nfor x in range(0, 10):\nif Score > FileData[x][1]:\nTemp1 = FileData[x][0]\nTemp2 = FileData[x][1]\nFileData[x][0] = Username\nFileData[x][1] = Score\nCount = x+1\nwhile(Count < 10):\nSecond1 = FileData[Count][0]\nSecond2 = FileData[Count][1]\nFileData[Count][0] = Temp1\nFileData[Count][1] = Temp2\nTemp1 = Second1\nTemp2 = Second2\nCount = Count + 1\nbreak;\n© UCLES 2022 Page 13 of 34\n\n1(e)(ii) VB.NET\nSub Arrange(Username, Score)\nDim Temp1 As String\nDim Temp2 As String\nDim Second1 As String\nDim Second2 As String\nFor x = 0 To 9\nIf Score > Integer.Parse(FileData(x, 1)) Then\nTemp1 = FileData(x, 0)\nTemp2 = FileData(x, 1)\nFileData(x, 0) = Username\nFileData(x, 1) = Score.ToString\nFor Count = x + 1 To 9\nSecond1 = FileData(Count, 0)\nSecond2 = FileData(Count, 1)\nFileData(Count, 0) = Temp1\nFileData(Count, 1) = Temp2\nTemp1 = Second1\nTemp2 = Second2\nx = 10\nNext\nEnd If\nNext\nEnd Sub\n© UCLES 2022 Page 14 of 34\n\n1(e)(iii) 1 mark per mark point 2\n Calling sorting procedure with correct parameters\n Outputting the array before and after procedure call\nExample program code:\nJava\npublic static void main(String[] args){\nScanner scanner = new Scanner(System.in);\nReadHighScores();\nOutputHighScores();\nSystem.out.println(\"Enter your Username\");\nString Username = scanner.nextLine();\nString Score = \"-1\";\ndo{\nSystem.out.println(\"Enter your score\");\nScore = scanner.nextLine();\n}while(Integer.parseInt(Score) < 0 || Integer.parseInt(Score) > 100000);\narrange(Username, Score);\nOutputHighScores();\n}\nPython\nReadHighScores()\nOutputHighScore()\nUsername = input(\"Enter your Username\")\nScore = -1\nwhile Score < 0 or Score > 100000:\nScore = int(input(\"Enter score\"))\nArrange(Username, Score)\nOutputHighScore()\n© UCLES 2022 Page 15 of 34\n\n1(e)(iii) VB.NET\nOutputHighScore()\nUsername = Console.ReadLine()\nScore = -1\nWhile(score < 0 or Score > 100000)\nScore = Console.ReadLine()\nEnd While\nArrange(Username, Score)\nOutputHighScore()\n\n1(e)(iv) 1 mark for screenshot. JKL, 9999 entered. After shows JKL in the second position. 1\ne.g.\n© UCLES 2022 Page 16 of 34\n\n1(f) 1 mark per mark point to max 4 4\n procedure header and end (where appropriate) and opening the file NewHighScore.txt to write\n Closing the file\n Looping through all 10 array values …\n … writing the username, then the score\n Exception handling and appropriate output\nExample program code:\nJava\npublic static void WriteTopTen(){\nString Filename = \"NewHighScore.txt\";\ntry{\nFileWriter F = new FileWriter(Filename);\nBufferedWriter Out = new BufferedWriter(F);\nfor(Integer x = 0; x < 10; x++){\nOut.write(FileData[x][0] + \"\\n\");\nOut.write(FileData[x][1] + \"\\n\");\n}\nOut.close();\n} catch(Exception e){\nSystem.err.println(\"No file\");\n}\n}\nPython\ndef WriteTopTen():\nFilename = \" NewHighScore.txt\"\nFilename = open(Filename, 'w')\nfor x in range(0, 10):\nFilename.write(str(FileData[x][0]) + '\\n')\nFilename.write(str(FileData[x][1]) + '\\n')\nFilename.close\n© UCLES 2022 Page 17 of 34\n\n1(f) VB.NET\nSub WriteTopTen()\nDim Filename As String = \" NewHighScore.txt\"\nDim NewFile As New System.IO.StreamWriter(Filename)\nFor x = 0 To 9\nNewFile.WriteLine(FileData(x, 0))\nNewFile.WriteLine(FileData(x, 1))\nNext\nNewFile.Close()\nEnd Sub\n© UCLES 2022 Page 18 of 34",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_41-p04.png",
        "../answer-assets/9618_s22_ms_41-p05.png",
        "../answer-assets/9618_s22_ms_41-p06.png",
        "../answer-assets/9618_s22_ms_41-p07.png",
        "../answer-assets/9618_s22_ms_41-p08.png",
        "../answer-assets/9618_s22_ms_41-p09.png",
        "../answer-assets/9618_s22_ms_41-p10.png",
        "../answer-assets/9618_s22_ms_41-p11.png",
        "../answer-assets/9618_s22_ms_41-p12.png",
        "../answer-assets/9618_s22_ms_41-p13.png",
        "../answer-assets/9618_s22_ms_41-p14.png",
        "../answer-assets/9618_s22_ms_41-p15.png",
        "../answer-assets/9618_s22_ms_41-p16.png",
        "../answer-assets/9618_s22_ms_41-p17.png",
        "../answer-assets/9618_s22_ms_41-p18.png"
      ]
    },
    {
      "id": "9618-2022-mj-41-q02",
      "question_id": "9618-2022-mj-41-q02",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 25,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark per mark point 5\n Class Balloon declaration (and end where appropriate)\n declaration of 3 attributes as private with suitable data types\n constructor header (and end) with two parameters …\n … initialising colour and defence item to parameters\n … initialising health to 100\nExample program code:\nJava\nclass Balloon{\nprivate Integer Health;\nprivate String Colour;\nprivate String DefenceItem;\npublic Balloon(String PDefenceItem, String PColour){\nColour = PColour;\nDefenceItem = PDefenceItem;\nHealth = 100;\n}\npublic static void main(String[] args){\n}\n}\nPython\nclass Balloon:\n#Health as integer\n#Colour as string\n#DefenceItem as string\ndef __init__(self, PDefenceItem, PColour):\nself.__Health = 100\nself.__Colour = PColour\nself.__DefenceItem = PDefenceItem\n© UCLES 2022 Page 19 of 34\n\n2(a) VB.NET\nClass balloon\nPrivate Health As Integer\nPrivate Colour As String\nPrivate DefenceItem As String\nPublic Sub New(PDefenceItem, PColour)\nHealth = 100\nColour = PColour\nDefenceItem = PDefenceItem\nEnd Sub\nEnd Class\n\n2(b) 1 mark per mark point 2\n get header and close with no parameter …\n … returning defence item attribute\nExample program code:\nJava\npublic String GetDefenceItem(){\nreturn DefenceItem;\n}\nPython\ndef GetDefenceItem(self):\nreturn self.__DefenceItem\nVB.NET\nPublic Function GetDefenceItem()\nReturn DefenceItem\nEnd Function\n© UCLES 2022 Page 20 of 34\n\n2(c) 1 mark per mark point 2\n procedure header and close taking 1 parameter …\n … adding parameter value to health attribute\nExample program code:\nJava\npublic void ChangeHealth(Integer Change){\nHealth = Health + Change;\n}\nPython\ndef ChangeHealth(self, Change):\nself.__Health = self.__Health + Change\nVB.NET\nPublic Sub ChangeHealth(Change)\nHealth = Health + Change\nEnd Sub\n© UCLES 2022 Page 21 of 34\n\n2(d) 1 mark per mark point 2\n method header and close and checking if health attribute is <= 0\n Returning TRUE if health attribute <= 0 and returning FALSE otherwise\nExample program code:\nJava\npublic Boolean CheckHealth(){\nif(Health <= 0){\nreturn true;\n}else{\nreturn false;\n}\n}\nPython\ndef CheckHealth(self):\nif self.__Health <= 0:\nreturn True\nelse:\nreturn False\nVB.NET\nFunction CheckHealth()\nIf Health <= 0 Then\nReturn True\nElse\nReturn False\nEnd If\nEnd Function\n© UCLES 2022 Page 22 of 34\n\n2(e) 1 mark per mark point 3\n take as input defence method and colour (2 strings)\n instantiating new balloon object with identifier Balloon1 …\n … with both input values as parameters\nExample program code:\nJava\npublic static void main(String[] args){\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Enter balloon defence method\");\nString Method = scanner.nextLine();\nSystem.out.println(\"Enter the balloon colour\");\nString Colour = scanner.nextLine();\nBalloon Balloon1 = new Balloon(Method, Colour);\n}\nPython\nMethod = input(\"Enter balloon defence method \")\nColour = input(\"Enter the balloon colour \")\nBalloon1 = Balloon(Method, Colour)\nVB.NET\nSub Main()\nConsole.WriteLine(\"Enter balloon defence method\")\nDim Method As String = Console.ReadLine\nConsole.WriteLine(\"Enter the balloons colour\")\nDim Colour As String = Console.ReadLine\nDim Balloon1 As Balloon = New Balloon(Method, Colour)\nEnd Sub\n© UCLES 2022 Page 23 of 34\n\n2(f) 1 mark per mark point to max 8 8\n function header (and end where appropriate) and taking balloon object as parameter\n Inputting strength\n Calling ChangeHealth method for the parameter object …\n … with the input as a subtraction\n outputting the defence item for the parameter object …\n … using GetDefenceItem()\n Calling CheckHealth()for the parameter object …\n … outputting appropriate message if TRUE is returned (no health remaining)\n … outputting appropriate message if FALSE is returned (health remaining).\n Returning the updated balloon object\nExample program code:\nJava\npublic Balloon Defend(Balloon My Balloon){\nSystem.out.println(\"Enter the strength of opponent\");\nScanner scanner = new Scanner(System.in);\nInteger Strength = Integer.parseInt(scanner.nextLine());\nMyBalloon.ChangeHealth(-Strength);\nif(MyBalloon.CheckHealth() == true){\nSystem.out.println(\"Defence failed\");\n}else {\nSystem.out.println(\"Defence succeeded\");\n}\nreturn MyBalloon;\n}\n© UCLES 2022 Page 24 of 34\n\n2(f) Python\ndef Defend(MyBalloon):\nStrength = int(input(\"Enter the strength of opponent\"))\nMyBalloon.VhangeHealth(-Strength)\nprint(\"You defended with \", str(MyBalloon.GetDefenceItem()))\nif(MyBalloon.CheckHealth() == True):\nprint(\"Defence failed\")\nelse:\nprint(\"Defence succeeded\")\nreturn MyBalloon\nVB.NET\nFunction Defend(MyBalloon)\nConsole.WriteLine(\"Enter the strength of opponent\")\nDim Strength As Integer = Console.ReadLine\nMyBalloon.ChangeHealth(-Strength)\nConsole.WriteLine(\"You defended with \" & MyBalloon.GetDefenceItem)\nIf (MyBalloon.CheckHealth() = True) Then\nConsole.WriteLine(\"Defence failed\")\nElse\nConsole.WriteLine(\"Defence succeeded\")\nEnd If\nReturn MyBalloon\nEnd Function\n© UCLES 2022 Page 25 of 34\n\n2(g)(i) 1 mark each 2\n calling Defend with balloon object …\n … and stores return value over object\nExample program code:\nJava\nBalloon1 = Defend(Balloon1);\nPython\nBalloon1 = Defend(Balloon1)\nVB.NET\nBalloon1 = Defend(Balloon1)\n\n2(g)(ii) 1 mark for screenshot with: 1\nShield, Red and 50 input\nOutput stating their defence item was Shield\nOutput says health is not 0 (in some manner)\ne.g.\n© UCLES 2022 Page 26 of 34",
      "source_pages": [
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_41-p19.png",
        "../answer-assets/9618_s22_ms_41-p20.png",
        "../answer-assets/9618_s22_ms_41-p21.png",
        "../answer-assets/9618_s22_ms_41-p22.png",
        "../answer-assets/9618_s22_ms_41-p23.png",
        "../answer-assets/9618_s22_ms_41-p24.png",
        "../answer-assets/9618_s22_ms_41-p25.png",
        "../answer-assets/9618_s22_ms_41-p26.png"
      ]
    },
    {
      "id": "9618-2022-mj-41-q03",
      "question_id": "9618-2022-mj-41-q03",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 21,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per mark point 2\n Declaring variables: head pointer, tail pointer and number of items all initialised as 0 (integer)\n QueueArray declared as 1D array as string with 10 elements\nExample program code:\nJava\npublic static void main(String[] args){\nString[] QueueArray = new String[10];\nInteger QueueHeadPointer = 0;\nInteger QueueTailPointer = 0;\nInteger NumberOfItems = 0;\n}\nPython\nQueueArray = ['','','','','','','','','',''] #string\nQueueHeadPointer = 0 #integer\nQueueTailPointer = 0 #integer\nNumberOfItems = 0 #integer\nVB.NET\nSub Main()\nDim QueueArray(0 To 9) As String\nDim QueueHeadPointer As Integer = 0\nDim QueueTailPointer As Integer = 0\nDim NumberOfItems As Integer = 0\nEnd Sub\n© UCLES 2022 Page 27 of 34\n\n3(b) 1 mark per complete statement (5) 7\n1 mark for function heading and end, dealing with ByRef\n1 mark for remainder of function correct and following the logic\nFUNCTION Enqueue(BYREF QueueArray[] : STRING, BYREF HeadPointer : Integer, BYREF\nTailPointer : Integer, NumberItems : INTEGER, DataToAdd : STRING) RETURNS\nBOOLEAN\nIF NumberItems = 10 THEN\nRETURN FALSE\nENDIF\nQueueArray[TailPointer]  DataToAdd\nIF TailPointer >= 9 THEN\nTailPointer  0\nELSE\nTailPointer  TailPointer + 1\nENDIF\nNumberItems  NumberItems + 1\nRETURN TRUE\nENDFUNCTION\nExample program code:\nJava\npublic static Boolean Enqueue(String DataToAdd){\nif(NumberOfItems == 10){\nreturn false;\n}\nQueueArray[QueueTailPointer] = DataToAdd;\nif(QueueTailPointer >= 9){\nQueueTailPointer = 0;\n}else{\nQueueTailPointer = QueueTailPointer + 1;\n}\nNumberOfItems = NumberOfItems + 1;\nreturn true;\n}\n© UCLES 2022 Page 28 of 34\n\n3(b) Python\ndef Enqueue(Queue, Head, Tail, NumItems, InputData):\nif NumItems >= 10:\nreturn (False, Queue, Head, Tail, NumItems)\nQueue[Tail] = InputData\nif Tail >= 9:\nTail = 0\nelse:\nTail = Tail + 1\nNumItems = NumItems + 1\nreturn (True, Queue, Head, Tail, NumItems)\nVB.NET\nFunction Enqueue(ByRef Queue() As String, ByRef Head As Integer, ByRef Tail As Integer,\nByRef NumItems As Integer, ByRef InputData As String)\nIf NumItems = 10 Then\nReturn False\nEnd If\nQueue(Tail) = InputData\nIf Tail >= 9 Then\nTail = 0\nElse\nTail = Tail + 1\n© UCLES 2022 Page 29 of 34\n\n3(c) 1 mark per mark point to max 6 6\n Function header and end\n checking if queue is empty …\n … returning False\n If not empty accessing and returning item at head pointer\n … incrementing head pointer …\n … changing head pointer to 0 if it's more than 9 after incrementing\n … decrement number of items\nExample program code:\nJava\npublic static String Dequeue(){\nif(NumberOfItems == 0){\nreturn \"FALSE\";\n}else{\nString ReturnValue = QueueArray[QueueHeadPointer];\nQueueHeadPointer = QueueHeadPointer + 1;\nif(QueueHeadPointer >= 9){\nQueueHeadPointer = 0;\n}\nNumberOfItems = NumberOfItems – 1;\nreturn ReturnValue;\n}\n}\nPython\ndef Dequeue(Queue, Head, Tail, NumItems):\nif NumItems == 0:\nreturn (false, Queue, Head, Tail, NumItems)\nelse:\nReturnValue = Queue(Head)\nHead = Head + 1\nif Head >= 9:\nHead = 0\nNumItems = NumItems - 1\nreturn(ReturnValue, Queue, Head, Tail, NumItems)\n© UCLES 2022 Page 30 of 34\n\n3(c) VB.NET\nFunction Dequeue(ByRef QueueArray() As String, ByRef QueueHeadPointer As Integer, ByRef\nQueueTailpointer As Integer, ByRef NumberOfItems As Integer)\nIf NumberOfItems = 0 Then\nReturn \"False\"\nElse\nDim ReturnValue = QueueArray(QueueHeadPointer)\nQueueHeadPointer = QueueHeadPointer + 1\nIf QueueHeadPointer >= 9 Then\nQueueHeadPointer = 0\nEnd If\nNumberOfItems = NumberOfItems - 1\nReturn ReturnValue\nEnd If\nEnd Function\n© UCLES 2022 Page 31 of 34\n\n3(d)(i) 1 mark per mark point 5\n Taking 11 inputs…\n … calling Enqueue with each of the 11 inputs …\n … outputting an appropriate message if added or not added\n Calling Dequeue twice …\n … outputting return value each time\nExample program code:\nJava\npublic static void main(String args[]){\nString InputString;\nfor(Integer x = 0; x < 11; x++){\nSystem.out.println(\"Enter a string\");\nScanner scanner = new Scanner(System.in);\nInputString = scanner.nextLine();\nif(Enqueue(InputString)){\nSystem.out.println(\"Successful\");\n}else{\nSystem.out.println(\"Unsuccessful\");\n}\n}\nSystem.out.println(Dequeue());\nSystem.out.println(Dequeue());\n}\n© UCLES 2022 Page 32 of 34\n\n3(d)(i) Python\nfor x in range(0, 11):\nInputString = input(\"Enter a string\")\nReturnValue, QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems =\nEnqueue(QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems, InputString)\nif ReturnValue == True:\nprint(\"Successful\")\nelse:\nprint(\"Unsuccessful\")\nReturnValue, QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems =\nDequeue(QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems)\nprint(ReturnValue)\nReturnValue, QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems =\nDequeue(QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems)\nprint(ReturnValue)\nVB.NET\nFor x = 0 To 10\nConsole.WriteLine(\"Enter a string\")\nInputString = Console.ReadLine\nIf(Enqueue(QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems, InputString))\nThen\nConsole.WriteLine(\"Successful\")\nElse\nConsole.WriteLine(\"Unsuccessful\")\nEnd If\nNext\nConsole.WriteLine(Dequeue)\nConsole.WriteLine(Dequeue)\n© UCLES 2022 Page 33 of 34\n\n3(d)(ii) 1 mark for showing inputs and outputs: 1\nA – J input and successful.\nK input and unsuccessful.\nOutput: A, B\ne.g.\n© UCLES 2022 Page 34 of 34",
      "source_pages": [
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_41-p27.png",
        "../answer-assets/9618_s22_ms_41-p28.png",
        "../answer-assets/9618_s22_ms_41-p29.png",
        "../answer-assets/9618_s22_ms_41-p30.png",
        "../answer-assets/9618_s22_ms_41-p31.png",
        "../answer-assets/9618_s22_ms_41-p32.png",
        "../answer-assets/9618_s22_ms_41-p33.png",
        "../answer-assets/9618_s22_ms_41-p34.png"
      ]
    },
    {
      "id": "9618-2022-mj-42-q01",
      "question_id": "9618-2022-mj-42-q01",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 25,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per mark point 3\n declaring array StackData and pointer StackPointer as (global data structures)\n StackData has 10 integer elements\n StackPointer initialised to 0\nExample program code:\nVB.NET\nDim StackData(9) As Integer\nDim StackPointer As Integer\nSub Main()\nStackPointer = 0\nend Sub\nPython\nglobal StackData #integer\nglobal StackPointer\nStackData = [0,0,0,0,0,0,0,0,0,0] #integer\nStackPointer = 0\nJava\nimport java.util.Scanner;\nclass Question1{\npublic static Integer[] StackData;\npublic static Integer StackPointer;\npublic static void main(String args[]){\nStackData = new Integer[10];\nStackPointer = 0;\n}\n}\n© UCLES 2022 Page 4 of 36\n\n1(b) 1 mark per mark point 3\n procedure header with sensible identifier (and end where appropriate)\n outputting StackPointer\n outputting all 10 elements in array\nExample program code:\nVB.NET\nSub PrintArray()\nConsole.WriteLine(StackPointer)\nFor x = 0 To 9\nConsole.WriteLine(StackData(x))\nNext\nEnd Sub\nPython\ndef PrintArray():\nglobal StackData\nglobal StackPointer\nprint(StackPointer)\nfor x in range (0, 10):\nprint(StackData[x])\nJava\npublic static void PrintArray(){\nSystem.out.println(StackPointer);\nfor(int x = 0; x < 10 ;x++){\nSystem.out.println(StackData[x]);\n}\n}\n© UCLES 2022 Page 5 of 36\n\n1(c) 1 mark per mark point 6\n function Push() taking an integer parameter\n checking if stack is full …\n …and returning FALSE\n (if not full) storing parameter to stack at StackPointer …\n …incrementing StackPointer\n …returning TRUE\nExample program code:\nVB.Net\nFunction Push(DataToPush)\nIf StackPointer = 10 Then\nReturn False\nElse\nStackData(StackPointer) = DataToPush\nStackPointer = StackPointer + 1\nReturn True\nEnd If\nEnd Function\nPython\ndef Push(DataToPush):\nglobal StackData\nglobal StackPointer\nif StackPointer == 10:\nreturn False\nelse:\nStackData[StackPointer] = DataToPush\nStackPointer = StackPointer + 1\nreturn True\n© UCLES 2022 Page 6 of 36\n\n1(c) Java\npublic static Boolean Push(Integer DataToPush){\nif(StackPointer == 10){\nreturn false;\n}else{\nStackData[StackPointer] = DataToPush;\nStackPointer = StackPointer + 1;\nreturn true;\n}\n}\n© UCLES 2022 Page 7 of 36\n\n1(d)(i) 1 mark per mark point 5\n Inputting 11 numbers …\n …calling Push() with each number input as a parameter …\n …outputting appropriate message if TRUE returned\n …outputting appropriate message if FALSE returned\n Calling their output procedure after all 11 additions\nExample program code:\nVB.NET\nSub Main()\nStackPointer = 0\nDim TempNumber As Integer\nFor x = 0 To 10\nConsole.WriteLine(\"Enter a number\")\nTempNumber = Console.ReadLine()\nIf Push(TempNumber) Then\nConsole.WriteLine(\"Stored\")\nElse\nConsole.WriteLine(\"Stack full\")\nEnd If\nNext\nPrintArray()\nConsole.ReadLine()\nEnd Sub\n© UCLES 2022 Page 8 of 36\n\n1(d)(i) Python\n#main\nStackPointer = 0\nStackData = [0,0,0,0,0,0,0,0,0,0]\nfor x in range(0, 11):\nTempNumber = int(input(\"Enter a number\"))\nif Push(TempNumber) == True:\nprint(\"Stored\")\nelse:\nprint(\"Stack full\")\nPrintArray()\nJava\npublic static void main(String[] args){\nStackData = new Integer[10];\nStackPointer = 0;\nInteger TempNumber = 0;\nfor(int x = 0; x < 10; x++){\nSystem.out.println(\"Enter a number\");\nScanner scanner = new Scanner(System.in);\nTempNumber = Integer.parseInt(scanner.nextLine());\nif(Push(TempNumber)){\nSystem.out.println(\"Stored\");\n}else{\nSystem.out.println(\"Stack full\");\n}\n}\nPrintArray();\n}\n© UCLES 2022 Page 9 of 36\n\n1(d)(ii) 1 mark for inputting all 11 numbers, message for first 10 saying added (11 to 20), message stating 11th number stating 1\nstack full. Full array contents output (11 12 13 14 15 16 17 18 19 20).\ne.g.\n© UCLES 2022 Page 10 of 36\n\n1(e)(i) 1 mark per mark point 5\n Pop() function header (and close where appropriate) and returning a number in all possible situations\n checking if stack is empty (StackPointer is 0) and returning -1\n (otherwise) accessing the item at the top of the stack …\n …decrementing the stack pointer\n …returning the item removed\nExample Program code:\nVB.NET\nFunction Pop()\nDim ReturnData As Integer\nIf StackPointer = 0 Then\nReturn -1\nElse\nReturnData = StackData(StackPointer – 1)\nStackPointer = StackPointer - 1\nReturn ReturnData\nEnd If\nEnd Function\nPython\ndef Pop():\nglobal StackData\nglobal StackPointer\nif StackPointer == 0:\nreturn -1\nelse:\nReturnData = StackData[StackPointer - 1]\nStackPointer = StackPointer - 1\nreturn ReturnData\n© UCLES 2022 Page 11 of 36\n\n1(e)(i) Java\npublic static Integer Pop(){\nInteger ReturnData = 0;\nif(StackPointer == 0){\nreturn -1;\n}else{\nReturnData = StackData[StackPointer - 1];\nStackPointer = StackPointer - 1;\nreturn ReturnData;\n}\n}\n\n1(e)(ii) 1 mark per mark point 2\n output of before removed with 11 inputs\n output of stack (after, this could be 11–20, 11–18, or 11–18 then ‘null’ ‘null’s)\ne.g.\n© UCLES 2022 Page 12 of 36",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_42-p04.png",
        "../answer-assets/9618_s22_ms_42-p05.png",
        "../answer-assets/9618_s22_ms_42-p06.png",
        "../answer-assets/9618_s22_ms_42-p07.png",
        "../answer-assets/9618_s22_ms_42-p08.png",
        "../answer-assets/9618_s22_ms_42-p09.png",
        "../answer-assets/9618_s22_ms_42-p10.png",
        "../answer-assets/9618_s22_ms_42-p11.png",
        "../answer-assets/9618_s22_ms_42-p12.png"
      ]
    },
    {
      "id": "9618-2022-mj-42-q02",
      "question_id": "9618-2022-mj-42-q02",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 23,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark per mark point 4\n in main local 2D array declared …\n … with 10  10 integer elements\n initialising all array elements to a number…\n …that is random between 1 and 100 (allow inclusive or exclusive)\nExample program code:\nVB.NET\nSub Main()\nDim Random As New Random\nDim ArrayData(10, 10) As Integer\nFor x = 0 To 9\nFor y = 0 To 9\nArrayData(x, y) = Random.Next(1, 100)\nNext\nNext\nConsole.ReadLine()\nEnd Sub\nPython\nimport random\n#main\nArrayData= [[0]*10 for i in range(10)] #integer\nfor x in range(0, 10):\nfor y in range(0,10):\nArrayData[x][y] = random.randint(1, 100)\n© UCLES 2022 Page 13 of 36\n\n2(a) Java\nimport java.util.Scanner;\nimport java.util.Random;\nclass Question2{\npublic static Integer[][] ArrayData;\npublic static void main(String args[]){\nRandom Rand = new Random();\nArrayData = new Integer[10][10];\nfor(int x=0; x < 10; x++){\nfor(int y = 0; y < 10; y++){\nArrayData[x][y] = Rand.nextInt(100);}\n}\n}\n}\n© UCLES 2022 Page 14 of 36\n\n2(b)(i) 1 mark per mark point 5\n 1st outer loop (dimension 1)\n 2nd loop (dimension 2)\n inner for loop for all second dimension\n Selection statement …\n …swapping the numbers correctly\nExample program code:\nVB.NET\nDim TempNumber As Integer\nDim ArrayLength As Integer = 10\nFor X = 0 To ArrayLength - 1\nFor Y = 0 To ArrayLength - 2\nFor Z = 0 To ArrayLength - Y - 2\nif ArrayData(X, Z) > ArrayData(X, Z + 1) then\nTempNumber = ArrayData(X, Z)\nArrayData(X, Z) = ArrayData(X, Z+1)\nArrayData(X, Z + 1) = TempNumber\nend if\nNext Z\nNext Y\nNext X\nPython\nArrayLength = 10\nfor X in range(0, ArrayLength):\nfor Y in range(0, ArrayLength-1):\nfor Z in range(0, ArrayLength - Y - 1):\nif(ArrayData[X][Z] > ArrayData[X][Z+1]):\nTempNumber = ArrayData[X][Z]\nArrayData[X][Z] = ArrayData[X][Z+1]\nArrayData[X][Z+1] = TempNumber\nAccept for MP5:\nArrayData[X][Z], ArrayData[X][Z+1] = ArrayData[X][Z+1], ArrayData[X][Z]\n© UCLES 2022 Page 15 of 36\n\n2(b)(i) Java\nInteger ArrayLength = 10;\nfor(int X = 0; X < ArrayLength; X++){\nfor(int Y = 0; Y < ArrayLength; Y++){\nfor(int Z = 0; Z < ArrayLength - Y - 1; Z++){\nif(ArrayData[X][Z] > ArrayData[X][Z + 1]){\nTempNumber = ArrayData[X][Z];\nArrayData[X][Z] = ArrayData[X][Z+1];\nArrayData[X][Z + 1] = TempNumber;\n}\n}\n}\n}\n© UCLES 2022 Page 16 of 36\n\n2(b)(ii) 1 mark per mark point 3\n procedure header (and end where appropriate)\n Outputting all 10  10 values with each 2nd dimension on a complete line\n Calling procedure before and after bubble sort\nExample program code:\nVB.NET\nSub Main()\nDim random As New Random\nDim ArrayData(10, 10) As Integer\nFor x = 0 To 9\nFor y = 0 To 9\nArrayData(x, y) = random.Next(1, 100)\nNext\nNext\nConsole.WriteLine(\"before\")\nprintarray(ArrayData)\nDim TempNumber As Integer\nDim ArrayLength As Integer = 10\nFor X = 0 To ArrayLength - 1\nFor Y = 0 To ArrayLength - 2\nFor Z = 0 To ArrayLength - Y - 2\nif ArrayData(X, Z) > ArrayData(X, Z + 1) then\nTempNumber = ArrayData(X, Z)\nArrayData(X, Z) = ArrayData(X, Z+1)\nArrayData(X, Z + 1) = TempNumber\nend if\nNext Z\nNext Y\nNext X\nConsole.WriteLine(\"after\")\nprintarray(ArrayData)\nConsole.ReadLine()\nEnd Sub\n© UCLES 2022 Page 17 of 36\n\n2(b)(ii) Sub Printarray(ByRef ArrayData(,) As Integer)\nFor x = 0 To 9\nFor y = 0 To 9\nConsole.Write(ArrayData(x, y) & \" \")\nNext\nConsole.WriteLine()\nNext\nEnd Sub\nPython\nimport random\ndef Printarray(ArrayData):\nfor x in range(0, 10):\nfor y in range(0, 10):\nprint(ArrayData[x][y], \" \", end='')\nprint(\"\")\n#main\nArrayData= [[0]*10 for i in range(10)] #integer\nfor x in range(0, 10):\nfor y in range(0,10):\nArrayData[x][y] = random.randint(1, 100)\nprint(\"Before\")\nprintarray(ArrayData)\nArrayLength = 10\nfor X in range(0, ArrayLength):\nfor Y in range(0, ArrayLength):\nfor Z in range(0, ArrayLength - Y - 1):\nif(ArrayData[X][Z] > ArrayData[X][Z+1]):\nTempNumber = ArrayData[X][Z]\nArrayData[X][Z] = ArrayData[X][Z+1]\nArrayData[X][Z+1] = TempNumber\nprint(\"After\")\nPrintarray(ArrayData)\n© UCLES 2022 Page 18 of 36\n\n2(b)(ii) Java\nimport java.util.Scanner;\nimport java.util.Random;\nclass Question2{\npublic static Integer[][] ArrayData;\npublic static void printArray(Integer[][] theArrayData){\nfor(int x = 0; x < 10; x++){\nfor(int y = 0; y < 10; y++){\nSystem.out.printf(theArrayData[x][y] + \" \");\n}\nSystem.out.println();\n}\n}\npublic static void main(String args[]){\nRandom rand = new Random(){\nArrayData = new Integer[10][10];\nfor(int x=0; x < 10; x++){\nfor(int y = 0; y < 10; y++){\nArrayData[x][y] = rand.nextInt(100);\n}\n}\nInteger TempNumber = 0;\nSystem.out.println(\"Before\");\nprintArray(ArrayData);\nInteger ArrayLength = 10;\nfor(int X = 0; X < ArrayLength; X++){\nfor(int Y = 0; Y < ArrayLength; Y++){\nfor(int Z = 0; Z < ArrayLength - Y - 1; Z++){\nif(ArrayData[X][Z] > ArrayData[X][Z + 1]){\n© UCLES 2022 Page 19 of 36\n\n2(b)(ii) TempNumber = ArrayData[X][Z];\nArrayData[X][Z] = ArrayData[X][Z+1];\nArrayData[X][Z + 1] = TempNumber;\n}\n}\n}\n}\nSystem.out.println(\"After\");\nPrintArray(ArrayData);\n}\n}\n© UCLES 2022 Page 20 of 36\n\n2(b)(iii) 1 mark for output showing array unsorted and then sorted on 1 of the dimensions 1\ne.g.\n© UCLES 2022 Page 21 of 36\n\n2(c)(i) 1 mark for each completed statement (6) 8\n1 mark per mark point\n function declaration taking appropriate parameters and recursive calls\n remainder of the function is accurate including appropriate DIV operator.\nExample program code:\nVB.NET\nFunction BinarySearch(ByVal SearchArray(,) As Integer, Lower As Integer, Upper As Integer,\nSearchValue As Integer)\nDim Mid As Integer\nIf Upper >= 0 Then\nMid = (Lower + (Upper - 1)) \\ 2\nIf SearchArray(0, Mid) = SearchValue Then\nReturn Mid\nElseIf SearchArray(0, Mid) > SearchValue Then\nReturn BinarySearch(SearchArray, Lower, Mid - 1, SearchValue)\nElse\nReturn BinarySearch(SearchArray, Mid + 1, Upper, SearchValue)\nEnd If\nEnd If\nReturn -1\nEnd Function\nPython\ndef BinarySearch(SearchArray, Lower, Upper, SearchValue):\nif Upper >= 0:\nMid = int((Lower + (Upper - 1)) / 2)\nIf SearchArray[0][Mid] == SearchValue:\nreturn Mid\nelif SearchArray[0][Mid] > SearchValue:\nreturn BinarySearch(SearchArray, Lower, Mid-1, SearchValue)\nelse:\nreturn BinarySearch(SearchArray, Mid+1, Upper, SearchValue)\nreturn -1\n© UCLES 2022 Page 22 of 36\n\n2(c)(i) Java\npublic static Integer BinarySearch(Integer[][] SearchArray, Integer Lower, Integer Upper,\nInteger SearchValue){\nInteger Mid = 0;\nIf Upper >= 0 {\nMid = (Lower + (Upper - 1)) / 2;\nIf SearchArray[0][Mid] == SearchValue ){\nreturn Mid;\n}else if SearchArray[0][Mid] > SearchValue {\nreturn BinarySearch(SearchArray, Lower, Mid-1, SearchValue);\n}else{\nreturn BinarySearch(SearchArray, Mid+1, Upper, SearchValue);\n}\n} return -1;\n}\n© UCLES 2022 Page 23 of 36\n\n2(c)(ii) 1 mark per mark point 2\n screenshot outputting the index when Number is found\n screenshot outputting –1 with a Number not found\ne.g.\n© UCLES 2022 Page 24 of 36",
      "source_pages": [
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23,
        24
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_42-p13.png",
        "../answer-assets/9618_s22_ms_42-p14.png",
        "../answer-assets/9618_s22_ms_42-p15.png",
        "../answer-assets/9618_s22_ms_42-p16.png",
        "../answer-assets/9618_s22_ms_42-p17.png",
        "../answer-assets/9618_s22_ms_42-p18.png",
        "../answer-assets/9618_s22_ms_42-p19.png",
        "../answer-assets/9618_s22_ms_42-p20.png",
        "../answer-assets/9618_s22_ms_42-p21.png",
        "../answer-assets/9618_s22_ms_42-p22.png",
        "../answer-assets/9618_s22_ms_42-p23.png",
        "../answer-assets/9618_s22_ms_42-p24.png"
      ]
    },
    {
      "id": "9618-2022-mj-42-q03",
      "question_id": "9618-2022-mj-42-q03",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 27,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per mark point 5\n Card class declaration (and end where appropriate)\n Both attributes (Number and Colour) declared with suitable data types …\n …as private\n correct constructor header (and end where appropriate) with two parameters …\n …both parameters assigned to the attributes\nExample program code:\nVB.NET\nClass Card\nPrivate Number As Integer\nPrivate Colour As String\nSub New(Numberp, Colourp)\nNumber = Numberp\nColour = Colourp\nEnd Sub\nEnd Class\nPython\nclass Card:\n#Number as Integer\n#Colour as string\ndef __init__(self, Numberp, Colourp):\nself.__Number = Numberp\nself.__Colour = Colourp\n© UCLES 2022 Page 25 of 36\n\n3(a) Java\nimport java.util.Scanner;\nimport java.io.*;\nclass Card{\nprivate Integer Number;\nprivate String Colour;\npublic Card(Integer pNumber, String pColour){\nNumber = pNumber;\nColour = pColour;\n}\npublic static void main(String args[]){\n}\n}\n© UCLES 2022 Page 26 of 36\n\n3(b) 1 mark per mark point 3\n 1 get method header (and close where appropriate) with no parameter …\n … returning attribute\n 2nd correct get method\nExample program code:\nVB.NET\nFunction GetNumber()\nReturn Number\nEnd Function\nFunction GetColour()\nReturn Colour\nEnd Function\nPython\ndef GetNumber(self):\nreturn self.__Number\ndef GetColour(self):\nreturn self.__Colour\nJava\npublic Integer GetNumber(){\nreturn Number;\n}\npublic String GetColour(){\nreturn Colour;\n}\n© UCLES 2022 Page 27 of 36\n\n3(c) 1 mark per mark point to max 7 7\n Declaration of array with 30 elements of type Card\n Opening the text file CardValues.txt for read\n Looping until EOF/30 times\n Reading in all sets of 2 lines (number then colour) …\n …creating object of type Card…\n …with number and colour read in from file …\n …storing in next array element\n Try and catch for file handling…s\n ….with appropriate outputs\n Closing the file in a suitable place\nExample program code:\nVB.NET\nSub Main()\nDim CardArray(0 To 29) As Card\nDim NumberRead As Integer\nDim ColourRead As String\nTry\nDim Filename As String = \"CardValues.txt\"\nDim FileReader As New System.IO.StreamReader(filename)\nFor x = 0 To 29\nNumberRead = FileReader.ReadLine()\nColourRead = FileReader.ReadLine()\nCardArray(x) = New Card(NumberRead, ColourRead)\nNext\nFileReader.close()\nCatch ex As Exception\n© UCLES 2022 Page 28 of 36\n\n3(c) Console.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\nPython\nCardArray = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] #integer\ntry:\nFilename = \"CardValues.txt\"\nFile = open(Filename,'r')\nfor x in range(0,30):\nNumberRead = int(File.readline())\nColourRead = File.readline()\nCardArray[x] = Card(NumberRead, ColourRead)\nFile.close\nexcept IOError:\nprint(\"Could not find file\")\nJava\npublic static void main(String args[]){\nCard[] CardArray = new Card[30];\nInteger NumberRead;\nString ColourRead;\nString FileName = \"CardValues.txt\";\ntry{\nFileReader F = new FileReader(FileName);\nBufferedReader Reader = new BufferedReader(f);\nfor(Integer x = 0; x < 30; x++){\nNumberRead = Integer.parseInt(Reader.readLine());\nColourRead = Reader.readLine();\nCardArray[x] = new Card(NumberRead, ColourRead);\n}\nReader.close();\n}\n© UCLES 2022 Page 29 of 36\n\n3(c) catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No file found\");\n}\n}\n© UCLES 2022 Page 30 of 36\n\n3(d) 1 mark per mark point to max 6 6\n Implementing a suitable way of storing which card have been selected\n Function ChooseCard() header (and close) and returning an integer (index) in all cases\n Reading in array index from the user …\n …with suitable validation looping until it is between 1 and 30 (inclusive)\n Converting input to array index (e.g. –1 each time)\n Check if the input is already selected…\n … if it is selected, loop until index input is not already selected\n … returning index of available card selected\n Stores the valid Card chosen as taken (using any suitable method)\nExample program code:\nVB.NET\nDim NumbersChosen(0 To 29) As Boolean\nSub Main()\nFor x = 0 To 29\nNumbersChosen(x) = False\nNext\n….\nEnd Sub\nFunction chooseCard()\nDim CardSelected As Integer\nDim flagContinue As Boolean = True\nWhile flagContinue = True\nConsole.WriteLine(\"Select a Card from 1 to 30\")\nCardSelected = Console.ReadLine()\nIf CardSelected < 1 Or CardSelected > 30 Then\nConsole.WriteLine(\"Number must be between \")\n© UCLES 2022 Page 31 of 36\n\n3(d) ElseIf NumbersChosen(CardSelected - 1) = True Then\nConsole.WriteLine(\"Already taken\")\nElse\nConsole.WriteLine(\"valid\")\nflagContinue = False\nEnd If\nEnd While\nNumbersChosen(CardSelected - 1) = True\nReturn CardSelected - 1\nEnd Function\nPython\nglobal NumbersChosen\n…\ndef chooseCard ():\nglobal NumbersChosen\nflagContinue = True\nwhile flagContinue == true:\nCardSelected = int(input(\"Select a Card from 1 to 30\"))\nif CardSelected < 1 or CardSelected > 30:\nprint(\"Number must be between 1 and 30\")\nelif NumbersChosen(CardSelected - 1) == True:\nprint(\"Already taken\")\nelse:\nprint(\"Valid\")\nflagContinue = False\nNumbersChosen[CardSelected-1] = True\nreturn CardSelected-1\n…\n#main\n…\nNumbersChosen = [False for i in range(30)]\n© UCLES 2022 Page 32 of 36\n\n3(d) Java\npublic static Boolean[] NumbersChosen = new Boolean[30];\npublic Integer chooseCard (){\nBoolean flagContinue = true;\nInteger CardSelected = -1;\nwhile(flagContinue){\nSystem.out.println(\"Select a Card from 1 to 30\");\nScanner scanner = new Scanner(System.in);\nCardSelected = Integer.parseInt(scanner.nextLine());\nif(CardSelected < 1 || CardSelected > 30){\nSystem.out.println(\"Number must be between 1 and 30\");\n}else if(NumbersChosen[CardSelected - 1]){\nSystem.out.println(\"Already taken\");\n}else{\nSystem.out.println(\"Valid\");\nflagContinue = false;\n}\n}\nNumbersChosen[CardSelected - 1] = true;\nreturn CardSelected - 1;\n}\n© UCLES 2022 Page 33 of 36\n\n3(e)(i) 1 mark per mark point 5\n declaring array Player1 of type Card\n calling the function ChooseCard() four times\n storing the card, that is in the index returned, in the array Player1\n outputting all four numbers and colours in Player1 …\n …. using the get methodss\nExample program code:\nVB.NET\nDim Player1(0 To 3) As Card\nFor x = 0 To 3\nPlayer1(x) = CardArray(ChooseCard(NumbersChosen))\nNext\nfor x = 0 to 3\nconsole.writeline(Player1(x).GetColour)\nconsole.writeline(Player1(x).GetNumber)\nnext x\nPython\nPlayer1 = [] #of type Card\nfor x in range(0, 4):\nReturnNumber = ChooseCard ()\nPlayer1.append(CardArray[ReturnNumber])\nfor x in range(0, 4):\nprint(Player1[x].GetColour())\nprint(Player1[x].GetNumber())\n© UCLES 2022 Page 34 of 36\n\n3(e)(i) Java\nCard[] Player1 = new Card[5];\nfor(Integer x = 0; x < 5; x++){\nPlayer1[x] = CardArray[ChooseCard()];\n}\nfor(Integer x = 0; x < 5; x++){\nSystem.out.println(Player1[x].GetColour());\nSystem.out.println(Player1[x].GetNumber());\n}\n\n3(e)(ii) 1 mark for both tests 1\nTest 1: inputting 1, 5, 9, 10. Outputting: 1 red 9 green 9 orange 10 red\nTest 2: inputting 2 2 3 4 4 5. Outputting: 2 already taken. Then 5 black 2 while 4 red 9 green\nTest 1 e.g.\n© UCLES 2022 Page 35 of 36\n\n3(e)(ii) Test 2 e.g.\n© UCLES 2022 Page 36 of 36",
      "source_pages": [
        25,
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_42-p25.png",
        "../answer-assets/9618_s22_ms_42-p26.png",
        "../answer-assets/9618_s22_ms_42-p27.png",
        "../answer-assets/9618_s22_ms_42-p28.png",
        "../answer-assets/9618_s22_ms_42-p29.png",
        "../answer-assets/9618_s22_ms_42-p30.png",
        "../answer-assets/9618_s22_ms_42-p31.png",
        "../answer-assets/9618_s22_ms_42-p32.png",
        "../answer-assets/9618_s22_ms_42-p33.png",
        "../answer-assets/9618_s22_ms_42-p34.png",
        "../answer-assets/9618_s22_ms_42-p35.png",
        "../answer-assets/9618_s22_ms_42-p36.png"
      ]
    },
    {
      "id": "9618-2022-mj-43-q01",
      "question_id": "9618-2022-mj-43-q01",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 29,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per mark point 2\n declaration of at least 1 array with appropriate identifier\n … 11 elements (and appropriate data type(s))\nExample program code:\nJava\nPublic static String[][] FileData = new String[10][2];\nVB.NET\nDim FileData(0 To 9, 0 To 1) As String\nPython\nFileData = [[\"\"] *2 for i in range(11)] #string\n© UCLES 2022 Page 4 of 34\n\n1(b) 1 mark per mark point to max 6 6\n procedure declaration (and end)\n Opening the text file (to read)\n Looping 10 times // looping until end of file (e.g. 10 pairs of data)\n Reading in each pair of lines …\n … storing player name and score in data structure(s)\n closing the file\n Try and catch on file handling …\n … with suitable output\nExample program code:\nJava\npublic static void ReadHighScores(){\nString Filename = \"HighScore.txt\";\ntry{\nFileReader F = new FileReader(Filename);\nBufferedReader Reader = new BufferedReader(F);\nfor(Integer x = 0; x < 10; x++){\nFileData[x][0] = Reader.readLine();\nFileData[x][1] = Reader.readLine();\n}\nReader.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No file found\");\n}\n}\n© UCLES 2022 Page 5 of 34\n\n1(b) Python\ndef ReadHighScores():\nFilename = \"HighScore.txt\"\nFile = open(Filename, 'r')\nfor x in range(0, 10):\nFileData[x][0] = File.readline()[:3]\nFileData[x][1] = File.readline()\nFile.close\nVB.NET\nSub ReadHighScores()\nDim Textfile As String = \"HighScore.txt\"\nDim FileReader As New System.IO.StreamReader(textfile)\nDim DataEntered As Integer = 0\nWhile FileReader.Peek <> -1 and DataEntered < 10\nFileData(DataEntered, 0) = FileReader.ReadLine()\nFileData(DataEntered, 1) = FileReader.ReadLine()\nDataEntered = DataEntered + 1\nEnd While\nFileReader.Close()\nEnd Sub\n© UCLES 2022 Page 6 of 34\n\n1(c) 1 mark per mark point 3\n procedure heading and end\n looping through all data structure elements\n outputting player name, space, score. Each player must start on a new line\nExample program code:\nJava\npublic static void OutputHighScores(){\nfor(Integer x = 0; x < 11; x++){\nSystem.out.println(FileData[x][0] + \" \" + FileData[x][1]);\n}\n}\nPython\ndef OutputHighScores ():\nfor x in range(0, 11):\nOutput = FileData[x][0] + \" \" + FileData[x][1]\nprint(Output)\nVB.NET\nSub OutputHighScores ()\nFor x = 0 To 10\nConsole.WriteLine(FileData(x, 0) & \" \" & FileData(x,1))\nNext\nEnd Sub\n© UCLES 2022 Page 7 of 34\n\n1(d)(i) 1 mark per mark point 2\n (Main program) calls ReadHighScores()\n … then calls OutputHighScores()\nExample program code:\nJava\npublic static void main(String[] args){\nReadHighScores();\nOutputHighScores();\n}\nPython\nReadHighScores()\nOutputHighScore()\nVB.NET\nSub Main()\nReadHighScores()\nOutputHighScore()\nConsole.ReadLine()\nEnd Sub\n© UCLES 2022 Page 8 of 34\n\n1(d)(ii) 1 mark for screenshot showing the 10 names and scores from the file (and one extra blank space may, or may not be 1\nincluded)\ne.g.\n© UCLES 2022 Page 9 of 34\n\n1(e)(i) 1 mark per mark point 3\n Read in a username and score\n Validate username input (3-characters, or just selecting the first 3 characters if there are definitely 3 characters)\n Validate score input (integer (cast) between 1 and 100 000 inclusive)\nExample program code:\nJava\npublic static void main(String[] args){\nScanner scanner = new Scanner(System.in);\nReadHighScores();\nOutputHighScores();\nString Username = \"ABCD\"\ndo{\nSystem.out.println(\"Enter your Username\");\nUsername = scanner.nextLine();\n}while(Username.length != 3)\nString Score = \"-1\";\ndo{\nSystem.out.println(\"Enter your score\");\nScore = scanner.nextLine();\n}while(Integer.parseInt(Score) < 1 || Integer.parseInt(Score) > 100000);\n}\nPython\nUsername = \"ABCD\"\nwhile len(Username) != 3:\nUsername = input(\"Enter your Username\")\nscore = -1\nwhile Score < 1 or Score > 100000:\nScore = int(input(\"Enter score\"))\n© UCLES 2022 Page 10 of 34\n\n1(e)(i) VB.NET\nConsole.WriteLine(\"Enter Username\")\nUsername = \"ABCD\"\nWhile Username.length <> 3\nUsername = Console.ReadLine()\nEnd While\nScore = -1\nWhile Score < 1 Or Score > 100000\nConsole.WriteLine(\"Enter score\")\nScore = Console.ReadLine()\nEnd While\n© UCLES 2022 Page 11 of 34\n\n1(e)(ii) 1 mark per mark point 5\n procedure declaration (and close where appropriate) taking 1 string and 1 integer parameter\n looping through each array element\n … finding the position to input the score\n storing the array data in the correct position\n storing the name and score in the correct position\nExample program code:\nJava\npublic static void Arrange(String Username, String Score){\nString Temp1; String Temp2; String Second1; String Second2;\nfor(Integer x = 0; x < 10; x++){\nif (Integer.parseInt(Score) > Integer.parseInt(FileData[x][1])){\nTemp1 = FileData[x][0];\nTemp2 = FileData[x][1];\nFileData[x][0] = Username;\nFileData[x][1] = Score;\nfor(Integer Count = x+1; Count < 10; Count++){\nsecond1 = FileData[count][0];\nsecond2 = FileData[count][1];\nFileData[Count][0] = Temp1;\nFileData[Count][1] = Temp2;\nTemp1 = Second1;\nTemp2 = Second2;\nx = 11;\n}\n}\n}\n}\n© UCLES 2022 Page 12 of 34\n\n1(e)(ii) Python\ndef Arrange(Username, Score):\nfor x in range(0, 10):\nif Score > FileData[x][1]:\nTemp1 = FileData[x][0]\nTemp2 = FileData[x][1]\nFileData[x][0] = Username\nFileData[x][1] = Score\nCount = x+1\nwhile(Count < 10):\nSecond1 = FileData[Count][0]\nSecond2 = FileData[Count][1]\nFileData[Count][0] = Temp1\nFileData[Count][1] = Temp2\nTemp1 = Second1\nTemp2 = Second2\nCount = Count + 1\nbreak;\n© UCLES 2022 Page 13 of 34\n\n1(e)(ii) VB.NET\nSub Arrange(Username, Score)\nDim Temp1 As String\nDim Temp2 As String\nDim Second1 As String\nDim Second2 As String\nFor x = 0 To 9\nIf Score > Integer.Parse(FileData(x, 1)) Then\nTemp1 = FileData(x, 0)\nTemp2 = FileData(x, 1)\nFileData(x, 0) = Username\nFileData(x, 1) = Score.ToString\nFor Count = x + 1 To 9\nSecond1 = FileData(Count, 0)\nSecond2 = FileData(Count, 1)\nFileData(Count, 0) = Temp1\nFileData(Count, 1) = Temp2\nTemp1 = Second1\nTemp2 = Second2\nx = 10\nNext\nEnd If\nNext\nEnd Sub\n© UCLES 2022 Page 14 of 34\n\n1(e)(iii) 1 mark per mark point 2\n Calling sorting procedure with correct parameters\n Outputting the array before and after procedure call\nExample program code:\nJava\npublic static void main(String[] args){\nScanner scanner = new Scanner(System.in);\nReadHighScores();\nOutputHighScores();\nSystem.out.println(\"Enter your Username\");\nString Username = scanner.nextLine();\nString Score = \"-1\";\ndo{\nSystem.out.println(\"Enter your score\");\nScore = scanner.nextLine();\n}while(Integer.parseInt(Score) < 0 || Integer.parseInt(Score) > 100000);\narrange(Username, Score);\nOutputHighScores();\n}\nPython\nReadHighScores()\nOutputHighScore()\nUsername = input(\"Enter your Username\")\nScore = -1\nwhile Score < 0 or Score > 100000:\nScore = int(input(\"Enter score\"))\nArrange(Username, Score)\nOutputHighScore()\n© UCLES 2022 Page 15 of 34\n\n1(e)(iii) VB.NET\nOutputHighScore()\nUsername = Console.ReadLine()\nScore = -1\nWhile(score < 0 or Score > 100000)\nScore = Console.ReadLine()\nEnd While\nArrange(Username, Score)\nOutputHighScore()\n\n1(e)(iv) 1 mark for screenshot. JKL, 9999 entered. After shows JKL in the second position. 1\ne.g.\n© UCLES 2022 Page 16 of 34\n\n1(f) 1 mark per mark point to max 4 4\n procedure header and end (where appropriate) and opening the file NewHighScore.txt to write\n Closing the file\n Looping through all 10 array values …\n … writing the username, then the score\n Exception handling and appropriate output\nExample program code:\nJava\npublic static void WriteTopTen(){\nString Filename = \"NewHighScore.txt\";\ntry{\nFileWriter F = new FileWriter(Filename);\nBufferedWriter Out = new BufferedWriter(F);\nfor(Integer x = 0; x < 10; x++){\nOut.write(FileData[x][0] + \"\\n\");\nOut.write(FileData[x][1] + \"\\n\");\n}\nOut.close();\n} catch(Exception e){\nSystem.err.println(\"No file\");\n}\n}\nPython\ndef WriteTopTen():\nFilename = \" NewHighScore.txt\"\nFilename = open(Filename, 'w')\nfor x in range(0, 10):\nFilename.write(str(FileData[x][0]) + '\\n')\nFilename.write(str(FileData[x][1]) + '\\n')\nFilename.close\n© UCLES 2022 Page 17 of 34\n\n1(f) VB.NET\nSub WriteTopTen()\nDim Filename As String = \" NewHighScore.txt\"\nDim NewFile As New System.IO.StreamWriter(Filename)\nFor x = 0 To 9\nNewFile.WriteLine(FileData(x, 0))\nNewFile.WriteLine(FileData(x, 1))\nNext\nNewFile.Close()\nEnd Sub\n© UCLES 2022 Page 18 of 34",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_43-p04.png",
        "../answer-assets/9618_s22_ms_43-p05.png",
        "../answer-assets/9618_s22_ms_43-p06.png",
        "../answer-assets/9618_s22_ms_43-p07.png",
        "../answer-assets/9618_s22_ms_43-p08.png",
        "../answer-assets/9618_s22_ms_43-p09.png",
        "../answer-assets/9618_s22_ms_43-p10.png",
        "../answer-assets/9618_s22_ms_43-p11.png",
        "../answer-assets/9618_s22_ms_43-p12.png",
        "../answer-assets/9618_s22_ms_43-p13.png",
        "../answer-assets/9618_s22_ms_43-p14.png",
        "../answer-assets/9618_s22_ms_43-p15.png",
        "../answer-assets/9618_s22_ms_43-p16.png",
        "../answer-assets/9618_s22_ms_43-p17.png",
        "../answer-assets/9618_s22_ms_43-p18.png"
      ]
    },
    {
      "id": "9618-2022-mj-43-q02",
      "question_id": "9618-2022-mj-43-q02",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 25,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark per mark point 5\n Class Balloon declaration (and end where appropriate)\n declaration of 3 attributes as private with suitable data types\n constructor header (and end) with two parameters …\n … initialising colour and defence item to parameters\n … initialising health to 100\nExample program code:\nJava\nclass Balloon{\nprivate Integer Health;\nprivate String Colour;\nprivate String DefenceItem;\npublic Balloon(String PDefenceItem, String PColour){\nColour = PColour;\nDefenceItem = PDefenceItem;\nHealth = 100;\n}\npublic static void main(String[] args){\n}\n}\nPython\nclass Balloon:\n#Health as integer\n#Colour as string\n#DefenceItem as string\ndef __init__(self, PDefenceItem, PColour):\nself.__Health = 100\nself.__Colour = PColour\nself.__DefenceItem = PDefenceItem\n© UCLES 2022 Page 19 of 34\n\n2(a) VB.NET\nClass balloon\nPrivate Health As Integer\nPrivate Colour As String\nPrivate DefenceItem As String\nPublic Sub New(PDefenceItem, PColour)\nHealth = 100\nColour = PColour\nDefenceItem = PDefenceItem\nEnd Sub\nEnd Class\n\n2(b) 1 mark per mark point 2\n get header and close with no parameter …\n … returning defence item attribute\nExample program code:\nJava\npublic String GetDefenceItem(){\nreturn DefenceItem;\n}\nPython\ndef GetDefenceItem(self):\nreturn self.__DefenceItem\nVB.NET\nPublic Function GetDefenceItem()\nReturn DefenceItem\nEnd Function\n© UCLES 2022 Page 20 of 34\n\n2(c) 1 mark per mark point 2\n procedure header and close taking 1 parameter …\n … adding parameter value to health attribute\nExample program code:\nJava\npublic void ChangeHealth(Integer Change){\nHealth = Health + Change;\n}\nPython\ndef ChangeHealth(self, Change):\nself.__Health = self.__Health + Change\nVB.NET\nPublic Sub ChangeHealth(Change)\nHealth = Health + Change\nEnd Sub\n© UCLES 2022 Page 21 of 34\n\n2(d) 1 mark per mark point 2\n method header and close and checking if health attribute is <= 0\n Returning TRUE if health attribute <= 0 and returning FALSE otherwise\nExample program code:\nJava\npublic Boolean CheckHealth(){\nif(Health <= 0){\nreturn true;\n}else{\nreturn false;\n}\n}\nPython\ndef CheckHealth(self):\nif self.__Health <= 0:\nreturn True\nelse:\nreturn False\nVB.NET\nFunction CheckHealth()\nIf Health <= 0 Then\nReturn True\nElse\nReturn False\nEnd If\nEnd Function\n© UCLES 2022 Page 22 of 34\n\n2(e) 1 mark per mark point 3\n take as input defence method and colour (2 strings)\n instantiating new balloon object with identifier Balloon1 …\n … with both input values as parameters\nExample program code:\nJava\npublic static void main(String[] args){\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Enter balloon defence method\");\nString Method = scanner.nextLine();\nSystem.out.println(\"Enter the balloon colour\");\nString Colour = scanner.nextLine();\nBalloon Balloon1 = new Balloon(Method, Colour);\n}\nPython\nMethod = input(\"Enter balloon defence method \")\nColour = input(\"Enter the balloon colour \")\nBalloon1 = Balloon(Method, Colour)\nVB.NET\nSub Main()\nConsole.WriteLine(\"Enter balloon defence method\")\nDim Method As String = Console.ReadLine\nConsole.WriteLine(\"Enter the balloons colour\")\nDim Colour As String = Console.ReadLine\nDim Balloon1 As Balloon = New Balloon(Method, Colour)\nEnd Sub\n© UCLES 2022 Page 23 of 34\n\n2(f) 1 mark per mark point to max 8 8\n function header (and end where appropriate) and taking balloon object as parameter\n Inputting strength\n Calling ChangeHealth method for the parameter object …\n … with the input as a subtraction\n outputting the defence item for the parameter object …\n … using GetDefenceItem()\n Calling CheckHealth()for the parameter object …\n … outputting appropriate message if TRUE is returned (no health remaining)\n … outputting appropriate message if FALSE is returned (health remaining).\n Returning the updated balloon object\nExample program code:\nJava\npublic Balloon Defend(Balloon My Balloon){\nSystem.out.println(\"Enter the strength of opponent\");\nScanner scanner = new Scanner(System.in);\nInteger Strength = Integer.parseInt(scanner.nextLine());\nMyBalloon.ChangeHealth(-Strength);\nif(MyBalloon.CheckHealth() == true){\nSystem.out.println(\"Defence failed\");\n}else {\nSystem.out.println(\"Defence succeeded\");\n}\nreturn MyBalloon;\n}\n© UCLES 2022 Page 24 of 34\n\n2(f) Python\ndef Defend(MyBalloon):\nStrength = int(input(\"Enter the strength of opponent\"))\nMyBalloon.VhangeHealth(-Strength)\nprint(\"You defended with \", str(MyBalloon.GetDefenceItem()))\nif(MyBalloon.CheckHealth() == True):\nprint(\"Defence failed\")\nelse:\nprint(\"Defence succeeded\")\nreturn MyBalloon\nVB.NET\nFunction Defend(MyBalloon)\nConsole.WriteLine(\"Enter the strength of opponent\")\nDim Strength As Integer = Console.ReadLine\nMyBalloon.ChangeHealth(-Strength)\nConsole.WriteLine(\"You defended with \" & MyBalloon.GetDefenceItem)\nIf (MyBalloon.CheckHealth() = True) Then\nConsole.WriteLine(\"Defence failed\")\nElse\nConsole.WriteLine(\"Defence succeeded\")\nEnd If\nReturn MyBalloon\nEnd Function\n© UCLES 2022 Page 25 of 34\n\n2(g)(i) 1 mark each 2\n calling Defend with balloon object …\n … and stores return value over object\nExample program code:\nJava\nBalloon1 = Defend(Balloon1);\nPython\nBalloon1 = Defend(Balloon1)\nVB.NET\nBalloon1 = Defend(Balloon1)\n\n2(g)(ii) 1 mark for screenshot with: 1\nShield, Red and 50 input\nOutput stating their defence item was Shield\nOutput says health is not 0 (in some manner)\ne.g.\n© UCLES 2022 Page 26 of 34",
      "source_pages": [
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_43-p19.png",
        "../answer-assets/9618_s22_ms_43-p20.png",
        "../answer-assets/9618_s22_ms_43-p21.png",
        "../answer-assets/9618_s22_ms_43-p22.png",
        "../answer-assets/9618_s22_ms_43-p23.png",
        "../answer-assets/9618_s22_ms_43-p24.png",
        "../answer-assets/9618_s22_ms_43-p25.png",
        "../answer-assets/9618_s22_ms_43-p26.png"
      ]
    },
    {
      "id": "9618-2022-mj-43-q03",
      "question_id": "9618-2022-mj-43-q03",
      "subject": "9618",
      "year": 2022,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 21,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per mark point 2\n Declaring variables: head pointer, tail pointer and number of items all initialised as 0 (integer)\n QueueArray declared as 1D array as string with 10 elements\nExample program code:\nJava\npublic static void main(String[] args){\nString[] QueueArray = new String[10];\nInteger QueueHeadPointer = 0;\nInteger QueueTailPointer = 0;\nInteger NumberOfItems = 0;\n}\nPython\nQueueArray = ['','','','','','','','','',''] #string\nQueueHeadPointer = 0 #integer\nQueueTailPointer = 0 #integer\nNumberOfItems = 0 #integer\nVB.NET\nSub Main()\nDim QueueArray(0 To 9) As String\nDim QueueHeadPointer As Integer = 0\nDim QueueTailPointer As Integer = 0\nDim NumberOfItems As Integer = 0\nEnd Sub\n© UCLES 2022 Page 27 of 34\n\n3(b) 1 mark per complete statement (5) 7\n1 mark for function heading and end, dealing with ByRef\n1 mark for remainder of function correct and following the logic\nFUNCTION Enqueue(BYREF QueueArray[] : STRING, BYREF HeadPointer : Integer, BYREF\nTailPointer : Integer, NumberItems : INTEGER, DataToAdd : STRING) RETURNS\nBOOLEAN\nIF NumberItems = 10 THEN\nRETURN FALSE\nENDIF\nQueueArray[TailPointer]  DataToAdd\nIF TailPointer >= 9 THEN\nTailPointer  0\nELSE\nTailPointer  TailPointer + 1\nENDIF\nNumberItems  NumberItems + 1\nRETURN TRUE\nENDFUNCTION\nExample program code:\nJava\npublic static Boolean Enqueue(String DataToAdd){\nif(NumberOfItems == 10){\nreturn false;\n}\nQueueArray[QueueTailPointer] = DataToAdd;\nif(QueueTailPointer >= 9){\nQueueTailPointer = 0;\n}else{\nQueueTailPointer = QueueTailPointer + 1;\n}\nNumberOfItems = NumberOfItems + 1;\nreturn true;\n}\n© UCLES 2022 Page 28 of 34\n\n3(b) Python\ndef Enqueue(Queue, Head, Tail, NumItems, InputData):\nif NumItems >= 10:\nreturn (False, Queue, Head, Tail, NumItems)\nQueue[Tail] = InputData\nif Tail >= 9:\nTail = 0\nelse:\nTail = Tail + 1\nNumItems = NumItems + 1\nreturn (True, Queue, Head, Tail, NumItems)\nVB.NET\nFunction Enqueue(ByRef Queue() As String, ByRef Head As Integer, ByRef Tail As Integer,\nByRef NumItems As Integer, ByRef InputData As String)\nIf NumItems = 10 Then\nReturn False\nEnd If\nQueue(Tail) = InputData\nIf Tail >= 9 Then\nTail = 0\nElse\nTail = Tail + 1\n© UCLES 2022 Page 29 of 34\n\n3(c) 1 mark per mark point to max 6 6\n Function header and end\n checking if queue is empty …\n … returning False\n If not empty accessing and returning item at head pointer\n … incrementing head pointer …\n … changing head pointer to 0 if it's more than 9 after incrementing\n … decrement number of items\nExample program code:\nJava\npublic static String Dequeue(){\nif(NumberOfItems == 0){\nreturn \"FALSE\";\n}else{\nString ReturnValue = QueueArray[QueueHeadPointer];\nQueueHeadPointer = QueueHeadPointer + 1;\nif(QueueHeadPointer >= 9){\nQueueHeadPointer = 0;\n}\nNumberOfItems = NumberOfItems – 1;\nreturn ReturnValue;\n}\n}\nPython\ndef Dequeue(Queue, Head, Tail, NumItems):\nif NumItems == 0:\nreturn (false, Queue, Head, Tail, NumItems)\nelse:\nReturnValue = Queue(Head)\nHead = Head + 1\nif Head >= 9:\nHead = 0\nNumItems = NumItems - 1\nreturn(ReturnValue, Queue, Head, Tail, NumItems)\n© UCLES 2022 Page 30 of 34\n\n3(c) VB.NET\nFunction Dequeue(ByRef QueueArray() As String, ByRef QueueHeadPointer As Integer, ByRef\nQueueTailpointer As Integer, ByRef NumberOfItems As Integer)\nIf NumberOfItems = 0 Then\nReturn \"False\"\nElse\nDim ReturnValue = QueueArray(QueueHeadPointer)\nQueueHeadPointer = QueueHeadPointer + 1\nIf QueueHeadPointer >= 9 Then\nQueueHeadPointer = 0\nEnd If\nNumberOfItems = NumberOfItems - 1\nReturn ReturnValue\nEnd If\nEnd Function\n© UCLES 2022 Page 31 of 34\n\n3(d)(i) 1 mark per mark point 5\n Taking 11 inputs…\n … calling Enqueue with each of the 11 inputs …\n … outputting an appropriate message if added or not added\n Calling Dequeue twice …\n … outputting return value each time\nExample program code:\nJava\npublic static void main(String args[]){\nString InputString;\nfor(Integer x = 0; x < 11; x++){\nSystem.out.println(\"Enter a string\");\nScanner scanner = new Scanner(System.in);\nInputString = scanner.nextLine();\nif(Enqueue(InputString)){\nSystem.out.println(\"Successful\");\n}else{\nSystem.out.println(\"Unsuccessful\");\n}\n}\nSystem.out.println(Dequeue());\nSystem.out.println(Dequeue());\n}\n© UCLES 2022 Page 32 of 34\n\n3(d)(i) Python\nfor x in range(0, 11):\nInputString = input(\"Enter a string\")\nReturnValue, QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems =\nEnqueue(QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems, InputString)\nif ReturnValue == True:\nprint(\"Successful\")\nelse:\nprint(\"Unsuccessful\")\nReturnValue, QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems =\nDequeue(QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems)\nprint(ReturnValue)\nReturnValue, QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems =\nDequeue(QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems)\nprint(ReturnValue)\nVB.NET\nFor x = 0 To 10\nConsole.WriteLine(\"Enter a string\")\nInputString = Console.ReadLine\nIf(Enqueue(QueueArray, QueueHeadPointer, QueueTailPointer, NumberOfItems, InputString))\nThen\nConsole.WriteLine(\"Successful\")\nElse\nConsole.WriteLine(\"Unsuccessful\")\nEnd If\nNext\nConsole.WriteLine(Dequeue)\nConsole.WriteLine(Dequeue)\n© UCLES 2022 Page 33 of 34\n\n3(d)(ii) 1 mark for showing inputs and outputs: 1\nA – J input and successful.\nK input and unsuccessful.\nOutput: A, B\ne.g.\n© UCLES 2022 Page 34 of 34",
      "source_pages": [
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34
      ],
      "source_pdf": "_source-pdfs/2022-may-june/ms/9618_s22_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-May-June/9618_s22_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s22_ms_43-p27.png",
        "../answer-assets/9618_s22_ms_43-p28.png",
        "../answer-assets/9618_s22_ms_43-p29.png",
        "../answer-assets/9618_s22_ms_43-p30.png",
        "../answer-assets/9618_s22_ms_43-p31.png",
        "../answer-assets/9618_s22_ms_43-p32.png",
        "../answer-assets/9618_s22_ms_43-p33.png",
        "../answer-assets/9618_s22_ms_43-p34.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q01",
      "question_id": "9618-2022-on-31-q01",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "1(a) Two marks for working 3\nOne mark for correct answer\nWorking:\nConversion to binary + 202 = 11001010 // repeated division by 2 // 128 + 64 + 8 + 2\nAppropriate shifting of binary point for + 202 = 0.1100101  28 // exponent = 8\nAnswer:\n= 01100101 00001000 (stored as mantissa and exponent)\n\n1(b) Two marks for working 3\nOne mark for correct answer\nWorking:\n• Appropriate method of conversion e.g.\n= 10011010 (one’s complement of 8-bit mantissa)\n= 10011011 (two’s complement of 8-bit mantissa)\n–256 + 32 + 16 + 4 +2\n• Realisation that the exponent doesn’t change // value of exponent = 8 // appropriate shifting of binary point\nAnswer:\n= 10011011 00001000 (stored as mantissa and exponent)\n\n1(c)(i) The mantissa does not begin with 01/10 (as its most significant bits) 1\n// the mantissa begins with 00 // first two digits are the same.\n\n1(c)(ii) One mark for each point: 2\n• Correct mantissa\n• Correct exponent\nMantissa Exponent\n0 1 1 1 1 0 0 0 0 0 0 1 0 1 1 0\n© UCLES 2022 Page 4 of 15",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q02",
      "question_id": "9618-2022-on-31-q02",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 2,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "2 One mark for each point (Max 3) 5\nMP1 The Transport Layer breaks data into manageable packets / performs segmentation\nMP2 It sequences the packets // adds data to the packet header // adds a packet header\nMP3 It sends the packets to the Internet / Network Layer // It receives data from the Application Layer\nMP4 It controls the flow of packets\nMP5 It handles packet loss/corruption // Acknowledges receipt of complete error free packets\nOne mark for each point (Max 3)\nMP6 The Internet Layer identifies the intended network and host\nMP7 It transmits packets to the (Data) Link / Physical Layer\nMP8 It routes the packets independently through the optimum route\nMP9 It addresses packets with their source and destination IP addresses\nMP10 It then uses an IP address and port number to form a socket.\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p05.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q03",
      "question_id": "9618-2022-on-31-q03",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 3,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "3(a) A (user-defined non-composite) data type with an ordered list of possible values. 1\n\n3(b) A user-defined non-composite data type used to reference a memory location. 1\n\n3(c) Marks as shown in the square brackets: 2\nTYPE Quarter1 = (January, February, March)\nTYPE Quarter1 = [1]\n(January, February, March) [1]\n\n3(d)(i) DECLARE Pet1 : Pet 1\n© UCLES 2022 Page 5 of 15\n\n3(d)(ii) One mark for each point: 3\n• Correct assignment of all string data values\n• Correct assignment of char data value\n• Correct assignment of integer data value\nExample answer:\nPet1.PetName  \"Tibbles\"\nPet1.AnimalType  \"Cat\"\nPet1.PetAge  8\nPet1.PetGender  'M'\nPet1.OwnerName  \"Jasmine Smith\"\n© UCLES 2022 Page 6 of 15",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p05.png",
        "../answer-assets/9618_w22_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q04",
      "question_id": "9618-2022-on-31-q04",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 4,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "4 One mark for each correct line connecting one stage of compilation to a description 4\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q05",
      "question_id": "9618-2022-on-31-q05",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "5(a) a b * b + d - 15 + 1\n\n5(b)(i) (a - b) * (c + d) / a 1\n\n5(b)(ii) –39 1\n© UCLES 2022 Page 7 of 15",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q06",
      "question_id": "9618-2022-on-31-q06",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 6,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for each correct point (Max 2) 2\n• A private key is the unpublished/secret key/never transmitted anywhere.\n• It has a matching public key\n• It is used to decrypt data that was encrypted with its matching public key.\n\n6(b) One mark for each correct point (Max 2) 2\n• The message to be sent is encrypted using the recipient’s public key. // The message to be sent is encrypted using\nthe sender’s private key.\n• The message is decrypted using the recipient’s private key. // The message is decrypted using the sender’s public\nkey.\n\n6(c) One mark for each correct point (Max 4) 4\n• The message together with the digital signature is decrypted using the receiver’s private key\n• The digital signature received is decrypted with the sender’s public key to recover the message digest sent\n• The decrypted message received is hashed with the agreed hashing algorithm to reproduce the message digest of the\nmessage received\n• The two message digests are compared\n• … if both digests are the same the message has not been altered // if they are different the message has been\naltered.\n© UCLES 2022 Page 8 of 15",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p08.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q07",
      "question_id": "9618-2022-on-31-q07",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "7(a) Two marks if no errors present 2\nOne mark if one error present\nAB\n00 01 11 10\nCD\n00 0 1 1 1\n01 0 1 1 1\n11 0 0 0 0\n10 0 0 0 0\n\n7(b) One mark for correct loop (Max 2) 2\n© UCLES 2022 Page 9 of 15\n\n7(c) One mark for each point 3\n• Any correct Boolean term\n• Boolean terms and operator correct and no other terms present\n_ _\n(Z =) BC + AC\nOne mark for simplest form\n_\n(Z =) C (A + B)\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p09.png",
        "../answer-assets/9618_w22_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q08",
      "question_id": "9618-2022-on-31-q08",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 8,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correct point (Max 3) 3\n• Disk / secondary storage is used to extend the RAM / memory available\n• … so the CPU appears to be able to access more memory space than the available RAM\n• Only the data in use needs to be in main memory so data can be swapped between RAM and virtual memory as\nnecessary\n• Virtual memory is created temporarily.\n\n8(b) One mark for a correct statement about the difference between paging and segmentation e.g. 1\n• Paging allows the memory to be divided into fixed size blocks and\nSegmentation divides the memory into variable sized blocks.\n• The operating system divides the memory into pages, the compiler is responsible for calculating the segment size.\n• Access times for paging is faster than for segmentation.\n© UCLES 2022 Page 10 of 15",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q09",
      "question_id": "9618-2022-on-31-q09",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 9,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark for each correct point (Max 2) 2\n• Uses artificial neural network(s)\n• … that contain(s) a high number of hidden layers\n• … modelled on the human brain.\n• Deep learning uses many layers to progressively extract higher level features from the (raw) input.\n• Deep learning is a specialised form of machine learning.\n\n9(b) One mark for each correct point (Max 2) 2\n• Deep learning makes good use of unstructured data.\n• Deep learning outperforms other methods if the data size is large.\n• Deep learning systems enable machines to process data with a nonlinear approach.\n• Deep learning is effective at identifying (hidden) patterns / patterns that humans might not be able to see / patterns that\nare too complex / time consuming for humans to carry out.\n• It can provide a more accurate outcome with higher numbers of hidden layers.\nQuestion Answer Marks",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p11.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q10",
      "question_id": "9618-2022-on-31-q10",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 10,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "10(a) Two marks for all five rows correct 2\nOne mark for four rows correct\nStatement RISC CISC\nuses a smaller instruction set ✓\nuses single-cycle instructions and limited addressing modes ✓\nuses fewer general-purpose registers ✓\nuses both hardwired and micro coded control unit ✓\nuses a system where cache is split between data and\n✓\ninstructions\n© UCLES 2022 Page 11 of 15\n\n10(b) One mark for each correct point (Max 4) 4\n• Instructions are divided into subtasks / 5 stages\n• … Instruction fetch / IF, Instruction decode / ID, operand fetch / OF, opcode/instruction execute IE, result store / write\nback result / WB\n• Each subtask is completed during one clock cycle\n• No two instructions can execute their same stage at the same clock cycle\n• The second instruction begins in the second clock cycle, while the first instruction has moved on to its second subtask.\n• The third instruction begins in the third clock cycle while the first and second instructions move on to their second and\nthird subtasks, respectively, etc.\nQuestion Answer Marks",
      "source_pages": [
        11,
        12
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p11.png",
        "../answer-assets/9618_w22_ms_31-p12.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q11",
      "question_id": "9618-2022-on-31-q11",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 11,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark for each correct OOP term definition: 3\n• Instance – an occurrence of an object // a specific object based on the class // an instantiation of a class.\n• Inheritance – the capability of defining a new class of objects that has all the attributes and methods from a parent\nclass.\n• Polymorphism – allows the same method to take on different behaviours depending on which class is instantiated //\nmethods can be redefined for derived classes.\n© UCLES 2022 Page 12 of 15\n\n11(b) One mark for each point: 5\n• Car and ENDCLASS\n• Four declarations – must use the identifiers used in the assignments\n• Constructor header – must use CarBodyType\n• Two assignments – must use CarMake\n• Constructor identifier for the car model and the identifier in the Model assignment statement match\nCLASS Car\nPRIVATE Make : STRING\nPRIVATE Model : STRING\nPRIVATE BodyType : STRING\nPRIVATE Fuel : STRING\nPRIVATE NumberBuilt : INTEGER\nPUBLIC PROCEDURE NEW (CarMake : STRING,\nCarModel : STRING, CarBodyType : STRING)\nMake  CarMake\nModel  CarModel\nBodyType  CarBodyType\nFuel  \"\"\nNumberBuilt  0\nENDPROCEDURE\ngetFuel()\ngetNumberBuilt()\nENDCLASS\n© UCLES 2022 Page 13 of 15",
      "source_pages": [
        12,
        13
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p12.png",
        "../answer-assets/9618_w22_ms_31-p13.png"
      ]
    },
    {
      "id": "9618-2022-on-31-q12",
      "question_id": "9618-2022-on-31-q12",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 12,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "12(a) One mark for each point (Max 6) 6\n• Initialisation of upper bound\n• Test if upper bound is less than lower bound\n• Re-setting of mid value if current value is lower than the target\n• Re-setting of mid value if current value is higher than the target\n• Finding the value\n• Correct termination of loop\nLower  0\nUpper  99\nMid  0\nExit  FALSE\nOUTPUT \"Enter the name to be found \"\nINPUT Target\nREPEAT\nIF Upper < Lower THEN\nOUTPUT Target, \" does not exist\"\nExit  TRUE\nENDIF\nMid  Lower + (Upper – Lower + 1) DIV 2\nIF Names[Mid] < Target THEN\nLower  Mid + 1\nENDIF\nIF Names[Mid] > Target THEN\nUpper  Mid - 1\nENDIF\nIF Names[Mid] = Target THEN\nOUTPUT Target, \" was found at location \", Mid\nExit  TRUE\nENDIF\nUNTIL Exit // UNTIL Exit = TRUE\n\n12(b)(i) O(n) 1\n© UCLES 2022 Page 14 of 15\n\n12(b)(ii) One mark for each point (Max 2) 2\n• O(log n) is a time complexity that uses logarithmic time.\n• The time taken goes up linearly as the number of items rises exponentially\n• O(log n) is the worst case scenario (time complexity for a binary search).\n© UCLES 2022 Page 15 of 15",
      "source_pages": [
        14,
        15
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_31-p14.png",
        "../answer-assets/9618_w22_ms_31-p15.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q01",
      "question_id": "9618-2022-on-32-q01",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) Mantissa Exponent 1\n0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1\n\n1(b) Two marks for working 3\n• correct calculation of exponent seen\n• correct application of exponent to mantissa seen\nOne mark for correct answer\nWorking:\n= 1.0110010011  29 //exponent = 9\n= 1011001001.1 (moving bp 9 places to right) // evaluate two’s complement\nFor example: –512 + 128 + 64 + 8 + 1 + 0.5\nAnswer:\n–310.5 // –3101/",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q02",
      "question_id": "9618-2022-on-32-q02",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 2,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "2\n1(c) One mark per point 2\n• Following an arithmetic/logical operation\n• … the result is too small to be precisely represented in the available system // When the number of bits is not enough /\ntoo small for the computer’s allocated word size / to represent the binary number\nQuestion Answer Marks\n\n2(a) One mark per point 2\n• Code generation\n• Optimisation\n© UCLES 2022 Page 4 of 16\n\n2(b) One mark per point (Max 2) 2\n• It checks that the code matches the grammar of the language // It checks that the tokens conform with the rules of the\nprogramming language\n• Syntax errors are reported\n• A parse tree is produced.\nQuestion Answer Marks",
      "source_pages": [
        4,
        5
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p04.png",
        "../answer-assets/9618_w22_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q03",
      "question_id": "9618-2022-on-32-q03",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per point (Max 2) 2\n• Protocols set a standard for communication\n• Protocols enable communication/compatibility between devices from different manufacturers/platforms\n• If two devices were sending messages to each other but using different protocols, they would not be able to\ncommunicate properly\n\n3(b) One mark for each correct answer 2\nApplication (Layer)\nTransport\nInternet/Network (Layer)\nLink\n\n3(c) One mark per point (Max 2) 2\n• used by email clients to retrieve email messages // a pull protocol\n• from a mail server (over a TCP/IP connection)\n• keeps the server and client in sync (by not deleting the original email). // allows a copy of the email to be downloaded\nfrom the mail server.\n© UCLES 2022 Page 5 of 16",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q04",
      "question_id": "9618-2022-on-32-q04",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 4,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "4(a) Marks as shown in the square brackets: 2\nTYPE Aircraft = (C300, C350, D242, E757, X380)\nTYPE Aircraft = [1]\n(C300, C350, D242, E757, X380) [1]\n\n4(b) One mark for each point (Max 4) 4\n• TYPE Flight and ENDTYPE correct\n• DECLARE FlightNumber and DECLARE Destination as STRING\n• DECLARE DepartureDate as DATE\n• DECLARE AircraftType as Aircraft (correct data type from part 4(a))\nExample answer:\nTYPE Flight\nDECLARE FlightNumber : STRING\nDECLARE Destination : STRING\nDECLARE DepartureDate : DATE\nDECLARE AircraftType : Aircraft\nENDTYPE\n\n4(c)(i) Example answer: 1\nDECLARE Flight1 : Flight\n© UCLES 2022 Page 6 of 16\n\n4(c)(ii) One mark for each point (Max 3) 3\n• Correct assignments of both string data values\n• Correct assignments of date data value\n• Correct assignments of enumerated data value\nExample answer:\nFlight1.FlightNumber  \"XA782\"\nFlight1.Destination  \"Cambridge\"\nFlight1.DepartureDate  12/12/2022\nFlight1.AircraftType  C350\n© UCLES 2022 Page 7 of 16",
      "source_pages": [
        6,
        7
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p06.png",
        "../answer-assets/9618_w22_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q05",
      "question_id": "9618-2022-on-32-q05",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 5,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "5 One mark for each description (Max 2) 6\n• The emulation of a computer system / hardware and/or software\n• … using a host computer system.\n• Using guest operating system(s) for emulation.\nOne mark for each correct benefit (Max 2)\n• Multiple guest operating systems / VMs can be used on the same computer.\n• Different instruction set architectures can be emulated on a single computer.\n• A virtual machine can crash without affecting the host machine.\n• There are security benefits // Trying a piece of suspicious software and if it is / has a virus, it will only infect the virtual\nmachine.\n• Cost savings due to not needing to purchase extra hardware.\n• Can run legacy applications that are currently incompatible.\nOne mark for each correct drawback (Max 2)\n• A virtual machine is less efficient / has poorer performance than real machines because of extra load on the host\ncomputer\n• Performance of the guest system cannot be adequately measured.\n• A virtual machine may be affected by any weaknesses of the host machine.\n• Costly and/or complex to maintain / implement / manage.\n• Cannot emulate some hardware.\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p08.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q06",
      "question_id": "9618-2022-on-32-q06",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 6,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for each point 2\n• Symmetric encryption uses a single key and asymmetric encryption uses a pair of keys.\n• The symmetric single key is used by all, whereas only one of the keys for asymmetric encryption is available to\neveryone / one of the asymmetric encryption keys needs to be kept secret.\n© UCLES 2022 Page 8 of 16\n\n6(b) One mark for each point (Max 4) 4\n• The organisation requests a certificate from a Certificate Authority (CA)\n• The organisation may send their public key to CA\n• The organisation gathers all the information required by the CA in order to obtain their certificate, which includes\ninformation to prove their identity\n• The CA verifies the organisation’s identity\n• The CA generates / issues the certificate including the organisation’s public key (and other information).\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p08.png",
        "../answer-assets/9618_w22_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q07",
      "question_id": "9618-2022-on-32-q07",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 7,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "7 One mark for each point 4\nSupervised learning (Max 3 of 4)\n• Supervised learning allows data to be collected, or a data output produced, from the previous experience.\n• In supervised learning, known input and associated outputs are given // uses sample data with known outputs (in\ntraining) // uses labelled input data.\n• Able to predict future outcomes based on past data.\nUnsupervised learning (Max 3 of 4)\n• Unsupervised machine learning helps all kinds of unknown patterns in data to be found.\n• Unsupervised learning only requires input data to be given.\n• Uses any data // not trained on the right output // uses unlabelled input data.\n© UCLES 2022 Page 9 of 16",
      "source_pages": [
        9
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q08",
      "question_id": "9618-2022-on-32-q08",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 8,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each point (Max 4) 4\n• One correct NAND or NOR gate with two separate inputs and one output\n• Second correct logic gate of same type as first with two separate inputs and one output\n• Correct connections between logic gates\n• Correctly labelled inputs\nExample answers:\nS/Set\nR/Reset\n© UCLES 2022 Page 10 of 16\n\n8(a) Or\nR/Reset\nS/Set\n\n8(b) To store a binary digit / (single) bit. 1\n© UCLES 2022 Page 11 of 16\n\n8(c) One mark for each point (Max 3) 3\n• Correct application of De Morgan’s Law\n• Correct application of Double Negation Law or Distributive Law\n• Correct answer\n(A.B).(A.C).(B.D)\n(A.B) + (A.C) + (B.D) [1]\n_ _ _\n(A.B) + (A.C) + (B.D) [1]\n_ _\nA. (B + C) + B.D [1]\nQuestion Answer Marks",
      "source_pages": [
        10,
        11,
        12
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p10.png",
        "../answer-assets/9618_w22_ms_32-p11.png",
        "../answer-assets/9618_w22_ms_32-p12.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q09",
      "question_id": "9618-2022-on-32-q09",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 9,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark for each point (Max 3) 3\n• Process scheduling allows more than one program/task to appear to be executed at the same time / enables multi-\ntasking / multiprogramming.\n• To allow high priority jobs to be completed first.\n• To keep the CPU busy all the time\n• … to ensure that all processes execute efficiently\n• … and to have reduced wait times for all processes / to ensure all processes have fair access to the CPU / prevent\nstarvation of some processes.\n© UCLES 2022 Page 12 of 16\n\n9(b) One mark for each point (Max 2) for Shortest job first: 6\n• Process are executed in ascending order of the amount of CPU time required // Short processes are executed first and\nfollowed by longer processes.\n• …which leads to an increased throughput (because more processes can be executed in a smaller amount of time).\nOne mark for each point (Max 2) for Round robin:\n• Each process is served by the CPU for a fixed time/time slice (so all processes are given the same priority).\n• Starvation doesn’t occur (because for each round robin cycle, every process is given a fixed time/time slice to execute).\nOne mark for each point (Max 2) for First come first served:\n• No complex logic, each process request is queued as it is received and executed one by one.\n• Starvation doesn’t occur (because every process will eventually get a chance to run) // less processor overhead.\nQuestion Answer Marks",
      "source_pages": [
        12,
        13
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p12.png",
        "../answer-assets/9618_w22_ms_32-p13.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q10",
      "question_id": "9618-2022-on-32-q10",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 10,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark for each correct OOP term definition 3\n• Encapsulation – putting properties and methods inside a class // ensures sensitive data is hidden from users by hiding\nvalues of a structured data object inside a class.\n• Getter – method that is used to return the value of a property.\n• Setter – method that is used to update the value of a property.\n© UCLES 2022 Page 13 of 16\n\n10(b) One mark for each point 3\n• properties correct\n• setters correct\n• getters correct\nSubstituteTeacher\nSubName : STRING\nTelephone : STRING\nInSchool : BOOLEAN\nSetSubName(StaffName : STRING)\nSetTelephone(Tel : STRING)\nSetInSchool(Present : BOOLEAN)\nGetSubName()\nGetTelephone()\nGetInSchool()\n© UCLES 2022 Page 14 of 16",
      "source_pages": [
        13,
        14
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p13.png",
        "../answer-assets/9618_w22_ms_32-p14.png"
      ]
    },
    {
      "id": "9618-2022-on-32-q11",
      "question_id": "9618-2022-on-32-q11",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 11,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark for each point 3\n• Correct HeadPointer\n• Any three correct NextPointer\n• All six NextPointer correct\nHeadPointer 5\nIndex Flower NextPointer\n1 Rose 0\n2 Marigold\n3 Foxglove 4\n4 Iris 9\n5 Daisy 3\n6 Dahlia\n7 Saxifrage\n8 Lupin 1\n9 Lily 8\n10 Hydrangea\n© UCLES 2022 Page 15 of 16\n\n11(b) One mark for each correct line 5\nPointer  HeadPointer\nFound  0\nOUTPUT \"Enter a flower name \"\nINPUT FlowerName\nWHILE Pointer <> 0\nIF Flower[Pointer] = FlowerName THEN\nFound  Pointer\nPointer  0\nELSE\nPointer  NextPointer[Pointer]\nENDIF\nENDWHILE\nIF Pointer = 0 THEN // IF Found <> 0 THEN\nOUTPUT Flower[Found], \" is found\"\nELSE\nOUTPUT \"The flower you wanted is not in the list\"\nENDIF\n\n11(c) One mark for each point (Max 2) 2\n• Include a free list pointer\n• …to reuse the unused space\n• …as a linked list of free space.\n© UCLES 2022 Page 16 of 16",
      "source_pages": [
        15,
        16
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_32-p15.png",
        "../answer-assets/9618_w22_ms_32-p16.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q01",
      "question_id": "9618-2022-on-33-q01",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "1(a) Two marks for working 3\nOne mark for correct answer\nWorking:\nConversion to binary + 202 = 11001010 // repeated division by 2 // 128 + 64 + 8 + 2\nAppropriate shifting of binary point for + 202 = 0.1100101  28 // exponent = 8\nAnswer:\n= 01100101 00001000 (stored as mantissa and exponent)\n\n1(b) Two marks for working 3\nOne mark for correct answer\nWorking:\n• Appropriate method of conversion e.g.\n= 10011010 (one’s complement of 8-bit mantissa)\n= 10011011 (two’s complement of 8-bit mantissa)\n–256 + 32 + 16 + 4 +2\n• Realisation that the exponent doesn’t change // value of exponent = 8 // appropriate shifting of binary point\nAnswer:\n= 10011011 00001000 (stored as mantissa and exponent)\n\n1(c)(i) The mantissa does not begin with 01/10 (as its most significant bits) 1\n// the mantissa begins with 00 // first two digits are the same.\n\n1(c)(ii) One mark for each point: 2\n• Correct mantissa\n• Correct exponent\nMantissa Exponent\n0 1 1 1 1 0 0 0 0 0 0 1 0 1 1 0\n© UCLES 2022 Page 4 of 15",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q02",
      "question_id": "9618-2022-on-33-q02",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 2,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "2 One mark for each point (Max 3) 5\nMP1 The Transport Layer breaks data into manageable packets / performs segmentation\nMP2 It sequences the packets // adds data to the packet header // adds a packet header\nMP3 It sends the packets to the Internet / Network Layer // It receives data from the Application Layer\nMP4 It controls the flow of packets\nMP5 It handles packet loss/corruption // Acknowledges receipt of complete error free packets\nOne mark for each point (Max 3)\nMP6 The Internet Layer identifies the intended network and host\nMP7 It transmits packets to the (Data) Link / Physical Layer\nMP8 It routes the packets independently through the optimum route\nMP9 It addresses packets with their source and destination IP addresses\nMP10 It then uses an IP address and port number to form a socket.\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p05.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q03",
      "question_id": "9618-2022-on-33-q03",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 3,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "3(a) A (user-defined non-composite) data type with an ordered list of possible values. 1\n\n3(b) A user-defined non-composite data type used to reference a memory location. 1\n\n3(c) Marks as shown in the square brackets: 2\nTYPE Quarter1 = (January, February, March)\nTYPE Quarter1 = [1]\n(January, February, March) [1]\n\n3(d)(i) DECLARE Pet1 : Pet 1\n© UCLES 2022 Page 5 of 15\n\n3(d)(ii) One mark for each point: 3\n• Correct assignment of all string data values\n• Correct assignment of char data value\n• Correct assignment of integer data value\nExample answer:\nPet1.PetName  \"Tibbles\"\nPet1.AnimalType  \"Cat\"\nPet1.PetAge  8\nPet1.PetGender  'M'\nPet1.OwnerName  \"Jasmine Smith\"\n© UCLES 2022 Page 6 of 15",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p05.png",
        "../answer-assets/9618_w22_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q04",
      "question_id": "9618-2022-on-33-q04",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 4,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "4 One mark for each correct line connecting one stage of compilation to a description 4\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q05",
      "question_id": "9618-2022-on-33-q05",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "5(a) a b * b + d - 15 + 1\n\n5(b)(i) (a - b) * (c + d) / a 1\n\n5(b)(ii) –39 1\n© UCLES 2022 Page 7 of 15",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q06",
      "question_id": "9618-2022-on-33-q06",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 6,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for each correct point (Max 2) 2\n• A private key is the unpublished/secret key/never transmitted anywhere.\n• It has a matching public key\n• It is used to decrypt data that was encrypted with its matching public key.\n\n6(b) One mark for each correct point (Max 2) 2\n• The message to be sent is encrypted using the recipient’s public key. // The message to be sent is encrypted using\nthe sender’s private key.\n• The message is decrypted using the recipient’s private key. // The message is decrypted using the sender’s public\nkey.\n\n6(c) One mark for each correct point (Max 4) 4\n• The message together with the digital signature is decrypted using the receiver’s private key\n• The digital signature received is decrypted with the sender’s public key to recover the message digest sent\n• The decrypted message received is hashed with the agreed hashing algorithm to reproduce the message digest of the\nmessage received\n• The two message digests are compared\n• … if both digests are the same the message has not been altered // if they are different the message has been\naltered.\n© UCLES 2022 Page 8 of 15",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p08.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q07",
      "question_id": "9618-2022-on-33-q07",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "7(a) Two marks if no errors present 2\nOne mark if one error present\nAB\n00 01 11 10\nCD\n00 0 1 1 1\n01 0 1 1 1\n11 0 0 0 0\n10 0 0 0 0\n\n7(b) One mark for correct loop (Max 2) 2\n© UCLES 2022 Page 9 of 15\n\n7(c) One mark for each point 3\n• Any correct Boolean term\n• Boolean terms and operator correct and no other terms present\n_ _\n(Z =) BC + AC\nOne mark for simplest form\n_\n(Z =) C (A + B)\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p09.png",
        "../answer-assets/9618_w22_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q08",
      "question_id": "9618-2022-on-33-q08",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 8,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correct point (Max 3) 3\n• Disk / secondary storage is used to extend the RAM / memory available\n• … so the CPU appears to be able to access more memory space than the available RAM\n• Only the data in use needs to be in main memory so data can be swapped between RAM and virtual memory as\nnecessary\n• Virtual memory is created temporarily.\n\n8(b) One mark for a correct statement about the difference between paging and segmentation e.g. 1\n• Paging allows the memory to be divided into fixed size blocks and\nSegmentation divides the memory into variable sized blocks.\n• The operating system divides the memory into pages, the compiler is responsible for calculating the segment size.\n• Access times for paging is faster than for segmentation.\n© UCLES 2022 Page 10 of 15",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q09",
      "question_id": "9618-2022-on-33-q09",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 9,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark for each correct point (Max 2) 2\n• Uses artificial neural network(s)\n• … that contain(s) a high number of hidden layers\n• … modelled on the human brain.\n• Deep learning uses many layers to progressively extract higher level features from the (raw) input.\n• Deep learning is a specialised form of machine learning.\n\n9(b) One mark for each correct point (Max 2) 2\n• Deep learning makes good use of unstructured data.\n• Deep learning outperforms other methods if the data size is large.\n• Deep learning systems enable machines to process data with a nonlinear approach.\n• Deep learning is effective at identifying (hidden) patterns / patterns that humans might not be able to see / patterns that\nare too complex / time consuming for humans to carry out.\n• It can provide a more accurate outcome with higher numbers of hidden layers.\nQuestion Answer Marks",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p11.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q10",
      "question_id": "9618-2022-on-33-q10",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 10,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "10(a) Two marks for all five rows correct 2\nOne mark for four rows correct\nStatement RISC CISC\nuses a smaller instruction set ✓\nuses single-cycle instructions and limited addressing modes ✓\nuses fewer general-purpose registers ✓\nuses both hardwired and micro coded control unit ✓\nuses a system where cache is split between data and\n✓\ninstructions\n© UCLES 2022 Page 11 of 15\n\n10(b) One mark for each correct point (Max 4) 4\n• Instructions are divided into subtasks / 5 stages\n• … Instruction fetch / IF, Instruction decode / ID, operand fetch / OF, opcode/instruction execute IE, result store / write\nback result / WB\n• Each subtask is completed during one clock cycle\n• No two instructions can execute their same stage at the same clock cycle\n• The second instruction begins in the second clock cycle, while the first instruction has moved on to its second subtask.\n• The third instruction begins in the third clock cycle while the first and second instructions move on to their second and\nthird subtasks, respectively, etc.\nQuestion Answer Marks",
      "source_pages": [
        11,
        12
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p11.png",
        "../answer-assets/9618_w22_ms_33-p12.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q11",
      "question_id": "9618-2022-on-33-q11",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 11,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark for each correct OOP term definition: 3\n• Instance – an occurrence of an object // a specific object based on the class // an instantiation of a class.\n• Inheritance – the capability of defining a new class of objects that has all the attributes and methods from a parent\nclass.\n• Polymorphism – allows the same method to take on different behaviours depending on which class is instantiated //\nmethods can be redefined for derived classes.\n© UCLES 2022 Page 12 of 15\n\n11(b) One mark for each point: 5\n• Car and ENDCLASS\n• Four declarations – must use the identifiers used in the assignments\n• Constructor header – must use CarBodyType\n• Two assignments – must use CarMake\n• Constructor identifier for the car model and the identifier in the Model assignment statement match\nCLASS Car\nPRIVATE Make : STRING\nPRIVATE Model : STRING\nPRIVATE BodyType : STRING\nPRIVATE Fuel : STRING\nPRIVATE NumberBuilt : INTEGER\nPUBLIC PROCEDURE NEW (CarMake : STRING,\nCarModel : STRING, CarBodyType : STRING)\nMake  CarMake\nModel  CarModel\nBodyType  CarBodyType\nFuel  \"\"\nNumberBuilt  0\nENDPROCEDURE\ngetFuel()\ngetNumberBuilt()\nENDCLASS\n© UCLES 2022 Page 13 of 15",
      "source_pages": [
        12,
        13
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p12.png",
        "../answer-assets/9618_w22_ms_33-p13.png"
      ]
    },
    {
      "id": "9618-2022-on-33-q12",
      "question_id": "9618-2022-on-33-q12",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 12,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "12(a) One mark for each point (Max 6) 6\n• Initialisation of upper bound\n• Test if upper bound is less than lower bound\n• Re-setting of mid value if current value is lower than the target\n• Re-setting of mid value if current value is higher than the target\n• Finding the value\n• Correct termination of loop\nLower  0\nUpper  99\nMid  0\nExit  FALSE\nOUTPUT \"Enter the name to be found \"\nINPUT Target\nREPEAT\nIF Upper < Lower THEN\nOUTPUT Target, \" does not exist\"\nExit  TRUE\nENDIF\nMid  Lower + (Upper – Lower + 1) DIV 2\nIF Names[Mid] < Target THEN\nLower  Mid + 1\nENDIF\nIF Names[Mid] > Target THEN\nUpper  Mid - 1\nENDIF\nIF Names[Mid] = Target THEN\nOUTPUT Target, \" was found at location \", Mid\nExit  TRUE\nENDIF\nUNTIL Exit // UNTIL Exit = TRUE\n\n12(b)(i) O(n) 1\n© UCLES 2022 Page 14 of 15\n\n12(b)(ii) One mark for each point (Max 2) 2\n• O(log n) is a time complexity that uses logarithmic time.\n• The time taken goes up linearly as the number of items rises exponentially\n• O(log n) is the worst case scenario (time complexity for a binary search).\n© UCLES 2022 Page 15 of 15",
      "source_pages": [
        14,
        15
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_33-p14.png",
        "../answer-assets/9618_w22_ms_33-p15.png"
      ]
    },
    {
      "id": "9618-2022-on-41-q01",
      "question_id": "9618-2022-on-41-q01",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 23,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per point: 2\n• (global) 1D (Integer) array DataArray\n• 100 elements\nExample program code:\nPython\nDataArray = [0 for I in range (100)]\nJava\npublic static Integer[] DataArray = new Integer[100];\nVB.NET\nDim DataArray(99) As Integer\n\n1(b) 1 mark per point: 6\n• Procedure ReadFile() header (and end where appropriate)\n• opening file IntegerData.txt (for read)\n• looping through the 100 elements // looping to end of file\n• reading each (and all) value from file and storing in array\n• closing file (in appropriate place)\n\n1 mark per point:\n• Exception Handling (for opening the file, or for reading values from the\nfile)…\n• …with appropriate catch and output messages\nExample program code:\nPython\ndef ReadFile():\nglobal DataArray\ntry:\nTextFile = \"IntegerData.txt\"\nFile = open(TextFile, 'r')\nfor X in range(0, 100):\nDataArray[X] = File.readline()\nDataArray[X].rstrip('\\n')\nDataArray[X] = int(DataArray[X])\nFile.close()\nexcept IOError:\nprint(\"Count not find file\")\n© UCLES 2022 Page 3 of 23\n\n1(b) Java\npublic static void ReadFile(){\nString Filename = \"IntegerData.txt\";\ntry{\nFileReader F = new FileReader(Filename);\nBufferedReader Reader = new BufferedReader(F);\nfor(Integer X = 0; X < 100; X++){\nDataArray[X] =\nInteger.parseInt(Reader.readLine());\n}\nReader.close();\n}\ncatch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No file found\");\n}\n}\nVB.NET\nSub ReadFile()\ntry\nDim TextFile As String = \"IntegerData.txt\"\nDim FileReader As New\nSystem.IO.StreamReader(TextFile)\nFor X = 0 To 99\nDataArray(X) = FileReader.ReadLine()\nNext\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\n\n1(c) 1 mark per point: 7\n• Function FindValues() (and end where appropriate) and input of data\nto search for in the array\n• …validation/casting(/storing as) of input as integer\n• …validation of input between 1 and 100 (inclusive)\n• looping through all 100 array elements…\n• …comparing input to each array element…\n• …initialising counter to 0 and then adding 1 each time it is found…\n• Returning the total\n© UCLES 2022 Page 4 of 23\n\n1(c) Example program code:\nPython\ndef FindValues():\nglobal DataArray\nDataToFind = -1\nwhile(DataToFind < 1 or DataToFind > 100):\nDataToFind = int(input(\"Enter a number between 1\nand 100\"))\nTotal = 0\nfor X in range(0, 99):\nif DataArray[X] == DataToFind:\nTotal = Total + 1\nreturn Total\nVB.NET\nFunction FindValues()\nDim DataToFind As Integer\nDo\nConsole.WriteLine(\"Enter a number between 1 and 100\")\nDataToFind = Console.ReadLine()\nLoop Until (DataToFind >= 1 And DataToFind <= 100)\nDim Total As Integer = 0\nFor X = 0 To 99\nIf DataArray(X) = DataToFind Then\nTotal = Total + 1\nEnd If\nNext\nReturn Total\nEnd Function\nJava\npublic static Integer FindValues(){\nInteger DataToFind = -1;\nwhile(DataToFind < 1 || DataToFind > 100){\nSystem.out.println(\"Enter a number between 1 and\n100\");\nScanner in = new Scanner(System.in);\nDataToFind = in.nextInt();\n}\nInteger Total = 0;\nfor(Integer X = 0; X < 100; X++){\nif(DataArray[X] == DataToFind){\nTotal = Total + 1;\n}\n}\nreturn Total;\n}\n© UCLES 2022 Page 5 of 23\n\n1(d)(i) 1 mark per point: 3\n• Calling ReadFile() and then FindValues() (in the main program)\n• storing/using return value from FindValues() …\n• …outputting return value with appropriate message\nExample program code:\nPython\nReadFile()\nprint(\"The number appears \" + str(FindValues()) + \"\ntimes\")\nJava\npublic static void main(String[] args){\nReadFile();\nInteger ReturnValue = FindValues();\nSystem.out.println(\"The number was found \" +\nReturnValue + \" times\");\n}\nVB.NET\nSub Main()\nReadFile()\nDim ReturnValue As Integer = FindValues()\nConsole.WriteLine(\"The number was found \" & ReturnValue\n& \" times\")\nEnd Sub\n\n1(d)(ii) Screenshot showing 61 input and 2 output, e.g. 1\n© UCLES 2022 Page 6 of 23\n\n1(e) 1 mark per point: 4\n• procedure declaration (and end where appropriate) and\noutputting array contents at end of procedure and\ncalling procedure from main program\n• correct outer loop …\n• … correct inner loop …\n• … swapping all elements if in incorrect order\nExample program code:\nPython\ndef BubbleSort():\nglobal DataArray\nN = 100\nfor I in range(N-1):\nfor J in range(0, N-I-1):\nif DataArray[J] > DataArray[J+1]:\nDataArray[J], DataArray[J+1] =\nDataArray[J+1], DataArray[J]\n#main\nReadFile()\nprint(\"The number appears \" + str(FindValues()) + \"\ntimes\")\nBubbleSort()\nprint(DataArray)\nJava\npublic static void BubbleSort(){\nInteger Temp = 0;\nfor(Integer I = 0; I < 100-1; I++){\nfor(Integer J = 0; J < 100-I-1; J++){\nif(DataArray[J] > DataArray[J+1]){\nTemp = DataArray[J];\nDataArray[J] = DataArray[J+1];\nDataArray[J+1] = Temp;\n}\n}\n}\nfor(Integer X = 0; X < 100; X ++){\nSystem.out.println(DataArray[X]);\n}\n}\npublic static void main(String[] args){\nReadFile();\nInteger ReturnValue = FindValues();\nSystem.out.println(\"The number was found \" +\nReturnValue + \" times\");\nBubbleSort();\n}\n© UCLES 2022 Page 7 of 23\n\n1(e) VB.NET\nSub Bubblesort()\nDim Outer As Integer = 100 - 1\nDim Swap As Boolean\nDim Inner As Integer\nDim Temp As Integer\nDo\nInner = 0\nSwap = False\nDo\nIf DataArray(Inner) > DataArray(Inner + 1) Then\nTemp = DataArray(Inner)\nDataArray(Inner) = DataArray(Inner + 1)\nDataArray(Inner + 1) = Temp\nSwap = True\nEnd If\nInner = Inner + 1\nLoop Until Inner = Outer\nOuter = Outer - 1\nLoop Until Swap = False Or Outer = 0\nFor X = 0 To 99\nConsole.WriteLine(DataArray(X))\nNext\nEnd Sub\nSub Main()\nReadFile()\nDim ReturnValue As Integer = FindValues()\nConsole.WriteLine(\"The number was found \" &\nReturnValue & \" times\")\nBubblesort()\nEnd Sub\nQuestion Answer Marks",
      "source_pages": [
        3,
        4,
        5,
        6,
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_41-p03.png",
        "../answer-assets/9618_w22_ms_41-p04.png",
        "../answer-assets/9618_w22_ms_41-p05.png",
        "../answer-assets/9618_w22_ms_41-p06.png",
        "../answer-assets/9618_w22_ms_41-p07.png",
        "../answer-assets/9618_w22_ms_41-p08.png"
      ]
    },
    {
      "id": "9618-2022-on-41-q02",
      "question_id": "9618-2022-on-41-q02",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 31,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) 1 mark per point: 5\n• class Card declaration (and end where appropriate)\n• Private attributes declared Number as integer and Colour as string\n• constructor header (and end where appropriate)…\n• …taking 2 parameters\n• assigning parameters to attributes\nExample program code:\nPython\nclass Card:\n#Number as integer\n#Colour as string\ndef __init__(self, Number1, Colour1):\nself.__Number = Number1;\nself.__Colour = Colour1;\n© UCLES 2022 Page 8 of 23\n\n2(a)(i) Java\nclass Card{\nprivate Integer Number;\nprivate String Colour;\npublic Card(Integer Number1, String Colourp){\nNumber = Number1;\nColour = Colourp;\n}}\nVB.NET\nClass Card\nPrivate Number As Integer\nPrivate Colour As String\nSub New(Number1, Colourp)\nNumber = Number1\nColour = Colourp\nEnd Sub\nEnd Class\n\n2(a)(ii) 1 mark per point: 3\n• 1 get method as function (and end where appropriate) with no\nparameters…\n• …returning the value\n• 2nd correct get method\nExample program code:\nPython\ndef GetNumber(self):\nreturn self.__Number\ndef GetColour(self):\nreturn self.__Colour\nJava\npublic Integer GetNumber(){\nreturn Number;\n}\npublic String GetColour(){\nreturn Colour;\n}\nVB.NET\nFunction GetNumber()\nReturn Number\nEnd Function\nFunction GetColour()\nReturn Colour\nEnd Function\n© UCLES 2022 Page 9 of 23\n\n2(a)(iii) 1 mark per point: 2\n• one card initialised as type Card …\n• … all 15 cards initialised correctly as type Card\nExample program code:\nPython\nOneRed = Card(1, \"red\")\nTwoRed = Card(2, \"red\")\nThreeRed = Card(3, \"red\")\nFourRed = Card(4, \"red\")\nFiveRed = Card(5, \"red\")\nOneBlue = Card(1, \"blue\")\nTwoBlue = Card(2, \"blue\")\nThreeBlue = Card(3, \"blue\")\nFourBlue = Card(4, \"blue\")\nFiveBlue = Card(5, \"blue\")\nOneYellow = Card(1, \"yellow\")\nTwoYellow = Card(2, \"yellow\")\nThreeYellow = Card(3, \"yellow\")\nFourYellow = Card(4, \"yellow\")\nFiveYellow = Card(5, \"yellow\")\nJava\nCARD oneRed = new Card(1, \"red\");\nCARD twoRed = new Card(2, \"red\");\nCARD threeRed = new Card(3, \"red\");\nCARD fourRed = new Card(4, \"red\");\nCARD fiveRed = new Card(5, \"red\");\nCARD oneBlue = new Card(1, \"blue\");\nCARD twoBlue = new Card(2, \"blue\");\nCARD threeBlue = new Card(3, \"blue\");\nCARD fourBlue = new Card(4, \"blue\");\nCARD fiveBlue = new Card(5, \"blue\");\nCARD oneYellow = new Card(1, \"yellow\");\nCARD twoYellow = new Card(2, \"yellow\");\nCARD threeYellow = new Card(3, \"yellow\");\nCARD fourYellow = new Card(4, \"yellow\");\nCARD fiveYellow = new Card(5, \"yellow\");\n© UCLES 2022 Page 10 of 23\n\n2(a)(iii) VB.NET\nDim OneRed As New Card (1, \"red\")\nDim TwoRed As New Card(2, \"red\")\nDim ThreeRed As New Card(3, \"red\")\nDim FourRed As New Card(4, \"red\")\nDim FiveRed As New Card(5, \"red\")\nDim OneBlue As New Card(1, \"blue\")\nDim TwoBlue As New Card(2, \"blue\")\nDim ThreeBlue As New Card(3, \"blue\")\nDim FourBlue As New Card(4, \"blue\")\nDim FiveBlue As New Card(5, \"blue\")\nDim OneYellow As New Card(1, \"yellow\")\nDim TwoYellow As New Card(2, \"yellow\")\nDim ThreeYellow As New Card(3, \"yellow\")\nDim FourYellow As New Card(4, \"yellow\")\nDim FiveYellow As New Card(5, \"yellow\")\n\n2(b)(i) 1 mark per point: 6\n• class Hand declaration (and end where appropriate)\n• private attribute declarations; FirstCard as integer, NumberCards as\ninteger\n• private attribute array named Cards of type Card with 10 elements\n• constructor with 5 Card objects as parameters\n• assigning each Card parameter to the array (in constructor)\n• initialising FirstCard to 0 and NumberCards to 5 (in constructor)\nExample program code:\nPython\nclass Hand:\n#Cards[10] as Card\n#FirstCard as integer\n#NumberCards as integer\ndef __init__(self, Card1, Card2, Card3, Card4,\nCard5):\nself.__Cards = []\nself.__Cards.append(Card1)\nself.__Cards.append(Card2)\nself.__Cards.append(Card3)\nself.__Cards.append(Card4)\nself.__Cards.append(Card5)\nself.__FirstCard = 0\nself.__NumberCards = 5\n© UCLES 2022 Page 11 of 23\n\n2(b)(i) Java\nclass Hand{\nprivate Card[] Cards = new Card[10];\nprivate Integer FirstCard;\nprivate Integer NumberCards;\npublic Hand(CARD Card1, CARD Card2, CARD Card3, CARD\nCard4, CARD Card5){\nCards[0] = Card1;\nCards[1] = Card2;\nCards[2] = Card3;\nCards[3] = Card4;\nCards[4] = Card5;\nFirstCard = 0;\nNumberCards = 5;\n}\n}\nVB.NET\nclass Hand\nPrivate Cards(9) As Card\nPrivate FirstCard As Integer\nPrivate NumberCards As Integer\nSub New(Card1, Card2, Card3, Card4, Card5)\nCards(0) = Card1\nCards(1) = Card2\nCards(2) = Card3\nCards(3) = Card4\nCards(4) = Card5\nFirstCard = 0\nNumberCards = 5\nEnd Sub\nEnd Class\n\n2(b)(ii) 1 mark per point: 2\n• function GetCard() header (and end where appropriate) taking (integer)\nparameter\n• returning the card at parameter index in array\nExample program code:\nPython\ndef GetCard(self, Position):\nreturn self.__Cards[Position]\nJava\npublic Card GetCard(Integer Position){\nreturn Cards[Position];\n}\nVB.NET\nFunction GetCard(Position)\nReturn Cards(Position)\nEnd Function\n© UCLES 2022 Page 12 of 23\n\n2(b)(iii) 1 mark per point: 2\n• 2 variables (player 1 and player 2) of type Hand\n• using constructor and sending the correct variables as parameters\nExample program code:\nPython\nPlayer1 = Hand(OneRed, TwoRed, ThreeRed, FourRed,\nOneYellow)\nPlayer2 = Hand(TwoYellow, ThreeYellow, FourYellow,\nFiveYellow, OneBlue)\nJava\nHand Player1 = new Hand(OneRed, TwoRed, ThreeRed,\nFourRed, OneYellow);\nHand Player2 = new Hand(TwoYellow, ThreeYellow,\nFourYellow, FiveYellow, OneBlue);\nVB.NET\nDim Player1 As New Hand(OneRed, TwoRed, ThreeRed,\nFourRed, OneYellow)\nDim Player2 As New Hand(TwoYellow, ThreeYellow,\nFourYellow, FiveYellow, OneBlue)\n\n2(c)(i) 1 mark per point: 6\n• function CalculateValue() header (and end where appropriate)\ntaking one parameter and initialising score to 0\n• looping through all 5 Card objects in parameter array…\n• … adding 5 to score for red, 10 to score for blue, 15 to score if yellow\n• … adding each card number to score\n• Using GetCard(), GetColour() and GetNumber() correctly\n• Returning calculated score\nExample program code:\nPython\ndef CalculateValue(Player):\nScore = 0\nfor Count in range(0, 4):\nCardGot = Player.GetCard(Count)\nScore = Score + CardGot.GetNumber()\nColour = CardGot.GetColour()\nif Colour == \"red\":\nScore = Score + 5\nelif Colour == \"blue\":\nScore = Score + 10\nelse:\nScore = Score + 15\nreturn Score\n© UCLES 2022 Page 13 of 23\n\n2(c)(i) Java\npublic static Integer CalculateValue(Hand Player){\nInteger Score = 0;\nString Colour;\nCard CardGot;\nfor(Integer X = 0; X<5; X++){\nCardGot = Player.GetCard(X);\nScore = Score + CardGot.GetNumber();\nColour = CardGot.GetColour();\nif(Colour == \"red\"){\nScore = Score + 5;\n}else if(Colour == \"blue\"){\nScore = Score + 10;\n} else {\nScore = Score + 15;\n}}return Score;}\nVB.NET\nFunction CalculateValue(Player As Hand)\nDim Score As Integer = 0\nDim Colour As String\nDim CardGot As Card\nFor Count = 0 To 4\nCardGot = Player.GetCard(Count)\nScore = Score + CardGot.GetNumber()\nColour = CardGot.GetColour()\nIf Colour = \"red\" Then\nScore = Score + 5\nElseIf Colour = \"blue\" Then\nScore = Score + 10\nElse\nScore = Score + 15\nEnd If\nNext\nReturn Score\nEnd Function\n© UCLES 2022 Page 14 of 23\n\n2(c)(ii) 1 mark per point: 4\n• One function call of CalculateValue( ) for each player …\n• …sending the player's hand as parameter\n• Comparing return values and outputting the player with the highest\nscore in an appropriate message …\n• … or if there was a draw in appropriate message\nExample program code:\nPython\nPlayer1score = CalculateValue(Player1)\nPlayer2score = CalculateValue(Player2)\nif Player1score > Player2score:\nprint(\"Player 1 wins\")\nelif Player1score < Player2score:\nprint(\"Player 2 wins\")\nelse:\nprint(\"It's a draw\")\nJava\nInteger Player1score = CalculateValue(Player1);\nInteger Player2score = CalculateValue(Player2);\nif(Player1score > Player2score){\nSystem.out.println(\"Player 1 wins\");\n}else if(Player2score > Player1score){\nSystem.out.println(\"Player2 wins\");\n} else {\nSystem.out.println(\"It's a draw\");\n}\nVB.NET\nDim Player1score As Integer\nDim Player2score As Integer\nPlayer1score = CalculateValue(Player1)\nPlayer2score = CalculateValue(Player2)\nIf Player1score > Player2score Then\nConsole.WriteLine(\"Player 1 wins\")\nElseIf Player1score < Player2score Then\nConsole.WriteLine(\"Player 2 wins\")\nElse\nConsole.WriteLine(\"It's a draw\")\nEnd If\n\n2(c)(iii) Output showing player 2 wins, for example: 1\n© UCLES 2022 Page 15 of 23",
      "source_pages": [
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_41-p08.png",
        "../answer-assets/9618_w22_ms_41-p09.png",
        "../answer-assets/9618_w22_ms_41-p10.png",
        "../answer-assets/9618_w22_ms_41-p11.png",
        "../answer-assets/9618_w22_ms_41-p12.png",
        "../answer-assets/9618_w22_ms_41-p13.png",
        "../answer-assets/9618_w22_ms_41-p14.png",
        "../answer-assets/9618_w22_ms_41-p15.png"
      ]
    },
    {
      "id": "9618-2022-on-41-q03",
      "question_id": "9618-2022-on-41-q03",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 21,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per point: 3\n• Declaring (global) 2D array ArrayNodes\n• looping through all 20  3 elements of array …\n• …. storing −1 in each element\nExample program code:\nJava\npublic static Integer[][] ArrayNodes = new\nInteger[20][3];\nfor(Integer X = 0; X<20; X++){\nfor(Integer Y = 0; Y<3; Y++){\nArrayNodes[X][Y] = -1\n}}\nPython\nArrayNodes = []\nfor x in range(0, 20):\nArrayNodes.append([-1, -1, -1])\nVB.NET\nDim ArrayNodes(19, 2) As Integer\nSub main()\nFor X = 0 To 19\nFor Y = 0 To 2\nArrayNodes(X, Y) = -1\nNext\nNext\nEnd Sub\n© UCLES 2022 Page 16 of 23\n\n3(b) 1 mark per point: 2\n• initialising each of the first 6 array elements correctly\n• declaring and initialising FreeNode to 6 and RootPointer to 0\nExample program code:\nPython\nArrayNodes = [[1,20,5],[2,15,-1],[-1,3,3],[-1,9,4],[-\n1,10,-1],[-1,58,-1]]\nFreeNodes = 6\nRootPointer = 0\nJava\nArrayNodes[0][0] = 1;\nArrayNodes[0][1] = 20;\nArrayNodes[0][2] = 5;\nArrayNodes[1][0] = 2;\nArrayNodes[1][1] = 15;\nArrayNodes[1][2] = -1;\nArrayNodes[2][0] = -1;\nArrayNodes[2][1] = 3;\nArrayNodes[2][2] = 3;\nArrayNodes[3][0] = -1;\nArrayNodes[3][1] = 9;\nArrayNodes[3][2] = 4;\nArrayNodes[4][0] = -1;\nArrayNodes[4][1] = 10;\nArrayNodes[4][2] = -1;\nArrayNodes[5][0] = -1;\nArrayNodes[5][1] = 58;\nArrayNodes[5][2] = -1;\nInteger FreeNode = 6;\nInteger RootPointer = 0;\n© UCLES 2022 Page 17 of 23\n\n3(b) VB.NET\nArrayNodes(0, 0) = 1\nArrayNodes(0, 1) = 20\nArrayNodes(0, 2) = 5\nArrayNodes(1, 0) = 2\nArrayNodes(1, 1) = 15\nArrayNodes(1, 2) = -1\nArrayNodes(2, 0) = -1\nArrayNodes(2, 1) = 3\nArrayNodes(2, 2) = 3\nArrayNodes(3, 0) = -1\nArrayNodes(3, 1) = 9\nArrayNodes(3, 2) = 4\nArrayNodes(4, 0) = -1\nArrayNodes(4, 1) = 10\nArrayNodes(4, 2) = -1\nArrayNodes(5, 0) = -1\nArrayNodes(5, 1) = 58\nArrayNodes(5, 2) = -1\nDim FreeNode As Integer = 6\nDim RootPointer As Integer = 0\n© UCLES 2022 Page 18 of 23\n\n3(c) 1 mark for each completed statement (4) 5\n1 mark for remainder of function correct\nPseudocode:\nFUNCTION SearchValue(BYVAL Root : INTEGER, ValueToFind :\nINTEGER)\nIF Root = -1 THEN\nRETURN -1\nELSE\nIF ArrayNodes[Root,1] = ValueToFind THEN\nRETURN Root\nELSE\nIF ArrayNodes[Root, 1] = -1 THEN\nRETURN -1\nENDIF\nENDIF\nENDIF\nIF ArrayNodes[Root,1] > ValueToFind THEN\nRETURN SearchValue(ArrayNodes[Root,0], ValueToFind)\nENDIF\nIF ArrayNodes[Root,1] < ValueToFind THEN\nRETURN SearchValue(ArrayNodes[Root,2], ValueToFind)\nENDIF\nENDFUNCTION\nExample program code:\nPython\ndef SearchValue(Root, ValueToFind):\nglobal ArrayNodes\nif Root == -1:\nreturn -1\nelif ArrayNodes[Root][1] == ValueToFind:\nreturn Root\nelif ArrayNodes[Root][1] == -1:\nreturn -1\nif(ArrayNodes[Root][1] > ValueToFind):\nreturn SearchValue(ArrayNodes[Root][0], ValueToFind)\nif(ArrayNodes[Root][1] < ValueToFind):\nreturn SearchValue(ArrayNodes[Root][2], ValueToFind)\n© UCLES 2022 Page 19 of 23\n\n3(c) Java\npublic static Integer SearchValue(Integer Root, Integer\nValueToFind){\nif(Root == -1){\nreturn -1;\n}else if(ArrayNodes[Root][1] == ValueToFind){;\nreturn Root;\n}else if(ArrayNodes[Root][1] == -1){\nreturn -1;\n}\nif(ArrayNodes[Root][1] > ValueToFind){\nreturn(SearchValue(ArrayNodes[Root][0],\nValueToFind));\n}\nif(ArrayNodes[Root][1] < ValueToFind){\nreturn(SearchValue(ArrayNodes[Root][2],\nValueToFind));\n}\nreturn -1;\n}\nVB.NET\nFunction SearchValue(ByVal Root, ByVal ValueToFind)\nIf ArrayNodes(Root, 1) = ValueToFind Then\nReturn Root\nElseIf ArrayNodes(Root, 1) = -1 Then\nReturn -1\nEnd If\nIf ArrayNodes(Root, 1) > ValueToFind Then\nReturn SearchValue(ArrayNodes(Root, 0), ValueToFind)\nEnd If\nIf ArrayNodes(Root, 1) < ValueToFind Then\nReturn SearchValue(ArrayNodes(Root, 2), ValueToFind)\nEnd If\nReturn -1\nEnd Function\n© UCLES 2022 Page 20 of 23\n\n3(d) 1 mark per point (Max 7): 7\n• (procedure) header (and end where appropriate) with one parameter\n(root node or index of root node) and at least one recursive call\n• checking if left node is −1 …\n• … if not recursive call with parameter as ArrayNodes[RootNode[0]]\n• checking if right node is −1 …\n• …if not recursive call with parameter as ArrayNodes[RootNode[2]]\n• outputting the element at the parameter RootNode[]\n• all 3 in the correct order\nExample program code:\nPython\ndef PostOrder(RootNode):\nif RootNode[0] != -1:\nPostOrder(ArrayNodes[RootNode[0]])\nif RootNode[2] != -1:\nPostOrder(ArrayNodes[RootNode[2]])\nprint(str(RootNode[1]))\nJava\npublic static void PostOrder(Integer[] RootNode){\nif(RootNode[0] != -1){\nPostOrder(ArrayNodes[RootNode[0]]);\n}\nif(RootNode[2] != -1){\nPostOrder(ArrayNodes[RootNode[2]]);\n}\nSystem.out.println(RootNode[1]);\n}\nVB.NET\nSub PostOrder(RootNode() As Integer)\nDim TempArray(2) As Integer\nIf RootNode(0) <> -1 Then\nTempArray(0) = ArrayNodes(RootNode(0), 0)\nTempArray(1) = ArrayNodes(RootNode(0), 1)\nTempArray(2) = ArrayNodes(RootNode(0), 2)\nPostOrder(TempArray)\nEnd If\nIf RootNode(2) <> -1 Then\nTempArray(0) = ArrayNodes(RootNode(2), 0)\nTempArray(1) = ArrayNodes(RootNode(2), 1)\nTempArray(2) = ArrayNodes(RootNode(2), 2)\nPostOrder(TempArray)\nEnd If\nConsole.WriteLine(RootNode(1))\nEnd Sub\n© UCLES 2022 Page 21 of 23\n\n3(e)(i) 1 mark per point: 3\n• calling SearchValue() with 15 and rootPointer as a parameter …\n• … if return value > -1 output returned index and\nif return value = -1 output not found\nBoth as appropriate messages\n• Calling PostOrder() with ArrayNodes[RootPointer] as a\nparameter\nExample program code:\nPython\nReturnValue = SearchValue(RootPointer, 15)\nif ReturnValue == -1:\nprint(\"Not found\")\nelse:\nprint(\"Found at \" + str(ReturnValue))\nPostOrder(ArrayNodes[RootPointer])\nJava\nInteger ReturnValue = SearchValue(RootPointer, 15);\nif(ReturnValue == -1){\nSystem.out.println(\"Not found\");\n} else {\nSystem.out.println(\"Found at \" + ReturnValue);\n}\nPostOrder(ArrayNodes[RootPointer]);\nVB.NET\nDim returnvalue As Integer = SearchValue(RootPointer, 15)\nIf returnvalue = -1 Then\nConsole.WriteLine(\"Not found\")\nElse\nConsole.WriteLine(\"Found at \" & returnvalue)\nEnd If\nConsole.WriteLine(\"Post order\")\nDim TempArray(2) As Integer\nTempArray(0) = ArrayNodes(RootPointer, 0)\nTempArray(1) = ArrayNodes(RootPointer, 1)\nTempArray(2) = ArrayNodes(RootPointer, 2)\nPostOrder(TempArray)\n© UCLES 2022 Page 22 of 23\n\n3(e)(ii) Screenshot with result as shown, for example: 1\n© UCLES 2022 Page 23 of 23",
      "source_pages": [
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_41-p16.png",
        "../answer-assets/9618_w22_ms_41-p17.png",
        "../answer-assets/9618_w22_ms_41-p18.png",
        "../answer-assets/9618_w22_ms_41-p19.png",
        "../answer-assets/9618_w22_ms_41-p20.png",
        "../answer-assets/9618_w22_ms_41-p21.png",
        "../answer-assets/9618_w22_ms_41-p22.png",
        "../answer-assets/9618_w22_ms_41-p23.png"
      ]
    },
    {
      "id": "9618-2022-on-42-q01",
      "question_id": "9618-2022-on-42-q01",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 23,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per point: 3\n• (global) 2-D array Jobs with correct identifier (and Integer data type)\n• … with 100 elements by 2 elements\n• (global) NumberOfJobs declared as variable (as Integer)\nExample program code:\nJava\npublic static Integer[][] Jobs = new Integer[100][2];\npublic static Integer NumberOfJobs;\nPython\nJobs # global integer, 100 by 2 elements\nNumberOfJobs # global integer\nVB.NET\nDim Jobs(99, 1) As Integer\nDim NumberOfJobs As Integer\n© UCLES 2022 Page 3 of 24\n\n1(b) 1 mark per point: 3\n• procedure heading (and end where appropriate) and assigns 0 to\nNumberOfJobs\n• looping through both array element dimensions\n• … assigns −1 to all elements\nExample program code:\nJava\npublic static void Initialise(){\nfor(Integer x = 0; x<100;x++){\nfor(Integer y = 0; y<2; y++){\nJobs[x][y] = -1;\n}\n}\nNumberOfJobs = 0;\n}\nPython\ndef Initialise():\nglobal Jobs\nglobal NumberOfJobs\nfor x in range(0, 100):\nJobs.append([-1,-1])\nNumberOfJobs = 0\nVB.NET\nSub Initialise()\nFor X = 0 To 99\nFor Y = 0 To 1\nJobs(X, Y) = -1\nNext\nNext\nNumberOfJobs = 0\nEnd Sub\n© UCLES 2022 Page 4 of 24\n\n1(c) 1 mark per point (Max 5): 5\n• Function header (and end where appropriate) with two (integer)\nparameters\n• Checks if array is full …\n• … if full outputs \"Not added\"\n• Storing parameters job number and priority to only the next available\narray position\n• Incrementing NumberOfJobs\n• Outputting \"Added\" if successful\nExample program code:\nJava\npublic static void AddJob(Integer Description, Integer\nPriority){\nif(NumberOfJobs == 100){\nSystem.out.println(\"Not added\");\n}else{\nJobs[NumberOfJobs][0] = Description;\nJobs[NumberOfJobs][1] = Priority;\nNumberOfJobs = NumberOfJobs + 1;\nSystem.out.println(\"Added\");\n}\n}\nPython\ndef AddJob(JobNumber, Priority):\nglobal NumberOfJobs\nglobal Jobs\nif NumberOfJobs == 100:\nprint(\"Not added\")\nelse:\nJobs[NumberOfJobs] = [JobNumber, Priority]\nprint(\"Added\")\nNumberOfJobs = NumberOfJobs + 1\nVB.NET\nSub AddJob(JobNumber, Priority)\nIf NumberOfJobs = 100 Then\nConsole.WriteLine(\"Not added\")\nElse\nJobs(NumberOfJobs, 0) = JobNumber\nJobs(NumberOfJobs, 1) = Priority\nNumberOfJobs = NumberOfJobs + 1\nConsole.WriteLine(\"Added\")\nEnd If\nEnd Sub\n© UCLES 2022 Page 5 of 24\n\n1(d) 1 mark per point: 2\n• Calls Initialise() (in the main program)\n• 5 AddJob calls with correct values as parameters in correct order\nExample program code:\nJava\npublic static void main(String args[]){\nInitialise();\nAddJob(12, 10);\nAddJob(526, 9);\nAddJob(33,8);\nAddJob(12,9);\nAddJob(78,1);\n}\nPython\nInitialise()\nAddJob(12,10)\nAddJob(526,9)\nAddJob(33,8)\nAddJob(12,9)\nAddJob(78,1)\nVB.NET\nSub Main()\nInitialise()\nAddJob(12, 10)\nAddJob(526, 9)\nAddJob(33, 8)\nAddJob(12, 9)\nAddJob(78, 1)\nEnd Sub\n© UCLES 2022 Page 6 of 24\n\n1(e) 1 mark per point: 5\n• Procedure header (and end where appropriate)\n• Outer loop through all 5 elements / number of jobs …\n• … inner loop through array elements …\n• …and comparing priority (second index) …\n• …moving the elements up and inserting correctly\nExample program code:\nPython\ndef InsertionSort():\nglobal Jobs\nglobal NumberOfJobs\nfor I in range(1, NumberOfJobs):\nCurrent1 = Jobs[I][0]\nCurrent2 = Jobs[I][1]\nwhile I > 0 and Jobs[I-1][1] > Current2:\nJobs[I][0] = Jobs[I-1][0]\nJobs[I][1] = Jobs[I-1][1]\nI = I - 1\nJobs[I][0] = Current1\nJobs[I][1] = Current2\nJava\npublic static void InsertionSort(){\nInteger Current1;\nInteger Current2;\nInteger Counter;\nInteger Placed;\nfor(Integer i = 1; i < NumberOfJobs; i++){\nCurrent1 = Jobs[i][0];\nCurrent2 = Jobs[i][1];\nwhile(i > 0 && Jobs[i-1][1] > Current2){\nJobs[i][0] = Jobs[i-1][0];\nJobs[i][1] = Jobs[i-1][1];\ni = i - 1;\n}\nJobs[i][0] = Current1;\nJobs[i][1] = Current2;\n}\n}\n© UCLES 2022 Page 7 of 24\n\n1(e) VB.NET\nSub InsertionSort()\nDim Tempa As Integer\nDim Tempb As Integer\nDim Counter As Integer\nDim Placed As Boolean\nFor i = 1 To NumberOfJobs - 1\nTempa = Jobs(i, 0)\nTempb = Jobs(i, 1)\nCounter = i\nPlaced = False\nWhile (Counter > 0 And Not Placed)\nIf (Jobs(Counter - 1, 1) > Tempb) Then\nJobs(Counter, 0) = Jobs(Counter - 1, 0)\nJobs(Counter, 1) = Jobs(Counter - 1, 1)\nCounter = Counter - 1\nElse\nPlaced = True\nEnd If\nEnd While\nJobs(Counter, 0) = Tempa\nJobs(Counter, 1) = Tempb\nNext i\nEnd Sub\n© UCLES 2022 Page 8 of 24\n\n1(f) 1 mark per point: 3\n• procedure heading (and end where appropriate) and outputting all job\nnumbers and priorities\n• Outputting the job and priority for each element on the same line, with a\nline break between each job …\n• … with 'priority' between job number and priority\nExample program code:\nJava\npublic static void PrintArray(){\nfor(Integer x = 0; x < NumberOfJobs; x++){\nSystem.out.println(Jobs[x][0] + \" priority \" +\nJobs[x][1]);\n}\n}\nPython\ndef PrintArray():\nglobal Jobs\nglobal NumberOfJobs\nfor X in range(0, NumberOfJobs):\nprint(str(Jobs[X][0]), \" priority \", str(Jobs[X][1]))\nVB.NET\nSub PrintArray()\nFor X = 0 To NumberOfJobs - 1\nConsole.WriteLine(Jobs(X, 0) & \" priority \" & Jobs(X,\n1))\nNext\nEnd Sub\n\n1(g)(i) • calling both subroutines in the main program in the correct order 1\nExample program code:\nJava\nInsertionSort();\nPrintArray();\nPython\nInsertionSort()\nPrintArray()\nVB.NET\nInsertionSort()\nPrintArray()\n© UCLES 2022 Page 9 of 24\n\n1(g)(ii) 1 mark for added 5 times and jobs in order. 1\n526 and 12 can be reversed\n© UCLES 2022 Page 10 of 24",
      "source_pages": [
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_42-p03.png",
        "../answer-assets/9618_w22_ms_42-p04.png",
        "../answer-assets/9618_w22_ms_42-p05.png",
        "../answer-assets/9618_w22_ms_42-p06.png",
        "../answer-assets/9618_w22_ms_42-p07.png",
        "../answer-assets/9618_w22_ms_42-p08.png",
        "../answer-assets/9618_w22_ms_42-p09.png",
        "../answer-assets/9618_w22_ms_42-p10.png"
      ]
    },
    {
      "id": "9618-2022-on-42-q02",
      "question_id": "9618-2022-on-42-q02",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 31,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark per point: 4\n• Class declaration (and end where appropriate) for Character\n• Declaring the 3 private attributes with appropriate data types; Name as\nstring, xCoordinate as integer, yCoordinate as integer\n• Constructor method (and end where appropriate) taking 3 parameters …\n• …assigning parameters to all 3 attributes\nExample program code:\nJava\nclass Character{\nprivate String Name;\nprivate Integer XCoordinate;\nprivate Integer YCoordinate;\npublic Character(String Namep, Integer XCoord,\nInteger YCoord){\nName = Namep;\nXCoordinate = XCoord;\nYCoordinate = YCoord; }}\nPython\nclass Character:\n#private Name as string\n#private XCoordinate as integer\n#private YCoordinate as integer\ndef __init__(self, Namep, Xcoord, Ycoord):\nself.__Name = Namep\nself.__XCoordiante = Xcoord\nself.__YCoordinate = Ycoord\nVB.NET\nClass Character\nPrivate Name As String\nPrivate XCoordinate As Integer\nPrivate YCoordinate As Integer\nSub New(Namep, Xcoord, Ycoord)\nName = Namep\nXCoordinate = Xcoord\nYCoordinate = Ycoord\nEnd Sub\nEnd Class\n© UCLES 2022 Page 11 of 24\n\n2(b) 1 mark per point: 3\n• 1 get method header (and end where appropriate) with no parameters…\n• …returning correct value\n• 2nd and 3rd correct get methods\nExample program code:\nJava\npublic String GetName(){\nreturn Name;}\npublic Integer GetX(){\nreturn XCoordinate;}\npublic Integer GetY(){\nreturn YCoordinate;}\nPython\ndef GetName(self):\nreturn self.__Name\ndef GetX(self):\nreturn self.__XCoordinate\ndef GetY(self):\nreturn self.__YCoordinate\nVB.NET\nFunction GetName()\nReturn Name\nEnd Function\nFunction GetX()\nReturn XCoordinate\nEnd Function\nFunction GetY()\nReturn YCoordinate\nEnd Function\n© UCLES 2022 Page 12 of 24\n\n2(c) 1 mark per point: 2\n• method header (and end where appropriate) taking 2 (integer)\nparameters\n• adding both parameters to existing x and y coordinate values\nExample program code:\nJava\npublic void ChangePosition(Integer XChange, Integer\nYChange){\nXCoordinate = XCoordinate + XChange;\nYCoordinate = YCoordinate + YChange;\n}\nPython\ndef ChangePosition(self, XChange, YChange):\nself.__XCoordinate = self.__XCoordinate + XChange\nself.__YCoordinate = self.__YCoordinate + YChange\nVB.NET\nSub changePosition(XChange, YChange)\nXCoordinate = XCoordinate + XChange\nYCoordinate = YCoordinate + YChange\nEnd Sub\n© UCLES 2022 Page 13 of 24\n\n2(d) 1 mark per point (Max 7): 7\n• declaration of 1D array, 10 elements of type Character\n• opening text file Characters.txt to read\n• looping until EOF/10 times…\n• … reading in each 3-set of values from file …\n• … instantiate a Character with correct parameters read in from file…\n• … store in next element/append in declared array\n• closing the text file (in appropriate place)\n• Exception handling for opening and reading data from file…\n• … with appropriate catch and output\nExample program code:\nJava\npublic static void main(String[] args){\nCharacter[] Characters = new Character[10];\nString TextFile = \"Characters.txt\";\nString Name = \"\";\nInteger Xcoord = 0;\nInteger Ycoord = 0;\ntry{\nFileReader f = new FileReader(TextFile);\nBufferedReader Reader = new BufferedReader(f);\nfor(Integer X = 0; X < 10; X++){\nName = Reader.readLine();\nXcoord = Integer.parseInt(Reader.readLine());\nYcoord = Integer.parseInt(Reader.readLine());\n}\nReader.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No file found\");\n}\n}\nPython\nCharacters = []\nTextFile = \"Characters.txt\"\ntry:\nFile = open(TextFile, 'r')\nfor X in range(0, 10):\nName = File.readline().strip()\nXCoord = File.readline().strip()\nYCoord = File.readline().strip()\nTempC = Character(Name, int(XCoord), int(YCoord))\nCharacters.append(TempC)\nFile.close()\nexcept:\nprint(\"File not found\")\n© UCLES 2022 Page 14 of 24\n\n2(d) VB.NET\nSub Main()\nDim Characters(0 To 9) As Character\nDim TextFile As String = \"Characters.txt\"\nTry\nDim FileReader As New\nSystem.IO.StreamReader(TextFile)\nFor X = 0 To 10\nName = FileReader.ReadLine()\nXcoord = FileReader.ReadLine()\nYcoord = FileReader.ReadLine()\nCharacters(X) = New Character(Name, Xcoord, Ycoord)\nNext\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"File not found\")\nEnd Try\nend sub\n© UCLES 2022 Page 15 of 24\n\n2(e) 1 mark per point (Max 5): 5\n• Taking name as input …\n• …converting/checking case e.g. all to lower\n• Looping through array of characters comparing each character name to\ninput …\n• …continuously taking repeat input if not found in array\n• …storing the index when found\n• Accessing the name of character in the array using GetName()\nExample program code:\nPython\nPosition = -1\nCharacterName = \"\"\nwhile(Position == -1):\nCharacterInput = input(\"Enter the Character to\nmove\").rstrip('\\n').lower()\nfor Count in range(0, 10):\nTemp = str(Characters[Count].GetName().strip())\nif(Temp == CharacterInput):\nPosition = Count\nVB.NET\nDim Position As Integer = -1\nDim CharacterName As String = \"\"\nWhile Position = -1\nConsole.WriteLine(\"Enter the Character to move\")\nCharacterName = Console.ReadLine\nFor Count = 0 To 9\nIf(Characters(Count).GetName).tolower =\nCharacterName.ToLower Then\nPosition = Count\nEnd If\nNext\nEnd While\n© UCLES 2022 Page 16 of 24\n\n2(e) Java\nInteger Position = -1;\nString CharacterName = \"\";\nScanner scanner = new Scanner(System.in);\nString Temp = \"\";\nwhile(Position == -1){\nSystem.out.println(\"Enter the Character to move\");\nCharacterName = scanner.nextLine();\nfor(Integer Count = 0; Count < 10; Count++){\nTemp = Characters[Count].GetName();\nTemp = Temp.toLowerCase();\nif(Temp.equals(CharacterName.toLowerCase())){\nPosition = Count;\n} }}\n© UCLES 2022 Page 17 of 24\n\n2(f) 1 mark per point (Max 7): 7\n• Taking move as input…\n• …looping until valid\n• Calling ChangePosition()with object\n• If A is input parameters are −1, 0\n• If D is input parameters are 1, 0\n• If W is input parameters are 0, 1\n• If S is input parameters are 0, −1\nExample program code:\nJava\nBoolean IsValid = false;\nString Move = \"\";\nwhile(IsValid != true){\nSystem.out.println(\"Enter A for left, W for up, S or\ndown or D for right\");\nMove = scanner.nextLine();\nif(Move.toUpperCase().equals(\"A\")){\nCharacters[Position].ChangePosition(-1,0);\nIsValid = true;\n} else if(Move.toUpperCase().equals(\"W\")){\nCharacters[Position].ChangePosition(0,1);\nIsValid = true;\n} else if(Move.toUpperCase().equals(\"S\")){\nCharacters[Position].ChangePosition(0,-1);\nIsValid = true;\n} else if(Move.toUpperCase().equals(\"D\")){\nCharacters[Position].ChangePosition(1,0);\nIsValid = true;\n} }\nPython\nIsValid = False\nwhile(IsValid != True):\nMove = input(\"Enter A for left, W for up, S for down,\nor D for right\")\nif(Move.upper() == \"A\"):\nCharacters[Position].ChangePosition(-1,0)\nIsValid = True\nelif (Move.upper() == \"W\"):\nCharacters[Position].ChangePosition(0,1)\nIsValid = True\nelif (Move.upper() == \"S\"):\nCharacters[Position].ChangePosition(0,-1)\nIsValid = True\nelif(Move.upper() == \"D\"):\nCharacters[Position].ChangePosition(1,0)\nIsValid = True\n© UCLES 2022 Page 18 of 24\n\n2(f) VB.NET\nDim IsValid As Boolean = False\nDim Move As String\nWhile IsValid <> True\nConsole.WriteLine(\"Enter A for left, W for up, S for\ndown or D for right\")\nMove = Console.ReadLine()\nIf Move.ToUpper = \"A\" Then\nCharacters(Position).ChangePosition(-1, 0)\nIsValid = True\nElseIf Move.ToUpper = \"W\" Then\nCharacters(Position).ChangePosition(0, 1)\nIsValid = True\nElseIf Move.ToUpper = \"S\" Then\nCharacters(Position).ChangePosition(0, -1)\nIsValid = True\nElseIf Move.ToUpper = \"D\" Then\nCharacters(Position).ChangePosition(1, 0)\nIsValid = True\nEnd If\nEnd While\n\n2(g)(i) 1 mark per point: 2\n• Outputting given message including name, x and y position\n• …all using appropriate get methods\nExample program code:\nJava\nSystem.out.println(CharacterName + \" has changed\ncoordinates to X = \" + Characters[Position].GetX() + \" Y\n= \" + Characters[Position].GetY());\nPython\nprint(CharacterName, \" has changed coordinate to X = \",\nstr(Characters[Position].GetX()), \" Y = \",\nstr(Characters[Position].GetY()))\nVB.NET\nConsole.WriteLine(CharacterName & \" has changed\ncoordinates to X = \" & Characters(Position).GetX & \" Y =\n\" & Characters(Position).GetY())\n© UCLES 2022 Page 19 of 24\n\n2(g)(ii) 1 mark for correct result, for example: 1\nQuestion Answer Marks",
      "source_pages": [
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_42-p11.png",
        "../answer-assets/9618_w22_ms_42-p12.png",
        "../answer-assets/9618_w22_ms_42-p13.png",
        "../answer-assets/9618_w22_ms_42-p14.png",
        "../answer-assets/9618_w22_ms_42-p15.png",
        "../answer-assets/9618_w22_ms_42-p16.png",
        "../answer-assets/9618_w22_ms_42-p17.png",
        "../answer-assets/9618_w22_ms_42-p18.png",
        "../answer-assets/9618_w22_ms_42-p19.png",
        "../answer-assets/9618_w22_ms_42-p20.png"
      ]
    },
    {
      "id": "9618-2022-on-42-q03",
      "question_id": "9618-2022-on-42-q03",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 21,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per point: 3\n• 1D array with 100 (Integer) spaces\n• head pointer declared initialised to appropriate value e.g. −1\n• tail pointer declared initialised to 0\nExample program code:\nJava\npublic Integer[] queue = new Integer[100];\npublic Integer HeadPointer = -1;\npublic Integer TailPointer = 0;\nPython\nQueue = [-1 for I in range(100)] #Integer\nHeadPointer = -1\nTailPointer = 0\nVB.NET\nDim Queue(0 To 99) As Integer\nDim HeadPointer As Integer = -1\nDim TailPointer As Integer = 0\n© UCLES 2022 Page 20 of 24\n\n3(b) 1 mark per point: 6\n• Function header (and close where appropriate) with integer parameter\n• Checking if queue full and returning false\n• If not full adding parameter to queue at tail pointer …\n• … incrementing tail pointer (after adding to queue)\n• … and returning true\n• Changing head pointer to 0 if this is the first element in array\nExample program code:\nJava\npublic Boolean Enqueue(Integer Data){\nif(TailPointer < 100){\nif(HeadPointer == -1){\nHeadPointer = 0;\n}\nQueue[TailPointer] = Data;\nTailPointer = TailPointer + 1;\nreturn true;\n}\nreturn false;\n}\nPython\ndef Enqueue(Data):\nglobal Queue\nglobal TailPointer\nif(TailPointer < 100):\nif HeadPointer == -1:\nHeadPointer = 0\nQueue[TailPointer] = Data\nTailPointer = TailPointer + 1\nreturn True\nreturn False\nVB.NET\nFunction Enqueue(Data)\nIf TailPointer < 100 Then\nIf HeadPointer = -1 Then\nHeadPointer = 0\nEnd If\nQueue(TailPointer) = data\nTailPointer = TailPointer + 1\nReturn True\nEnd If\nReturn False\nEnd Function\n© UCLES 2022 Page 21 of 24\n\n3(c) 1 mark per point: 4\n• Looping 20 times\n• … using Enqueue() with each number 1 to 20 in ascending numerical\norder…\n• … and storing/using the return value\n• … based on return value, outputting \"Successful\" and \"Unsuccessful\" if\nall numbers are added\nExample program code:\nJava\npublic static void main(String[] args){\nBoolean success = false;\nfor(Integer count = 1; count <= 20; count++){\nsuccess = enqueue(count);\n}\nif(success == false){\nSystem.Out.Println(\"Unsuccessful \")\nelse{\nSystem.Out.Println(\"Successful \")\n}\n}\nPython\nSuccess = False\nfor Count in range(1, 21):\nSuccess = Enqueue(Count)\nif(Success == False):\nprint(\"Unsuccessful\")\nelse:\nprint(\"Successful\")\nVB.NET\nDim Success As Boolean\nFor Count = 1 To 20\nSuccess = Enqueue(Count)\nNext\nIf Success = False THEN\nConsole.WriteLine(\"Unsuccessful\")\nELSE\nConsole.WriteLine(\"Successful\")\nENDIF\n© UCLES 2022 Page 22 of 24\n\n3(d) 1 mark per point: 6\n• function call (and end where appropriate) taking a parameter\n• checking if at start of queue//20 …\n• …returning the last value in the queue\n• (otherwise) adding return value to a total // adding value in queue before\nrecursive call and using this in the recursive call …\n• recursive call with Start/pointer −1\n• returning the final total\nExample program code:\nJava\npublic static Integer RecursiveOutput(Integer Start){\nif(Start == 0){\nreturn Queue[Start];\n}else{\nreturn Queue[Start] + RecursiveOutput(Start -1);\n}}\nPython\ndef RecursiveOutput(Start):\nif(Start == 0):\nreturn Queue[Start]\nelse:\nreturn Queue[Start] + RecursiveOutput(Start - 1)\nVB.NET\nFunction RecursiveOutput(ByVal Start)\nIf (Start = 0) Then\nReturn Queue(Start)\nElse\nReturn Queue(Start) + RecursiveOutput(Start - 1)\nEnd If\nEnd Function\n\n3(e)(i) 1 mark for calling function and outputting return value. 1\nExample program code:\nJava\nSystem.out.println(RecursiveOutput(TailPointer-1));\nPython\nprint(str(RecursiveOutput(TailPointer - 1)))\nVB.NET\nConsole.WriteLine(RecursiveOutput(TailPointer - 1))\n© UCLES 2022 Page 23 of 24\n\n3(e)(ii) 1 mark for screenshot showing 210, for example: 1\n© UCLES 2022 Page 24 of 24",
      "source_pages": [
        20,
        21,
        22,
        23,
        24
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_42-p20.png",
        "../answer-assets/9618_w22_ms_42-p21.png",
        "../answer-assets/9618_w22_ms_42-p22.png",
        "../answer-assets/9618_w22_ms_42-p23.png",
        "../answer-assets/9618_w22_ms_42-p24.png"
      ]
    },
    {
      "id": "9618-2022-on-43-q01",
      "question_id": "9618-2022-on-43-q01",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 23,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark per point: 2\n• (global) 1D (Integer) array DataArray\n• 100 elements\nExample program code:\nPython\nDataArray = [0 for I in range (100)]\nJava\npublic static Integer[] DataArray = new Integer[100];\nVB.NET\nDim DataArray(99) As Integer\n\n1(b) 1 mark per point: 6\n• Procedure ReadFile() header (and end where appropriate)\n• opening file IntegerData.txt (for read)\n• looping through the 100 elements // looping to end of file\n• reading each (and all) value from file and storing in array\n• closing file (in appropriate place)\n\n1 mark per point:\n• Exception Handling (for opening the file, or for reading values from the\nfile)…\n• …with appropriate catch and output messages\nExample program code:\nPython\ndef ReadFile():\nglobal DataArray\ntry:\nTextFile = \"IntegerData.txt\"\nFile = open(TextFile, 'r')\nfor X in range(0, 100):\nDataArray[X] = File.readline()\nDataArray[X].rstrip('\\n')\nDataArray[X] = int(DataArray[X])\nFile.close()\nexcept IOError:\nprint(\"Count not find file\")\n© UCLES 2022 Page 3 of 23\n\n1(b) Java\npublic static void ReadFile(){\nString Filename = \"IntegerData.txt\";\ntry{\nFileReader F = new FileReader(Filename);\nBufferedReader Reader = new BufferedReader(F);\nfor(Integer X = 0; X < 100; X++){\nDataArray[X] =\nInteger.parseInt(Reader.readLine());\n}\nReader.close();\n}\ncatch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\ncatch(IOException ex){\nSystem.out.println(\"No file found\");\n}\n}\nVB.NET\nSub ReadFile()\ntry\nDim TextFile As String = \"IntegerData.txt\"\nDim FileReader As New\nSystem.IO.StreamReader(TextFile)\nFor X = 0 To 99\nDataArray(X) = FileReader.ReadLine()\nNext\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\n\n1(c) 1 mark per point: 7\n• Function FindValues() (and end where appropriate) and input of data\nto search for in the array\n• …validation/casting(/storing as) of input as integer\n• …validation of input between 1 and 100 (inclusive)\n• looping through all 100 array elements…\n• …comparing input to each array element…\n• …initialising counter to 0 and then adding 1 each time it is found…\n• Returning the total\n© UCLES 2022 Page 4 of 23\n\n1(c) Example program code:\nPython\ndef FindValues():\nglobal DataArray\nDataToFind = -1\nwhile(DataToFind < 1 or DataToFind > 100):\nDataToFind = int(input(\"Enter a number between 1\nand 100\"))\nTotal = 0\nfor X in range(0, 99):\nif DataArray[X] == DataToFind:\nTotal = Total + 1\nreturn Total\nVB.NET\nFunction FindValues()\nDim DataToFind As Integer\nDo\nConsole.WriteLine(\"Enter a number between 1 and 100\")\nDataToFind = Console.ReadLine()\nLoop Until (DataToFind >= 1 And DataToFind <= 100)\nDim Total As Integer = 0\nFor X = 0 To 99\nIf DataArray(X) = DataToFind Then\nTotal = Total + 1\nEnd If\nNext\nReturn Total\nEnd Function\nJava\npublic static Integer FindValues(){\nInteger DataToFind = -1;\nwhile(DataToFind < 1 || DataToFind > 100){\nSystem.out.println(\"Enter a number between 1 and\n100\");\nScanner in = new Scanner(System.in);\nDataToFind = in.nextInt();\n}\nInteger Total = 0;\nfor(Integer X = 0; X < 100; X++){\nif(DataArray[X] == DataToFind){\nTotal = Total + 1;\n}\n}\nreturn Total;\n}\n© UCLES 2022 Page 5 of 23\n\n1(d)(i) 1 mark per point: 3\n• Calling ReadFile() and then FindValues() (in the main program)\n• storing/using return value from FindValues() …\n• …outputting return value with appropriate message\nExample program code:\nPython\nReadFile()\nprint(\"The number appears \" + str(FindValues()) + \"\ntimes\")\nJava\npublic static void main(String[] args){\nReadFile();\nInteger ReturnValue = FindValues();\nSystem.out.println(\"The number was found \" +\nReturnValue + \" times\");\n}\nVB.NET\nSub Main()\nReadFile()\nDim ReturnValue As Integer = FindValues()\nConsole.WriteLine(\"The number was found \" & ReturnValue\n& \" times\")\nEnd Sub\n\n1(d)(ii) Screenshot showing 61 input and 2 output, e.g. 1\n© UCLES 2022 Page 6 of 23\n\n1(e) 1 mark per point: 4\n• procedure declaration (and end where appropriate) and\noutputting array contents at end of procedure and\ncalling procedure from main program\n• correct outer loop …\n• … correct inner loop …\n• … swapping all elements if in incorrect order\nExample program code:\nPython\ndef BubbleSort():\nglobal DataArray\nN = 100\nfor I in range(N-1):\nfor J in range(0, N-I-1):\nif DataArray[J] > DataArray[J+1]:\nDataArray[J], DataArray[J+1] =\nDataArray[J+1], DataArray[J]\n#main\nReadFile()\nprint(\"The number appears \" + str(FindValues()) + \"\ntimes\")\nBubbleSort()\nprint(DataArray)\nJava\npublic static void BubbleSort(){\nInteger Temp = 0;\nfor(Integer I = 0; I < 100-1; I++){\nfor(Integer J = 0; J < 100-I-1; J++){\nif(DataArray[J] > DataArray[J+1]){\nTemp = DataArray[J];\nDataArray[J] = DataArray[J+1];\nDataArray[J+1] = Temp;\n}\n}\n}\nfor(Integer X = 0; X < 100; X ++){\nSystem.out.println(DataArray[X]);\n}\n}\npublic static void main(String[] args){\nReadFile();\nInteger ReturnValue = FindValues();\nSystem.out.println(\"The number was found \" +\nReturnValue + \" times\");\nBubbleSort();\n}\n© UCLES 2022 Page 7 of 23\n\n1(e) VB.NET\nSub Bubblesort()\nDim Outer As Integer = 100 - 1\nDim Swap As Boolean\nDim Inner As Integer\nDim Temp As Integer\nDo\nInner = 0\nSwap = False\nDo\nIf DataArray(Inner) > DataArray(Inner + 1) Then\nTemp = DataArray(Inner)\nDataArray(Inner) = DataArray(Inner + 1)\nDataArray(Inner + 1) = Temp\nSwap = True\nEnd If\nInner = Inner + 1\nLoop Until Inner = Outer\nOuter = Outer - 1\nLoop Until Swap = False Or Outer = 0\nFor X = 0 To 99\nConsole.WriteLine(DataArray(X))\nNext\nEnd Sub\nSub Main()\nReadFile()\nDim ReturnValue As Integer = FindValues()\nConsole.WriteLine(\"The number was found \" &\nReturnValue & \" times\")\nBubblesort()\nEnd Sub\nQuestion Answer Marks",
      "source_pages": [
        3,
        4,
        5,
        6,
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_43-p03.png",
        "../answer-assets/9618_w22_ms_43-p04.png",
        "../answer-assets/9618_w22_ms_43-p05.png",
        "../answer-assets/9618_w22_ms_43-p06.png",
        "../answer-assets/9618_w22_ms_43-p07.png",
        "../answer-assets/9618_w22_ms_43-p08.png"
      ]
    },
    {
      "id": "9618-2022-on-43-q02",
      "question_id": "9618-2022-on-43-q02",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 31,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) 1 mark per point: 5\n• class Card declaration (and end where appropriate)\n• Private attributes declared Number as integer and Colour as string\n• constructor header (and end where appropriate)…\n• …taking 2 parameters\n• assigning parameters to attributes\nExample program code:\nPython\nclass Card:\n#Number as integer\n#Colour as string\ndef __init__(self, Number1, Colour1):\nself.__Number = Number1;\nself.__Colour = Colour1;\n© UCLES 2022 Page 8 of 23\n\n2(a)(i) Java\nclass Card{\nprivate Integer Number;\nprivate String Colour;\npublic Card(Integer Number1, String Colourp){\nNumber = Number1;\nColour = Colourp;\n}}\nVB.NET\nClass Card\nPrivate Number As Integer\nPrivate Colour As String\nSub New(Number1, Colourp)\nNumber = Number1\nColour = Colourp\nEnd Sub\nEnd Class\n\n2(a)(ii) 1 mark per point: 3\n• 1 get method as function (and end where appropriate) with no\nparameters…\n• …returning the value\n• 2nd correct get method\nExample program code:\nPython\ndef GetNumber(self):\nreturn self.__Number\ndef GetColour(self):\nreturn self.__Colour\nJava\npublic Integer GetNumber(){\nreturn Number;\n}\npublic String GetColour(){\nreturn Colour;\n}\nVB.NET\nFunction GetNumber()\nReturn Number\nEnd Function\nFunction GetColour()\nReturn Colour\nEnd Function\n© UCLES 2022 Page 9 of 23\n\n2(a)(iii) 1 mark per point: 2\n• one card initialised as type Card …\n• … all 15 cards initialised correctly as type Card\nExample program code:\nPython\nOneRed = Card(1, \"red\")\nTwoRed = Card(2, \"red\")\nThreeRed = Card(3, \"red\")\nFourRed = Card(4, \"red\")\nFiveRed = Card(5, \"red\")\nOneBlue = Card(1, \"blue\")\nTwoBlue = Card(2, \"blue\")\nThreeBlue = Card(3, \"blue\")\nFourBlue = Card(4, \"blue\")\nFiveBlue = Card(5, \"blue\")\nOneYellow = Card(1, \"yellow\")\nTwoYellow = Card(2, \"yellow\")\nThreeYellow = Card(3, \"yellow\")\nFourYellow = Card(4, \"yellow\")\nFiveYellow = Card(5, \"yellow\")\nJava\nCARD oneRed = new Card(1, \"red\");\nCARD twoRed = new Card(2, \"red\");\nCARD threeRed = new Card(3, \"red\");\nCARD fourRed = new Card(4, \"red\");\nCARD fiveRed = new Card(5, \"red\");\nCARD oneBlue = new Card(1, \"blue\");\nCARD twoBlue = new Card(2, \"blue\");\nCARD threeBlue = new Card(3, \"blue\");\nCARD fourBlue = new Card(4, \"blue\");\nCARD fiveBlue = new Card(5, \"blue\");\nCARD oneYellow = new Card(1, \"yellow\");\nCARD twoYellow = new Card(2, \"yellow\");\nCARD threeYellow = new Card(3, \"yellow\");\nCARD fourYellow = new Card(4, \"yellow\");\nCARD fiveYellow = new Card(5, \"yellow\");\n© UCLES 2022 Page 10 of 23\n\n2(a)(iii) VB.NET\nDim OneRed As New Card (1, \"red\")\nDim TwoRed As New Card(2, \"red\")\nDim ThreeRed As New Card(3, \"red\")\nDim FourRed As New Card(4, \"red\")\nDim FiveRed As New Card(5, \"red\")\nDim OneBlue As New Card(1, \"blue\")\nDim TwoBlue As New Card(2, \"blue\")\nDim ThreeBlue As New Card(3, \"blue\")\nDim FourBlue As New Card(4, \"blue\")\nDim FiveBlue As New Card(5, \"blue\")\nDim OneYellow As New Card(1, \"yellow\")\nDim TwoYellow As New Card(2, \"yellow\")\nDim ThreeYellow As New Card(3, \"yellow\")\nDim FourYellow As New Card(4, \"yellow\")\nDim FiveYellow As New Card(5, \"yellow\")\n\n2(b)(i) 1 mark per point: 6\n• class Hand declaration (and end where appropriate)\n• private attribute declarations; FirstCard as integer, NumberCards as\ninteger\n• private attribute array named Cards of type Card with 10 elements\n• constructor with 5 Card objects as parameters\n• assigning each Card parameter to the array (in constructor)\n• initialising FirstCard to 0 and NumberCards to 5 (in constructor)\nExample program code:\nPython\nclass Hand:\n#Cards[10] as Card\n#FirstCard as integer\n#NumberCards as integer\ndef __init__(self, Card1, Card2, Card3, Card4,\nCard5):\nself.__Cards = []\nself.__Cards.append(Card1)\nself.__Cards.append(Card2)\nself.__Cards.append(Card3)\nself.__Cards.append(Card4)\nself.__Cards.append(Card5)\nself.__FirstCard = 0\nself.__NumberCards = 5\n© UCLES 2022 Page 11 of 23\n\n2(b)(i) Java\nclass Hand{\nprivate Card[] Cards = new Card[10];\nprivate Integer FirstCard;\nprivate Integer NumberCards;\npublic Hand(CARD Card1, CARD Card2, CARD Card3, CARD\nCard4, CARD Card5){\nCards[0] = Card1;\nCards[1] = Card2;\nCards[2] = Card3;\nCards[3] = Card4;\nCards[4] = Card5;\nFirstCard = 0;\nNumberCards = 5;\n}\n}\nVB.NET\nclass Hand\nPrivate Cards(9) As Card\nPrivate FirstCard As Integer\nPrivate NumberCards As Integer\nSub New(Card1, Card2, Card3, Card4, Card5)\nCards(0) = Card1\nCards(1) = Card2\nCards(2) = Card3\nCards(3) = Card4\nCards(4) = Card5\nFirstCard = 0\nNumberCards = 5\nEnd Sub\nEnd Class\n\n2(b)(ii) 1 mark per point: 2\n• function GetCard() header (and end where appropriate) taking (integer)\nparameter\n• returning the card at parameter index in array\nExample program code:\nPython\ndef GetCard(self, Position):\nreturn self.__Cards[Position]\nJava\npublic Card GetCard(Integer Position){\nreturn Cards[Position];\n}\nVB.NET\nFunction GetCard(Position)\nReturn Cards(Position)\nEnd Function\n© UCLES 2022 Page 12 of 23\n\n2(b)(iii) 1 mark per point: 2\n• 2 variables (player 1 and player 2) of type Hand\n• using constructor and sending the correct variables as parameters\nExample program code:\nPython\nPlayer1 = Hand(OneRed, TwoRed, ThreeRed, FourRed,\nOneYellow)\nPlayer2 = Hand(TwoYellow, ThreeYellow, FourYellow,\nFiveYellow, OneBlue)\nJava\nHand Player1 = new Hand(OneRed, TwoRed, ThreeRed,\nFourRed, OneYellow);\nHand Player2 = new Hand(TwoYellow, ThreeYellow,\nFourYellow, FiveYellow, OneBlue);\nVB.NET\nDim Player1 As New Hand(OneRed, TwoRed, ThreeRed,\nFourRed, OneYellow)\nDim Player2 As New Hand(TwoYellow, ThreeYellow,\nFourYellow, FiveYellow, OneBlue)\n\n2(c)(i) 1 mark per point: 6\n• function CalculateValue() header (and end where appropriate)\ntaking one parameter and initialising score to 0\n• looping through all 5 Card objects in parameter array…\n• … adding 5 to score for red, 10 to score for blue, 15 to score if yellow\n• … adding each card number to score\n• Using GetCard(), GetColour() and GetNumber() correctly\n• Returning calculated score\nExample program code:\nPython\ndef CalculateValue(Player):\nScore = 0\nfor Count in range(0, 4):\nCardGot = Player.GetCard(Count)\nScore = Score + CardGot.GetNumber()\nColour = CardGot.GetColour()\nif Colour == \"red\":\nScore = Score + 5\nelif Colour == \"blue\":\nScore = Score + 10\nelse:\nScore = Score + 15\nreturn Score\n© UCLES 2022 Page 13 of 23\n\n2(c)(i) Java\npublic static Integer CalculateValue(Hand Player){\nInteger Score = 0;\nString Colour;\nCard CardGot;\nfor(Integer X = 0; X<5; X++){\nCardGot = Player.GetCard(X);\nScore = Score + CardGot.GetNumber();\nColour = CardGot.GetColour();\nif(Colour == \"red\"){\nScore = Score + 5;\n}else if(Colour == \"blue\"){\nScore = Score + 10;\n} else {\nScore = Score + 15;\n}}return Score;}\nVB.NET\nFunction CalculateValue(Player As Hand)\nDim Score As Integer = 0\nDim Colour As String\nDim CardGot As Card\nFor Count = 0 To 4\nCardGot = Player.GetCard(Count)\nScore = Score + CardGot.GetNumber()\nColour = CardGot.GetColour()\nIf Colour = \"red\" Then\nScore = Score + 5\nElseIf Colour = \"blue\" Then\nScore = Score + 10\nElse\nScore = Score + 15\nEnd If\nNext\nReturn Score\nEnd Function\n© UCLES 2022 Page 14 of 23\n\n2(c)(ii) 1 mark per point: 4\n• One function call of CalculateValue( ) for each player …\n• …sending the player's hand as parameter\n• Comparing return values and outputting the player with the highest\nscore in an appropriate message …\n• … or if there was a draw in appropriate message\nExample program code:\nPython\nPlayer1score = CalculateValue(Player1)\nPlayer2score = CalculateValue(Player2)\nif Player1score > Player2score:\nprint(\"Player 1 wins\")\nelif Player1score < Player2score:\nprint(\"Player 2 wins\")\nelse:\nprint(\"It's a draw\")\nJava\nInteger Player1score = CalculateValue(Player1);\nInteger Player2score = CalculateValue(Player2);\nif(Player1score > Player2score){\nSystem.out.println(\"Player 1 wins\");\n}else if(Player2score > Player1score){\nSystem.out.println(\"Player2 wins\");\n} else {\nSystem.out.println(\"It's a draw\");\n}\nVB.NET\nDim Player1score As Integer\nDim Player2score As Integer\nPlayer1score = CalculateValue(Player1)\nPlayer2score = CalculateValue(Player2)\nIf Player1score > Player2score Then\nConsole.WriteLine(\"Player 1 wins\")\nElseIf Player1score < Player2score Then\nConsole.WriteLine(\"Player 2 wins\")\nElse\nConsole.WriteLine(\"It's a draw\")\nEnd If\n\n2(c)(iii) Output showing player 2 wins, for example: 1\n© UCLES 2022 Page 15 of 23",
      "source_pages": [
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_43-p08.png",
        "../answer-assets/9618_w22_ms_43-p09.png",
        "../answer-assets/9618_w22_ms_43-p10.png",
        "../answer-assets/9618_w22_ms_43-p11.png",
        "../answer-assets/9618_w22_ms_43-p12.png",
        "../answer-assets/9618_w22_ms_43-p13.png",
        "../answer-assets/9618_w22_ms_43-p14.png",
        "../answer-assets/9618_w22_ms_43-p15.png"
      ]
    },
    {
      "id": "9618-2022-on-43-q03",
      "question_id": "9618-2022-on-43-q03",
      "subject": "9618",
      "year": 2022,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 21,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark per point: 3\n• Declaring (global) 2D array ArrayNodes\n• looping through all 20  3 elements of array …\n• …. storing −1 in each element\nExample program code:\nJava\npublic static Integer[][] ArrayNodes = new\nInteger[20][3];\nfor(Integer X = 0; X<20; X++){\nfor(Integer Y = 0; Y<3; Y++){\nArrayNodes[X][Y] = -1\n}}\nPython\nArrayNodes = []\nfor x in range(0, 20):\nArrayNodes.append([-1, -1, -1])\nVB.NET\nDim ArrayNodes(19, 2) As Integer\nSub main()\nFor X = 0 To 19\nFor Y = 0 To 2\nArrayNodes(X, Y) = -1\nNext\nNext\nEnd Sub\n© UCLES 2022 Page 16 of 23\n\n3(b) 1 mark per point: 2\n• initialising each of the first 6 array elements correctly\n• declaring and initialising FreeNode to 6 and RootPointer to 0\nExample program code:\nPython\nArrayNodes = [[1,20,5],[2,15,-1],[-1,3,3],[-1,9,4],[-\n1,10,-1],[-1,58,-1]]\nFreeNodes = 6\nRootPointer = 0\nJava\nArrayNodes[0][0] = 1;\nArrayNodes[0][1] = 20;\nArrayNodes[0][2] = 5;\nArrayNodes[1][0] = 2;\nArrayNodes[1][1] = 15;\nArrayNodes[1][2] = -1;\nArrayNodes[2][0] = -1;\nArrayNodes[2][1] = 3;\nArrayNodes[2][2] = 3;\nArrayNodes[3][0] = -1;\nArrayNodes[3][1] = 9;\nArrayNodes[3][2] = 4;\nArrayNodes[4][0] = -1;\nArrayNodes[4][1] = 10;\nArrayNodes[4][2] = -1;\nArrayNodes[5][0] = -1;\nArrayNodes[5][1] = 58;\nArrayNodes[5][2] = -1;\nInteger FreeNode = 6;\nInteger RootPointer = 0;\n© UCLES 2022 Page 17 of 23\n\n3(b) VB.NET\nArrayNodes(0, 0) = 1\nArrayNodes(0, 1) = 20\nArrayNodes(0, 2) = 5\nArrayNodes(1, 0) = 2\nArrayNodes(1, 1) = 15\nArrayNodes(1, 2) = -1\nArrayNodes(2, 0) = -1\nArrayNodes(2, 1) = 3\nArrayNodes(2, 2) = 3\nArrayNodes(3, 0) = -1\nArrayNodes(3, 1) = 9\nArrayNodes(3, 2) = 4\nArrayNodes(4, 0) = -1\nArrayNodes(4, 1) = 10\nArrayNodes(4, 2) = -1\nArrayNodes(5, 0) = -1\nArrayNodes(5, 1) = 58\nArrayNodes(5, 2) = -1\nDim FreeNode As Integer = 6\nDim RootPointer As Integer = 0\n© UCLES 2022 Page 18 of 23\n\n3(c) 1 mark for each completed statement (4) 5\n1 mark for remainder of function correct\nPseudocode:\nFUNCTION SearchValue(BYVAL Root : INTEGER, ValueToFind :\nINTEGER)\nIF Root = -1 THEN\nRETURN -1\nELSE\nIF ArrayNodes[Root,1] = ValueToFind THEN\nRETURN Root\nELSE\nIF ArrayNodes[Root, 1] = -1 THEN\nRETURN -1\nENDIF\nENDIF\nENDIF\nIF ArrayNodes[Root,1] > ValueToFind THEN\nRETURN SearchValue(ArrayNodes[Root,0], ValueToFind)\nENDIF\nIF ArrayNodes[Root,1] < ValueToFind THEN\nRETURN SearchValue(ArrayNodes[Root,2], ValueToFind)\nENDIF\nENDFUNCTION\nExample program code:\nPython\ndef SearchValue(Root, ValueToFind):\nglobal ArrayNodes\nif Root == -1:\nreturn -1\nelif ArrayNodes[Root][1] == ValueToFind:\nreturn Root\nelif ArrayNodes[Root][1] == -1:\nreturn -1\nif(ArrayNodes[Root][1] > ValueToFind):\nreturn SearchValue(ArrayNodes[Root][0], ValueToFind)\nif(ArrayNodes[Root][1] < ValueToFind):\nreturn SearchValue(ArrayNodes[Root][2], ValueToFind)\n© UCLES 2022 Page 19 of 23\n\n3(c) Java\npublic static Integer SearchValue(Integer Root, Integer\nValueToFind){\nif(Root == -1){\nreturn -1;\n}else if(ArrayNodes[Root][1] == ValueToFind){;\nreturn Root;\n}else if(ArrayNodes[Root][1] == -1){\nreturn -1;\n}\nif(ArrayNodes[Root][1] > ValueToFind){\nreturn(SearchValue(ArrayNodes[Root][0],\nValueToFind));\n}\nif(ArrayNodes[Root][1] < ValueToFind){\nreturn(SearchValue(ArrayNodes[Root][2],\nValueToFind));\n}\nreturn -1;\n}\nVB.NET\nFunction SearchValue(ByVal Root, ByVal ValueToFind)\nIf ArrayNodes(Root, 1) = ValueToFind Then\nReturn Root\nElseIf ArrayNodes(Root, 1) = -1 Then\nReturn -1\nEnd If\nIf ArrayNodes(Root, 1) > ValueToFind Then\nReturn SearchValue(ArrayNodes(Root, 0), ValueToFind)\nEnd If\nIf ArrayNodes(Root, 1) < ValueToFind Then\nReturn SearchValue(ArrayNodes(Root, 2), ValueToFind)\nEnd If\nReturn -1\nEnd Function\n© UCLES 2022 Page 20 of 23\n\n3(d) 1 mark per point (Max 7): 7\n• (procedure) header (and end where appropriate) with one parameter\n(root node or index of root node) and at least one recursive call\n• checking if left node is −1 …\n• … if not recursive call with parameter as ArrayNodes[RootNode[0]]\n• checking if right node is −1 …\n• …if not recursive call with parameter as ArrayNodes[RootNode[2]]\n• outputting the element at the parameter RootNode[]\n• all 3 in the correct order\nExample program code:\nPython\ndef PostOrder(RootNode):\nif RootNode[0] != -1:\nPostOrder(ArrayNodes[RootNode[0]])\nif RootNode[2] != -1:\nPostOrder(ArrayNodes[RootNode[2]])\nprint(str(RootNode[1]))\nJava\npublic static void PostOrder(Integer[] RootNode){\nif(RootNode[0] != -1){\nPostOrder(ArrayNodes[RootNode[0]]);\n}\nif(RootNode[2] != -1){\nPostOrder(ArrayNodes[RootNode[2]]);\n}\nSystem.out.println(RootNode[1]);\n}\nVB.NET\nSub PostOrder(RootNode() As Integer)\nDim TempArray(2) As Integer\nIf RootNode(0) <> -1 Then\nTempArray(0) = ArrayNodes(RootNode(0), 0)\nTempArray(1) = ArrayNodes(RootNode(0), 1)\nTempArray(2) = ArrayNodes(RootNode(0), 2)\nPostOrder(TempArray)\nEnd If\nIf RootNode(2) <> -1 Then\nTempArray(0) = ArrayNodes(RootNode(2), 0)\nTempArray(1) = ArrayNodes(RootNode(2), 1)\nTempArray(2) = ArrayNodes(RootNode(2), 2)\nPostOrder(TempArray)\nEnd If\nConsole.WriteLine(RootNode(1))\nEnd Sub\n© UCLES 2022 Page 21 of 23\n\n3(e)(i) 1 mark per point: 3\n• calling SearchValue() with 15 and rootPointer as a parameter …\n• … if return value > -1 output returned index and\nif return value = -1 output not found\nBoth as appropriate messages\n• Calling PostOrder() with ArrayNodes[RootPointer] as a\nparameter\nExample program code:\nPython\nReturnValue = SearchValue(RootPointer, 15)\nif ReturnValue == -1:\nprint(\"Not found\")\nelse:\nprint(\"Found at \" + str(ReturnValue))\nPostOrder(ArrayNodes[RootPointer])\nJava\nInteger ReturnValue = SearchValue(RootPointer, 15);\nif(ReturnValue == -1){\nSystem.out.println(\"Not found\");\n} else {\nSystem.out.println(\"Found at \" + ReturnValue);\n}\nPostOrder(ArrayNodes[RootPointer]);\nVB.NET\nDim returnvalue As Integer = SearchValue(RootPointer, 15)\nIf returnvalue = -1 Then\nConsole.WriteLine(\"Not found\")\nElse\nConsole.WriteLine(\"Found at \" & returnvalue)\nEnd If\nConsole.WriteLine(\"Post order\")\nDim TempArray(2) As Integer\nTempArray(0) = ArrayNodes(RootPointer, 0)\nTempArray(1) = ArrayNodes(RootPointer, 1)\nTempArray(2) = ArrayNodes(RootPointer, 2)\nPostOrder(TempArray)\n© UCLES 2022 Page 22 of 23\n\n3(e)(ii) Screenshot with result as shown, for example: 1\n© UCLES 2022 Page 23 of 23",
      "source_pages": [
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23
      ],
      "source_pdf": "_source-pdfs/2022-oct-nov/ms/9618_w22_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2022-Oct-Nov/9618_w22_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w22_ms_43-p16.png",
        "../answer-assets/9618_w22_ms_43-p17.png",
        "../answer-assets/9618_w22_ms_43-p18.png",
        "../answer-assets/9618_w22_ms_43-p19.png",
        "../answer-assets/9618_w22_ms_43-p20.png",
        "../answer-assets/9618_w22_ms_43-p21.png",
        "../answer-assets/9618_w22_ms_43-p22.png",
        "../answer-assets/9618_w22_ms_43-p23.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q01",
      "question_id": "9618-2023-mj-31-q01",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point (Max 4) 4\n conversion of 113.75 to binary seen 1110001.11\n exponent for normalisation 7 converted to binary 111 // evidence of binary\npoint moved 7 places // evidence of finding exponent = 7\n system 1 answer\n system 2 answer showing correct version from system 1\nSystem 1 Mantissa Exponent\n0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1\nSystem 2 Mantissa Exponent\n0 1 1 1 0 0 0 1 0 0 0 0 0 1 1 1\n\n1(b) One mark per mark point (Max 2) 2\n the mantissa in system 2 does not have enough bits to store the whole\nbinary number // 10 bits required and only 8 bits available\n so precision is lost / the number is truncated\nQuestion Answer Marks",
      "source_pages": [
        3
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p03.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q02",
      "question_id": "9618-2023-mj-31-q02",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 2,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark for each correct line connecting a machine learning technique to its 4\nmost appropriate description (Max 4).\nMachine learning category Description\nsimulates the data processing\ncapabilities of the human brain to\nmake decisions\nSupervised\nlearning\nenables learning by mapping an input\nto an output based on example input-\nReinforcement output pairs\nlearning\nenables information related to errors\nproduced by the neural network to be\ntransmitted\nDeep learning\nenables learning in an interactive\nenvironment by trial and error using\nits own experiences\nUnsupervised\nlearning\nenables learning by allowing the\nprocess to discover patterns on its\nown that were previously undetected\n© UCLES 2023 Page 3 of 10\n\n2(b) One mark per mark point (Max 2) 2\n to find the optimal / shortest / most cost-effective route\n … between two nodes in a\n … based on distance / cost / time.\nQuestion Answer Marks",
      "source_pages": [
        3,
        4
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p03.png",
        "../answer-assets/9618_s23_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q03",
      "question_id": "9618-2023-mj-31-q03",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 3,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark for each correct hash value (Max 2) 2\nRecord key Hash value\n1030 1\n1050 0\n1025 2\n\n3(b) One mark per mark point (Max 4) 4\nMP1 A collision occurs when the record key doesn’t match the stored record\nkey\nMP2 … this means the determined storage location has already been used\nfor another record.\nIf the record is to be stored\nMP3 Search the file linearly\nMP4 … to find the next available storage space (closed hash)\nMP5 Search the overflow area linearly\nMP6 … to find next available storage space (open hash)\nIf the record is to be found\nMP7 … search the overflow area linearly (open hash) until the matching\nrecord key is found\nMP8 … search linearly from where you are (closed hash) until the matching\nrecord key is found\nMP9 If not found record is not in file\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q04",
      "question_id": "9618-2023-mj-31-q04",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 4,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark per mark point (Max 2) 2\n TYPE Prime\n = (2, 3, 5, 7, 11, 13, 17, 19)\nExample answer\nTYPE Prime = (2, 3, 5, 7, 11, 13, 17, 19)\n\n4(b) One mark per mark point (Max 2) 2\n TYPE TDayPointer\n = ^STRING //^DayOfWeek\nExample answer\nTYPE TDayPointer = ^STRING // ^DayOfWeek\n© UCLES 2023 Page 4 of 10",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q05",
      "question_id": "9618-2023-mj-31-q05",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 5,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark per mark point (Max 2) 2\n Circuit switching is used where a dedicated path needs to be sustained\nthroughout the call / communication // where the whole bandwidth is\nrequired // where a real time communication is used.\n A typical application is standard voice communications / video streaming /\nprivate data networks\n\n5(b) One mark per benefit (Max 2) 4\nMP1 Whole of bandwidth is available\nMP2 Dedicated communication channel increases the quality of transmission\nMP3 Data is transmitted with a fixed data rate\nMP4 No waiting time at switches\nMP5 Suitable for long continuous communication\nMP6 Fast method of data transfer\nMP7 Data arrives in the same order as it was sent\nMP8 Data can’t get lost\nMP9 Data all follows the same path / route\nMP10 Better for real-time\nMP11 Simple method of data transfer.\nOne mark per drawback (Max 2)\nMP1 A dedicated connection makes it impossible to transmit other data even\nif the channel is free\nMP2 Not very flexible\nMP3 No alternative route in case of failure\nMP4 The time required to establish the physical link between the two stations\ncan be too long\nMP5 The need to establish a dedicated path for each connection can have\ncost implications\nMP6 Dedicated channels require the whole bandwidth / bandwidth can’t be\nshared\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p05.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q06",
      "question_id": "9618-2023-mj-31-q06",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 6,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark per correct valid/invalid and reason combination (Max 3) 3\nDPAD99$ – Valid\nReason – 4/multiple letters followed by 2/multiple digits followed by a symbol.\nDAD#95 – Invalid\nReason – The symbol comes before the digits – it should be after.\nADY123? – Invalid\nReason – The ? is not a valid symbol.\n\n6(b) <symbol> ::= $ | % | & | @ | # 1\n<letter> ::= A | D | P | R | Y\n© UCLES 2023 Page 5 of 10\n\n6(c) One mark per mark point (Max 4) 4\n begins with a letter\n letter can repeat and digit present\n digit can repeat or can be bypassed\n correct structure – name, boxes and arrows (in and out).\nExample answers:\nidentifier\nletter digit\nidentifier\nletter letter digit\nQuestion Answer Marks",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p05.png",
        "../answer-assets/9618_s23_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q07",
      "question_id": "9618-2023-mj-31-q07",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "7(a) Two marks if no errors present 2\nOne mark if one error present\n\n7(b) One mark for each correct loop (Max 2) 2\n© UCLES 2023 Page 6 of 10\n\n7(c) One mark for each mark point (Max 2) 2\n Any correct Boolean term\n Boolean terms and operator correct and no other terms present\n(Z =) AC + BC\n\n7(d) One mark for simplest form (Max 1) 1\n(Z =) C (A + B)\nQuestion Answer Marks",
      "source_pages": [
        6,
        7
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p06.png",
        "../answer-assets/9618_s23_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q08",
      "question_id": "9618-2023-mj-31-q08",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 8,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "8 One mark per mark point (Max 3) 3\nMP1 A large number of computer processors / separate computers\nconnected together\nMP2 … simultaneously performing a set of coordinated computations //\ncollaborative processing\nMP3 network infrastructure\nMP4 communicate using a message interface / by sending messages.\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q09",
      "question_id": "9618-2023-mj-31-q09",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 9,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark per mark point (Max 2) 2\nMP1 To provide better security\nMP2 … by using two different keys / a public key and a private key\nMP3 One of the keys is used to encrypt the message\nMP4 … the matching key is used to decrypt the message.\n\n9(b) One mark per benefit (Max 2) 4\nMP1 Provides security based on laws of physics rather than mathematical\nalgorithms, so more secure.\nMP2 To protect the security of data transmitted over fibre optic cables.\nMP3 Virtually unhackable.\nMP4 The performance of quantum cryptography is continuously improved,\nmaking it suitable for most valuable government/industrial secrets.\nMP5 Longer keys can be used\nMP6 Eavesdropping can be detected\nOne mark per drawback (Max 2)\nMP1 Lacks many vital features such as digital signature, certified mail, etc.\nMP2 High cost of purchasing / maintaining equipment required.\nMP3 Currently only works over relatively short distances.\nMP4 Error rates are relatively high as technology is still being developed.\nMP5 Polarisation of light can change during transmission.\nMP6 Allows criminals and terrorists to hide their communications.\n© UCLES 2023 Page 7 of 10",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q10",
      "question_id": "9618-2023-mj-31-q10",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 10,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "10 One mark for each correctly completed line (Max 5) 5\nDECLARE Account : STRING\nOPENFILE \"ActiveFile.txt\" FOR READ\nOPENFILE \"ArchiveFile.txt\" FOR WRITE\nWHILE NOT EOF(\"ActiveFile.txt\")\nREADFILE \"ActiveFile.txt\", Account\nIF Account = \"\" THEN\nWRITEFILE \"ArchiveFile.txt\", \"Account not present\"\nELSE\nWRITEFILE \"ArchiveFile.txt\", Account\nENDIF\nENDWHILE\nCLOSEFILE \"ActiveFile.txt\"\nCLOSEFILE \"ArchiveFile.txt\"\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p08.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q11",
      "question_id": "9618-2023-mj-31-q11",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 11,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 11,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark per mark point (Max 3) 3\n correctly defined constant\n correctly defined array\n three correctly defined integers\nCONSTANT MaxSize = 60\nDECLARE Queue : ARRAY[1:60] OF STRING // DECLARE Queue :\nARRAY[0:59] OF STRING // DECLARE Queue : ARRAY[1:MaxSize]\nOF STRING // DECLARE Queue : ARRAY[0:MaxSize - 1] OF\nSTRING\nDECLARE FrontPointer : INTEGER\nDECLARE RearPointer : INTEGER\nDECLARE Length : INTEGER\n© UCLES 2023 Page 8 of 10\n\n11(b) One mark for each correctly completed line (Max 4) 4\nFUNCTION Dequeue RETURNS STRING\nDECLARE Item : STRING\nIF Length > 0 THEN\nItem  Queue[FrontPointer]\nFrontPointer  FrontPointer + 1\nLength  Length – 1\nIF Length = 0 THEN\nCALL Initialise // procedure to reset the\npointers\nELSE\nIF FrontPointer > MaxSize THEN\nFrontPointer  1\nENDIF\nENDIF\nELSE\nOUTPUT \"The print queue was empty – error\"\nItem  \"\"\nENDIF\nRETURN Item\nENDFUNCTION\n\n11(c) One mark per mark point (Max 4) 4\nMP1 (Two stacks are required) so that the second stack can reverse the\norder of the first stack.\nMP2 Stack 1 operates as the queue with the newest elements at the bottom.\nStack 2 is empty.\nMP3 To add an element, pop all the elements from stack 1 and push onto\nstack 2.\nMP4 Push the new element onto either stack.\nMP5 Pop all the elements of stack 2 back onto stack 1.\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p08.png",
        "../answer-assets/9618_s23_ms_31-p09.png"
      ]
    },
    {
      "id": "9618-2023-mj-31-q12",
      "question_id": "9618-2023-mj-31-q12",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 12,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "12(a) One mark per mark point (Max 2) 2\n A process using a function or procedure defined in terms of itself / calls\nitself.\n A recursive process must have a base case (which is a way to return\nwithout making a recursive call) // terminating solution // concept of\nunwinding described\n There must (also) be a general case where the recursive call takes place.\n© UCLES 2023 Page 9 of 10\n\n12(b) One mark per mark point (Max 5) 5\n Call number column correct\n Function call and Number columns correct\n Result column down to base case (Winding) rows 1–6 correct\n Result column down from base case (Unwinding) rows 7–10 correct\n Return value column correct\nCall Function call Number Result Return\nnumber value\n1 Fib(5) 5 Fib(4) + Fib(3)\n2 Fib(4) 4 Fib(3) + Fib(2)\n3 Fib(3) 3 Fib(2) + Fib(1)\n4 Fib(2) 2 Fib(1) + Fib(0)\n5 Fib(1) 1 1 1\n6 Fib(0) 0 0 0\n(4) Fib(2) 2 1 + 0 1\n(3) Fib(3) 3 1 + 1 2\n(2) Fib(4) 4 2 + 1 3\n(1) Fib(5) 5 3 + 2 5\n© UCLES 2023 Page 10 of 10",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_31-p09.png",
        "../answer-assets/9618_s23_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q01",
      "question_id": "9618-2023-mj-32-q01",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point 2\n correct mantissa\n correct exponent with associated working\nAnswer\nMantissa Exponent\n0 1 0 1 0 1 0 1 1 1 0 0 0 1 1 0\nWorking\nexponent = 6 (movement of 6 bicimal places seen to find what exponent should\nbe)\ncalculation of denary 6 to binary (000)110\n\n1(b) One mark per mark point (Max 3) 3\nMP1 the mantissa of the number would need to be 0.101011111001 / 13\nbits / digits\nMP2 … it can only store 10 bits / digits\nMP3 The 3 least significant digits would be truncated\nMP4 …causing a loss of precision\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q02",
      "question_id": "9618-2023-mj-32-q02",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 2,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark per mark point (Max 3) 3\nMP1 records are stored in a particular order\nMP2 the order is determined based on the value in a key field\nMP3 records are accessed one after the other\nMP4 records can be found by searching from the beginning of the file,\nrecord by record,\nMP5 … until the required record is found or key field value is exceeded.\n\n2(b) One mark for each correct hash value (Max 2) 2\nRecord key Hash value\n3003 3\n1029 4\n7630 0\n© UCLES 2023 Page 4 of 12",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q03",
      "question_id": "9618-2023-mj-32-q03",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 3,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per correct valid/invalid and reason combination (Max 2) 2\n9SW – Invalid\nReason - This begins with a digit and a variable must begin with a letter\nUWY – Valid\nReason – This begins with a letter and is followed by two other letters.\n\n3(b) One mark per mark point (Max 3) 3\n <word> ::= <letter>|\n …<word><letter>\n <variable> ::= <word>|<word><digit>\nExample answers\n<word> ::= <letter>|<word><letter>\n<word> ::= <letter><word>|<letter>\n<variable> ::= <word>|<word><digit>\n<variable> ::= <word><digit>|<word>\n\n3(c)(i) Answer must be two letters followed by one, two or three digits using the letters 1\nand digits on the syntax diagram.\nExample answer\nAC768\n\n3(c)(ii) One mark per mark point (Max 3) 3\n always has only two letters\n one, two or three digits possible\n correct arrows, boxes and name of syntax diagram\nExample answer\nVehicle registration\nletter letter digit digit digit\n© UCLES 2023 Page 5 of 12",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q04",
      "question_id": "9618-2023-mj-32-q04",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 4,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "4 One mark for each correct line connecting an OOP term to its description 4\n(Max 4).\nOOP term Description\nmethods used to return the value of a\nproperty\nEncapsulation\nthe process of putting data and\nmethods together as a single unit\nGetters\nmethods used to update the value of\na property\nPolymorphism\nallows methods to be redefined for\nderived classes\nSetters\nenables the defining of a new class\nthat inherits from a parent class\nQuestion Answer Marks",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q05",
      "question_id": "9618-2023-mj-32-q05",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 5,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark per mark point (Max 2) 2\nMP1 to produce a virtually unbreakable encryption system / send\nvirtually un-hackable secure messages …\nMP2 …using the laws / principles of quantum mechanics / properties of\nphotons\nMP3 detects eavesdropping …\nMP4 …because the properties of photons change\nMP5 to protect security of data transmitted over fibre optic cables\nMP6 to enable the use of longer keys.\n\n5(b) One mark per mark point (Max 3) 3\nMP1 Symmetric cryptography uses a single key to encrypt and decrypt\nmessages, Asymmetric cryptography uses two.\nMP2 The symmetric key is shared, whereas with asymmetric, only the\npublic key is shared (and the private key isn’t).\nMP3 … the risk of compromise is higher with symmetric encryption and\nasymmetric encryption is more secure.\nMP4 Symmetric cryptography is a simple process that can be carried out\nquickly, but asymmetric is much more complex, so slower.\nMP5 The length of the keys in symmetric encryption are (usually) shorter\nthan those for asymmetric (128/256 bits v 2048 bits).\n© UCLES 2023 Page 6 of 12",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q06",
      "question_id": "9618-2023-mj-32-q06",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 6,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for TYPE TAppointments and ENDTYPE correct 4\nOne mark for every two correct declarations (Max 3)\nExample answer\nTYPE TAppointments\nDECLARE Name : STRING\nDECLARE DateOfBirth : DATE\nDECLARE Telephone : STRING\nDECLARE LastAppointment : DATE\nDECLARE NextAppointment : DATE\nDECLARE TreatmentsComplete : BOOLEAN\nENDTYPE\n\n6(b) One mark for each correctly completed line (Max 5) 5\nDECLARE DentalRecord : ARRAY[1:250] OF TAppointments\nDECLARE DentalFile : STRING\nDECLARE Count : INTEGER\nDentalFile  \"DentalFile.dat\"\nOUTPUT \"The file \", DentalFile, \" contains these records:\"\nOPENFILE DentalFile FOR RANDOM\nCount  1\nREPEAT\nSEEK DentalFile, Count\nGETRECORD DentalFile, DentalRecord[Count]\nOUTPUT DentalRecord[Count]\nCount  Count + 1\nUNTIL EOF(DentalFile)\nCLOSEFILE DentalFile\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q07",
      "question_id": "9618-2023-mj-32-q07",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 7,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark per mark point (Max 2) 2\nMP1 Packet switching is most commonly used on data networks such as\nthe internet to send large data files that don’t need to be live streamed\nMP2 Packet switching is used when it is necessary to be able to overcome\nfailed/faulty lines by rerouting.\nMP3 Packet switching is used when it is necessary for the communication\nto be more secure.\nMP4 Packet switching is used for high volume data transmission.\nMP5 Packet switching is used when it isn’t necessary to use all the\nbandwidth.\nMP6 Specific examples e.g. email, text messages, documents, VOIP etc.\n(up to two marks).\n© UCLES 2023 Page 7 of 12\n\n7(b) One mark per mark point (Max 4) 4\nMP1 Circuit switching uses a dedicated channel to make communication,\nwhereas packet switching forms data into packets to transmit over a\ndigital network.\nMP2 The dedicated path for circuit switching must be established before\nthe transfer of data can commence, which is not the case with packet\nswitching (as it doesn’t require a dedicated path).\nMP3 Data in packet switching is split into packets, in circuit switching the\nmessage remains intact.\nMP4 All of the transmission in circuit switching follows the same path\nwhereas different packets in packet switching can take different\nroutes.\nMP5 The message is received in the same order in which it is sent with\ncircuit switching, but with packet switching, the packets can be\nreceived out of order (for assembly at the destination).\nMP6 Circuit switching is implemented at the physical layer while packet\nswitching is implemented at the network layer.\nMP7 Circuit switching uses the whole bandwidth of the channel used,\npacket switching can share bandwidth.\nMP8 Circuit switching communication ends with an error but packet\nswitching allows packets to be re-sent.\nMP9 Circuit switching is a simpler process than packet switching.\nQuestion Answer Marks",
      "source_pages": [
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p07.png",
        "../answer-assets/9618_s23_ms_32-p08.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q08",
      "question_id": "9618-2023-mj-32-q08",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 8,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark per mark point (Max 2) 2\nMP1 Pipelining allows several instructions to be processed simultaneously\n/ concurrently.\nMP2 … therefore, increasing the CPU instruction throughput / the number\nof instructions completed per unit of time.\nMP3 Each instruction stage / subtask is completed during one clock cycle\nMP4 No two instructions can execute their same stage of instruction /\nsubtask at the same clock cycle.\nMP5 … e.g., while one instruction is being decoded, the next instruction\ncan be fetched, etc.\n© UCLES 2023 Page 8 of 12\n\n8(b) One mark per mark point (Max 4)\n First stage of first instruction in first clock cycle\n First instruction successfully completed over five clock cycles\n Remaining instructions completed over ten clock cycles …\n … with no extra instruction sections added on any row.\nExample answer 1\nClock cycles\n© UCLES 2023 Page 9 of 12\nsegats\nrossecorP\n1 2 3 4 5 6 7 8 9 10 11 12\nIF 1.1 2.1 3.1 4.1 5.1 6.1\nID 1.2 2.2 3.2 4.2 5.2 6.2\nOF 1.3 2.3 3.3 4.3 5.3 6.3\nIE 1.4 2.4 3.4 4.4 5.4 6.4\nWB 1.5 2.5 3.5 4.5 5.5 6.5\nExample answer 2\nClock cycles\nsegats\nrossecorP\n4\n1 2 3 4 5 6 7 8 9 10 11 12\nIF A B C D E F\nID A B C D E F\nOF A B C D E F\nIE A B C D E F\nWB A B C D E F\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p08.png",
        "../answer-assets/9618_s23_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q09",
      "question_id": "9618-2023-mj-32-q09",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 9,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark for every two correct products (Max 3) 3\n(Z =) ABCD + ABCD + ABCD + ABCD + ABCD + ABCD\n\n9(b) Two marks if no errors present 2\nOne mark if one error present\n\n9(c) One mark for each correct loop (Max 2) 2\n\n9(d) One mark for each mark point (Max 2) 2\n Any correct Boolean term\n Boolean terms and operator correct and no other terms present\n(Z =) AB + AC\n\n9(e) One mark for simplest form (Max 1) 1\n(Z =) A (B + C)\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p09.png",
        "../answer-assets/9618_s23_ms_32-p10.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q10",
      "question_id": "9618-2023-mj-32-q10",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 10,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark from: 1\nSupervised (learning)\nUnsupervised (learning)\nReinforcement (learning)\nDeep (learning)\n© UCLES 2023 Page 10 of 12\n\n10(b) One mark for each correct calculation as follows (Max 2): 5\n Node B (from Begin) (Line 3 in table)\n Node C (from Begin) (Line 4 in table)\n Node D (from Begin) (Line 5 in table)\nOne mark for each correct calculation as follows (Max 2):\n Node G (from C) (Line 6 in table)\n Node F and Node End (from G) (Lines 7 and 8 in table)\n Node End (from F) (Line 9 in table)\nOne mark for correct path (Max 1):\n Begin  C  G  F  End\nCost from\nStart Destination Heuristic Total\nstart node\nnode node (h) (f = g + h)\n(g)\nBegin Begin 0 12 12\nBegin A 5 8 13\nBegin B 6 7 13\nBegin C 5 7 12\nBegin D 4 11 15\nC G 5 + 2 = 7 5 12\nG F 5 + 2 + 4 = 11 1 12\nG End 5 + 2 + 7 = 14 0 14\n5 + 2 + 4 + 1 =\nF End 0 12\n12\nFinal Path Begin  C  G  F  End\n© UCLES 2023 Page 11 of 12",
      "source_pages": [
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p10.png",
        "../answer-assets/9618_s23_ms_32-p11.png"
      ]
    },
    {
      "id": "9618-2023-mj-32-q11",
      "question_id": "9618-2023-mj-32-q11",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 11,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "11(a)(i) One mark for every two correct identifiers (Max 2) 2\nIdentifier Data type Description\nQueue STRING An array to store the contents of the queue.\nRearPointer INTEGER Points to the last term of the queue.\nLength INTEGER Indicates the number of items in the queue.\nFrontPointer INTEGER Points to the first term of the queue.\n\n11(a)(ii) One mark for each correctly completed line (Max 5) 5\nCONSTANT MaxLength = 50\nDECLARE FrontPointer : INTEGER\nDECLARE RearPointer : INTEGER\nDECLARE Length : INTEGER\nDECLARE Queue : ARRAY[0:MaxLength – 1] OF STRING\n// Initialisation of queue\nPROCEDURE Initialise\nFrontPointer  -1\nRearPointer  -1\nLength  0\nENDPROCEDURE\n// Adding a new item to the queue\nPROCEDURE Enqueue(NewItem : STRING)\nIF Length < MaxLength THEN // IF Length <= MaxLength -\n1 THEN\nRearPointer  RearPointer + 1\nIF RearPointer > MaxLength – 1 THEN\nRearPointer  0\nENDIF\nQueue[RearPointer]  NewItem\nLength  Length + 1\nENDIF\nENDPROCEDURE\n\n11(b) One mark per mark point (Max 3) 3\n Print jobs are expected to be actioned by the printer in the order they are\nreceived\n … because the printer queue is a queue, the first job to be sent to the\nprinter would be the first job printed.\n If the printer queue was on a stack, the first job the printer received would\nnot be printed until all the other jobs have been printed.\n© UCLES 2023 Page 12 of 12",
      "source_pages": [
        12
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_32-p12.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q01",
      "question_id": "9618-2023-mj-33-q01",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point (Max 4) 4\n conversion of 113.75 to binary seen 1110001.11\n exponent for normalisation 7 converted to binary 111 // evidence of binary\npoint moved 7 places // evidence of finding exponent = 7\n system 1 answer\n system 2 answer showing correct version from system 1\nSystem 1 Mantissa Exponent\n0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1\nSystem 2 Mantissa Exponent\n0 1 1 1 0 0 0 1 0 0 0 0 0 1 1 1\n\n1(b) One mark per mark point (Max 2) 2\n the mantissa in system 2 does not have enough bits to store the whole\nbinary number // 10 bits required and only 8 bits available\n so precision is lost / the number is truncated\nQuestion Answer Marks",
      "source_pages": [
        3
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p03.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q02",
      "question_id": "9618-2023-mj-33-q02",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 2,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark for each correct line connecting a machine learning technique to its 4\nmost appropriate description (Max 4).\nMachine learning category Description\nsimulates the data processing\ncapabilities of the human brain to\nmake decisions\nSupervised\nlearning\nenables learning by mapping an input\nto an output based on example input-\nReinforcement output pairs\nlearning\nenables information related to errors\nproduced by the neural network to be\ntransmitted\nDeep learning\nenables learning in an interactive\nenvironment by trial and error using\nits own experiences\nUnsupervised\nlearning\nenables learning by allowing the\nprocess to discover patterns on its\nown that were previously undetected\n© UCLES 2023 Page 3 of 10\n\n2(b) One mark per mark point (Max 2) 2\n to find the optimal / shortest / most cost-effective route\n … between two nodes in a\n … based on distance / cost / time.\nQuestion Answer Marks",
      "source_pages": [
        3,
        4
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p03.png",
        "../answer-assets/9618_s23_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q03",
      "question_id": "9618-2023-mj-33-q03",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 3,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark for each correct hash value (Max 2) 2\nRecord key Hash value\n1030 1\n1050 0\n1025 2\n\n3(b) One mark per mark point (Max 4) 4\nMP1 A collision occurs when the record key doesn’t match the stored record\nkey\nMP2 … this means the determined storage location has already been used\nfor another record.\nIf the record is to be stored\nMP3 Search the file linearly\nMP4 … to find the next available storage space (closed hash)\nMP5 Search the overflow area linearly\nMP6 … to find next available storage space (open hash)\nIf the record is to be found\nMP7 … search the overflow area linearly (open hash) until the matching\nrecord key is found\nMP8 … search linearly from where you are (closed hash) until the matching\nrecord key is found\nMP9 If not found record is not in file\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q04",
      "question_id": "9618-2023-mj-33-q04",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 4,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark per mark point (Max 2) 2\n TYPE Prime\n = (2, 3, 5, 7, 11, 13, 17, 19)\nExample answer\nTYPE Prime = (2, 3, 5, 7, 11, 13, 17, 19)\n\n4(b) One mark per mark point (Max 2) 2\n TYPE TDayPointer\n = ^STRING //^DayOfWeek\nExample answer\nTYPE TDayPointer = ^STRING // ^DayOfWeek\n© UCLES 2023 Page 4 of 10",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q05",
      "question_id": "9618-2023-mj-33-q05",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 5,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark per mark point (Max 2) 2\n Circuit switching is used where a dedicated path needs to be sustained\nthroughout the call / communication // where the whole bandwidth is\nrequired // where a real time communication is used.\n A typical application is standard voice communications / video streaming /\nprivate data networks\n\n5(b) One mark per benefit (Max 2) 4\nMP1 Whole of bandwidth is available\nMP2 Dedicated communication channel increases the quality of transmission\nMP3 Data is transmitted with a fixed data rate\nMP4 No waiting time at switches\nMP5 Suitable for long continuous communication\nMP6 Fast method of data transfer\nMP7 Data arrives in the same order as it was sent\nMP8 Data can’t get lost\nMP9 Data all follows the same path / route\nMP10 Better for real-time\nMP11 Simple method of data transfer.\nOne mark per drawback (Max 2)\nMP1 A dedicated connection makes it impossible to transmit other data even\nif the channel is free\nMP2 Not very flexible\nMP3 No alternative route in case of failure\nMP4 The time required to establish the physical link between the two stations\ncan be too long\nMP5 The need to establish a dedicated path for each connection can have\ncost implications\nMP6 Dedicated channels require the whole bandwidth / bandwidth can’t be\nshared\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p05.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q06",
      "question_id": "9618-2023-mj-33-q06",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 6,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark per correct valid/invalid and reason combination (Max 3) 3\nDPAD99$ – Valid\nReason – 4/multiple letters followed by 2/multiple digits followed by a symbol.\nDAD#95 – Invalid\nReason – The symbol comes before the digits – it should be after.\nADY123? – Invalid\nReason – The ? is not a valid symbol.\n\n6(b) <symbol> ::= $ | % | & | @ | # 1\n<letter> ::= A | D | P | R | Y\n© UCLES 2023 Page 5 of 10\n\n6(c) One mark per mark point (Max 4) 4\n begins with a letter\n letter can repeat and digit present\n digit can repeat or can be bypassed\n correct structure – name, boxes and arrows (in and out).\nExample answers:\nidentifier\nletter digit\nidentifier\nletter letter digit\nQuestion Answer Marks",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p05.png",
        "../answer-assets/9618_s23_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q07",
      "question_id": "9618-2023-mj-33-q07",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "7(a) Two marks if no errors present 2\nOne mark if one error present\n\n7(b) One mark for each correct loop (Max 2) 2\n© UCLES 2023 Page 6 of 10\n\n7(c) One mark for each mark point (Max 2) 2\n Any correct Boolean term\n Boolean terms and operator correct and no other terms present\n(Z =) AC + BC\n\n7(d) One mark for simplest form (Max 1) 1\n(Z =) C (A + B)\nQuestion Answer Marks",
      "source_pages": [
        6,
        7
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p06.png",
        "../answer-assets/9618_s23_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q08",
      "question_id": "9618-2023-mj-33-q08",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 8,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "8 One mark per mark point (Max 3) 3\nMP1 A large number of computer processors / separate computers\nconnected together\nMP2 … simultaneously performing a set of coordinated computations //\ncollaborative processing\nMP3 network infrastructure\nMP4 communicate using a message interface / by sending messages.\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q09",
      "question_id": "9618-2023-mj-33-q09",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 9,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark per mark point (Max 2) 2\nMP1 To provide better security\nMP2 … by using two different keys / a public key and a private key\nMP3 One of the keys is used to encrypt the message\nMP4 … the matching key is used to decrypt the message.\n\n9(b) One mark per benefit (Max 2) 4\nMP1 Provides security based on laws of physics rather than mathematical\nalgorithms, so more secure.\nMP2 To protect the security of data transmitted over fibre optic cables.\nMP3 Virtually unhackable.\nMP4 The performance of quantum cryptography is continuously improved,\nmaking it suitable for most valuable government/industrial secrets.\nMP5 Longer keys can be used\nMP6 Eavesdropping can be detected\nOne mark per drawback (Max 2)\nMP1 Lacks many vital features such as digital signature, certified mail, etc.\nMP2 High cost of purchasing / maintaining equipment required.\nMP3 Currently only works over relatively short distances.\nMP4 Error rates are relatively high as technology is still being developed.\nMP5 Polarisation of light can change during transmission.\nMP6 Allows criminals and terrorists to hide their communications.\n© UCLES 2023 Page 7 of 10",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q10",
      "question_id": "9618-2023-mj-33-q10",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 10,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "10 One mark for each correctly completed line (Max 5) 5\nDECLARE Account : STRING\nOPENFILE \"ActiveFile.txt\" FOR READ\nOPENFILE \"ArchiveFile.txt\" FOR WRITE\nWHILE NOT EOF(\"ActiveFile.txt\")\nREADFILE \"ActiveFile.txt\", Account\nIF Account = \"\" THEN\nWRITEFILE \"ArchiveFile.txt\", \"Account not present\"\nELSE\nWRITEFILE \"ArchiveFile.txt\", Account\nENDIF\nENDWHILE\nCLOSEFILE \"ActiveFile.txt\"\nCLOSEFILE \"ArchiveFile.txt\"\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p08.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q11",
      "question_id": "9618-2023-mj-33-q11",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 11,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 11,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark per mark point (Max 3) 3\n correctly defined constant\n correctly defined array\n three correctly defined integers\nCONSTANT MaxSize = 60\nDECLARE Queue : ARRAY[1:60] OF STRING // DECLARE Queue :\nARRAY[0:59] OF STRING // DECLARE Queue : ARRAY[1:MaxSize]\nOF STRING // DECLARE Queue : ARRAY[0:MaxSize - 1] OF\nSTRING\nDECLARE FrontPointer : INTEGER\nDECLARE RearPointer : INTEGER\nDECLARE Length : INTEGER\n© UCLES 2023 Page 8 of 10\n\n11(b) One mark for each correctly completed line (Max 4) 4\nFUNCTION Dequeue RETURNS STRING\nDECLARE Item : STRING\nIF Length > 0 THEN\nItem  Queue[FrontPointer]\nFrontPointer  FrontPointer + 1\nLength  Length – 1\nIF Length = 0 THEN\nCALL Initialise // procedure to reset the\npointers\nELSE\nIF FrontPointer > MaxSize THEN\nFrontPointer  1\nENDIF\nENDIF\nELSE\nOUTPUT \"The print queue was empty – error\"\nItem  \"\"\nENDIF\nRETURN Item\nENDFUNCTION\n\n11(c) One mark per mark point (Max 4) 4\nMP1 (Two stacks are required) so that the second stack can reverse the\norder of the first stack.\nMP2 Stack 1 operates as the queue with the newest elements at the bottom.\nStack 2 is empty.\nMP3 To add an element, pop all the elements from stack 1 and push onto\nstack 2.\nMP4 Push the new element onto either stack.\nMP5 Pop all the elements of stack 2 back onto stack 1.\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p08.png",
        "../answer-assets/9618_s23_ms_33-p09.png"
      ]
    },
    {
      "id": "9618-2023-mj-33-q12",
      "question_id": "9618-2023-mj-33-q12",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 12,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "12(a) One mark per mark point (Max 2) 2\n A process using a function or procedure defined in terms of itself / calls\nitself.\n A recursive process must have a base case (which is a way to return\nwithout making a recursive call) // terminating solution // concept of\nunwinding described\n There must (also) be a general case where the recursive call takes place.\n© UCLES 2023 Page 9 of 10\n\n12(b) One mark per mark point (Max 5) 5\n Call number column correct\n Function call and Number columns correct\n Result column down to base case (Winding) rows 1–6 correct\n Result column down from base case (Unwinding) rows 7–10 correct\n Return value column correct\nCall Function call Number Result Return\nnumber value\n1 Fib(5) 5 Fib(4) + Fib(3)\n2 Fib(4) 4 Fib(3) + Fib(2)\n3 Fib(3) 3 Fib(2) + Fib(1)\n4 Fib(2) 2 Fib(1) + Fib(0)\n5 Fib(1) 1 1 1\n6 Fib(0) 0 0 0\n(4) Fib(2) 2 1 + 0 1\n(3) Fib(3) 3 1 + 1 2\n(2) Fib(4) 4 2 + 1 3\n(1) Fib(5) 5 3 + 2 5\n© UCLES 2023 Page 10 of 10",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_33-p09.png",
        "../answer-assets/9618_s23_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2023-mj-41-q01",
      "question_id": "9618-2023-mj-41-q01",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 18,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) 1 mark for 1\n 1D array with name DataArray (with 25 elements of type Integer)\nExample program code:\nJava\npublic static Integer[] DataArray = new Integer[25];\nVB.NET\nDim DataArray(24) As Integer\nPython\nDataArray = [] #25 elements Integer\n© UCLES 2023 Page 4 of 38\n\n1(a)(ii) 1 mark each to max 4 4\n Opening file Data.txt to read\n Looping through all the 25/EOF …\n … reading each line and storing/appending into array\n Exception handling with appropriate output\n Closing the file (in an appropriate place)\nExample program code:\nJava\nInteger Counter = 0;\ntry{\nScanner Scanner1 = new Scanner(new File(\"Data.txt\"));\nwhile(Scanner1.hasNextLine()){\nDataArray[Counter] = Integer.parseInt(Scanner1.next());\nCounter++;\n}\nScanner1.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No data file found\");\n}\nVB.NET\ntry\nDim DataReader As New System.IO.StreamReader(\"Data.txt\")\nDim X As Integer = 0\nDo Until DataReader.EndOfStream\nDataArray(X) = DataReader.ReadLine()\nX = X + 1\nLoop\nDataReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\n© UCLES 2023 Page 5 of 38\n\n1(a)(ii) Python\ntry:\nDataFile = open(\"Data.txt\",'r')\nfor Line in DataFile:\nDataArray.append(int(Line))\nDataFile.close()\nexcept IOError:\nprint(\"Could not find file\")\n© UCLES 2023 Page 6 of 38\n\n1(b)(i) 1 mark each 3\n Procedure header (and close where appropriate) with (at least) one (integer array) parameter\n Outputting all (25) array elements …\n …on one line\nExample program code:\nJava\npublic static void PrintArray(Integer[] DataArray){\nString OutputData;\nfor(Integer X = 0; X < DataArray.length - 1; X++){\nOutputData = OutputData + DataArray[X] + \" \";\n}\nSystem.out.print(OutputData);\n}\nVB.NET\nSub PrintArray(DataArray)\nDim OutputData As String = \"\";\nFor x = 0 To DataArray.length - 1\nOutputData = OutputData & DataArray(x) & \" \"\nNext\nConsole.WriteLine(OutputData)\nEnd Sub\nPython\ndef PrintArray(DataArray):\noutput = \"\"\nfor X in range(0, len(DataArray)):\noutput = output + str((DataArray[X])) + \" \"\nprint(output)\n© UCLES 2023 Page 7 of 38\n\n1(b)(ii) 1 mark for calling PrintArray with the array as a parameter 1\nExample program code:\nJava\nPrintArray(DataArray);\nVB.NET\nPrintArray(DataArray)\nPython\nPrintArray(DataArray)\n\n1(b)(iii) 1 mark for screenshot 1\ne.g.\n© UCLES 2023 Page 8 of 38\n\n1(c) 1 mark each 3\n Function header (and close where appropriate) taking array and search value as parameters\n Looping through each array element and keeping count of the number of times the parameter appears\n Returning the calculated count value\nExample program code:\nJava\npublic static Integer LinearSearch(Integer[] DataArray, Integer DataToFind){\nInteger Count = 0;\nfor(Integer x = 0; x < DataArray.length - 1; x++){\nif(DataArray[x] == DataToFind){\nCount++;\n}\n}\nreturn Count;\n}\nVB.NET\nFunction LinearSearch(DataArray, DataToFind)\nDim Count As Integer = 0\nFor x = 0 To DataArray.length - 1\nIf DataArray(x) = DataToFind Then\nCount = Count + 1\nEnd If\nNext\nReturn Count\nEnd Function\nPython\ndef LinearSearch(DataArray, DataToFind):\nCount = 0\nfor X in range(0, len(DataArray)):\nif(DataArray[X] == DataToFind):\nCount +=1\nreturn Count\n© UCLES 2023 Page 9 of 38\n\n1(d)(i) 1 mark each 4\n Prompt and reading input …\n …with validation for whole number between 0 and 100 inclusive\n Calling LinearSearch() with array and valid data input and storing/using return value\n Output of the message with return value\nExample program code:\nJava\nSystem.out.println(\"Enter a number to find\");\nInteger DataToFind = -1;\nScanner NewScanner = new Scanner(System.in);\nwhile(DataToFind < 0 || DataToFind > 100){\nDataToFind = Integer.parseInt(NewScanner.nextLine());\n}\nInteger NumberTimes = LinearSearch(DataArray, DataToFind);\nSystem.out.println(\"The number \" + DataToFind + \" is found \" + NumberTimes + \" times\");\nVB.NET\nConsole.WriteLine(\"Enter a number to find \")\nDim DataToFind As Integer = -1\nDo Until DataToFind >= 0 And DataToFind <= 100\nDataToFind = Console.ReadLine()\nLoop\nDim NumberTimes = LinearSearch(DataArray, DataToFind)\nConsole.WriteLine(\"The number \" & DataToFind & \" is found \" & NumberTimes & \" times.\")\nPython\nDataToFind = int(input(\"Enter a number to find \"))\nwhile DataToFind < 0 or DataToFind > 100:\nDataToFind = int(input(\"Enter a number to find \"))\nNumberTimes = LinearSearch(DataArray, DataToFind)\nprint(\"The number\", DataToFind, \"is found\", NumberTimes, \"times\")\n© UCLES 2023 Page 10 of 38\n\n1(d)(ii) 1 mark for screenshot e.g. 1\n© UCLES 2023 Page 11 of 38",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_41-p04.png",
        "../answer-assets/9618_s23_ms_41-p05.png",
        "../answer-assets/9618_s23_ms_41-p06.png",
        "../answer-assets/9618_s23_ms_41-p07.png",
        "../answer-assets/9618_s23_ms_41-p08.png",
        "../answer-assets/9618_s23_ms_41-p09.png",
        "../answer-assets/9618_s23_ms_41-p10.png",
        "../answer-assets/9618_s23_ms_41-p11.png"
      ]
    },
    {
      "id": "9618-2023-mj-41-q02",
      "question_id": "9618-2023-mj-41-q02",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 32,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) 1 mark each 5\n Class header (and close where appropriate)\n 5 (private) attribute declarations including data types\n Constructor header (and close where appropriate) taking 3 parameters (min)\n Assigning ID, MaxSpeed and IncreaseAmount to parameters\n Assigning CurrentSpeed and HorizontalPosition to 0\nExample program code:\nVB.NET\nClass Vehicle\nPrivate ID As String\nPrivate MaxSpeed As Integer\nPrivate CurrentSpeed As Integer\nPrivate IncreaseAmount As Integer\nPrivate HorizontalPosition As Integer\nSub New(IDP, MaxSpeedP, IncreaseAmountP)\nID = IDP\nMaxSpeed = MaxSpeedP\nCurrentSpeed = 0\nIncreaseAmount = IncreaseAmountP\nHorizontalPosition = 0\nEnd Sub\nEnd Class\nJava\nclass Vehicle{\nprivate String ID;\nprivate Integer MaxSpeed;\nprivate Integer CurrentSpeed;\nprivate Integer IncreaseAmount;\nprivate Integer HorizontalPosition;\n© UCLES 2023 Page 12 of 38\n\n2(a)(i) public Vehicle(String IDP, Integer MaxSpeedP, Integer IncreaseAmountP){\nID = IDP;\nMaxSpeed = MaxSpeedP;\nIncreaseAmount = IncreaseAmountP;\nCurrentSpeed = 0;\nHorizontalPosition = 0;\n}}\nPython\nclass Vehicle:\n#self.__ID string\n#self.__MaxSpeed integer\n#self.__CurrentSpeed integer\n#self.__IncreaseAmount integer\n#self.__HorizontalPosition\ndef __init__(self, IDP, MaxSpeedP, IncreaseAmountP):\nself.__ID = IDP\nself.__MaxSpeed = MaxSpeedP\nself.__IncreaseAmount = IncreaseAmountP\nself.__CurrentSpeed = 0\nself.__HorizontalPosition = 0\n© UCLES 2023 Page 13 of 38\n\n2(a)(ii) 1 mark each 3\n 1 get function header (and end where appropriate) with no parameter …\n …returning attribute (without overwriting)\n 3 further correct get methods\nExample program code:\nVB.NET\nFunction GetCurrentSpeed()\nReturn CurrentSpeed\nEnd Function\nFunction GetIncreaseAmount()\nReturn IncreaseAmount\nEnd Function\nFunction GetHorizontalPosition()\nReturn HorizontalPosition\nEnd Function\nFunction GetMaxSpeed()\nReturn MaxSpeed\nEnd Function\nJava\npublic Integer GetCurrentSpeed(){\nreturn CurrentSpeed;\n}\npublic Integer GetIncreaseAmount(){\nreturn IncreaseAmount;\n}\npublic Integer GetHorizontalPosition(){\nreturn HorizontalPosition;\n}\npublic Integer GetMaxSpeed(){\nreturn MaxSpeed;\n}\n© UCLES 2023 Page 14 of 38\n\n2(a)(ii) Python\ndef GetCurrentSpeed(self):\nreturn self.__CurrentSpeed\ndef GetIncreaseAmount(self):\nreturn self.__IncreaseAmount\ndef GetHorizontalPosition(self):\nreturn self.__HorizontalPosition\ndef GetMaxSpeed(self):\nreturn self.__MaxSpeed\n© UCLES 2023 Page 15 of 38\n\n2(a)(iii) 1 mark each 3\n 1 set procedure (and end where appropriate) taking parameter …\n … assigns parameter to the attribute (without overriding)\n Second correct set method\nExample program code:\nVB.NET\nSub SetCurrentSpeed(CSp)\nCurrentSpeed = CSp\nEnd Sub\nSub SetHorizontalPosition(HPP)\nHorizontalPosition = HPP\nEnd Sub\nJava\npublic void SetCurrentSpeed(Integer CSP){\nCurrentSpeed = CSP;\n}\npublic void SetHorizontalPosition(Integer HPP){\nHorizontalPosition = HPP;\n}\nPython\ndef SetCurrentSpeed(self, CSP):\nself.__CurrentSpeed = CSP\ndef SetHorizontalPosition(self, HPP):\nself.__HorizontalPosition = HPP\n© UCLES 2023 Page 16 of 38\n\n2(a)(iv) 1 mark each 3\n Method header (and close where appropriate) with no parameter and adding IncreaseAmount to CurrentSpeed\n Checking if MaxSpeed is exceeded and limiting to max speed (remove increase or assign maximum)\n Adding updated CurrentSpeed to HorizontalPosition in all cases (whether MaxSpeed is exceeded or not)\nExample program code:\nVB.NET\nSub IncreaseSpeed()\nCurrentSpeed = CurrentSpeed + IncreaseAmount\nIf CurrentSpeed > MaxSpeed Then\nCurrentSpeed = MaxSpeed\nEnd If\nHorizontalPosition = HorizontalPosition + CurrentSpeed\nEnd Sub\nJava\npublic void IncreaseSpeed(){\nCurrentSpeed = CurrentSpeed + IncreaseAmount;\nif(CurrentSpeed > MaxSpeed){\nCurrentSpeed = MaxSpeed;\n}\nHorizontalPosition = HorizontalPosition + CurrentSpeed;\n}\nPython\ndef IncreaseSpeed(self):\nself.__CurrentSpeed = self.__CurrentSpeed + self.__IncreaseAmount\nif(self.__CurrentSpeed > self.__MaxSpeed):\nself.__CurrentSpeed = self.__MaxSpeed\nself.__HorizontalPosition = self.__HorizontalPosition + self.__CurrentSpeed\n© UCLES 2023 Page 17 of 38\n\n2(b)(i) 1 mark each 5\n Class header (and end where appropriate) inheriting from Vehicle\n 3 (private) attribute declarations with data types\n Constructor (and end where appropriate) with (min) 5 parameters\n Calling parent constructor with appropriate parameters\n Initialising VerticalPosition to 0 and VerticalChange and MaxHeight to attributes\nExample program code:\nVB.NET\nClass Helicopter\nInherits Vehicle\nPrivate VerticalPosition As Integer\nPrivate VerticalChange As Integer\nPrivate MaxHeight As Integer\nSub New(IDP, MaxSpeedP, IncreaseAmountP, VertChangeP, MaxHeightP)\nMyBase.New(IDP, MaxSpeedP, IncreaseAmountP)\nVerticalPosition = 0\nVerticalChange = VertChangeP\nMaxHeight = MaxHeightP\nEnd Sub\nEnd Class\nJava\nclass Helicopter extends Vehicle{\nprivate Integer VerticalPosition;\nprivate Integer VerticalChange;\nprivate Integer MaxHeight;\npublic Helicopter(String IDP, Integer MaxSpeedP, Integer IncreaseAmountP, Integer\nVertChangeP, Integer MaxHeightP){\n© UCLES 2023 Page 18 of 38\n\n2(b)(i) super(IDP, MaxSpeedP, IncreaseAmountP);\nVerticalPosition = 0;\nVerticalChange = VertChangeP;\nMaxHeight = MaxHeightP;\n}}\nPython\nclass Helicopter(Vehicle):\n#VerticalPosition Integer\n#VerticalChange Integer\n#MaxHeight Integer\ndef __init__(self, IDP, MaxSpeedP, IncreaseAmountP, VertChangeP, MaxHeightP):\nVehicle.__init__(self,IDP, MaxSpeedP, IncreaseAmountP)\nself.__VerticalPosition = 0\nself.__VerticalChange = VertChangeP\nself.__MaxHeight = MaxHeightP\n© UCLES 2023 Page 19 of 38\n\n2(b)(ii) 1 mark each to max 4 4\n Method header (overriding where required) with no parameter\n Adding vertical change to vertical position …\n …limiting to maximum height\n Repeating/calling/using the code from original for horizontal increase (in every case)\nExample program code:\nVB.NET\nOverrides Sub IncreaseSpeed()\nVerticalPosition = VerticalPosition + VerticalChange\nIf VerticalPosition > MaxHeight Then\nVerticalPosition = MaxHeight\nEnd If\nMe.SetCurrentSpeed(GetCurrentSpeed() + GetIncreaseAmount())\nIf Me.GetCurrentSpeed() > Me.GetMaxSpeed() Then\nMe.SetCurrentSpeed(Me.GetMaxSpeed())\nEnd If\nMe.SetHorizontalPosition(Me.GetHorizontalPosition() + Me.GetCurrentSpeed())\nEnd Sub\nJava\npublic void IncreaseSpeed(){\nVerticalPosition = VerticalPosition + VerticalChange;\nif(VerticalPosition > MaxHeight){\nVerticalPosition = MaxHeight;\n}\nsuper.SetCurrentSpeed(super.GetCurrentSpeed() + super.GetIncreaseAmount());\nif(super.GetCurrentSpeed() > super.GetMaxSpeed()){\nsuper.SetCurrentSpeed(super.GetMaxSpeed());\n}\nsuper.SetHorizontalPosition(super.GetHorizontalPosition() + super.GetCurrentSpeed());\n}\n© UCLES 2023 Page 20 of 38\n\n2(b)(ii) Python\ndef IncreaseSpeed(self):\nself.__VerticalPosition = self.__VerticalPosition + self.__VerticalChange\nif(self.__VerticalPosition > self.__MaxHeight):\nself.__VerticalPosition = MaxHeight\nVehicle.SetCurrentSpeed(self, Vehicle.GetCurrentSpeed(self) +\nVehicle.GetIncreaseAmount(self))\nif(Vehicle.GetCurrentSpeed(self) > Vehicle.GetMaxSpeed(self)):\nVehicle.SetCurrentSpeed(self, Vehicle.GetMaxSpeed(self));\nVehicle.SetHorizontalPosition(self, Vehicle.GetHorizontalPosition(self) +\nVehicle.GetCurrentSpeed(self))\n© UCLES 2023 Page 21 of 38\n\n2(c) 1 mark each to max 3 3\n Suitable method/procedure heading (and end where appropriate) and outputting horizontal position and current speed\nin an appropriate message\n Checking if object is a Vehicle or Helicopter // overriding methods in each class for output // one method in each class\n// try except …\n …outputting vertical position only if helicopter with appropriate message\nExample program code:\nVB.NET\nSub OutputCurrentPosition(ObjectToOutput)\nConsole.WriteLine(\"Current position = \" & ObjectToOutput.GetHorizontalPosition())\nConsole.WriteLine(\"Current speed = \" & ObjectToOutput.GetCurrentSpeed())\nIf TypeOf ObjectToOutput Is Helicopter Then\nConsole.WriteLine(\"Current vertical position = \" &\nObjectToOutput.GetVerticalPosition())\nEnd If\nEnd Sub\nJava\npublic void OutputCurrentPosition(){\nSystem.out.println(\"Current position = \" + HorizontalPosition);\nSystem.out.println(\"Current speed = \" + CurrentSpeed);\n}\npublic void OutputCurrentPosition(){\nSystem.out.println(\"Current position = \" +super.GetHorizontalPosition());\nSystem.out.println(\"Current speed = \" + super.GetCurrentSpeed());\nSystem.out.println(\"Current vertical position = \" + VerticalPosition);\n}\nPython\ndef OutputCurrentPosition(self):\nprint(\"Current position = \", self.__HorizontalPosition)\nprint(\"Current speed = \", self.__CurrentSpeed)\n© UCLES 2023 Page 22 of 38\n\n2(c) def OutputCurrentPosition(self):\nprint(\"Current position = \", Vehicle.GetHorizontalPosition(self))\nprint(\"Current speed = \", Vehicle.GetCurrentSpeed(self))\nprint(\"Current verticalposition = \", self.__VerticalPosition)\n© UCLES 2023 Page 23 of 38\n\n2(d)(i) 1 mark each 5\n Instantiating an object of type Vehicle with correct parameters (\"Tiger\", 100, 20)\n Instantiating an object of type Helicopter with correct parameters (\"Lion\", 350, 40, 3, 100)\n Calling IncreaseSpeed() twice for the car\n Calling IncreaseSpeed() twice for the helicopter\n Calling the output for both objects\nExample program code:\nVB.NET\nSub Main()\nDim Car As Vehicle\nCar = New Vehicle(\"Tiger\", 100, 20)\nDim Heli1 As Helicopter\nHeli1 = New Helicopter(\"Lion\", 350, 40, 3, 100)\nCar.IncreaseSpeed()\nCar.IncreaseSpeed()\nOutputCurrentPosition(Car)\nConsole.WriteLine(\"\")\nHeli1.IncreaseSpeed()\nHeli1.IncreaseSpeed()\nOutputCurrentPosition(Heli1)\nEnd Sub\nJava\npublic static void main(String args[]){\nVehicle Car = new Vehicle(\"Tiger\", 100, 20);\nHelicopter Heli1 = new Helicopter(\"Lion\", 350, 40, 3, 100);\nCar.IncreaseSpeed();\nCar.IncreaseSpeed();\nCar.OutputCurrentPosition();\nSystem.out.println(\"\");\nHeli1.IncreaseSpeed();\nHeli1.IncreaseSpeed();\nHeli1.OutputCurrentPosition();\n}\n© UCLES 2023 Page 24 of 38\n\n2(d)(i) Python\n#main\nCar = Vehicle(\"Tiger\", 100, 20)\nHeli1 = Helicopter(\"Lion\", 350, 40, 3, 100)\nCar.IncreaseSpeed()\nCar.IncreaseSpeed()\nCar.OutputCurrentPosition()\nprint(\"\")\nHeli1.IncreaseSpeed()\nHeli1.IncreaseSpeed()\nHeli1.OutputCurrentPosition()\n\n2(d)(ii) Screenshot of results e.g. 1\n© UCLES 2023 Page 25 of 38",
      "source_pages": [
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23,
        24,
        25
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_41-p12.png",
        "../answer-assets/9618_s23_ms_41-p13.png",
        "../answer-assets/9618_s23_ms_41-p14.png",
        "../answer-assets/9618_s23_ms_41-p15.png",
        "../answer-assets/9618_s23_ms_41-p16.png",
        "../answer-assets/9618_s23_ms_41-p17.png",
        "../answer-assets/9618_s23_ms_41-p18.png",
        "../answer-assets/9618_s23_ms_41-p19.png",
        "../answer-assets/9618_s23_ms_41-p20.png",
        "../answer-assets/9618_s23_ms_41-p21.png",
        "../answer-assets/9618_s23_ms_41-p22.png",
        "../answer-assets/9618_s23_ms_41-p23.png",
        "../answer-assets/9618_s23_ms_41-p24.png",
        "../answer-assets/9618_s23_ms_41-p25.png"
      ]
    },
    {
      "id": "9618-2023-mj-41-q03",
      "question_id": "9618-2023-mj-41-q03",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 25,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark each 3\n (Global) Animal array (with 20 string elements)\n (Global) Colour array (with 10 string elements)\n (Global) AnimalTopPointer and ColourTopPointer initialised to 0\nExample program code:\nJava\npublic static String[] Animal = new String[20];\npublic static String[] Colour = new String[10];\npublic static Integer AnimalTopPointer = 0;\npublic static Integer ColourTopPointer = 0;\nVB.NET\nDim Animal(0 to 19) As String\nDim Colour(0 to 9) As String\nDim AnimalTopPointer As Integer = 0\nDim ColourTopPointer As Integer = 0\nPython\nAnimal = [] #20 elements\nColour = [] #10 elements\nglobal AnimalTopPointer\nglobal ColourTopPointer\nAnimalTopPointer = 0\nColourTopPointer = 0\n© UCLES 2023 Page 26 of 38\n\n3(b)(i) 1 mark each 3\n Function header (and close where appropriate) with parameter, checking if full (AnimalTopPointer = 20) and returning\nfalse\n If not full, inserting parameter value into AnimalTopPointer\n …incrementing pointer and returning true\nExample program code:\nJava\npublic static Boolean PushAnimal(String DataToPush){\nif(AnimalTopPointer == 20){\nreturn false;\n}else{\nAnimal[AnimalTopPointer] = DataToPush;\nAnimalTopPointer++;\nreturn true;\n}\n}\nVB.NET\nFunction PushAnimal(DataToPush)\nIf AnimalTopPointer = 20 Then\nReturn False\nElse\nAnimal(AnimalTopPointer) = DataToPush\nAnimalTopPointer = AnimalTopPointer + 1\nReturn True\nEnd If\nEnd Function\nPython\ndef PushAnimal(DataToPush):\nglobal AnimalTopPointer\nglobal ColourTopPointer\nif AnimalTopPointer == 20:\nreturn False\n© UCLES 2023 Page 27 of 38\n\n3(b)(i) else:\nAnimal.append(DataToPush)\nAnimalTopPointer +=1\nreturn True\n\n3(b)(ii) 1 mark each 3\n Procedure header (and end where appropriate) with no parameter, checking if empty (AnimalTopPointer = 0) and\nreturning empty string\n If not empty returning the top data item (AnimalTopPointer-1)\n … and decrementing AnimalTopPointer\nExample program code:\nJava\npublic static String PopAnimal(){\nString ReturnData;\nif(AnimalTopPointer == 0){\nreturn \"\";\n}else{\nReturnData = Animal[AnimalTopPointer - 1];\nAnimalTopPointer--;\nreturn ReturnData;\n}\n}\nVB.NET\nFunction PopAnimal()\nDim ReturnData As String\nIf AnimalTopPointer = 0 Then\nReturn \"\"\nElse\nReturnData = Animal(AnimalTopPointer - 1)\nAnimalTopPointer = AnimalTopPointer - 1\nReturn ReturnData\nEnd If\nEnd Function\n© UCLES 2023 Page 28 of 38\n\n3(b)(ii) Python\ndef PopAnimal():\nglobal AnimalTopPointer\nglobal ColourTopPointer\nif AnimalTopPointer == 0:\nreturn \"\"\nelse:\nReturnData = Animal[AnimalTopPointer - 1]\nAnimalTopPointer -=1\nreturn ReturnData\n© UCLES 2023 Page 29 of 38\n\n3(b)(iii) 1 mark 5\n Procedure header (and close where appropriate) and opening correct file for read\n Looping until end of file // looping until all animal names read in // looping 8 times\n Calling PushAnimal() with each line read from file (for all lines)\n Closing the file\n Exception handling with appropriate error message\nExample program code:\nJava\nprivate static void ReadData(){\ntry{\nScanner Scanner1 = new Scanner(new File(\"AnimalData.txt\"));\nwhile(Scanner1.hasNextLine()){\nPushAnimal(Scanner1.next());\n}\nScanner1.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No Animal file found\");\n}\n}\nVB.NET\nSub ReadData()\ntry\nDim AnimalFile As String = \"AnimalData.txt\"\nDim AnimalFileReader As New System.IO.StreamReader(AnimalFile)\nDo Until AnimalFileReader.EndOfStream\nPushAnimal(AnimalFileReader.ReadLine())\nLoop\nAnimalFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\n© UCLES 2023 Page 30 of 38\n\n3(b)(iii) Python\ndef ReadData():\ntry:\nglobal AnimalTopPointer\nglobal ColourTopPointer\nAnimalFile = open(\"AnimalData.txt\", 'r')\nfor Line in AnimalFile:\nPushAnimal(Line)\nAnimalFile.close()\nexcept IOError:\nprint(\"Could not find file\")\n© UCLES 2023 Page 31 of 38\n\n3(b)(iv) 1 mark each 2\n PushColour function\n PopColour function\nExample program code:\nJava\npublic static Boolean PushColour(String DataToPush){\nif(ColourTopPointer == 10){\nreturn false;\n}else{\nColour[ColourTopPointer] = DataToPush;\nColourTopPointer++;\nreturn true;\n}\n}\npublic static String PopColour(){\nString ReturnData;\nif(ColourTopPointer == 0){\nreturn \"\";\n}else{\nReturnData = Colour[ColourTopPointer - 1];\nColourTopPointer--;\nreturn ReturnData;\n}\n}\nVB.NET\nFunction PushColour(DataToPush)\nIf ColourTopPointer = 10 Then\nReturn False\nElse\nColour(ColourTopPointer) = DataToPush\nColourTopPointer = ColourTopPointer + 1\nReturn True\nEnd If\n© UCLES 2023 Page 32 of 38\n\n3(b)(iv) End Function\nFunction PopColour()\nDim ReturnData As String\nIf ColourTopPointer = 0 Then\nReturn \"\"\nElse\nReturnData = Colour(ColourTopPointer - 1)\nColourTopPointer = ColourTopPointer - 1\nReturn ReturnData\nEnd If\nEnd Function\nPython\ndef PushColour(DataToPush):\nglobal AnimalTopPointer\nglobal ColourTopPointer\nif ColourTopPointer == 10:\nreturn False\nelse:\nColour.append(DataToPush)\nColourTopPointer +=1\nreturn True\ndef PopColour():\nglobal AnimalTopPointer\nglobal ColourTopPointer\nif ColourTopPointer == 0:\nreturn \"\"\nelse:\nReturnData = Colour[ColourTopPointer - 1]\nColourTopPointer -=1\nreturn ReturnData\n© UCLES 2023 Page 33 of 38\n\n3(b)(v) 1 mark each 2\n Opening ColourData.txt to read, reading until EOF, closing file and exception handling\n Using PushColour() to store each item read from the file for all lines\nExample program code:\nJava\nprivate static void ReadData(){\ntry{\nScanner Scanner1 = new Scanner(new File(\"AnimalData.txt\"));\nwhile(Scanner1.hasNextLine()){\nPushAnimal(Scanner1.next());\n}\nScanner1.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No Animal file found\");\n}\ntry{\nScanner Scanner2 = new Scanner(new File(\"ColourData.txt\"));\nwhile(Scanner2.hasNextLine()){\nPushColour(Scanner2.next());\n}\nScanner2.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No Colour file found\");\n}\n}\nVB.NET\nSub ReadData()\ntry\nDim AnimalFile As String = \"AnimalData.txt\"\nDim AnimalFileReader As New System.IO.StreamReader(AnimalFile)\nDo Until AnimalFileReader.EndOfStream\nPushAnimal(AnimalFileReader.ReadLine())\n© UCLES 2023 Page 34 of 38\n\n3(b)(v) Loop\nAnimalFileReader.Close()\nDim ColourFile As String = \"ColourData.txt\"\nDim ColourFileReader As New System.IO.StreamReader(ColourFile)\nDo Until ColourFileReader.EndOfStream\nPushColour(ColourFileReader.ReadLine())\nLoop\nColourFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\nPython\ndef ReadData():\ntry:\nglobal AnimalTopPointer\nglobal ColourTopPointer\nAnimalFile = open(\"AnimalData.txt\", 'r')\nfor Line in AnimalFile:\nPushAnimal(Line)\nAnimalFile.close()\nColourFile = open(\"ColourData.txt\", 'r')\nfor Line in ColourFile:\nPushColour(Line)\nColourFile.close()\nexcept IOError:\nprint(\"Could not find file\")\n© UCLES 2023 Page 35 of 38\n\n3(c) 1 mark each to max 5 5\n Procedure heading (and close where appropriate) and outputting the colour and animal using PopColour() and\nPopAnimal() (only if both are successfully popped)\n Checking if no colour and outputting \"No colour\" …\n ….pushing the removed animal back onto the stack\n Checking if no animal and outputting \"No animal\" …\n …pushing the removed colour back onto the stack\nExample program code:\nJava\npublic static void OutputItem(){\nString ColourReturned = PopColour();\nString AnimalReturned = PopAnimal();\nif(ColourReturned.equals(\"\")){\nSystem.out.println(\"No colour\");\nPushAnimal(AnimalReturned);\n}else{\nif(AnimalReturned.equals(\"\")){\nSystem.out.println(\"No animal\");\nPushColour(ColourReturned);\n}else{\nSystem.out.println(\"A \" + ColourReturned + \" \" + AnimalReturned);\n}\n}\n}\nVB.NET\nSub OutputItem()\nDim ColourReturned As String = PopColour()\nDim Animalreturned As String = PopAnimal()\nIf ColourReturned = \"\" Then\nConsole.WriteLine(\"No colour\")\nPushAnimal(AnimalReturned)\n© UCLES 2023 Page 36 of 38\n\n3(c) Else\nIf Animalreturned = \"\" Then\nConsole.WriteLine(\"No animal\")\nPushColour(ColourReturned)\nElse\nConsole.WriteLine(\"A \" & ColourReturned & \" \" & Animalreturned)\nEnd If\nEnd If\nEnd Sub\nPython\ndef OutputItem():\nglobal AnimalTopPointer\nglobal ColourTopPointer\nColourReturned = PopColour()\nAnimalReturned = PopAnimal()\nif ColourReturned == \"\":\nprint(\"No colour\")\nPushAnimal(AnimalReturned)\nelse:\nif AnimalReturned == \"\":\nprint(\"No animal\")\nPushColour(ColourReturned)\nelse:\nprint(ColourReturned, AnimalReturned)\n© UCLES 2023 Page 37 of 38\n\n3(d)(i) 1 mark for 1\n Calling ReadData() and calling OutputItem() 4 times\nExample program code:\nJava\npublic static void main(String args[]){\nReadData();\nOutputItem();\nOutputItem();\nOutputItem();\nOutputItem();\n}\nVB.NET\nSub Main()\nReadData()\nOutputItem()\nOutputItem()\nOutputItem()\nOutputItem()\nEnd Sub\nPython\nReadData()\nOutputItem()\nOutputItem()\nOutputItem()\nOutputItem()\n\n3(d)(ii) 1 mark for output 1\ne.g.\n© UCLES 2023 Page 38 of 38",
      "source_pages": [
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37,
        38
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_41-p26.png",
        "../answer-assets/9618_s23_ms_41-p27.png",
        "../answer-assets/9618_s23_ms_41-p28.png",
        "../answer-assets/9618_s23_ms_41-p29.png",
        "../answer-assets/9618_s23_ms_41-p30.png",
        "../answer-assets/9618_s23_ms_41-p31.png",
        "../answer-assets/9618_s23_ms_41-p32.png",
        "../answer-assets/9618_s23_ms_41-p33.png",
        "../answer-assets/9618_s23_ms_41-p34.png",
        "../answer-assets/9618_s23_ms_41-p35.png",
        "../answer-assets/9618_s23_ms_41-p36.png",
        "../answer-assets/9618_s23_ms_41-p37.png",
        "../answer-assets/9618_s23_ms_41-p38.png"
      ]
    },
    {
      "id": "9618-2023-mj-42-q01",
      "question_id": "9618-2023-mj-42-q01",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 14,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark each 2\n Global array named Animals\n 10 string elements\nExample Program code:\nJava\npublic static String[] Animals = new String[10];\nVB.NET\nDim Animals(9) As String\nPython\nglobal Animals #array 10 elements string\n© UCLES 2023 Page 4 of 37\n\n1(b) 1 mark each 2\n Storing all 10 items in the array …\n … in the correct order and all in lower case\nExample Program code:\nJava\nAnimals[0] = \"horse\";\nAnimals[1] = \"lion\";\nAnimals[2] = \"rabbit\";\nAnimals[3] = \"mouse\";\nAnimals[4] = \"bird\";\nAnimals[5] = \"deer\";\nAnimals[6] = \"whale\";\nAnimals[7] = \"elephant\";\nAnimals[8] = \"kangaroo\";\nAnimals[9] = \"tiger\";\nVB.NET\nSub Main()\nAnimals(0) = \"horse\"\nAnimals(1) = \"lion\"\nAnimals(2) = \"rabbit\"\nAnimals(3) = \"mouse\"\nAnimals(4) = \"bird\"\nAnimals(5) = \"deer\"\nAnimals(6) = \"whale\"\nAnimals(7) = \"elephant\"\nAnimals(8) = \"kangaroo\"\nAnimals(9) = \"tiger\"\nEnd Sub\n© UCLES 2023 Page 5 of 37\n\n1(b) Python\n#main\nAnimals = []\nAnimals.append(\"horse\")\nAnimals.append(\"lion\")\nAnimals.append(\"rabbit\")\nAnimals.append(\"mouse\")\nAnimals.append(\"bird\")\nAnimals.append(\"deer\")\nAnimals.append(\"whale\")\nAnimals.append(\"elephant\")\nAnimals.append(\"kangaroo\")\nAnimals.append(\"tiger\")\n© UCLES 2023 Page 6 of 37\n\n1(c) 1 mark for each completed statement to MAX 4 6\n\n1 mark each:\n Use of appropriate string functions to access e.g. MID and length\n Remainder of procedure correct and following example\nPseudocode:\nPROCEDURE SortDescending()\nDECLARE ArrayLength : INTEGER\nDECLARE Temp : STRING\nArrayLength  LENGTH(Animals)\nFOR X  0 TO ArrayLength - 1\nFOR Y  0 TO (ArrayLength - X - 1)\nIF MID(Animals[Y], 0, 1) < MID(Animals[Y+1], 0, 1)\nTHEN\nTemp  Animals[Y]\nAnimals[Y]  Animals[Y + 1]\nAnimals[Y + 1]  Temp\nENDIF\nNEXT Y\nNEXT X\nENDPROCEDURE\nExample Program code:\nJava\npublic static void SortDescending(){\nInteger ArrayLength = 10;\nString Temp = \"\";\nfor(Integer X = 0; X < ArrayLength - 1; X++){\nfor(Integer Y = 0; Y < ArrayLength-X-1; Y++){\n© UCLES 2023 Page 7 of 37\n\n1(c) if(Animals[Y].charAt(0) < Animals[Y+1].charAt(0)){\nTemp = Animals[Y];\nAnimals[Y] = Animals[Y+1];\nAnimals[Y+1] = Temp;\n}\n}\n}\n}\nVB.NET\nSub SortDescending()\nDim ArrayLength As Integer = 10\nDim Temp As String = \"\"\nFor X = 0 To ArrayLength - 1\nFor Y = 0 To ArrayLength - X - 2\nIf Left(Animals(Y), 1) < Left(Animals(Y + 1), 1) Then\nTemp = Animals(Y)\nAnimals(Y) = Animals(Y + 1)\nAnimals(Y + 1) = Temp\nEnd If\nNext\nNext\nEnd Sub\nPython\ndef SortDescending():\nArrayLength = 10\nfor X in range(0, ArrayLength-1):\nfor Y in range(0, ArrayLength-X-1):\nif(Animals[Y][0] < Animals[Y+1][0]):\nTemp = Animals[Y]\nAnimals[Y] = Animals[Y + 1]\nAnimals[Y + 1] = Temp\n© UCLES 2023 Page 8 of 37\n\n1(d)(i) 1 mark each 3\n calling the procedure SortDescending()\n looping through all array elements\n outputting each array element on a new line\nExample Program code:\nJava\nSortDescending();\nfor(Integer X = 0; X < 10; X++){\nSystem.out.println(Animals[X]);\n}\nVB.NET\nSortDescending()\nFor X = 0 to 9\nConsole.WriteLine(Animals(X))\nNext X\nPython\nSortDescending()\nfor X in range(0, 10):\nprint(Animals[X])\n© UCLES 2023 Page 9 of 37\n\n1(d)(ii) 1 mark for screenshot e.g. 1\n© UCLES 2023 Page 10 of 37",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_42-p04.png",
        "../answer-assets/9618_s23_ms_42-p05.png",
        "../answer-assets/9618_s23_ms_42-p06.png",
        "../answer-assets/9618_s23_ms_42-p07.png",
        "../answer-assets/9618_s23_ms_42-p08.png",
        "../answer-assets/9618_s23_ms_42-p09.png",
        "../answer-assets/9618_s23_ms_42-p10.png"
      ]
    },
    {
      "id": "9618-2023-mj-42-q02",
      "question_id": "9618-2023-mj-42-q02",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 28,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark each 2\n Record declaration named SaleData // class declaration (and end) named SaleData…\n …SaleID declared as string, Quantity as integer in record\n// if a class then a constructor assigning attributes SaleID and Quantity\nExample Program code:\nJava\nclass SaleData{\nprivate String SaleId;\nprivate Integer Quantity;\npublic SaleData(String SaleIDP, Integer Quantityp){\nSaleId = SaleIDP;\nQuantity = Quantityp;\n}\n}\nVB.NET\nStructure SaleData\nPublic SaleID As String\nPublic Quantity As Integer\nEnd Structure\nPython\nclass SaleData:\ndef __init__(self, SaleIDp, Quantityp):\nself.SaleID = SaleIDp #string\nself.Quantity = Quantityp #integer\n© UCLES 2023 Page 11 of 37\n\n2(b) 1 mark each 4\n Global array CircularQueue of 5 items of type SaleData\n Global variables Head, Tail and NumberOfItems all initialised to 0\n One record declared setting ID to \"\" and Quantity to -1 …\n ...stored in all 5 array elements\nExample Program code:\nJava\npublic static SaleData[] CircularQueue = new SaleData[5];\npublic static Integer NumberOfItems = 0;\npublic static Integer Head = 0;\npublic static Integer Tail = 0;\npublic static void main(String args[]){\nfor(Integer X = 0; X < 5; X++){\nCircularQueue[X] = new SaleData(\"\",-1);\n}}\nVB.NET\nDim CircularQueue(0 To 4) As SaleData\nDim NumberOfItems As Integer\nDim Head As Integer\nDim Tail As Integer\nSub Main()\nNumberOfItems = 0\nHead = 0\nTail = 0\nFor x = 0 To 4\nCircularQueue(x).SaleID = \"\"\nCircularQueue(x).Quantity = -1\nNext\nEnd Sub\n© UCLES 2023 Page 12 of 37\n\n2(b) Python\nCircularQueue = [] #SaleData, 5 items\nglobal NumberOfItems #int\nglobal Head #int\nglobal Tail #int\n#main\nNumberOfItems = 0\nHead = 0\nTail = 0\nfor x in range(0, 5):\nCircularQueue.append((SaleData(\"\",-1)))\n© UCLES 2023 Page 13 of 37\n\n2(c) 1 mark each 6\n Function Enqueue() header (and end) taking one parameter (type SaleData)\n Checks if queue is full …\n … and returns -1\n (otherwise) Inserts parameter to CircularQueue[Tail] …\n … increments Tail and resets to 0 if 5\n Increments number of items and returns 1\nExample Program code:\nJava\npublic static Integer Enqueue(SaleData RecordToAdd){\nif(NumberOfItems == 5){\nreturn -1;\n}else{\nCircularQueue[Tail].SetSaleID(RecordToAdd.GetSaleID());\nCircularQueue[Tail].SetQuantity(RecordToAdd.GetQuantity());\nif(Tail == 4){\nTail = 0;\n}else{\nTail++;\n}\nNumberOfItems++;\nreturn 1;\n}\n}\nVB.NET\nFunction Enqueue(RecordToAdd)\nIf (NumberOfItems = 5) Then\nReturn -1\nElse\nCircularQueue(Tail) = RecordToAdd\nIf (Tail = 4) Then\nTail = 0\n© UCLES 2023 Page 14 of 37\n\n2(c) Else\nTail += 1\nEnd If\nNumberOfItems += 1\nReturn 1\nEnd If\nEnd Function\nPython\ndef Enqueue(RecordToAdd):\nglobal NumberOfItems #int\nglobal Head #int\nglobal Tail #int\nif(NumberOfItems == 5):\nreturn -1\nelse:\nCircularQueue[Tail] = RecordToAdd\nif(Tail == 4):\nTail = 0\nelse:\nTail +=1\nNumberOfItems +=1\nreturn 1\n© UCLES 2023 Page 15 of 37\n\n2(d) 1 mark each 6\n Function header Dequeue() (and end where appropriate)\n Checking if queue is empty…\n ….and returning appropriate empty/null record/object/list element\n (Otherwise) returning the item at Head\n Incrementing Head and changing value 0 if it is 4/5\n Decrement number of items\nExample Program code:\nJava\npublic static SaleData Dequeue(){\nSaleData RecordRemoved;\nRecordRemoved = new SaleData(\"\", -1);\nif(!(NumberOfItems == 0)){\nRecordRemoved.SetSaleID(CircularQueue[Head].GetSaleID());\nRecordRemoved.SetQuantity(CircularQueue[Head].GetQuantity());\nNumberOfItems--;\nif(Head == 4){\nHead = 0;\n}else{Head++;}\n}\nreturn RecordRemoved;\n}\nVB.NET\nFunction Dequeue()\nDim RecordRemoved As SaleData\nRecordRemoved.SaleID = \"\"\nRecordRemoved.Quantity = -1\nIf Not (NumberOfItems = 0) Then\nRecordRemoved = CircularQueue(Head)\nNumberOfItems -= 1\nIf Head = 4 Then\nHead = 0\n© UCLES 2023 Page 16 of 37\n\n2(d) Else\nHead += 1\nEnd If\nEnd If\nReturn RecordRemoved\nEnd Function\nPython\ndef Dequeue():\nglobal NumberOfItems #int\nglobal Head #int\nglobal Tail #int\nRecordRemoved = SaleData(\"\", -1)\nif not(NumberOfItems == 0):\nRecordRemoved = CircularQueue[Head]\nNumberOfItems -=1\nif Head == 4:\nHead = 0\nelse:\nHead +=1\nreturn RecordRemoved\n© UCLES 2023 Page 17 of 37\n\n2(e) 1 mark each 5\n Procedure header EnterRecord (and end where appropriate) (ignore parameters)\n Takes as input an ID (string) and quantity (integer)\n Creates a record/object using inputs\n Calls Enqueue() with record as parameter and stores/uses return value\n Outputs \"Full\" and \"Stored\" in correct places\nExample Program code:\nJava\npublic static void EnterRecord(){\nSystem.out.println(\"Enter ID\");\nScanner NewScanner = new Scanner(System.in);\nString ID = NewScanner.nextLine();\nSystem.out.println(\"Enter quantity\");\nQuan = Integer.parseInt(NewScanner.nextLine());\nSaleData Record;\nRecord = new SaleData(ID, Quan);\nif(Enqueue(Record) == -1){ System.out.println(\"Full\");}\nelse{System.out.println(\"Stored\");}\n}\nVB.NET\nSub EnterRecord()\nDim Record As SaleData\nConsole.WriteLine(\"Enter ID\")\nRecord.SaleID = Console.ReadLine()\nConsole.WriteLine(\"Enter quantity\")\nRecord.Quantity = Console.ReadLine()\nIf Enqueue(Record) = -1 Then\nConsole.WriteLine(\"Full\")\nElse\nConsole.WriteLine(\"Stored\")\nEnd If\nEnd Sub\n© UCLES 2023 Page 18 of 37\n\n2(e) Python\ndef EnterRecord():\nID = input(\"Enter ID\")\nQuantityP = input(\"Enter quantity\")\nRecord = SaleData(ID, QuantityP)\nif Enqueue(Record) == -1:\nprint(\"Full\")\nelse:\nprint(\"Stored\")\n© UCLES 2023 Page 19 of 37\n\n2(f)(i) 1 mark each to max 4 4\n Calling EnterRecord() 6 times before dequeue\n Calling Dequeue() and storing/using return value …\n … checking if an empty record is returned and outputting either the ID and quantity of returned record or outputting\nthe error message if empty record\n Calling EnterRecord() again after dequeue\n Output the ID and quantity for all the records currently stored in CircularQueue\nExample Program code:\nJava\nEnterRecord();\nEnterRecord();\nEnterRecord();\nEnterRecord();\nEnterRecord();\nEnterRecord();\nSaleData ReturnValue = new SaleData;\nReturnValue = Dequeue();\nif(ReturnValue.GetSaleID() == \"\"){\nSystem.out.println(\"No items\");\n}else{\nSystem.out.println(ReturnValue.GetSaleID() + \" \" + ReturnValue. GetQuantity());\n}\nEnterRecord();\nfor(Integer X = 0; X < 5; X++){\nSystem.out.println(CircularQueue[X].GetSaleID() + \" \" +\nCircularQueue[X].GetQuantity());\n}\nVB.NET\nEnterRecord()\nEnterRecord()\nEnterRecord()\nEnterRecord()\n© UCLES 2023 Page 20 of 37\n\n2(f)(i) EnterRecord()\nEnterRecord()\nDim ReturnValue As SaleData = new SaleData\nReturnValue = Dequeue()\nIf (ReturnValue.SaleID = \"\") Then\nConsole.WriteLine(\"No items\")\nElse\nConsole.WriteLine(ReturnValue.SaleID & \" \" & ReturnValue.Quantity)\nEnd If\nEnterRecord()\nFor x = 0 To 4\nConsole.WriteLine(CircularQueue(x).SaleID & \" \" & CircularQueue(x).Quantity)\nNext\nPython\nEnterRecord()\nEnterRecord()\nEnterRecord()\nEnterRecord()\nEnterRecord()\nEnterRecord()\nReturnValue = Dequeue()\nif ReturnValue.SaleID == \"\":\nprint(\"No items\")\nelse:\nprint(ReturnValue.SaleID, \" \", ReturnValue.Quantity)\nEnterRecord()\nfor x in range(0, 5):\nprint(CircularQueue[x].SaleID, \" \", CircularQueue[x].Quantity)\n© UCLES 2023 Page 21 of 37\n\n2(f)(ii) 1 mark for screenshot showing: 1\n Data for 6 records input\n 5 messages stating (e.g.) stored and 1 message stating (e.g.) full\n 1 output of ADF 10 (dequeued)\n Repeat successful input of LLP 3\n Output of the 5 records\ne.g.\n© UCLES 2023 Page 22 of 37",
      "source_pages": [
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_42-p11.png",
        "../answer-assets/9618_s23_ms_42-p12.png",
        "../answer-assets/9618_s23_ms_42-p13.png",
        "../answer-assets/9618_s23_ms_42-p14.png",
        "../answer-assets/9618_s23_ms_42-p15.png",
        "../answer-assets/9618_s23_ms_42-p16.png",
        "../answer-assets/9618_s23_ms_42-p17.png",
        "../answer-assets/9618_s23_ms_42-p18.png",
        "../answer-assets/9618_s23_ms_42-p19.png",
        "../answer-assets/9618_s23_ms_42-p20.png",
        "../answer-assets/9618_s23_ms_42-p21.png",
        "../answer-assets/9618_s23_ms_42-p22.png"
      ]
    },
    {
      "id": "9618-2023-mj-42-q03",
      "question_id": "9618-2023-mj-42-q03",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 33,
      "status": "available",
      "reason": null,
      "text": "3(a)(i) For X = 0 To 51\nPayYear2022(X) = 0.00\nNext\nEnd Sub\nEnd Class\nPython\nclass Employee:\n#self.__HourlyPay single\n#self.__EmployeeNumber string\n#self.__JobTitle string\ndef __init__(self, EmpNumP, PayP, JobP):\nself.__HourlyPay = PayP\nself.__EmployeeNumber = EmpNumP\nself.__JobTitle = JobP\nself.__PayYear2022 = []#array 52 elements single\nfor x in range(0, 52):\nself.__PayYear2022.append(0.00)\n© UCLES 2023 Page 24 of 37\n\n3(a)(ii) 1 mark each 2\n Get method header (and end) with no parameters …\n … returning employee number (without overriding)\nExample program code:\nJava\npublic String GetEmployeeNumber(){\nreturn EmployeeNumber;\n}\nVB.NET\nPublic Function GetEmployeeNumber()\nReturn EmployeeNumber\nEnd Function\nPython\ndef GetEmployeeNumber(self):\nreturn self.__EmployeeNumber\n© UCLES 2023 Page 25 of 37\n\n3(a)(iii) 1 mark each 3\n Method header (and close) with two parameters (week number and number of hours)\n Calculates pay as number of hours (parameter) * HourlyPay (attribute)\n … stores result in correct index in PayYear2022\nExample program code:\nJava\npublic void SetPay(Integer WeekNumber, Double Hours){\nPayYear2022[WeekNumber - 1] = Hours * HourlyPay;\n}\nVB.NET\nOverridable Sub SetPay(WeekNumber, Hours)\nPayYear2022(WeekNumber - 1) = Hours * HourlyPay\nEnd Sub\nPython\ndef SetPay(self, WeekNumber, Hours):\nself.__PayYear2022[WeekNumber-1] = Hours * self.__HourlyPay\n© UCLES 2023 Page 26 of 37\n\n3(a)(iv) 1 mark each 2\n Method header (and close) and returning calculated total (ignore parameters, allow return of any reasonable attempt\nat calculation)\n Totalling all elements in PayYear2022\nExample program code:\nJava\npublic Double GetTotalPay(){\nDouble TotalPay = 0.0;\nfor(Integer X = 0; X < 52; X++){\nTotalPay = TotalPay + PayYear2022[X];\n}\nreturn TotalPay;\n}\nVB.NET\nPublic Function GetTotalPay()\nDim TotalPay As Single = 0\nFor X = 0 To 51\nTotalPay = TotalPay + PayYear2022(X)\nNext\nReturn TotalPay\nEnd Function\nPython\ndef GetTotalPay(self):\nTotalPay = 0\nfor X in range (0, 52):\nTotalPay = TotalPay + self.__PayYear2022[X]\nreturn TotalPay\n© UCLES 2023 Page 27 of 37\n\n3(b)(i) 1 mark each 4\n Class Manager header (and end) inheriting from Employee\n Constructor within class (and end) taking 4 parameters…\n …calling parent class constructor with 3 values from parameters\n Declaring BonusValue (real) and assigning parameter to it within constructor\nExample program code:\nJava\nclass Manager extends Employee{\nprivate Double BonusValue;\npublic Manager(String EmpNumP, Double PayP, String JobP, Double BonusP){\nsuper(EmpNumP, PayP, JobP);\nBonusValue = BonusP;\n}\n}\nVB.NET\nClass Manager\nInherits Employee\nPrivate BonusValue As Single\nSub New(EmpNumP As String, PayP As Single, JobP As String, BonusP As Single)\nMyBase.New(EmpNumP, PayP, JobP)\nBonusValue = BonusP\nEnd Sub\nEnd Class\n© UCLES 2023 Page 28 of 37\n\n3(b)(i) Python\nclass Manager(Employee):\n#BonusValue single\ndef __init__(self, EmpNumP, PayP, JobP, BonusP):\nsuper().__init__(EmpNumP, PayP, JobP)\nself.__BonusValue = BonusP\n\n3(b)(ii) 1 mark each 3\n Method SetPay header (and end) taking 2 parameters\n Calculating hours (from parameter) * bonus as a percentage\n Overriding / calling parent SetPay with week number from parameter and updated hours as parameters\nExample program code:\nJava\npublic void SetPay(Integer WeekNumber, Double Hours){\nsuper.SetPay(WeekNumber, Hours * ((BonusValue / 100) + 1));\n}\nVB.NET\nOverrides Sub SetPay(WeekNumber, Hours)\nMyBase.SetPay(WeekNumber, Hours * ((BonusValue / 100) + 1))\nEnd Sub\nAlternative VB.NET:\nOverloads Sub SetPay(WeekNumber, Hours)\nSetPay(WeekNumber, Hours * ((BonusValue / 100) + 1))\nEnd Sub\nPython\ndef SetPay(self, WeekNumber, Hours):\nHours = Hours * (1 + self.__BonusValue / 100)\nsuper().SetPay(WeekNumber, Hours)\n© UCLES 2023 Page 29 of 37\n\n3(c) 1 mark each to max 7 7\n Opening file Employees.txt to read and closing file in an appropriate place\n Exception handling with appropriate output for opening the file\n Looping to EOF / 8 times\n (Attempting to) Read in all lines from the file for each employee\nFor each employee:\n Instantiating and storing an object of type Manager (not Employee) when bonus is included...\n …with correct read in values\n (otherwise) instantiating and storing an object of type Employee …\n .. with correct read in values\nExample program code:\nJava\npublic static void main(String args[]){\nDouble Pay = 0.0;\nString ID = \"\";\nDouble Bonus = 0.00;\nString Title = \"\";\nInteger NumberEmployees = 0;\nString Temp = \"\";\nString TextFile = \"Employees.txt\";\ntry{\nFileReader f = new FileReader(TextFile);\nBufferedReader Reader = new BufferedReader(f);\nfor(Integer X = 0; X < 8; X++){\nBonus = 0.00;\ntry{\nPay = Double.parseDouble(Reader.readLine());\nID = Reader.readLine();\nTemp = Reader.readLine();\n© UCLES 2023 Page 30 of 37\n\n3(c) try{\nBonus = Double.parseDouble(Temp);\nTitle = Reader.readLine();\nEmployeeArray[NumberEmployees] = new Manager(ID, Pay, Title, Bonus);\n}catch(NumberFormatException e){\nTitle = Temp;\nEmployeeArray[NumberEmployees] = new Employee(ID, Pay, Title);\n} NumberEmployees++;\n} catch(IOException ex){\n}\n} try{\nReader.close();\n}catch(IOException ex){}\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}}\nVB.NET\nDim Pay As Single\nDim ID As String\nDim Bonus As Single\nDim Title As String\nDim NumberEmployees As Integer = 0\nDim Temp As String\ntry\nDim TextFile As String = \"Employees.txt\"\nDim FileReader As New System.IO.StreamReader(TextFile)\nFor x = 0 To 7\nPay = CSng(FileReader.ReadLine())\nID = FileReader.ReadLine\nTemp = FileReader.ReadLine\nIf Single.TryParse(Temp, Bonus) Then\nBonus = Temp\nTitle = FileReader.ReadLine()\nEmployeeArray(NumberEmployees) = New Manager(ID, Pay, Title, Bonus)\n© UCLES 2023 Page 31 of 37\n\n3(c) Else\nTitle = Temp\nEmployeeArray(NumberEmployees) = New Employee(ID, Pay, Title)\nEnd If\nNumberEmployees += 1\nNext\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nPython\n#main\nPay = 0.00\nID = \"\"\nBonus = 0.00\nTitle = \"\"\nTemp = \"\"\ntry:\nTextFile = \"Employees.txt\"\nFile = open(TextFile, 'r')\nfor x in range(0, 8):\nPay = float(File.readline())\nID = File.readline()\nTemp = File.readline()\ntry:\nBonus = float(Temp)\nTitle = File.readline()\nEmployeeArray.append(Manager(ID, Pay, Title, Bonus))\nexcept:\nTitle = Temp\nEmployeeArray.append(Employee(ID, Pay, Title))\n© UCLES 2023 Page 32 of 37\n\n3(c) File.close()\nexcept IOError:\nprint(\"Could not find file\")\n© UCLES 2023 Page 33 of 37\n\n3(d) 1 mark each to max 4 4\n Procedure header EnterHours() (ignore parameters) and opening file to read and closing file in appropriate place\n Exception handling with appropriate output for opening file\n Looping to EOF/8 times and reading in each line\n Searching array for employee number …\n … using GetEmployeeNumber()\n …calling SetPay() with the number of hours and week number 1 as parameters, for that employee in the array\nExample program code:\nJava\npublic static void EnterHours(){\nString TextFile = \"HoursWeek1.txt\";\nString EmpID = \"\";\ntry{\nFileReader f = new FileReader(TextFile);\nBufferedReader Reader = new BufferedReader(f);\nfor(Integer X = 0; X < 8; X++){\ntry{\nEmpID = Reader.readLine();\nfor(Integer Y = 0; Y < 8; Y++){\nif(Employees[Y].GetEmployeeNumber().equals(EmpID)){\nEmployees[Y].SetPay(1, Double.parseDouble(Reader.readLine()));\n}\n}\n} catch(IOException ex){\n}\n}\ntry{\nReader.close();\n}catch(IOException ex){}\n}catch(FileNotFoundException e){\nSystem.out.println(\"File not found\");\n}\n}\n© UCLES 2023 Page 34 of 37\n\n3(d) VB.NET\nSub EnterHours()\ntry\nDim TextFile As String = \"HoursWeek1.txt\"\nDim FileReader As New System.IO.StreamReader(TextFile)\nDim EmpId As String\nFor X = 0 To 7\nEmpId = FileReader.ReadLine()\nFor Y = 0 To 7\nIf Employees(Y).GetEmployeeNumber = EmpId Then\nEmployees(Y).SetPay(1, CSng(FileReader.ReadLine()))\nEnd If\nNext\nNext\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\nPython\ndef EnterHours():\ntry:\nTextFile = \"HoursWeek1.txt\"\nFile = open(TextFile, 'r')\nEmpID = \"\"\nfor X in range(0, 8):\nEmpID = File.readline()\nfor Y in range(0, 8):\nif Employees[Y].GetEmployeeNumber() == EmpID:\nEmployees[Y].SetPay(1, float(File.readline()))\nexcept IOError:\nprint(\"Could not find file\")\n© UCLES 2023 Page 35 of 37\n\n3(e)(i) 1 mark each 2\n Calling EnterHours() and looping through each employee …\n … outputting the employee number and their total pay using GetTotalPay() and GetEmployeeNumber()\nExample program code:\nJava\nEnterHours();\nfor(Integer X = 0; X < 8; X++){\nSystem.out.println(Employees[Y].GetEmployeeNumber() + \" \" + Employees[Y].GetTotalPay());\n}\nVB.NET\nEnterHours()\nFor Y = 0 To 7\nConsole.WriteLine(Employees(Y).GetEmployeeNumber & \" \" & Employees(Y).GetTotalPay())\nNext\nPython\nEnterHours()\nfor(Y in range(0, 8):\nprint(Employees[Y].GetEmployeeNumber(), \" \", Employees[Y].GetTotalPay())\n© UCLES 2023 Page 36 of 37\n\n3(e)(ii) 1 mark for screenshot e.g. 1\n© UCLES 2023 Page 37 of 37",
      "source_pages": [
        24,
        25,
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_42-p24.png",
        "../answer-assets/9618_s23_ms_42-p25.png",
        "../answer-assets/9618_s23_ms_42-p26.png",
        "../answer-assets/9618_s23_ms_42-p27.png",
        "../answer-assets/9618_s23_ms_42-p28.png",
        "../answer-assets/9618_s23_ms_42-p29.png",
        "../answer-assets/9618_s23_ms_42-p30.png",
        "../answer-assets/9618_s23_ms_42-p31.png",
        "../answer-assets/9618_s23_ms_42-p32.png",
        "../answer-assets/9618_s23_ms_42-p33.png",
        "../answer-assets/9618_s23_ms_42-p34.png",
        "../answer-assets/9618_s23_ms_42-p35.png",
        "../answer-assets/9618_s23_ms_42-p36.png",
        "../answer-assets/9618_s23_ms_42-p37.png"
      ]
    },
    {
      "id": "9618-2023-mj-43-q01",
      "question_id": "9618-2023-mj-43-q01",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 18,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) 1 mark for 1\n 1D array with name DataArray (with 25 elements of type Integer)\nExample program code:\nJava\npublic static Integer[] DataArray = new Integer[25];\nVB.NET\nDim DataArray(24) As Integer\nPython\nDataArray = [] #25 elements Integer\n© UCLES 2023 Page 4 of 38\n\n1(a)(ii) 1 mark each to max 4 4\n Opening file Data.txt to read\n Looping through all the 25/EOF …\n … reading each line and storing/appending into array\n Exception handling with appropriate output\n Closing the file (in an appropriate place)\nExample program code:\nJava\nInteger Counter = 0;\ntry{\nScanner Scanner1 = new Scanner(new File(\"Data.txt\"));\nwhile(Scanner1.hasNextLine()){\nDataArray[Counter] = Integer.parseInt(Scanner1.next());\nCounter++;\n}\nScanner1.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No data file found\");\n}\nVB.NET\ntry\nDim DataReader As New System.IO.StreamReader(\"Data.txt\")\nDim X As Integer = 0\nDo Until DataReader.EndOfStream\nDataArray(X) = DataReader.ReadLine()\nX = X + 1\nLoop\nDataReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\n© UCLES 2023 Page 5 of 38\n\n1(a)(ii) Python\ntry:\nDataFile = open(\"Data.txt\",'r')\nfor Line in DataFile:\nDataArray.append(int(Line))\nDataFile.close()\nexcept IOError:\nprint(\"Could not find file\")\n© UCLES 2023 Page 6 of 38\n\n1(b)(i) 1 mark each 3\n Procedure header (and close where appropriate) with (at least) one (integer array) parameter\n Outputting all (25) array elements …\n …on one line\nExample program code:\nJava\npublic static void PrintArray(Integer[] DataArray){\nString OutputData;\nfor(Integer X = 0; X < DataArray.length - 1; X++){\nOutputData = OutputData + DataArray[X] + \" \";\n}\nSystem.out.print(OutputData);\n}\nVB.NET\nSub PrintArray(DataArray)\nDim OutputData As String = \"\";\nFor x = 0 To DataArray.length - 1\nOutputData = OutputData & DataArray(x) & \" \"\nNext\nConsole.WriteLine(OutputData)\nEnd Sub\nPython\ndef PrintArray(DataArray):\noutput = \"\"\nfor X in range(0, len(DataArray)):\noutput = output + str((DataArray[X])) + \" \"\nprint(output)\n© UCLES 2023 Page 7 of 38\n\n1(b)(ii) 1 mark for calling PrintArray with the array as a parameter 1\nExample program code:\nJava\nPrintArray(DataArray);\nVB.NET\nPrintArray(DataArray)\nPython\nPrintArray(DataArray)\n\n1(b)(iii) 1 mark for screenshot 1\ne.g.\n© UCLES 2023 Page 8 of 38\n\n1(c) 1 mark each 3\n Function header (and close where appropriate) taking array and search value as parameters\n Looping through each array element and keeping count of the number of times the parameter appears\n Returning the calculated count value\nExample program code:\nJava\npublic static Integer LinearSearch(Integer[] DataArray, Integer DataToFind){\nInteger Count = 0;\nfor(Integer x = 0; x < DataArray.length - 1; x++){\nif(DataArray[x] == DataToFind){\nCount++;\n}\n}\nreturn Count;\n}\nVB.NET\nFunction LinearSearch(DataArray, DataToFind)\nDim Count As Integer = 0\nFor x = 0 To DataArray.length - 1\nIf DataArray(x) = DataToFind Then\nCount = Count + 1\nEnd If\nNext\nReturn Count\nEnd Function\nPython\ndef LinearSearch(DataArray, DataToFind):\nCount = 0\nfor X in range(0, len(DataArray)):\nif(DataArray[X] == DataToFind):\nCount +=1\nreturn Count\n© UCLES 2023 Page 9 of 38\n\n1(d)(i) 1 mark each 4\n Prompt and reading input …\n …with validation for whole number between 0 and 100 inclusive\n Calling LinearSearch() with array and valid data input and storing/using return value\n Output of the message with return value\nExample program code:\nJava\nSystem.out.println(\"Enter a number to find\");\nInteger DataToFind = -1;\nScanner NewScanner = new Scanner(System.in);\nwhile(DataToFind < 0 || DataToFind > 100){\nDataToFind = Integer.parseInt(NewScanner.nextLine());\n}\nInteger NumberTimes = LinearSearch(DataArray, DataToFind);\nSystem.out.println(\"The number \" + DataToFind + \" is found \" + NumberTimes + \" times\");\nVB.NET\nConsole.WriteLine(\"Enter a number to find \")\nDim DataToFind As Integer = -1\nDo Until DataToFind >= 0 And DataToFind <= 100\nDataToFind = Console.ReadLine()\nLoop\nDim NumberTimes = LinearSearch(DataArray, DataToFind)\nConsole.WriteLine(\"The number \" & DataToFind & \" is found \" & NumberTimes & \" times.\")\nPython\nDataToFind = int(input(\"Enter a number to find \"))\nwhile DataToFind < 0 or DataToFind > 100:\nDataToFind = int(input(\"Enter a number to find \"))\nNumberTimes = LinearSearch(DataArray, DataToFind)\nprint(\"The number\", DataToFind, \"is found\", NumberTimes, \"times\")\n© UCLES 2023 Page 10 of 38\n\n1(d)(ii) 1 mark for screenshot e.g. 1\n© UCLES 2023 Page 11 of 38",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_43-p04.png",
        "../answer-assets/9618_s23_ms_43-p05.png",
        "../answer-assets/9618_s23_ms_43-p06.png",
        "../answer-assets/9618_s23_ms_43-p07.png",
        "../answer-assets/9618_s23_ms_43-p08.png",
        "../answer-assets/9618_s23_ms_43-p09.png",
        "../answer-assets/9618_s23_ms_43-p10.png",
        "../answer-assets/9618_s23_ms_43-p11.png"
      ]
    },
    {
      "id": "9618-2023-mj-43-q02",
      "question_id": "9618-2023-mj-43-q02",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 32,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) 1 mark each 5\n Class header (and close where appropriate)\n 5 (private) attribute declarations including data types\n Constructor header (and close where appropriate) taking 3 parameters (min)\n Assigning ID, MaxSpeed and IncreaseAmount to parameters\n Assigning CurrentSpeed and HorizontalPosition to 0\nExample program code:\nVB.NET\nClass Vehicle\nPrivate ID As String\nPrivate MaxSpeed As Integer\nPrivate CurrentSpeed As Integer\nPrivate IncreaseAmount As Integer\nPrivate HorizontalPosition As Integer\nSub New(IDP, MaxSpeedP, IncreaseAmountP)\nID = IDP\nMaxSpeed = MaxSpeedP\nCurrentSpeed = 0\nIncreaseAmount = IncreaseAmountP\nHorizontalPosition = 0\nEnd Sub\nEnd Class\nJava\nclass Vehicle{\nprivate String ID;\nprivate Integer MaxSpeed;\nprivate Integer CurrentSpeed;\nprivate Integer IncreaseAmount;\nprivate Integer HorizontalPosition;\n© UCLES 2023 Page 12 of 38\n\n2(a)(i) public Vehicle(String IDP, Integer MaxSpeedP, Integer IncreaseAmountP){\nID = IDP;\nMaxSpeed = MaxSpeedP;\nIncreaseAmount = IncreaseAmountP;\nCurrentSpeed = 0;\nHorizontalPosition = 0;\n}}\nPython\nclass Vehicle:\n#self.__ID string\n#self.__MaxSpeed integer\n#self.__CurrentSpeed integer\n#self.__IncreaseAmount integer\n#self.__HorizontalPosition\ndef __init__(self, IDP, MaxSpeedP, IncreaseAmountP):\nself.__ID = IDP\nself.__MaxSpeed = MaxSpeedP\nself.__IncreaseAmount = IncreaseAmountP\nself.__CurrentSpeed = 0\nself.__HorizontalPosition = 0\n© UCLES 2023 Page 13 of 38\n\n2(a)(ii) 1 mark each 3\n 1 get function header (and end where appropriate) with no parameter …\n …returning attribute (without overwriting)\n 3 further correct get methods\nExample program code:\nVB.NET\nFunction GetCurrentSpeed()\nReturn CurrentSpeed\nEnd Function\nFunction GetIncreaseAmount()\nReturn IncreaseAmount\nEnd Function\nFunction GetHorizontalPosition()\nReturn HorizontalPosition\nEnd Function\nFunction GetMaxSpeed()\nReturn MaxSpeed\nEnd Function\nJava\npublic Integer GetCurrentSpeed(){\nreturn CurrentSpeed;\n}\npublic Integer GetIncreaseAmount(){\nreturn IncreaseAmount;\n}\npublic Integer GetHorizontalPosition(){\nreturn HorizontalPosition;\n}\npublic Integer GetMaxSpeed(){\nreturn MaxSpeed;\n}\n© UCLES 2023 Page 14 of 38\n\n2(a)(ii) Python\ndef GetCurrentSpeed(self):\nreturn self.__CurrentSpeed\ndef GetIncreaseAmount(self):\nreturn self.__IncreaseAmount\ndef GetHorizontalPosition(self):\nreturn self.__HorizontalPosition\ndef GetMaxSpeed(self):\nreturn self.__MaxSpeed\n© UCLES 2023 Page 15 of 38\n\n2(a)(iii) 1 mark each 3\n 1 set procedure (and end where appropriate) taking parameter …\n … assigns parameter to the attribute (without overriding)\n Second correct set method\nExample program code:\nVB.NET\nSub SetCurrentSpeed(CSp)\nCurrentSpeed = CSp\nEnd Sub\nSub SetHorizontalPosition(HPP)\nHorizontalPosition = HPP\nEnd Sub\nJava\npublic void SetCurrentSpeed(Integer CSP){\nCurrentSpeed = CSP;\n}\npublic void SetHorizontalPosition(Integer HPP){\nHorizontalPosition = HPP;\n}\nPython\ndef SetCurrentSpeed(self, CSP):\nself.__CurrentSpeed = CSP\ndef SetHorizontalPosition(self, HPP):\nself.__HorizontalPosition = HPP\n© UCLES 2023 Page 16 of 38\n\n2(a)(iv) 1 mark each 3\n Method header (and close where appropriate) with no parameter and adding IncreaseAmount to CurrentSpeed\n Checking if MaxSpeed is exceeded and limiting to max speed (remove increase or assign maximum)\n Adding updated CurrentSpeed to HorizontalPosition in all cases (whether MaxSpeed is exceeded or not)\nExample program code:\nVB.NET\nSub IncreaseSpeed()\nCurrentSpeed = CurrentSpeed + IncreaseAmount\nIf CurrentSpeed > MaxSpeed Then\nCurrentSpeed = MaxSpeed\nEnd If\nHorizontalPosition = HorizontalPosition + CurrentSpeed\nEnd Sub\nJava\npublic void IncreaseSpeed(){\nCurrentSpeed = CurrentSpeed + IncreaseAmount;\nif(CurrentSpeed > MaxSpeed){\nCurrentSpeed = MaxSpeed;\n}\nHorizontalPosition = HorizontalPosition + CurrentSpeed;\n}\nPython\ndef IncreaseSpeed(self):\nself.__CurrentSpeed = self.__CurrentSpeed + self.__IncreaseAmount\nif(self.__CurrentSpeed > self.__MaxSpeed):\nself.__CurrentSpeed = self.__MaxSpeed\nself.__HorizontalPosition = self.__HorizontalPosition + self.__CurrentSpeed\n© UCLES 2023 Page 17 of 38\n\n2(b)(i) 1 mark each 5\n Class header (and end where appropriate) inheriting from Vehicle\n 3 (private) attribute declarations with data types\n Constructor (and end where appropriate) with (min) 5 parameters\n Calling parent constructor with appropriate parameters\n Initialising VerticalPosition to 0 and VerticalChange and MaxHeight to attributes\nExample program code:\nVB.NET\nClass Helicopter\nInherits Vehicle\nPrivate VerticalPosition As Integer\nPrivate VerticalChange As Integer\nPrivate MaxHeight As Integer\nSub New(IDP, MaxSpeedP, IncreaseAmountP, VertChangeP, MaxHeightP)\nMyBase.New(IDP, MaxSpeedP, IncreaseAmountP)\nVerticalPosition = 0\nVerticalChange = VertChangeP\nMaxHeight = MaxHeightP\nEnd Sub\nEnd Class\nJava\nclass Helicopter extends Vehicle{\nprivate Integer VerticalPosition;\nprivate Integer VerticalChange;\nprivate Integer MaxHeight;\npublic Helicopter(String IDP, Integer MaxSpeedP, Integer IncreaseAmountP, Integer\nVertChangeP, Integer MaxHeightP){\n© UCLES 2023 Page 18 of 38\n\n2(b)(i) super(IDP, MaxSpeedP, IncreaseAmountP);\nVerticalPosition = 0;\nVerticalChange = VertChangeP;\nMaxHeight = MaxHeightP;\n}}\nPython\nclass Helicopter(Vehicle):\n#VerticalPosition Integer\n#VerticalChange Integer\n#MaxHeight Integer\ndef __init__(self, IDP, MaxSpeedP, IncreaseAmountP, VertChangeP, MaxHeightP):\nVehicle.__init__(self,IDP, MaxSpeedP, IncreaseAmountP)\nself.__VerticalPosition = 0\nself.__VerticalChange = VertChangeP\nself.__MaxHeight = MaxHeightP\n© UCLES 2023 Page 19 of 38\n\n2(b)(ii) 1 mark each to max 4 4\n Method header (overriding where required) with no parameter\n Adding vertical change to vertical position …\n …limiting to maximum height\n Repeating/calling/using the code from original for horizontal increase (in every case)\nExample program code:\nVB.NET\nOverrides Sub IncreaseSpeed()\nVerticalPosition = VerticalPosition + VerticalChange\nIf VerticalPosition > MaxHeight Then\nVerticalPosition = MaxHeight\nEnd If\nMe.SetCurrentSpeed(GetCurrentSpeed() + GetIncreaseAmount())\nIf Me.GetCurrentSpeed() > Me.GetMaxSpeed() Then\nMe.SetCurrentSpeed(Me.GetMaxSpeed())\nEnd If\nMe.SetHorizontalPosition(Me.GetHorizontalPosition() + Me.GetCurrentSpeed())\nEnd Sub\nJava\npublic void IncreaseSpeed(){\nVerticalPosition = VerticalPosition + VerticalChange;\nif(VerticalPosition > MaxHeight){\nVerticalPosition = MaxHeight;\n}\nsuper.SetCurrentSpeed(super.GetCurrentSpeed() + super.GetIncreaseAmount());\nif(super.GetCurrentSpeed() > super.GetMaxSpeed()){\nsuper.SetCurrentSpeed(super.GetMaxSpeed());\n}\nsuper.SetHorizontalPosition(super.GetHorizontalPosition() + super.GetCurrentSpeed());\n}\n© UCLES 2023 Page 20 of 38\n\n2(b)(ii) Python\ndef IncreaseSpeed(self):\nself.__VerticalPosition = self.__VerticalPosition + self.__VerticalChange\nif(self.__VerticalPosition > self.__MaxHeight):\nself.__VerticalPosition = MaxHeight\nVehicle.SetCurrentSpeed(self, Vehicle.GetCurrentSpeed(self) +\nVehicle.GetIncreaseAmount(self))\nif(Vehicle.GetCurrentSpeed(self) > Vehicle.GetMaxSpeed(self)):\nVehicle.SetCurrentSpeed(self, Vehicle.GetMaxSpeed(self));\nVehicle.SetHorizontalPosition(self, Vehicle.GetHorizontalPosition(self) +\nVehicle.GetCurrentSpeed(self))\n© UCLES 2023 Page 21 of 38\n\n2(c) 1 mark each to max 3 3\n Suitable method/procedure heading (and end where appropriate) and outputting horizontal position and current speed\nin an appropriate message\n Checking if object is a Vehicle or Helicopter // overriding methods in each class for output // one method in each class\n// try except …\n …outputting vertical position only if helicopter with appropriate message\nExample program code:\nVB.NET\nSub OutputCurrentPosition(ObjectToOutput)\nConsole.WriteLine(\"Current position = \" & ObjectToOutput.GetHorizontalPosition())\nConsole.WriteLine(\"Current speed = \" & ObjectToOutput.GetCurrentSpeed())\nIf TypeOf ObjectToOutput Is Helicopter Then\nConsole.WriteLine(\"Current vertical position = \" &\nObjectToOutput.GetVerticalPosition())\nEnd If\nEnd Sub\nJava\npublic void OutputCurrentPosition(){\nSystem.out.println(\"Current position = \" + HorizontalPosition);\nSystem.out.println(\"Current speed = \" + CurrentSpeed);\n}\npublic void OutputCurrentPosition(){\nSystem.out.println(\"Current position = \" +super.GetHorizontalPosition());\nSystem.out.println(\"Current speed = \" + super.GetCurrentSpeed());\nSystem.out.println(\"Current vertical position = \" + VerticalPosition);\n}\nPython\ndef OutputCurrentPosition(self):\nprint(\"Current position = \", self.__HorizontalPosition)\nprint(\"Current speed = \", self.__CurrentSpeed)\n© UCLES 2023 Page 22 of 38\n\n2(c) def OutputCurrentPosition(self):\nprint(\"Current position = \", Vehicle.GetHorizontalPosition(self))\nprint(\"Current speed = \", Vehicle.GetCurrentSpeed(self))\nprint(\"Current verticalposition = \", self.__VerticalPosition)\n© UCLES 2023 Page 23 of 38\n\n2(d)(i) 1 mark each 5\n Instantiating an object of type Vehicle with correct parameters (\"Tiger\", 100, 20)\n Instantiating an object of type Helicopter with correct parameters (\"Lion\", 350, 40, 3, 100)\n Calling IncreaseSpeed() twice for the car\n Calling IncreaseSpeed() twice for the helicopter\n Calling the output for both objects\nExample program code:\nVB.NET\nSub Main()\nDim Car As Vehicle\nCar = New Vehicle(\"Tiger\", 100, 20)\nDim Heli1 As Helicopter\nHeli1 = New Helicopter(\"Lion\", 350, 40, 3, 100)\nCar.IncreaseSpeed()\nCar.IncreaseSpeed()\nOutputCurrentPosition(Car)\nConsole.WriteLine(\"\")\nHeli1.IncreaseSpeed()\nHeli1.IncreaseSpeed()\nOutputCurrentPosition(Heli1)\nEnd Sub\nJava\npublic static void main(String args[]){\nVehicle Car = new Vehicle(\"Tiger\", 100, 20);\nHelicopter Heli1 = new Helicopter(\"Lion\", 350, 40, 3, 100);\nCar.IncreaseSpeed();\nCar.IncreaseSpeed();\nCar.OutputCurrentPosition();\nSystem.out.println(\"\");\nHeli1.IncreaseSpeed();\nHeli1.IncreaseSpeed();\nHeli1.OutputCurrentPosition();\n}\n© UCLES 2023 Page 24 of 38\n\n2(d)(i) Python\n#main\nCar = Vehicle(\"Tiger\", 100, 20)\nHeli1 = Helicopter(\"Lion\", 350, 40, 3, 100)\nCar.IncreaseSpeed()\nCar.IncreaseSpeed()\nCar.OutputCurrentPosition()\nprint(\"\")\nHeli1.IncreaseSpeed()\nHeli1.IncreaseSpeed()\nHeli1.OutputCurrentPosition()\n\n2(d)(ii) Screenshot of results e.g. 1\n© UCLES 2023 Page 25 of 38",
      "source_pages": [
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23,
        24,
        25
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_43-p12.png",
        "../answer-assets/9618_s23_ms_43-p13.png",
        "../answer-assets/9618_s23_ms_43-p14.png",
        "../answer-assets/9618_s23_ms_43-p15.png",
        "../answer-assets/9618_s23_ms_43-p16.png",
        "../answer-assets/9618_s23_ms_43-p17.png",
        "../answer-assets/9618_s23_ms_43-p18.png",
        "../answer-assets/9618_s23_ms_43-p19.png",
        "../answer-assets/9618_s23_ms_43-p20.png",
        "../answer-assets/9618_s23_ms_43-p21.png",
        "../answer-assets/9618_s23_ms_43-p22.png",
        "../answer-assets/9618_s23_ms_43-p23.png",
        "../answer-assets/9618_s23_ms_43-p24.png",
        "../answer-assets/9618_s23_ms_43-p25.png"
      ]
    },
    {
      "id": "9618-2023-mj-43-q03",
      "question_id": "9618-2023-mj-43-q03",
      "subject": "9618",
      "year": 2023,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 25,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark each 3\n (Global) Animal array (with 20 string elements)\n (Global) Colour array (with 10 string elements)\n (Global) AnimalTopPointer and ColourTopPointer initialised to 0\nExample program code:\nJava\npublic static String[] Animal = new String[20];\npublic static String[] Colour = new String[10];\npublic static Integer AnimalTopPointer = 0;\npublic static Integer ColourTopPointer = 0;\nVB.NET\nDim Animal(0 to 19) As String\nDim Colour(0 to 9) As String\nDim AnimalTopPointer As Integer = 0\nDim ColourTopPointer As Integer = 0\nPython\nAnimal = [] #20 elements\nColour = [] #10 elements\nglobal AnimalTopPointer\nglobal ColourTopPointer\nAnimalTopPointer = 0\nColourTopPointer = 0\n© UCLES 2023 Page 26 of 38\n\n3(b)(i) 1 mark each 3\n Function header (and close where appropriate) with parameter, checking if full (AnimalTopPointer = 20) and returning\nfalse\n If not full, inserting parameter value into AnimalTopPointer\n …incrementing pointer and returning true\nExample program code:\nJava\npublic static Boolean PushAnimal(String DataToPush){\nif(AnimalTopPointer == 20){\nreturn false;\n}else{\nAnimal[AnimalTopPointer] = DataToPush;\nAnimalTopPointer++;\nreturn true;\n}\n}\nVB.NET\nFunction PushAnimal(DataToPush)\nIf AnimalTopPointer = 20 Then\nReturn False\nElse\nAnimal(AnimalTopPointer) = DataToPush\nAnimalTopPointer = AnimalTopPointer + 1\nReturn True\nEnd If\nEnd Function\nPython\ndef PushAnimal(DataToPush):\nglobal AnimalTopPointer\nglobal ColourTopPointer\nif AnimalTopPointer == 20:\nreturn False\n© UCLES 2023 Page 27 of 38\n\n3(b)(i) else:\nAnimal.append(DataToPush)\nAnimalTopPointer +=1\nreturn True\n\n3(b)(ii) 1 mark each 3\n Procedure header (and end where appropriate) with no parameter, checking if empty (AnimalTopPointer = 0) and\nreturning empty string\n If not empty returning the top data item (AnimalTopPointer-1)\n … and decrementing AnimalTopPointer\nExample program code:\nJava\npublic static String PopAnimal(){\nString ReturnData;\nif(AnimalTopPointer == 0){\nreturn \"\";\n}else{\nReturnData = Animal[AnimalTopPointer - 1];\nAnimalTopPointer--;\nreturn ReturnData;\n}\n}\nVB.NET\nFunction PopAnimal()\nDim ReturnData As String\nIf AnimalTopPointer = 0 Then\nReturn \"\"\nElse\nReturnData = Animal(AnimalTopPointer - 1)\nAnimalTopPointer = AnimalTopPointer - 1\nReturn ReturnData\nEnd If\nEnd Function\n© UCLES 2023 Page 28 of 38\n\n3(b)(ii) Python\ndef PopAnimal():\nglobal AnimalTopPointer\nglobal ColourTopPointer\nif AnimalTopPointer == 0:\nreturn \"\"\nelse:\nReturnData = Animal[AnimalTopPointer - 1]\nAnimalTopPointer -=1\nreturn ReturnData\n© UCLES 2023 Page 29 of 38\n\n3(b)(iii) 1 mark 5\n Procedure header (and close where appropriate) and opening correct file for read\n Looping until end of file // looping until all animal names read in // looping 8 times\n Calling PushAnimal() with each line read from file (for all lines)\n Closing the file\n Exception handling with appropriate error message\nExample program code:\nJava\nprivate static void ReadData(){\ntry{\nScanner Scanner1 = new Scanner(new File(\"AnimalData.txt\"));\nwhile(Scanner1.hasNextLine()){\nPushAnimal(Scanner1.next());\n}\nScanner1.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No Animal file found\");\n}\n}\nVB.NET\nSub ReadData()\ntry\nDim AnimalFile As String = \"AnimalData.txt\"\nDim AnimalFileReader As New System.IO.StreamReader(AnimalFile)\nDo Until AnimalFileReader.EndOfStream\nPushAnimal(AnimalFileReader.ReadLine())\nLoop\nAnimalFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\n© UCLES 2023 Page 30 of 38\n\n3(b)(iii) Python\ndef ReadData():\ntry:\nglobal AnimalTopPointer\nglobal ColourTopPointer\nAnimalFile = open(\"AnimalData.txt\", 'r')\nfor Line in AnimalFile:\nPushAnimal(Line)\nAnimalFile.close()\nexcept IOError:\nprint(\"Could not find file\")\n© UCLES 2023 Page 31 of 38\n\n3(b)(iv) 1 mark each 2\n PushColour function\n PopColour function\nExample program code:\nJava\npublic static Boolean PushColour(String DataToPush){\nif(ColourTopPointer == 10){\nreturn false;\n}else{\nColour[ColourTopPointer] = DataToPush;\nColourTopPointer++;\nreturn true;\n}\n}\npublic static String PopColour(){\nString ReturnData;\nif(ColourTopPointer == 0){\nreturn \"\";\n}else{\nReturnData = Colour[ColourTopPointer - 1];\nColourTopPointer--;\nreturn ReturnData;\n}\n}\nVB.NET\nFunction PushColour(DataToPush)\nIf ColourTopPointer = 10 Then\nReturn False\nElse\nColour(ColourTopPointer) = DataToPush\nColourTopPointer = ColourTopPointer + 1\nReturn True\nEnd If\n© UCLES 2023 Page 32 of 38\n\n3(b)(iv) End Function\nFunction PopColour()\nDim ReturnData As String\nIf ColourTopPointer = 0 Then\nReturn \"\"\nElse\nReturnData = Colour(ColourTopPointer - 1)\nColourTopPointer = ColourTopPointer - 1\nReturn ReturnData\nEnd If\nEnd Function\nPython\ndef PushColour(DataToPush):\nglobal AnimalTopPointer\nglobal ColourTopPointer\nif ColourTopPointer == 10:\nreturn False\nelse:\nColour.append(DataToPush)\nColourTopPointer +=1\nreturn True\ndef PopColour():\nglobal AnimalTopPointer\nglobal ColourTopPointer\nif ColourTopPointer == 0:\nreturn \"\"\nelse:\nReturnData = Colour[ColourTopPointer - 1]\nColourTopPointer -=1\nreturn ReturnData\n© UCLES 2023 Page 33 of 38\n\n3(b)(v) 1 mark each 2\n Opening ColourData.txt to read, reading until EOF, closing file and exception handling\n Using PushColour() to store each item read from the file for all lines\nExample program code:\nJava\nprivate static void ReadData(){\ntry{\nScanner Scanner1 = new Scanner(new File(\"AnimalData.txt\"));\nwhile(Scanner1.hasNextLine()){\nPushAnimal(Scanner1.next());\n}\nScanner1.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No Animal file found\");\n}\ntry{\nScanner Scanner2 = new Scanner(new File(\"ColourData.txt\"));\nwhile(Scanner2.hasNextLine()){\nPushColour(Scanner2.next());\n}\nScanner2.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No Colour file found\");\n}\n}\nVB.NET\nSub ReadData()\ntry\nDim AnimalFile As String = \"AnimalData.txt\"\nDim AnimalFileReader As New System.IO.StreamReader(AnimalFile)\nDo Until AnimalFileReader.EndOfStream\nPushAnimal(AnimalFileReader.ReadLine())\n© UCLES 2023 Page 34 of 38\n\n3(b)(v) Loop\nAnimalFileReader.Close()\nDim ColourFile As String = \"ColourData.txt\"\nDim ColourFileReader As New System.IO.StreamReader(ColourFile)\nDo Until ColourFileReader.EndOfStream\nPushColour(ColourFileReader.ReadLine())\nLoop\nColourFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\nPython\ndef ReadData():\ntry:\nglobal AnimalTopPointer\nglobal ColourTopPointer\nAnimalFile = open(\"AnimalData.txt\", 'r')\nfor Line in AnimalFile:\nPushAnimal(Line)\nAnimalFile.close()\nColourFile = open(\"ColourData.txt\", 'r')\nfor Line in ColourFile:\nPushColour(Line)\nColourFile.close()\nexcept IOError:\nprint(\"Could not find file\")\n© UCLES 2023 Page 35 of 38\n\n3(c) 1 mark each to max 5 5\n Procedure heading (and close where appropriate) and outputting the colour and animal using PopColour() and\nPopAnimal() (only if both are successfully popped)\n Checking if no colour and outputting \"No colour\" …\n ….pushing the removed animal back onto the stack\n Checking if no animal and outputting \"No animal\" …\n …pushing the removed colour back onto the stack\nExample program code:\nJava\npublic static void OutputItem(){\nString ColourReturned = PopColour();\nString AnimalReturned = PopAnimal();\nif(ColourReturned.equals(\"\")){\nSystem.out.println(\"No colour\");\nPushAnimal(AnimalReturned);\n}else{\nif(AnimalReturned.equals(\"\")){\nSystem.out.println(\"No animal\");\nPushColour(ColourReturned);\n}else{\nSystem.out.println(\"A \" + ColourReturned + \" \" + AnimalReturned);\n}\n}\n}\nVB.NET\nSub OutputItem()\nDim ColourReturned As String = PopColour()\nDim Animalreturned As String = PopAnimal()\nIf ColourReturned = \"\" Then\nConsole.WriteLine(\"No colour\")\nPushAnimal(AnimalReturned)\n© UCLES 2023 Page 36 of 38\n\n3(c) Else\nIf Animalreturned = \"\" Then\nConsole.WriteLine(\"No animal\")\nPushColour(ColourReturned)\nElse\nConsole.WriteLine(\"A \" & ColourReturned & \" \" & Animalreturned)\nEnd If\nEnd If\nEnd Sub\nPython\ndef OutputItem():\nglobal AnimalTopPointer\nglobal ColourTopPointer\nColourReturned = PopColour()\nAnimalReturned = PopAnimal()\nif ColourReturned == \"\":\nprint(\"No colour\")\nPushAnimal(AnimalReturned)\nelse:\nif AnimalReturned == \"\":\nprint(\"No animal\")\nPushColour(ColourReturned)\nelse:\nprint(ColourReturned, AnimalReturned)\n© UCLES 2023 Page 37 of 38\n\n3(d)(i) 1 mark for 1\n Calling ReadData() and calling OutputItem() 4 times\nExample program code:\nJava\npublic static void main(String args[]){\nReadData();\nOutputItem();\nOutputItem();\nOutputItem();\nOutputItem();\n}\nVB.NET\nSub Main()\nReadData()\nOutputItem()\nOutputItem()\nOutputItem()\nOutputItem()\nEnd Sub\nPython\nReadData()\nOutputItem()\nOutputItem()\nOutputItem()\nOutputItem()\n\n3(d)(ii) 1 mark for output 1\ne.g.\n© UCLES 2023 Page 38 of 38",
      "source_pages": [
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37,
        38
      ],
      "source_pdf": "_source-pdfs/2023-may-june/ms/9618_s23_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-May-June/9618_s23_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s23_ms_43-p26.png",
        "../answer-assets/9618_s23_ms_43-p27.png",
        "../answer-assets/9618_s23_ms_43-p28.png",
        "../answer-assets/9618_s23_ms_43-p29.png",
        "../answer-assets/9618_s23_ms_43-p30.png",
        "../answer-assets/9618_s23_ms_43-p31.png",
        "../answer-assets/9618_s23_ms_43-p32.png",
        "../answer-assets/9618_s23_ms_43-p33.png",
        "../answer-assets/9618_s23_ms_43-p34.png",
        "../answer-assets/9618_s23_ms_43-p35.png",
        "../answer-assets/9618_s23_ms_43-p36.png",
        "../answer-assets/9618_s23_ms_43-p37.png",
        "../answer-assets/9618_s23_ms_43-p38.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q01",
      "question_id": "9618-2023-on-31-q01",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark for working (Max 1) 3\n• conversion of 65.25 to binary seen e.g. 1000001.01 = 65.25 //\n64 + 1 + 0.25 / ¼\nOne mark per mark point (Max 2)\n• correct mantissa\n• correct exponent\nMantissa Exponent\n0 1 0 0 0 0 0 1 0 1 0 0 0 1 1 1\n\n1(b) One mark per mark point (Max 2) 2\nMP1 the decimal fraction 0.20 cannot be represented exactly (the closest\nis 0.25 / 0.1875)\nMP2 therefore, there will be a loss of precision due to a rounding\nerror/truncation\nQuestion Answer Marks",
      "source_pages": [
        3
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p03.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q02",
      "question_id": "9618-2023-on-31-q02",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 2,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark for each correct line connecting a protocol to its most appropriate 4\ndescription (Max 4).\nProtocol Use\nto provide peer-to-peer file sharing\nHTTP\nwhen retrieving email messages from a\nmail server over a TCP/IP connection\nBitTorrent\nwhen transmitting hypertext\ndocuments\nSMTP\nto map MAC addresses onto IP\naddresses\nIMAP\nwhen sending email messages\ntowards the intended destination\n\n2(b) One mark per mark point (Max 2) 2\nMP1 To ensure correct network protocols are followed\nMP2 To enable the upper layers to access the physical medium //\nenables connection/ communication with the internet / network layer\nMP3 To be responsible for transporting data within the network/local\nsegments\nMP4 To format the data into frames for transmission\nMP5 Maps IP addresses to MAC/Physical addresses.\n© UCLES 2023 Page 3 of 9",
      "source_pages": [
        3
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p03.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q03",
      "question_id": "9618-2023-on-31-q03",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 3,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "3 One mark per mark point – enumerated type (Max 2) 4\nMP1 A user-defined non-composite (data type) (only award once)\nMP2 …with a list of all possible values\nMP3 …that is ordered.\nOne mark per mark point – pointer type (Max 2)\nMP4 A user-defined non-composite (data type) (only award once)\nMP5 …that stores addresses/memory locations only\nMP6 …and indicates the type of data stored in the memory location.\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q04",
      "question_id": "9618-2023-on-31-q04",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 4,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark per mark point – sequential (Max 2) 4\nMP1 Records (in the file) are ordered\nMP2 …based on the key field\nMP3 A new version (of the file) has to be created to update the file\nOne mark per mark point – random (Max 2)\nMP4 Records are stored in no particular order within the file // There is no\nsequencing in the placement of the records\nMP5 There is a relationship between the key of the record and its location\nwithin the file // a hashing algorithm is used to find the location of the\nrecord\nMP6 Updates to the file can be carried out directly.\n\n4(b) One mark per mark point (Max 2) 2\nMP1 Start at the beginning of the file\nMP2 …check records linearly\nMP3 …until the desired record is found // … processing / updating records\nas required //… EOF found.\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q05",
      "question_id": "9618-2023-on-31-q05",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 5,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "5 One mark per mark point – SISD (Max 2) 4\nMP1 Single Instruction, Single Data (architecture). // Data is taken from a\nsingle source and a single instruction is performed on the data.\nMP2 Contains one processor, a control unit and a memory unit.\nMP3 …that executes instructions sequentially.\nOne mark per mark point – MIMD (Max 2)\nMP4 Multiple Instruction, Multiple Data (architecture). // At any time, any\nprocessor can execute different instructions on different sets of data.\nMP5 Contains many processors\nMP6 …that operate asynchronously / independently.\n© UCLES 2023 Page 4 of 9",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q06",
      "question_id": "9618-2023-on-31-q06",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for every shaded block of rows for column Z correct (Max 3) 3\nA B C D Z\n0 0 0 0 1\n0 0 0 1 0\n0 0 1 0 1\n0 0 1 1 0\n0 1 0 0 1\n0 1 0 1 0\n0 1 1 0 1\n0 1 1 1 0\n1 0 0 0 1\n1 0 0 1 0\n1 0 1 0 1\n1 0 1 1 0\n1 1 0 0 1\n1 1 0 1 0\n1 1 1 0 0\n1 1 1 1 0\n\n6(b) One mark for correct working from points (Max 2), for example: 3\n(Y =) A.B.C.D + A.B.C.D + A.B.C.D + A.B.C.D\n(Y =) A.D.(B.C + B.C + B.C + B.C)\n(Y =) A.D.(B.(C + C) + B.(C + C))\n(Y =) A.D.(B.(1) + B.(1))\n(Y =) A.D.(B + B)\n(Y =) A.D.(1)\nOne mark for correct answer\n(Y =) A.D\n© UCLES 2023 Page 5 of 9",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p05.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q07",
      "question_id": "9618-2023-on-31-q07",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 7,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark for a benefit (Max 1) e.g. 2\nMP1 The user interface hides the complexities of the computer\nhardware/operating system from the user\nMP2 It provides appropriate access systems for users with differing needs\nMP3 Complex commands involving memory locations/buses/computer\nhardware/ are avoided\nOne mark for a valid example (Max 1) e.g.\nClicking on icon rather than writing code\nUsing a graphical user interface / icons for navigation\n\n7(b) Blocked (state) 1\n\n7(c) One mark per mark point (Max 2) 2\nMP1 When the time slice of the running process expires (round robin).\nMP2 …and there is a process with a higher priority in the ready queue, the\nrunning process is pre-empted\nMP3 When an interrupt arrives at the CPU, (the process running on the\nCPU gets pre-empted).\nQuestion Answer Marks",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q08",
      "question_id": "9618-2023-on-31-q08",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 8,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correctly completed line (Max 5) 5\nDECLARE Customer : TAccount\nDECLARE Location : INTEGER\nDECLARE AccountFile : STRING\nAccountFile  \"AccountRecords.dat\"\nOPENFILE AccountFile FOR RANDOM\nOUTPUT \"Please enter an account number\"\nINPUT Customer.AccountNumber\nLocation  Hash(Customer.AccountNumber)\nSEEK AccountFile, Location\nGETRECORD AccountFile, Customer\nOUTPUT Customer\nCLOSEFILE AccountFile\n\n8(b) One mark for correct definition 1\n(Exception handling is the process of) responding to an unexpected event\nwhen the program is running so it does not halt unexpectedly\n\n8(c) One mark per mark point (Max 2), for example: 2\n• Programming errors\n• User errors\n• Hardware failure\n• Runtime errors\n© UCLES 2023 Page 6 of 9",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q09",
      "question_id": "9618-2023-on-31-q09",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 9,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "9(a)(i) One mark per mark point (Max 2) 2\n• (5 – 2)\n• * (5 + 4) / 9\nFinal correct expression\n(5 – 2) * (5 + 4) / 9\n\n9(a)(ii) One mark per ring (Max 4) 4\n4\n2 5 5 9 9\n5 5 3 3 3 3 27 27 3\nOR\n5 2 3 5 4 9 27 9 3\n5 3 5 3 27\n3\n\n9(b) One mark per mark point (Max 3) 3\nMP1 Evaluate the RPN expression from left to right\nMP2 Push each element of the RPN expression onto the stack in order\nuntil an operator is reached\nMP3 Pop the last two elements from the stack and apply the operator\nMP4 Push the result of the operation onto the stack\nMP5 Repeat the process until the whole expression is evaluated.\n© UCLES 2023 Page 7 of 9",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q10",
      "question_id": "9618-2023-on-31-q10",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 10,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark per mark point (Max 3) 3\nMP1 Correct constant declaration\nMP2 Two correct variable declarations\nMP3 Correct array declaration\nExample answer:\nCONSTANT Capacity = 25\nDECLARE BasePointer : INTEGER\nDECLARE TopPointer : INTEGER\nDECLARE Stack : ARRAY[1:25] OF REAL\n\n10(b) One mark for each correctly completed line (Max 5) 5\n// popping an item from the stack\nFUNCTION Pop() RETURNS REAL\nDECLARE Item : REAL\nItem  0\nIF TopPointer >= BasePointer THEN\nItem  Stack[TopPointer]\nTopPointer  TopPointer – 1\nELSE\nOUTPUT \"The stack is empty – error\"\nENDIF\nRETURN Item\nENDFUNCTION\n\n10(c) One mark per mark point (Max 2) 2\nMP1 A queue is a first in first out / FIFO data structure and a stack is a first\nin last out / FILO / LIFO data structure // Data is removed from a\nqueue in the order it is received and removed from a stack in the\nreverse order to which it is received\nMP2 Both ADTs can vary in size / are of indeterminate length\nMP3 Data is popped and pushed (onto/from a stack) at the same end but\nit is enqueued and dequeued (to/from a queue) at different/opposite\nends // a queue has two accessible ends and a stack has only one\nMP4 A stack has only one moveable pointer whereas a queue has two.\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p08.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q11",
      "question_id": "9618-2023-on-31-q11",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 11,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark for each correctly completed clause (Max 3) 3\n(22) student(anthony).\n(23) choice1(anthony, history).\n(24) choice2(anthony, geography).\n\n11(b) X = tomaz, pietre, nico 1\n© UCLES 2023 Page 8 of 9\n\n11(c) One mark per mark point (Max 4) 4\n• student(N)\n• subject(S)\n• choice1(N, S)\n• all logical operators correct with no additional code (see example\nanswers)\nExample answers:\nmay_choose_subject(N, S)\nIF student(N) AND subject(S) AND NOT choice1(N, S)\nmay_choose_subject(N, S)\nIF NOT choice1(N, S), student(N), subject(S)\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p08.png",
        "../answer-assets/9618_w23_ms_31-p09.png"
      ]
    },
    {
      "id": "9618-2023-on-31-q12",
      "question_id": "9618-2023-on-31-q12",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 12,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "12 One mark per mark point (Max 4) 4\nMP1 An artificial neural network is the component of artificial intelligence\nthat is meant to simulate the functioning of a biological brain.\nMP2 Artificial neural networks are a key component of machine learning.\nMP3 They can solve problems that would prove impossible or difficult for\nhumans // Artificial neural networks have self-learning capabilities\nthat enable them to produce better results as more data becomes\navailable\nMP4 Artificial neural networks can be layered (input, hidden and output\nlayers) // Artificial neural networks have many interconnected layers,\nsome / many of which are hidden\nMP5 Weights are assigned between nodes\nMP6 Weights are adjusted through training to give a more accurate result\nMP7 More complex learning capabilities / more accurate results are\navailable with larger numbers of hidden layers\n© UCLES 2023 Page 9 of 9",
      "source_pages": [
        9
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_31.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_31-p09.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q01",
      "question_id": "9618-2023-on-32-q01",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point (Max 1) 3\n• conversion of −96.75 to binary e.g., positive 96.75, flip the bits + 1 to give\n10011111.01\n// –128 + 16 + 8 + 4 + 2 + 1 + 0.25 / ¼ seen\nOne mark per mark point (Max 2)\n• correct mantissa\n• correct exponent\nMantissa Exponent\n\n1 0 0 1 1 1 1 1 0 1 0 0 0 1 1 1\n\n1(b) One mark per mark point (Max 3) 3\nMP1 Real numbers (can) have a fractional part (such as 1/3 and ½) / (such\nas 0.4 and 0.25)\nMP2 The fixed length of the storage means that you can’t store very large /\nvery small numbers\nMP3 Binary numbers represent numbers based on powers of 2, with limited\nfractional representations such as 1/2, 1/4, 1/8, 1/16, etc.\nMP4 It isn’t possible to store all fractions with the level of precision provided\nby this system\nMP5 …the fractional part of the number is as close as possible within these\nconstraints.\nQuestion Answer Marks",
      "source_pages": [
        3
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p03.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q02",
      "question_id": "9618-2023-on-32-q02",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 2,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "2 One mark per mark point – composite (Max 2) 4\nMP1 A (user defined) data type that is a collection of data that can consist\nof multiple elements\nMP2 …of different or the same data types\nMP3 …grouped under a single identifier.\nOne mark per mark point – non-composite (Max 2)\nMP4 It can be defined without referencing another data type.\nMP5 It can be a primitive type available in a programming language, or a\nuser- defined type.\nQuestion Answer Marks",
      "source_pages": [
        3
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p03.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q03",
      "question_id": "9618-2023-on-32-q03",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 3,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per mark point (Max 2) 2\nMP1 A collision is when the two values / data items in the key field for two\nrecords (pass through a hashing algorithm and) result in the same\nhash value\nMP2 …so the location identified (by the hashing algorithm) may already be\nin use // two records cannot occupy the same address.\n© UCLES 2023 Page 3 of 9\n\n3(b) One mark per mark point (Max 3) 3\nMP1 A process of collision resolution is used\nMP2 Start at the original hashed storage space\nMP3 …go through the following spaces in a linear fashion\nMP4 …and store the data item in the first available slot.\nOR\nMP5 Search the overflow area\nMP6 …go through the following spaces in a linear fashion\nMP7 …and store the data item in the first available slot.\nOR\nMP8 Each storage space holds a reference to a collection / chain of items\nMP9 …which can be searched individually.\nMP10 The data item is stored in the first available space in this chain.\nQuestion Answer Marks",
      "source_pages": [
        3,
        4
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p03.png",
        "../answer-assets/9618_w23_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q04",
      "question_id": "9618-2023-on-32-q04",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 4,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "4 One mark for each correct word (Max 3) 3\nThe protocols in a stack determine the interconnectivity rules for a layered\nnetwork model such as the TCP/IP model.\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q05",
      "question_id": "9618-2023-on-32-q05",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark per mark point (Max 2) 2\nMP1 Virtual memory is used when RAM is running low\nMP2 …such as when a computer is running many processes at once.\nMP3 Virtual memory may be used for efficient use of RAM / the processor\nMP4 …such as if data / programs are not immediately needed, they can be\nmoved from RAM to virtual memory\n\n5(b) One mark per mark point (Max 3) 3\nMP1 Disk thrashing is a problem that may occur when frequent transfers\nbetween main memory and secondary memory take place // Disk\nthrashing is a problem that may occur when virtual memory is being\nused\nMP2 As main memory fills up, more pages need to be swapped in and out\nof secondary/virtual memory\nMP3 This swapping leads to a very high rate of hard disk head movements\nMP4 Eventually, more time is spent swapping the pages/data than\nprocessing the data.\n© UCLES 2023 Page 4 of 9",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q06",
      "question_id": "9618-2023-on-32-q06",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 6,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark per ring (Max 4). 4\n5\n3 2 10 10 2\n20 20 60 60 30 30 30 30 60\nOR\n20 3 60 2 30 10 5 2 60\n20 60 30 10 30\n30\n\n6(b) One mark per mark point (Max 3) 3\nMP1 The (RPN) expression is read from left to right, one item at a time\nMP2 Each element is checked to see if it as operator or a value\nMP3 Values are pushed onto a stack until an operator is found\nMP4 The operator is applied to the last two values on the stack and the\nresult is pushed back onto the stack\nMP5 This repeats until a single value remains, which is the solution.\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q07",
      "question_id": "9618-2023-on-32-q07",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "7(a) A B C X 1\n0 0 0 1\n0 0 1 0\n0 1 0 0\n0 1 1 0\n1 0 0 0\n1 0 1 0\n1 1 0 0\n1 1 1 0\n\n7(b) X= A.B.C 1\n© UCLES 2023 Page 5 of 9\n\n7(c) (Max 2) for correct working from points shown 3\n(T =) X.Y.Z + X.Y.Z + X\nDistributive law\n(T=) X.Z.(Y + Y) + X\nComplement law\n(T=) X.Z.(1) + X\nIdentity law\n(T=) X.Z + X\nRedundancy law (to get final answer)\nOne mark for correct answer\n(T=) X + Z\nQuestion Answer Marks",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p05.png",
        "../answer-assets/9618_w23_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q08",
      "question_id": "9618-2023-on-32-q08",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 8,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "8 One mark per mark point - working (Max 3) 5\nMay be seen on diagram or in working section\nMP1 Initialisation – setting Start to 0\nMP2 …and the rest of the towns to\nMP3 Evidence to show values at nodes being updated\nMP4 Evidence to show ‘visited node(s)’\nMP5 Evidence to show a correct calculation of at least one route\nMP6 Evidence to show more than one route has been calculated for at\nleast one town\nCorrect Answers (Max 2)\nTwo marks for all six correct values\nOne mark for four or five correct values.\nA B C D E F\n\n8 12 19 14 16 10\nQuestion Answer Marks",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q09",
      "question_id": "9618-2023-on-32-q09",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 9,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 13,
      "status": "available",
      "reason": null,
      "text": "9(a)(i) Two marks for all five empty boxes correct 2\nOne mark for any three or four empty boxes correct\nIdentifier Data type Description\nBasePointer INTEGER Points to the bottom of the stack\nTopPointer INTEGER Points to the top of the stack\nStack REAL List of decimal numbers stored in the stack\n© UCLES 2023 Page 6 of 9\n\n9(a)(ii) One mark for each correctly completed line (Max 5) 5\nCONSTANT MaxSize = 40\nDECLARE BasePointer : INTEGER\nDECLARE TopPointer : INTEGER\nDECLARE Stack : ARRAY[1:40] OF REAL\n// initialisation of stack\nPROCEDURE Initialise()\nBasePointer  1\nTopPointer  0\nENDPROCEDURE\n// adding an item to the stack\nPROCEDURE Push(NewItem)\nIF TopPointer < MaxSize THEN\nTopPointer  TopPointer + 1\nStack[TopPointer]  NewItem\nENDIF\nENDPROCEDURE\n\n9(b) One mark for linked list and one mark for array (Max 2) 2\nLinked list\nMP1 A linked list is a dynamic data structure / not restricted in size\nMP2 Has greater freedom to expand or contract by adding or removing\nnodes as necessary\nMP3 Allows more efficient editing using pointers (instead of moving the\ndata).\nArray\nMP4 An array is a static data structure1 generally fixed in size\nMP5 When the array is full, the stack cannot be extended any further.\n\n9(c) One mark per mark point (Max 1) 4\nMP1 The compiler must produce object code to\nOne mark per mark point (Max 3)\nMP2 …push return addresses / values of local variables onto a stack\nMP3 …with each recursive call // … to set up winding\nMP4 …pop return addresses / values of local variables off the stack …\nMP5 …after the base case is reached // … to implement unwinding.\n© UCLES 2023 Page 7 of 9",
      "source_pages": [
        6,
        7
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p06.png",
        "../answer-assets/9618_w23_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q10",
      "question_id": "9618-2023-on-32-q10",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 10,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "10 One mark per mark point – SIMD (Max 2) 4\nMP1 Single Instruction, Multiple Data (architecture) // Performs the same\noperation on multiple different data streams simultaneously.\nMP2 The instructions can be performed sequentially, taking advantage of\npipelining.\nMP3 Parallel computers with multiple processors.\nOne mark per mark point – MISD (Max 2)\nMP4 Multiple Instruction, Single Data (architecture) // Performs different\noperations on the same data stream.\nMP5 Each processor works on the same data stream independently.\nMP6 Parallel computers with multiple processors.\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p08.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q11",
      "question_id": "9618-2023-on-32-q11",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 11,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark for each correctly completed clause (Max 4) 4\n20 person(carlos).\n21 hobby(cycling).\n22 enjoys(carlos, cycling).\n23 dislikes(carlos, music).\n\n11(b) P = toby, nina 1\n\n11(c) One mark per mark point (Max 4) 4\n• person(N)\n• hobby(H)\n• dislikes(N, H)\n• all logical operators correct with no additional code (see example\nanswers)\nExample answers:\nmight_enjoy(N, H)\nIF person(N) AND hobby(H) AND NOT dislikes(N, H)\nmight_enjoy(N, H)\nIF NOT dislikes(N, H), person(N), hobby(H)\n© UCLES 2023 Page 8 of 9",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p08.png"
      ]
    },
    {
      "id": "9618-2023-on-32-q12",
      "question_id": "9618-2023-on-32-q12",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 12,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "12(a) One mark for description, for example: 2\nAn exception is an event that occurs during the execution of a program that\ndisrupts the normal flow of instructions / causes the program to halt execution\nOne mark for example:\n• Hardware failure // hard disk crash\n• Programming error // trying to access out-of-bounds array element // divide\nby zero error // runtime error\n• User error // typing incorrect filename / data type\n\n12(b) One mark for each correctly completed blank (Max 7) 7\nDECLARE Customer : TAccount\nDECLARE Location : INTEGER\nDECLARE MaxSize : INTEGER\nDECLARE: FoundFlag : BOOLEAN\nDECLARE SearchCustomer : STRING\nMaxSize  1000\nOPENFILE \"AccountRecord.dat\" FOR RANDOM\nLocation  1\nFoundFlag  FALSE\nOUTPUT \"Enter the customer’s name\"\nINPUT SearchCustomer\nWHILE NOT FoundFlag AND Location <= MaxSize\nSEEK \"AccountRecord.dat\", Location\nGETRECORD \"AccountRecord.dat\", Customer\nIF SearchCustomer = Customer.Name THEN\nOUTPUT \"Customer found: \"\nOUTPUT Customer\nFoundFlag  TRUE\nENDIF\nLocation  Location + 1\nENDWHILE\nIF NOT FoundFlag THEN\nOUTPUT \"Customer does not exist.\"\nENDIF\n© UCLES 2023 Page 9 of 9",
      "source_pages": [
        9
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q01",
      "question_id": "9618-2023-on-33-q01",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark for working (Max 1) 3\n• conversion of 65.25 to binary seen e.g. 1000001.01 = 65.25 //\n64 + 1 + 0.25 / ¼\nOne mark per mark point (Max 2)\n• correct mantissa\n• correct exponent\nMantissa Exponent\n0 1 0 0 0 0 0 1 0 1 0 0 0 1 1 1\n\n1(b) One mark per mark point (Max 2) 2\nMP1 the decimal fraction 0.20 cannot be represented exactly (the closest\nis 0.25 / 0.1875)\nMP2 therefore, there will be a loss of precision due to a rounding\nerror/truncation\nQuestion Answer Marks",
      "source_pages": [
        3
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p03.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q02",
      "question_id": "9618-2023-on-33-q02",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 2,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark for each correct line connecting a protocol to its most appropriate 4\ndescription (Max 4).\nProtocol Use\nto provide peer-to-peer file sharing\nHTTP\nwhen retrieving email messages from a\nmail server over a TCP/IP connection\nBitTorrent\nwhen transmitting hypertext\ndocuments\nSMTP\nto map MAC addresses onto IP\naddresses\nIMAP\nwhen sending email messages\ntowards the intended destination\n\n2(b) One mark per mark point (Max 2) 2\nMP1 To ensure correct network protocols are followed\nMP2 To enable the upper layers to access the physical medium //\nenables connection/ communication with the internet / network layer\nMP3 To be responsible for transporting data within the network/local\nsegments\nMP4 To format the data into frames for transmission\nMP5 Maps IP addresses to MAC/Physical addresses.\n© UCLES 2023 Page 3 of 9",
      "source_pages": [
        3
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p03.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q03",
      "question_id": "9618-2023-on-33-q03",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 3,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "3 One mark per mark point – enumerated type (Max 2) 4\nMP1 A user-defined non-composite (data type) (only award once)\nMP2 …with a list of all possible values\nMP3 …that is ordered.\nOne mark per mark point – pointer type (Max 2)\nMP4 A user-defined non-composite (data type) (only award once)\nMP5 …that stores addresses/memory locations only\nMP6 …and indicates the type of data stored in the memory location.\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q04",
      "question_id": "9618-2023-on-33-q04",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 4,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark per mark point – sequential (Max 2) 4\nMP1 Records (in the file) are ordered\nMP2 …based on the key field\nMP3 A new version (of the file) has to be created to update the file\nOne mark per mark point – random (Max 2)\nMP4 Records are stored in no particular order within the file // There is no\nsequencing in the placement of the records\nMP5 There is a relationship between the key of the record and its location\nwithin the file // a hashing algorithm is used to find the location of the\nrecord\nMP6 Updates to the file can be carried out directly.\n\n4(b) One mark per mark point (Max 2) 2\nMP1 Start at the beginning of the file\nMP2 …check records linearly\nMP3 …until the desired record is found // … processing / updating records\nas required //… EOF found.\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q05",
      "question_id": "9618-2023-on-33-q05",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 5,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "5 One mark per mark point – SISD (Max 2) 4\nMP1 Single Instruction, Single Data (architecture). // Data is taken from a\nsingle source and a single instruction is performed on the data.\nMP2 Contains one processor, a control unit and a memory unit.\nMP3 …that executes instructions sequentially.\nOne mark per mark point – MIMD (Max 2)\nMP4 Multiple Instruction, Multiple Data (architecture). // At any time, any\nprocessor can execute different instructions on different sets of data.\nMP5 Contains many processors\nMP6 …that operate asynchronously / independently.\n© UCLES 2023 Page 4 of 9",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q06",
      "question_id": "9618-2023-on-33-q06",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for every shaded block of rows for column Z correct (Max 3) 3\nA B C D Z\n0 0 0 0 1\n0 0 0 1 0\n0 0 1 0 1\n0 0 1 1 0\n0 1 0 0 1\n0 1 0 1 0\n0 1 1 0 1\n0 1 1 1 0\n1 0 0 0 1\n1 0 0 1 0\n1 0 1 0 1\n1 0 1 1 0\n1 1 0 0 1\n1 1 0 1 0\n1 1 1 0 0\n1 1 1 1 0\n\n6(b) One mark for correct working from points (Max 2), for example: 3\n(Y =) A.B.C.D + A.B.C.D + A.B.C.D + A.B.C.D\n(Y =) A.D.(B.C + B.C + B.C + B.C)\n(Y =) A.D.(B.(C + C) + B.(C + C))\n(Y =) A.D.(B.(1) + B.(1))\n(Y =) A.D.(B + B)\n(Y =) A.D.(1)\nOne mark for correct answer\n(Y =) A.D\n© UCLES 2023 Page 5 of 9",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p05.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q07",
      "question_id": "9618-2023-on-33-q07",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 7,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark for a benefit (Max 1) e.g. 2\nMP1 The user interface hides the complexities of the computer\nhardware/operating system from the user\nMP2 It provides appropriate access systems for users with differing needs\nMP3 Complex commands involving memory locations/buses/computer\nhardware/ are avoided\nOne mark for a valid example (Max 1) e.g.\nClicking on icon rather than writing code\nUsing a graphical user interface / icons for navigation\n\n7(b) Blocked (state) 1\n\n7(c) One mark per mark point (Max 2) 2\nMP1 When the time slice of the running process expires (round robin).\nMP2 …and there is a process with a higher priority in the ready queue, the\nrunning process is pre-empted\nMP3 When an interrupt arrives at the CPU, (the process running on the\nCPU gets pre-empted).\nQuestion Answer Marks",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q08",
      "question_id": "9618-2023-on-33-q08",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 8,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correctly completed line (Max 5) 5\nDECLARE Customer : TAccount\nDECLARE Location : INTEGER\nDECLARE AccountFile : STRING\nAccountFile  \"AccountRecords.dat\"\nOPENFILE AccountFile FOR RANDOM\nOUTPUT \"Please enter an account number\"\nINPUT Customer.AccountNumber\nLocation  Hash(Customer.AccountNumber)\nSEEK AccountFile, Location\nGETRECORD AccountFile, Customer\nOUTPUT Customer\nCLOSEFILE AccountFile\n\n8(b) One mark for correct definition 1\n(Exception handling is the process of) responding to an unexpected event\nwhen the program is running so it does not halt unexpectedly\n\n8(c) One mark per mark point (Max 2), for example: 2\n• Programming errors\n• User errors\n• Hardware failure\n• Runtime errors\n© UCLES 2023 Page 6 of 9",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q09",
      "question_id": "9618-2023-on-33-q09",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 9,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "9(a)(i) One mark per mark point (Max 2) 2\n• (5 – 2)\n• * (5 + 4) / 9\nFinal correct expression\n(5 – 2) * (5 + 4) / 9\n\n9(a)(ii) One mark per ring (Max 4) 4\n4\n2 5 5 9 9\n5 5 3 3 3 3 27 27 3\nOR\n5 2 3 5 4 9 27 9 3\n5 3 5 3 27\n3\n\n9(b) One mark per mark point (Max 3) 3\nMP1 Evaluate the RPN expression from left to right\nMP2 Push each element of the RPN expression onto the stack in order\nuntil an operator is reached\nMP3 Pop the last two elements from the stack and apply the operator\nMP4 Push the result of the operation onto the stack\nMP5 Repeat the process until the whole expression is evaluated.\n© UCLES 2023 Page 7 of 9",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q10",
      "question_id": "9618-2023-on-33-q10",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 10,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark per mark point (Max 3) 3\nMP1 Correct constant declaration\nMP2 Two correct variable declarations\nMP3 Correct array declaration\nExample answer:\nCONSTANT Capacity = 25\nDECLARE BasePointer : INTEGER\nDECLARE TopPointer : INTEGER\nDECLARE Stack : ARRAY[1:25] OF REAL\n\n10(b) One mark for each correctly completed line (Max 5) 5\n// popping an item from the stack\nFUNCTION Pop() RETURNS REAL\nDECLARE Item : REAL\nItem  0\nIF TopPointer >= BasePointer THEN\nItem  Stack[TopPointer]\nTopPointer  TopPointer – 1\nELSE\nOUTPUT \"The stack is empty – error\"\nENDIF\nRETURN Item\nENDFUNCTION\n\n10(c) One mark per mark point (Max 2) 2\nMP1 A queue is a first in first out / FIFO data structure and a stack is a first\nin last out / FILO / LIFO data structure // Data is removed from a\nqueue in the order it is received and removed from a stack in the\nreverse order to which it is received\nMP2 Both ADTs can vary in size / are of indeterminate length\nMP3 Data is popped and pushed (onto/from a stack) at the same end but\nit is enqueued and dequeued (to/from a queue) at different/opposite\nends // a queue has two accessible ends and a stack has only one\nMP4 A stack has only one moveable pointer whereas a queue has two.\nQuestion Answer Marks",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p08.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q11",
      "question_id": "9618-2023-on-33-q11",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 11,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark for each correctly completed clause (Max 3) 3\n(22) student(anthony).\n(23) choice1(anthony, history).\n(24) choice2(anthony, geography).\n\n11(b) X = tomaz, pietre, nico 1\n© UCLES 2023 Page 8 of 9\n\n11(c) One mark per mark point (Max 4) 4\n• student(N)\n• subject(S)\n• choice1(N, S)\n• all logical operators correct with no additional code (see example\nanswers)\nExample answers:\nmay_choose_subject(N, S)\nIF student(N) AND subject(S) AND NOT choice1(N, S)\nmay_choose_subject(N, S)\nIF NOT choice1(N, S), student(N), subject(S)\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p08.png",
        "../answer-assets/9618_w23_ms_33-p09.png"
      ]
    },
    {
      "id": "9618-2023-on-33-q12",
      "question_id": "9618-2023-on-33-q12",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 12,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "12 One mark per mark point (Max 4) 4\nMP1 An artificial neural network is the component of artificial intelligence\nthat is meant to simulate the functioning of a biological brain.\nMP2 Artificial neural networks are a key component of machine learning.\nMP3 They can solve problems that would prove impossible or difficult for\nhumans // Artificial neural networks have self-learning capabilities\nthat enable them to produce better results as more data becomes\navailable\nMP4 Artificial neural networks can be layered (input, hidden and output\nlayers) // Artificial neural networks have many interconnected layers,\nsome / many of which are hidden\nMP5 Weights are assigned between nodes\nMP6 Weights are adjusted through training to give a more accurate result\nMP7 More complex learning capabilities / more accurate results are\navailable with larger numbers of hidden layers\n© UCLES 2023 Page 9 of 9",
      "source_pages": [
        9
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_33.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_33-p09.png"
      ]
    },
    {
      "id": "9618-2023-on-41-q01",
      "question_id": "9618-2023-on-41-q01",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 16,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) One mark each to max 5 5\n• Function header (and end where appropriate) taking one string parameter\n• Calculating length of parameter string\n• Looping correct number of times\n• Checking the first character against all vowels\n• Accessing the remainder of the string\n• Remainder of function correct with nothing extra i.e. totalling, must match structure of given algorithm\n© UCLES 2023 Page 4 of 37\n\n9618/41 Cambridge International AS & A Level – Mark Scheme October/November 2023\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nJava\npublic static Integer IterativeVowels(String Value){\nInteger Total = 0;\nInteger LengthString = Value.length();\nchar FirstCharacter;\nfor(Integer X = 0; X < LengthString; X++){\nFirstCharacter = Value.charAt(0);\nif(FirstCharacter == 'a' || FirstCharacter == 'e' || FirstCharacter =='i' || FirstCharacter == 'o'\n|| FirstCharacter == 'u'){\nTotal++;\n}\nValue = Value.substring(1, Value.length());\n}\nreturn Total;\n}\nVB.NET\nFunction IterativeVowels(Value)\nDim Total As Integer = 0\nDim FirstCharacter As Char\nFor x = 0 To Len(Value) - 1\nFirstCharacter = Left(Value, 1)\nIf FirstCharacter = \"a\" Or FirstCharacter = \"e\" Or FirstCharacter = \"i\" Or FirstCharacter = \"o\" Or\nFirstCharacter = \"u\" Then\nTotal = Total + 1\nEnd If\nValue = Right(Value, Len(Value) - 1)\nNext\nReturn Total\nEnd Function\n© UCLES 2023 Page 5 of 37\n\n1(a)(ii) One mark each 2\n• Calling the function with \"house\"\n• Outputting the return value\nExample program code:\nJava\nSystem.out.println(IterativeVowels(\"house\"));\nVB.NET\nConsole.WriteLine(IterativeVowels(\"house\"))\nPython\nprint(IterativeVowels(\"house\"))\n\n1(a)(iii) One mark for screenshot outputting 3 1\n\n1(b)(i) One mark each 6\n• Recursive call\n• Function header (and end where appropriate) taking string parameter (returning integer where given)\n• Base case checking (length is 0) and returning 0\n• Extracting first character and checking if a vowel …\n• … if it is a vowel, returning 1 + recursive call with 1 less character\n• … if not a vowel, return recursive call with 1 less character\n© UCLES 2023 Page 6 of 37\n\n9618/41 Cambridge International AS & A Level – Mark Scheme October/November 2023\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nJava\npublic static Integer RecursiveVowels(String Value){\nchar FirstCharacter;\nif(Value.length() == 0){\nreturn 0;\n}else{\nFirstCharacter = Value.charAt(0);\nif(FirstCharacter == 'a' || FirstCharacter == 'e' || FirstCharacter =='i' || FirstCharacter == 'o'\n|| FirstCharacter == 'u'){\nreturn 1 + RecursiveVowels(Value.substring(1, Value.length()));\n}else{\nreturn RecursiveVowels(Value.substring(1, Value.length()));\n}\n}\n}\nVB.NET\nFunction RecursiveVowels(Value)\nDim firstCharacter As Char\nIf Len(Value) = 0 Then\nReturn 0\nElse\nfirstCharacter = Left(Value, 1)\nIf firstCharacter = \"a\" Or firstCharacter = \"e\" Or firstCharacter = \"i\" Or firstCharacter = \"o\" Or\nfirstCharacter = \"u\" Then\nReturn 1 + RecursiveVowels(Right(Value, Len(Value) - 1))\nElse\nReturn RecursiveVowels(Right(Value, Len(Value) - 1))\n© UCLES 2023 Page 7 of 37\n\n1(b)(ii) One mark for calling recursive function with \"imagine\" and outputting return value 1\nExample program code:\nJava\nSystem.out.println(RecursiveVowels(\"imagine\"));\nVB.NET\nConsole.WriteLine(RecursiveVowels(\"imagine\"))\nPython\nprint(RecursiveVowels(\"imagine\"))\n\n1(b)(iii) One mark for screenshot showing 4 1\n© UCLES 2023 Page 8 of 37",
      "source_pages": [
        4,
        5,
        6,
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_41-p04.png",
        "../answer-assets/9618_w23_ms_41-p05.png",
        "../answer-assets/9618_w23_ms_41-p06.png",
        "../answer-assets/9618_w23_ms_41-p07.png",
        "../answer-assets/9618_w23_ms_41-p08.png"
      ]
    },
    {
      "id": "9618-2023-on-41-q02",
      "question_id": "9618-2023-on-41-q02",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 29,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) One mark each 2\n• (Global) array with identifier Queue with (minimum) 50 elements (of type string)\n• TailPointer (integer) initialised to 0, HeadPointer (integer) initialised to -1\nExample program code:\nJava\npublic static String[] Queue = new String[50];\npublic static Integer HeadPointer = -1;\npublic static Integer TailPointer = 0;\nVB.NET\nDim Queue(50) As String\nDim HeadPointer As Integer\nDim TailPointer As Integer\nSub Main(args As String())\nHeadPointer = -1\nTailPointer = 0\nEnd Sub\nPython\nglobal Queue #string 50 elements\nglobal HeadPointer\nglobal TailPointer\n#main\nQueue = []\nHeadPointer = -1\nTailPointer = 0\n© UCLES 2023 Page 9 of 37\n\n2(a)(ii) One mark each 4\n• Procedure Enqueue() header (and close where appropriate) with one (string) parameter\n• Checking if queue is full and outputting suitable message\n• … otherwise inserting parameter to next space\n• … increment TailPointer and set HeadPointer to 0 if first item (HeadPointer = -1)\nExample program code:\nJava\npublic static void Enqueue(String Value){\nif(TailPointer == 50){\nSystem.out.println(\"Queue full\");\n}else{\nQueue[TailPointer] = Value;\nTailPointer++;\nif(HeadPointer == -1){ HeadPointer = 0;}\n}\n}\nVB.NET\nSub Enqueue(Data)\nIf TailPointer = 50 Then\nConsole.WriteLine(\"Queue full\")\nElse\nQueue(TailPointer) = Data\nTailPointer = TailPointer + 1\nIf (HeadPointer = -1) Then\nHeadPointer = 0\nEnd If\nEnd If\nEnd Sub\n© UCLES 2023 Page 10 of 37\n\n2(a)(ii) Python\ndef Enqueue(Data):\nglobal TailPointer\nglobal HeadPointer\nglobal Queue\nif TailPointer == 50:\nprint(\"Queue full\")\nelse:\nQueue.append(Data)\nTailPointer +=1\nif HeadPointer == -1:\nHeadPointer = 0\n© UCLES 2023 Page 11 of 37\n\n2(a)(iii) One mark each to max 4 4\n• Function header Dequeue() (and end where appropriate) with no parameter\n• Checking if empty …\n• … outputting suitable message and returning \"Empty\"\n• (otherwise) incrementing head pointer\n• returning next value (at head pointer before incrementing)\nExample program code:\nJava\npublic static String Dequeue(){\nif(HeadPointer == -1 || HeadPointer == TailPointer){\nSystem.out.println(\"Queue empty\");\nreturn \"Empty\";\n}else{\nHeadPointer ++;\nreturn Queue[HeadPointer - 1];}}\nVB.NET\nFunction Dequeue()\nIf HeadPointer = -1 Or HeadPointer = TailPointer Then\nConsole.WriteLine(\"Queue empty\")\nReturn \"Empty\"\nElse\nHeadPointer = HeadPointer + 1\nReturn Queue(HeadPointer - 1)\nEnd If\nEnd Function\n© UCLES 2023 Page 12 of 37\n\n2(a)(iii) Python\ndef Dequeue():\nglobal Queue\nglobal HeadPointer\nif HeadPointer == -1 or HeadPointer == TailPointer:\nprint(\"Queue empty\")\nreturn \"Empty\"\nelse:\nHeadPointer +=1\nreturn Queue[HeadPointer - 1]\n© UCLES 2023 Page 13 of 37\n\n2(b) One mark each to max 6 6\n• Procedure header ReadData() with no parameters\n• Opening file …\n• … and closing file\n• Looping until EOF/set amount\n• Reading in each value\n• … calling Enqueue() with each value\n• Use of exception handling with appropriate output\nExample program code:\nJava\npublic static void ReadData(){\ntry{\nScanner Scanner1 = new Scanner(new File(\"QueueData.txt\"));\nwhile(Scanner1.hasNextLine()){\nEnqueue(Scanner1.next());\n}\nScanner1.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\n}\nVB.NET\nSub ReadData()\nTry\nDim DataReader As New System.IO.StreamReader(\"QueueData.txt\")\nDo Until DataReader.EndOfStream\nEnqueue(DataReader.ReadLine())\n© UCLES 2023 Page 14 of 37\n\n2(b) Loop\nDataReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"No file\")\nEnd Try\nEnd Sub\nPython\ndef ReadData():\ntry:\nDataFile = open(\"QueueData.txt\")\nfor Line in DataFile:\nEnqueue(Line.strip())\nDataFile.close()\nexcept IOError:\nprint(\"No file\")\n© UCLES 2023 Page 15 of 37\n\n2(c)(i) One mark each 2\n• Declaration of record type/class RecordData\n• ID as a string and total as an Integer\nExample program code:\nJava\nclass RecordData{\npublic String ID;\npublic Integer Total;\npublic RecordData(String IDP, Integer TotalP){\nID = IDP;\nTotal = TotalP;\n} }\nVB.NET\nStructure RecordData\nDim ID As String\nDim Total As Integer\nEnd Structure\nPython\nclass RecordData:\n#self. ID string\n#self. Total integer\ndef init (self, IDP, TotalP):\nself. ID = IDP\nself. Total = TotalP\n© UCLES 2023 Page 16 of 37\n\n2(c)(i) def SetID(self, Value):\nself. ID = Value\ndef GetID(self):\nreturn self. ID\ndef SetTotal(self, Value):\nself. Total = Value\ndef GetTotal(self): return self. Total\n\n2(c)(ii) One mark each 2\n• (global) 1D Array named Records of type RecordData\n• (global) NumberRecords declared as integer and initialised to 0\nExample program code:\nJava\npublic static RecordData[] Records = new RecordData[50]; public static Integer\nNumberRecords = 0;\nVB.NET\nDim Records(49) As RecordData Dim NumberRecords As Integer\nSub Main(args As String())\nNumberRecords = 0\nEnd Sub\nPython\n#main\nRecords = [] #50 elements of type RecordData NumberRecords = 0\n© UCLES 2023 Page 17 of 37\n\n2(c)(iii) One mark each to max 5 5\n• Incrementing NumberRecords each time (twice) a new record is added\n• Procedure header (and end) and using Dequeue() and storing/using return value\nDataAccessed  Dequeue()\n• Checking if NumberRecords is 0 and creating a new record with ID and total as 1:\nIF NumberRecords = 0 THEN\nRecords[NumberRecords].ID  DataAccessed\nRecords[NumberRecords].Total  1\nFlag  TRUE\n• Looping through all array elements to find matching ID and incrementing total if found\nFOR X  0 TO NumberRecords – 1 Check Python loop end\nIF Records[X].ID = DataAccessed THEN\nRecords[X].Total  Records[X].Total + 1\nFlag  TRUE\nENDIF\nNEXT X\n• Adding new record if record is not found, storing ID and total as 1\nIF Flag = FALSE THEN\nRecords[NumberRecords].ID  DataAccessed\nRecords[NumberRecords].Total  1\nNumberRecords  NumberRecords + 1\nENDIF\n© UCLES 2023 Page 18 of 37\n\n2(c)(iii) • Example program code:\nJava\npublic static void TotalData(){\nString DataAccessed = Dequeue();\nBoolean Flag = false;\nif(NumberRecords == 0){\nRecords[NumberRecords] = new RecordData(DataAccessed, 1);\nNumberRecords ++;\nFlag = true;\n}else{\nfor(Integer X = 0; X < NumberRecords; X++){\nif(Records[X].ID.equals(DataAccessed)){\nRecords[X].Total++;\nFlag = true;\n}\n}\n}\nif(Flag == false){\nRecords[NumberRecords] = new RecordData(DataAccessed, 1);\nNumberRecords ++;\n}\n}\nVB.NET\nSub TotalData()\nDim DataAccessed As String\nDim Flag As Boolean = False\nDataAccessed = Dequeue()\n© UCLES 2023 Page 19 of 37\n\n2(c)(iii) If NumberRecords = 0 Then\nRecords(NumberRecords).ID = DataAccessed\nRecords(NumberRecords).Total = Records(NumberRecords).Total + 1\nNumberRecords = NumberRecords + 1\nFlag = True\nElse\nFor X = 0 To NumberRecords – 1\nIf Records(X).ID = DataAccessed Then\nRecords(X).Total = Records(X).Total + 1\nFlag = True\nEnd If\nNext\nEnd If\nIf Flag = False Then\nRecords(NumberRecords).ID = DataAccessed\nRecords(NumberRecords).Total = Records(NumberRecords).Total + 1\nNumberRecords = NumberRecords + 1\nEnd If\nEnd Sub\nPython\ndef TotalData():\nglobal NumberRecords\nglobal Records\nFlag = False\nDataAccessed = Dequeue()\nif NumberRecords == 0:\nRecords.append(RecordData(DataAccessed, 1))\n© UCLES 2023 Page 20 of 37\n\n2(c)(iii) NumberRecords += 1\nFlag = True\nelse:\nfor X in range(0, NumberRecords):\nif(Records[X].GetID() == DataAccessed):\nRecords[X].SetTotal(Records[X].GetTotal() + 1)\nFlag = True\nif Flag == False:\nRecords.append(RecordData(DataAccessed, 1))\nNumberRecords += 1\n\n2(d) One mark each 1\n• Looping through all array elements and outputting ID and total in correct format\n© UCLES 2023 Page 21 of 37\n\n9618/41 Cambridge International AS & A Level – Mark Scheme October/November 2023\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nJava\npublic static void OutputRecords(){\nfor(Integer X = 0; X < NumberRecords; X++){\nSystem.out.println(\"ID \", Records[X].ID + \" Total \" + Records[X].Total);\n}\n}\nVB.NET\nSub OutputRecords()\nFor X = 0 To NumberRecords - 1\nConsole.WriteLine(\"ID \" & Records(X).ID & \" Total \" & Records(X).Total)\nNext\nEnd Sub\nPython\ndef OutputRecords():\nfor X in range(0, NumberRecords):\nprint(\"ID\", Records[X].GetID(), \" Total \", Records[X].GetTotal())\n© UCLES 2023 Page 22 of 37\n\n2(e)(i) One mark each 2\n• Calling ReadData() first and OutputRecords() last\n• Looping through all queue elements and calling TotalData() for each queue element\nExample program code:\nJava\npublic static void main(String args[]){\nReadData();\nwhile(HeadPointer != TailPointer){\nTotalData();\n}\nOutputRecords();\n}\nVB.NET\nSub Main(args As String())\nHeadPointer = 0\nTailPointer = 0\nReadData()\nNumberRecords = 0\nWhile HeadPointer <> TailPointer\nTotalData()\nEnd While\nOutputRecords()\nEnd Sub\n© UCLES 2023 Page 23 of 37\n\n2(e)(i) Python\n#main Queue = []\nRecords = []\nHeadPointer = 0\nTailPointer = 0\nReadData()\nNumberRecords = 0\nwhile HeadPointer != TailPointer:\nTotalData()\nOutputRecords()\n\n2(e)(ii) One mark for screenshot e.g. 1\n© UCLES 2023 Page 24 of 37",
      "source_pages": [
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23,
        24
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_41-p09.png",
        "../answer-assets/9618_w23_ms_41-p10.png",
        "../answer-assets/9618_w23_ms_41-p11.png",
        "../answer-assets/9618_w23_ms_41-p12.png",
        "../answer-assets/9618_w23_ms_41-p13.png",
        "../answer-assets/9618_w23_ms_41-p14.png",
        "../answer-assets/9618_w23_ms_41-p15.png",
        "../answer-assets/9618_w23_ms_41-p16.png",
        "../answer-assets/9618_w23_ms_41-p17.png",
        "../answer-assets/9618_w23_ms_41-p18.png",
        "../answer-assets/9618_w23_ms_41-p19.png",
        "../answer-assets/9618_w23_ms_41-p20.png",
        "../answer-assets/9618_w23_ms_41-p21.png",
        "../answer-assets/9618_w23_ms_41-p22.png",
        "../answer-assets/9618_w23_ms_41-p23.png",
        "../answer-assets/9618_w23_ms_41-p24.png"
      ]
    },
    {
      "id": "9618-2023-on-41-q03",
      "question_id": "9618-2023-on-41-q03",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 30,
      "status": "available",
      "reason": null,
      "text": "3(a)(i) One mark each to max 4 4\n• Class header (and end where appropriate)\n• Three attributes with correct names and data types\n• Constructor header (and end where appropriate) with 3 parameters\n• Within constructor, assigns attributes to parameters\nExample program code:\nJava\nclass Character{\nprivate Integer XPosition;\nprivate Integer YPosition;\nprivate String Name;\npublic Character(Integer XPositionP, Integer YPositionP, String NameP){\nXPosition = XPositionP;\nYPosition = YPositionP;\nName = NameP;\n}\n}\nVB.NET\nClass Character\nPrivate XPosition As Integer\nPrivate YPosition As Integer\nPrivate Name As String\nSub New(XPositionP, YPositionP, NameP)\nXPosition = XPositionP\nYPosition = YPositionP\nName = NameP\nEnd Sub\nEnd Class\n© UCLES 2023 Page 25 of 37\n\n3(a)(i) Python\nclass Character:\n#self.XPosition integer\n#self.YPosition integer\n#self.Name string\ndef init (self, XPositionP, YPositionP, NameP):\nself.XPosition = XPositionP\nself.YPosition = YPositionP\nself.Name = NameP\n© UCLES 2023 Page 26 of 37\n\n3(a)(ii) One mark each 3\n• 1 get header with no parameter …\n• … returning correct value\n• 2nd get method\nExample program code:\nJava\npublic Integer GetXPosition(){\nreturn XPosition;\n}\npublic Integer GetYPosition(){\nreturn YPosition;\n}\nVB.NET\nFunction GetXPosition()\nReturn XPosition\nEnd Function\nFunction GetYPosition()\nReturn YPosition\nEnd Function\nPython\ndef GetXPosition(self):\nreturn self. XPosition\ndef GetYPosition(self):\nreturn self. YPosition\n© UCLES 2023 Page 27 of 37\n\n3(a)(iii) One mark each to max 4 4\n• 1 set method header (and end where appropriate) with parameter …\n• … adding parameter to X/Y Position attribute and storing in the X/Y attribute\n• If (resulting value is) more than 10 000 limiting to 10 000 and if less than 0 limiting to 0\n• Second correct set method\nExample program code:\nJava\npublic void SetXPosition(Integer Value){\nXPosition = XPosition + Value;\nif(XPosition > 10000){\nXPosition = 10000;\n}else if(XPosition < 0){\nXPosition = 0;\n}\n}\npublic void SetYPosition(Integer Value){\nYPosition = YPosition + Value;\nif(YPosition > 10000){\nYPosition = 10000;\n}else if(YPosition < 0){\nYPosition = 0;\n}\n}\nVB.NET\nFunction SetXPosition(Value)\nXPosition = XPosition + Value\nIf XPosition > 10000 Then\nXPosition = 10000\n© UCLES 2023 Page 28 of 37\n\n3(a)(iii) ElseIf XPosition < 0 Then\nXPosition = 0\nEnd If\nEnd Function\nFunction SetYPosition(Value)\nYPosition = YPosition + Value\nIf YPosition > 10000 Then\nYPosition = 10000\nElseIf YPosition < 0 Then\nYPosition = 0\nEnd If\nEnd Function\nPython\ndef SetXPosition(self, Value):\nself. XPosition = self. XPosition + Value\nif(self.XPosition > 10000):\nself.XPosition = 10000\nelif self.XPosition < 0:\nself.XPosition = 0\ndef SetYPosition(self, Value):\nself.YPosition = self.YPosition + Value\nif(self.YPosition > 10000):\nself.YPosition = 10000\nelif self.YPosition < 0:\nself.YPosition = 0\n© UCLES 2023 Page 29 of 37\n\n3(a)(iv) One mark each 4\n• Method header with (string) parameter\n• Checking parameter for direction …\n• … using SetYPosition() and SetXPosition() correctly …\n• … with correct parameters\nExample program code:\nJava\npublic void Move(String Direction){\nif(Direction.equals(\"up\")){\nSetYPosition(10);\n}else if(Direction.equals(\"down\")){\nSetYPosition(-10);\n}else if(Direction.equals(\"right\")){\nSetXPosition(10);\n}else{\nSetXPosition(-10);\n}\n}\nVB.NET\nOverridable Sub Move(Direction)\nIf Direction = \"up\" Then\nSetYPosition(10)\nElseIf Direction = \"down\" Then\nSetYPosition(-10)\nElseIf Direction = \"right\" Then\nSetXPosition(10)\nElseIf Direction = \"left\" Then\nSetXPosition(-10)\nEnd If\nEnd Sub\n© UCLES 2023 Page 30 of 37\n\n3(a)(iv) Python\ndef Move(self, Direction):\nif(Direction == \"up\"):\nself.SetYPosition(10)\nelif(Direction == \"down\"):\nself.SetYPosition(-10)\nelif(Direction == \"right\"):\nself.SetXPosition(10)\nelse:\nself.SetXPosition(-10)\n\n3(b) One mark each 2\n• New instance of Character created with identifier Jack …\n• … correct constructor called and values passed\nExample program code:\nJava\nCharacter Jack = new Character(50, 50, \"Jack\");\nVB.NET\nDim Jack As Character = New Character(50, 50, \"Jack\")\nPython\nJack = Character(50, 50, \"Jack\")\n© UCLES 2023 Page 31 of 37\n\n3(c)(i) One mark each 3\n• Class header inheriting from Character\n• Constructor taking all 3 parameters …\n• … calling parent/super constructor with the 3 parameters\nExample program code:\nJava\nclass BikeCharacter extends Character{\npublic BikeCharacter(Integer XPositionP, Integer YPositionP, String NameP){\nsuper(XPositionP, YPositionP, NameP);\n}\n}\nVB.NET\nClass BikeCharacter\nInherits Character\nSub New(XPositionP, YPositionP, NameP)\nMyBase.New(XPositionP, YPositionP, NameP)\nEnd Sub\nEnd Class\nPython\nclass BikeCharacter(Character):\ndef init (self, XPositionP, YPositionP, NameP):\nsuper(). init (XPositionP, YPositionP, NameP)\n© UCLES 2023 Page 32 of 37\n\n3(c)(ii) One mark each 2\n• Method header taking parameter and overriding parent/super Move()\n• Correct changes to method to update values by 20\nExample program code:\nJava\npublic void Move(String Direction){\nif(Direction.equals(\"up\")){\nsuper.SetYPosition(20);\n}else if(Direction.equals(\"down\")){\nsuper.SetYPosition(-20);\n}else if(Direction.equals(\"right\")){\nsuper.SetXPosition(20);\n}else{\nsuper.SetXPosition(-20);\n}\n}\nVB.NET\nOverrides Sub\nMove(Direction) If\nDirection = \"up\" Then\nSetYPosition(20)\nElseIf Direction = \"down\" Then\nSetYPosition(-20)\nElseIf Direction = \"right\" Then\nSetXPosition(20)\nElseIf Direction = \"left\" Then\nSetXPosition(-20)\nEnd If\nEnd Sub\n© UCLES 2023 Page 33 of 37\n\n3(c)(ii) Python\ndef Move(self, Direction):\nif(Direction == \"up\"):\nsuper().SetYPosition(20)\nelif(Direction == \"down\"):\nsuper().SetYPosition(-20)\nelif(Direction == \"right\"):\nsuper().SetXPosition(2)\nelse:\nsuper().SetXPosition(-20)\n\n3(d) One mark each 1\n• Declaring new BikeCharacter with correct values e.g.\nJava\nBikeCharacter Karla = new BikeCharacter(100, 50, \"Karla\");\nVB.NET\nDim Karla As BikeCharacter = New BikeCharacter(100, 50, \"Karla\")\nPython\nKarla = BikeCharacter(100, 50, \"Karla\")\n© UCLES 2023 Page 34 of 37\n\n3(e)(i) One mark each to max 5 5\n• Reading in both values (character and direction) with appropriate prompts\n• Character name is validated as e.g. Jack/Karla, and direction is validated as e.g. up/down/left/right\n• Calling Move() for the character input, with direction input as a parameter\n• Outputting character's new X and Y position in a suitable format …\n• … using get methods\nExample program code:\nJava\nSystem.out.println(\"Would you like to move Jack or Karla?\");\nCharacterToMove = (scanner.nextLine()).toLowerCase();\nwhile(CharacterToMove.equals(\"jack\") == false &&\nCharacterToMove.equals(\"karla\") == false){\nSystem.out.println(\"Invalid, try again\");\nCharacterToMove = (scanner.nextLine()).toLowerCase();\n}\nSystem.out.println(\"Which direction? Up, down, left or right?\");\nDirection = (scanner.nextLine()).toLowerCase();\nwhile(Direction.equals(\"up\") == false && Direction.equals(\"down\") == false\n&& Direction.equals(\"left\") == false && Direction.equals(\"right\")== false){\nSystem.out.println(\"Invalid, try again\");\nDirection = (scanner.nextLine()).toLowerCase();\n}\nif(CharacterToMove.equals(\"jack\")){\nJack.Move(Direction);\nSystem.out.println(\"Jack's new position is X = \"\n+ Jack.GetXPosition() + \" Y = \" + Jack.GetYPosition());\n}else{\nKarla.Move(Direction);\nSystem.out.println(\"Karla's new position is \" +\nKarla.GetXPosition()\n+ \" \" + Karla.GetYPosition());\n}\n© UCLES 2023 Page 35 of 37\n\n3(e)(i) VB.NET\nConsole.WriteLine(\"Would you like to move Jack or Karla?\")\nCharacterToMove = Console.ReadLine.ToLower()\nWhile CharacterToMove <> \"jack\" And CharacterToMove <> \"karla\"\nConsole.WriteLine(\"Invalid try again\")\nCharacterToMove = Console.ReadLine\nEnd While\nConsole.WriteLine(\"Which direction? Up, down, left or right\")\nDirection = Console.ReadLine.ToLower()\nWhile Direction <> \"up\" And Direction <> \"down\" And Direction <> \"left\" And Direction <>\n\"right\"\nConsole.WriteLine(\"Invalid try again\")\nDirection = Console.ReadLine\nEnd While\nIf CharacterToMove = \"jack\"\nThen Jack.Move(Direction)\nConsole.WriteLine(\"Jack's new position is X = \" & Jack.GetXPosition & \" Y = \" &\nJack.GetYPosition)\nElse\nKarla.Move(Direction)\nConsole.WriteLine(\"Karla's new position is X = \" & Karla.GetXPosition & \" Y = \" &\nKarla.GetYPosition)\nEnd If\nConsole.WriteLine(\"Would you like to Continue? Enter True to continue, or anything else to\nquit\")\n© UCLES 2023 Page 36 of 37\n\n3(e)(i) Python\nCharacterToMove = input(\"Would you like to move Jack or Karla?\").lower()\nwhile CharacterToMove != \"jack\" and CharacterToMove != \"karla\":\nCharacterToMove = input(\"Invalid try again\")\nDirection = input(\"Which direction? Up, down, left or right?\")\nwhile Direction != \"up\" and Direction != \"down\" and Direction != \"left\" and Direction !=\n\"right\":\nDirection = input(\"Invalid try again\")\nif CharacterToMove == \"jack\":\nJack.Move(Direction)\nprint(\"Jack's new position is X =\", Jack.GetXPosition(), \"Y =\", Jack.GetYPosition())\nelse:\nKarla.Move(Direction)\nprint(\"Karla's new position is X =\", Karla.GetXPosition(), \"Y =\", Karla.GetYPosition())\n\n3(e)(ii) One mark for each test 2\n© UCLES 2023 Page 37 of 37",
      "source_pages": [
        25,
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_41-p25.png",
        "../answer-assets/9618_w23_ms_41-p26.png",
        "../answer-assets/9618_w23_ms_41-p27.png",
        "../answer-assets/9618_w23_ms_41-p28.png",
        "../answer-assets/9618_w23_ms_41-p29.png",
        "../answer-assets/9618_w23_ms_41-p30.png",
        "../answer-assets/9618_w23_ms_41-p31.png",
        "../answer-assets/9618_w23_ms_41-p32.png",
        "../answer-assets/9618_w23_ms_41-p33.png",
        "../answer-assets/9618_w23_ms_41-p34.png",
        "../answer-assets/9618_w23_ms_41-p35.png",
        "../answer-assets/9618_w23_ms_41-p36.png",
        "../answer-assets/9618_w23_ms_41-p37.png"
      ]
    },
    {
      "id": "9618-2023-on-42-q01",
      "question_id": "9618-2023-on-42-q01",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 27,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) One mark each 2\n• Two arrays with correct identifiers of type string/character\n• Each has 100 elements\nExample program code:\nJava\npublic static String[] StackVowel = new String[100];\npublic static String[] StackConsonant = new String[100];\nVB.NET\nDim StackVowel(0 To 99) As Char\nDim StackConsonant(0 To 99) As Char\nPython\nStackVowel = [] #string 100\nStackConsonant = [] #string 100\n© UCLES 2023 Page 4 of 34\n\n1(a)(ii) One mark for 1\n• Declaring both variables as type integer global and initialised to 0\nExample program code:\nJava\npublic static Integer VowelTop = 0;\npublic static Integer ConsonantTop = 0;\nVB.NET\nDim VowelTop As Integer = 0\nDim ConsonantTop As Integer = 0\nPython\nglobal VowelTop #integer\nglobal ConsonantTop #integer\n#main\nVowelTop = 0\nConsonantTop = 0\n© UCLES 2023 Page 5 of 34\n\n1(b)(i) One mark each 6\n• Procedure PushData() heading (and end where appropriate) taking one parameter\n• Checking if parameter is a (lowercase) vowel …\n• … checking if StackVowel is full and outputting suitable message\n• … otherwise inserting parameter in next position\n• … incrementing VowelTop\n• Repeated for Consonant\nExample program code:\nJava\npublic static void PushData(String Letter){\nif(Letter.equals(\"a\") || Letter.equals(\"e\") || Letter.equals(\"i\") || Letter.equals(\"o\")\n|| Letter.equals(\"u\")){\nif(VowelTop == 100){\nSystem.out.println(\"Vowel stack full\");\n}else{\nStackVowel[VowelTop] = Letter;\nVowelTop++;\n}\n}else{\nif(ConsonantTop == 100){\nSystem.out.println(\"Consonant stack full\");\n}else{\nStackConsonant[ConsonantTop] = Letter;\nConsonantTop++;\n}\n}\n}\n© UCLES 2023 Page 6 of 34\n\n1(b)(i) VB.NET\nSub PushData(Letter As Char)\nIf Letter = \"a\" Or Letter = \"e\" Or Letter = \"i\" Or Letter = \"o\" Or Letter = \"u\" Then\nIf VowelTop = 100 Then\nConsole.WriteLine(\"Vowel stack full\")\nElse\nStackVowel(VowelTop) = Letter\nVowelTop += 1\nEnd If\nElse\nIf ConsonantTop = 100 Then\nConsole.WriteLine(\"Consonant stack full\")\nElse\nStackConsonant(ConsonantTop) = Letter\nConsonantTop += 1\nEnd If\nEnd If\nEnd Sub\nPython\ndef PushData(Letter):\nglobal VowelTop\nglobal ConsonantTop\nif Letter == \"a\" or Letter == \"e\" or Letter == \"i\" or Letter == \"o\" or Letter == \"u\":\nif VowelTop == 100:\nprint(\"Vowel stack full\")\nelse:\nStackVowel.append(Letter)\nVowelTop = VowelTop + 1\nelse:\nif ConsonantTop == 100:\nprint(\"Consonant stack full\")\nelse:\nStackConsonant.append(Letter)\nConsonantTop = ConsonantTop + 1\n© UCLES 2023 Page 7 of 34\n\n1(b)(ii) One mark each 6\n• Procedure header ReadData() with no parameter\n• Opening StackData.txt to read and closing file\n• Looping until EOF // Looping 100 times\n• Read each item from the file\n• Calling PushData() with each value as parameter\n• Appropriate exception handling with suitable output\nExample program code:\nJava\nprivate static void ReadData(){\ntry{\nScanner Scanner1 = new Scanner(new File(\"StackData.txt\"));\nwhile(Scanner1.hasNextLine()){\nPushData(Scanner1.next());\n}\nScanner1.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\n}\nVB.NET\nSub ReadData()\nTry\nDim DataReader As New System.IO.StreamReader(\"StackData.txt\")\nDo Until DataReader.EndOfStream\nPushData(DataReader.ReadLine())\nLoop\nDataReader.Close()\n© UCLES 2023 Page 8 of 34\n\n1(b)(ii) Catch ex As Exception\nConsole.WriteLine(\"File not found\")\nEnd Try\nEnd Sub\nPython\ndef ReadData():\ntry:\nDataFile = open(\"StackData.txt\")\nfor Line in DataFile:\nPushData(Line.strip())\nDataFile.close()\nexcept:\nprint(\"File not found\")\n© UCLES 2023 Page 9 of 34\n\n1(c) One mark each 5\n• One function header with no parameter\n• Checking if stack is empty and returning \"No data\"\n• …otherwise, decrementing correct pointer\n• Returning value at top of stack\n• 2nd function fully correct\nExample program code:\nJava\npublic static String PopVowel(){\nString DataToReturn = \"\";\nif(VowelTop - 1 >= 0){\nVowelTop --;\nDataToReturn = StackVowel[VowelTop];\nreturn DataToReturn;\n}else{\nreturn \"No data\";\n}\n}\npublic static String PopConsonant(){\nString DataToReturn = \"\";\nif(ConsonantTop - 1 >= 0){\nConsonantTop--;\nDataToReturn = StackConsonant[ConsonantTop];\nreturn DataToReturn;\n}else{\nreturn \"No data\";\n}\n}\n© UCLES 2023 Page 10 of 34\n\n1(c) VB.NET\nFunction PopVowel()\nIf VowelTop - 1 >= 0 Then\nVowelTop -= 1\nDim DataToReturn As Char = StackVowel(VowelTop)\nReturn DataToReturn\nElse\nReturn \"No data\"\nEnd If\nEnd Function\nFunction PopConsonant()\nIf ConsonantTop - 1 >= 0 Then\nConsonantTop -= 1\nDim DataToReturn As Char = StackConsonant(ConsonantTop)\nReturn DataToReturn\nElse\nReturn \"No data\"\nEnd If\nEnd Function\nPython\ndef PopVowel():\nglobal VowelTop\nglobal ConsonantTop\nif VowelTop - 1 >= 0:\nVowelTop = VowelTop - 1\nDataToReturn = StackVowel[VowelTop]\ndel StackVowel[-1]\nreturn DataToReturn\nelse:\nreturn \"No data\"\n© UCLES 2023 Page 11 of 34\n\n1(c) def PopConsonant():\nglobal VowelTop\nglobal ConsonantTop\nif ConsonantTop - 1 >= 0:\nConsonantTop = ConsonantTop - 1\nDataToReturn = StackConsonant[ConsonantTop]\ndel StackConsonant[-1]\nreturn DataToReturn\nelse:\nreturn \"No data\"\n© UCLES 2023 Page 12 of 34\n\n1(d)(i) One mark each to max 6 6\n• Calling ReadData()\n• Looping until 5 letters successfully accessed\n• Prompt and read in input of choice …\n• … if vowel is input calling PopVowel() and if consonant calling PopConsonant() …\n• … storing return values\n• Outputting appropriate message if no vowels and if no consonants (stacks full) within loop\n• Outputting the five returned letters on one line\nExample program code:\nJava\npublic static void main(String args[]){\nVowelTop = 0;\nConsonantTop = 0;\nReadData();\nString Letters = \"\";\nBoolean Flag = false;\nString Choice = \"\";\nString DataAccessed = \"\";\nfor(Integer X = 0; X < 5; X++){\nFlag = false;\nwhile(Flag == false){\nSystem.out.println(\"Vowel or Consonant\");\nScanner scanner = new Scanner(System.in);\nChoice = (scanner.nextLine()).toLowerCase();\nif(Choice.equals(\"vowel\")){\nDataAccessed = PopVowel();\nif(DataAccessed.equals(\"No data\") == false){\nLetters = Letters + DataAccessed;\nFlag = true;\n}else{\nSystem.out.println(\"No vowels left\");\n}\n© UCLES 2023 Page 13 of 34\n\n1(d)(i) }else if(Choice.equals(\"consonant\")){\nDataAccessed = PopConsonant();\nif(DataAccessed.equals(\"No data\") == false){\nLetters = Letters + DataAccessed;\nFlag = true;\n}else{\nSystem.out.println(\"No consonants left\");\n}\n}\n}\n}\nSystem.out.println(Letters);\n}\nVB.NET\nSub Main(args As String())\nVowelTop = 0\nConsonantTop = 0\nReadData()\nDim Letters As String = \"\"\nDim Flag As Boolean = False\nDim Choice As String\nDim DataAccessed As String\nFor x = 0 To 4\nFlag = False\nWhile Flag = False\nConsole.WriteLine(\"Vowel or Consonant?\")\nChoice = Console.ReadLine().ToLower()\nIf Choice = \"vowel\" Then\nDataAccessed = PopVowel()\nIf DataAccessed <> \"No data\" Then\nLetters = Letters & DataAccessed\nFlag = True\nElse\nConsole.WriteLine(\"No vowels left\")\n© UCLES 2023 Page 14 of 34\n\n1(d)(i) End If\nElseIf Choice = \"consonant\" Then\nDataAccessed = PopConsonant()\nIf DataAccessed <> \"No data\" Then\nLetters = Letters & DataAccessed\nFlag = True\nElse\nConsole.WriteLine(\"No consonants left\")\nEnd If\nEnd If\nEnd While\nNext\nConsole.WriteLine(Letters)\nEnd Sub\nPython\n#main\nVowelTop = 0\nConsonantTop = 0\nReadData()\nLetters = \"\"\nFlag = False\nfor x in range(0, 5):\nFlag = False\nwhile Flag == False:\nChoice = input(\"Vowel or Consonant\").lower()\nif Choice == \"vowel\":\nDataAccessed = PopVowel()\nif DataAccessed != \"No data\":\nLetters = Letters + DataAccessed\nFlag = True\nelse:\nprint(\"No vowels left\")\n© UCLES 2023 Page 15 of 34\n\n1(d)(i) elif Choice == \"consonant\":\nDataAccessed = PopConsonant()\nif DataAccessed != \"No data\":\nLetters = Letters + DataAccessed\nFlag = True\nelse:\nprint(\"No consonants left\")\nprint(Letters)\n\n1(d)(ii) One mark showing input in order vowel, cons, cons, vowel, vowel. Output is then utxoe 1\ne.g.\n© UCLES 2023 Page 16 of 34",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_42-p04.png",
        "../answer-assets/9618_w23_ms_42-p05.png",
        "../answer-assets/9618_w23_ms_42-p06.png",
        "../answer-assets/9618_w23_ms_42-p07.png",
        "../answer-assets/9618_w23_ms_42-p08.png",
        "../answer-assets/9618_w23_ms_42-p09.png",
        "../answer-assets/9618_w23_ms_42-p10.png",
        "../answer-assets/9618_w23_ms_42-p11.png",
        "../answer-assets/9618_w23_ms_42-p12.png",
        "../answer-assets/9618_w23_ms_42-p13.png",
        "../answer-assets/9618_w23_ms_42-p14.png",
        "../answer-assets/9618_w23_ms_42-p15.png",
        "../answer-assets/9618_w23_ms_42-p16.png"
      ]
    },
    {
      "id": "9618-2023-on-42-q02",
      "question_id": "9618-2023-on-42-q02",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 17,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) One mark each 5\n• Function header with parameter\n• Correct loop\n• Modulus calculation\n• Return of correct value at correct place\n• Remainder of function correct\nExample program code:\nJava\npublic static Integer IterativeCalculate(Integer Number){\nInteger ToFind = Number;\nInteger Total = 0;\nwhile(Number != 0){\nif(ToFind % Number == 0){\nTotal += Number;\n}\nNumber--;\n}\nreturn Total;\n}\nVB.NET\nFunction IterativeCalculate(Number As Integer)\nDim total As Integer = 0\nDim ToFind As Integer = Number\nWhile Number <> 0\nIf ToFind Mod Number = 0 Then\ntotal = total + Number\nEnd If\nNumber = Number - 1\nEnd While\nReturn total\nEnd Function\n© UCLES 2023 Page 17 of 34\n\n2(a)(i) Python\ndef IterativeCalculate(Number):\nTotal = 0\nToFind = Number\nwhile Number != 0:\nif ToFind % Number == 0:\nTotal = Total + Number\nNumber = Number - 1\nreturn Total\n\n2(a)(ii) One mark each 2\n• Calling IterativeCalculate(10)\n• Outputting return value\nExample program code:\nJava\nSystem.out.println(IterativeCalculate(10));\nVB.NET\nSub Main(args As String())\nConsole.WriteLine(IterativeCalculate(10))\nEnd Sub\nPython\nprint(IterativeCalculate(10))\n\n2(a)(iii) One mark for screenshot showing 18 1\n© UCLES 2023 Page 18 of 34\n\n2(b)(i) One mark for each gap (5) 7\nOne mark for recursive calls both accurate and in correct places\nOne mark for remainder of function with nothing superfluous\nFUNCTION RecursiveValue(Number : Integer, ToFind : Integer) RETURNS INTEGER\nIF Number = 0 THEN\nRETURN 0\nELSE\nIF ToFind MODULUS Number = 0 THEN\nRETURN Number + RecursiveValue(Number - 1, ToFind)\nELSE\nRETURN RecursiveValue(Number - 1, ToFind)\nENDIF\nENDIF\nENDFUNCTION\nExample program code:\nJava\npublic static Integer RecursiveValue(Integer Number, Integer ToFind){\nif(Number == 0){\nreturn 0;\n}else{\nif(ToFind % Number == 0){\nreturn Number + RecursiveValue(Number - 1, ToFind);\n}else{\nreturn RecursiveValue(Number - 1, ToFind);\n}\n}\n}\n© UCLES 2023 Page 19 of 34\n\n2(b)(i) VB.NET\nFunction RecursiveValue(Number As Integer, ToFind As Integer)\nIf Number = 0 Then\nReturn 0\nElse\nIf ToFind Mod Number = 0 Then\nReturn Number + RecursiveValue(Number - 1, ToFind)\nElse\nReturn RecursiveValue(Number - 1, ToFind)\nEnd If\nEnd If\nEnd Function\nPython\ndef RecursiveValue(Number, ToFind):\nif Number == 0:\nreturn 0\nelse:\nif ToFind % Number == 0:\nreturn Number + RecursiveValue(Number - 1, ToFind)\nelse:\nreturn RecursiveValue(Number - 1, ToFind)\n© UCLES 2023 Page 20 of 34\n\n2(b)(ii) One mark for calling RecursiveValue(50,50)and outputting return value 1\nExample program code:\nJava\nSystem.out.println(RecursiveValue(50,50));\nVB.NET\nConsole.WriteLine(RecursiveValue(50,50))\nPython\nprint(RecursiveValue(50,50))\n\n2(b)(iii) One mark for screenshot showing 93 1\n© UCLES 2023 Page 21 of 34",
      "source_pages": [
        17,
        18,
        19,
        20,
        21
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_42-p17.png",
        "../answer-assets/9618_w23_ms_42-p18.png",
        "../answer-assets/9618_w23_ms_42-p19.png",
        "../answer-assets/9618_w23_ms_42-p20.png",
        "../answer-assets/9618_w23_ms_42-p21.png"
      ]
    },
    {
      "id": "9618-2023-on-42-q03",
      "question_id": "9618-2023-on-42-q03",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 31,
      "status": "available",
      "reason": null,
      "text": "3(a)(i) One mark each: 5\n• Class declaration\n• Four attributes with correct data types\n• Constructor header\n• … taking 4 parameters\n• Setting attributes to parameter values\nExample program code:\nJava\nclass Character{\nprivate String CharacterName;\nprivate Date DateOfBirth;\nprivate Double Intelligence;\nprivate Integer Speed;\npublic Character(String CName, Date DBirth, Double Intell, Integer SpeedP){\nCharacterName = CName;\nDateOfBirth = DBirth;\nIntelligence = Intell;\nSpeed = SpeedP;\n}\n}\nVB.NET\nClass Character\nPrivate CharacterName As String\nPrivate DateOfBirth As Date\nPrivate Intelligence As Single\nPrivate Speed As Integer\nSub New(CName, DBirth, Intell, SpeedP)\nCharacterName = CName\nDateOfBirth = DBirth\n© UCLES 2023 Page 22 of 34\n\n3(a)(i) Intelligence = Intell\nSpeed = SpeedP\nEnd Sub\nEnd Class\nPython\nclass Character:\n#self.__CharacterName string\n#self.__DateOfBirth date\n#self.__Intelligence real\n#self.__Speed integer\ndef __init__(self, CName, DBirth, Intell, SpeedP):\nself.__CharacterName = CName\nself.__DateOfBirth = DBirth\nself.__Intelligence = Intell\nself.__Speed = SpeedP\n© UCLES 2023 Page 23 of 34\n\n3(a)(ii) One mark each: 3\n• 1 get header with no parameter …\n• … returning attribute\n• Second correct get method\nExample program code:\nJava\npublic Double GetIntelligence(){\nreturn Intelligence;\n}\npublic String GetName(){\nreturn CharacterName;\n}\nVB.NET\nFunction GetIntelligence()\nReturn Intelligence\nEnd Function\nFunction GetName()\nReturn CharacterName\nEnd Function\nPython\ndef GetIntelligence(self):\nreturn self.__Intelligence\ndef GetName(self):\nreturn self.__CharacterName\n© UCLES 2023 Page 24 of 34\n\n3(a)(iii) One mark each 2\n• Set header with 1 parameter …\n• … assigns parameter to attribute\nExample program code:\nJava\npublic void SetIntelligence(Double NewValue){\nIntelligence = NewValue;\n}\nVB.NET\nSub SetIntelligence(NewValue)\nIntelligence = NewValue\nEnd Sub+\nPython\ndef SetIntelligence(self, NewValue):\nself.__Intelligence = NewValue\n© UCLES 2023 Page 25 of 34\n\n3(a)(iv) One mark for method multiplying attribute intelligence by 1.1 (or equivalent) and storing in attribute. 1\nExample program code:\nJava\npublic void Learn(){\nIntelligence = Intelligence * 1.1;\n}\nVB.NET\nOverridable Sub Learn()\nIntelligence = Intelligence * 1.1\nEnd Sub\nPython\ndef Learn(self):\nself.__Intelligence = self.__Intelligence * 1.1\n© UCLES 2023 Page 26 of 34\n\n3(a)(v) One mark each 2\n• Method (function) header (and end where appropriate) no parameter, returning a calculated age\n• Extracting attribute year of birth from date and subtracting from 2023\nExample program code:\nJava\npublic Integer ReturnAge(){\nreturn 2023 - DateOfBirth.getYear();\n}\nVB.NET\nFunction ReturnAge()\nReturn DateDiff(DateInterval.Year, DateOfBirth, #01/01/2023#)\nEnd Function\nPython\ndef ReturnAge(self):\nreturn 2023 - self.__DateOfBirth.year\n© UCLES 2023 Page 27 of 34\n\n3(b)(i) One mark each: 2\n• Creating new instance of Character with identifier FirstCharacter …\n• … sending correct values as parameters\nExample program code:\nJava\nCharacter FirstCharacter = new Character(\"Royal\", new Date(2019,01,01), 70.0, 30);\nVB.NET\nSub Main(args As String())\nDim FirstCharacter As Character\nFirstCharacter = New Character(\"Royal\", #1/1/2019#, 70, 30)\nEnd Sub\nPython\nFirstCharacter = Character(\"Royal\", datetime.datetime(2019, 1, 1), 70, 30)\n© UCLES 2023 Page 28 of 34\n\n3(b)(ii) One mark each 3\n• Calling Learn() for FirstCharacter\n• Calling ReturnAge() and outputting return value\n• Outputting name and intelligence using gets with suitable message\nExample program code:\nJava\nFirstCharacter.Learn();\nSystem.out.println(FirstCharacter.GetName() + \" is \" + FirstCharacter.ReturnAge() + \" years\nold and has intelligence \" + FirstCharacter.GetIntelligence());\nVB.NET\nFirstCharacter.Learn()\nConsole.WriteLine(FirstCharacter.GetName() & \" is \" & FirstCharacter.ReturnAge() &\n\" years old and has intelligence \" & FirstCharacter.GetIntelligence())\nPython\nFirstCharacter.Learn()\nprint(FirstCharacter.GetName(), \"is\", FirstCharacter.ReturnAge(), \"years old and has\nintelligence\" , FirstCharacter.GetIntelligence())\n\n3(b(iii) One mark for screenshot with Royal, 4 years, 77 intelligence e.g. 1\n© UCLES 2023 Page 29 of 34\n\n3(c)(i) One mark each: 5\n• Class header inheriting from Character\n• Declaring Element as string\n• Constructor header taking 5 parameters …\n• … calling parent constructor with the 4 parameters\n• … assigning parameter to Element\nExample program code:\nJava\nclass MagicCharacter extends Character{\nprivate String Element;\npublic MagicCharacter(String ElementP, String CName, Date DBirth, Double Intell,\nInteger SpeedP){\nsuper(CName, DBirth, Intell, SpeedP);\nElement = ElementP;\n}\n}\nVB.NET\nClass MagicCharacter\nInherits Character\nPrivate Element As String\nSub New(ElementP, CName, DBirth, Intell, SpeedP)\nMyBase.New(CName, DBirth, Intell, SpeedP)\nElement = ElementP\nEnd Sub\nEnd Class\n© UCLES 2023 Page 30 of 34\n\n3(c)(i) Python\nclass MagicCharacter(Character):\n#self.__Element String\ndef __init__(self, ElementP, CName, DBirth, Intell, SpeedP):\nsuper().__init__(CName, DBirth, Intell, SpeedP)\nself.__Element = ElementP\n© UCLES 2023 Page 31 of 34\n\n3(c)(ii) One mark each: 3\n• Method header overriding parent method but no parameters\n• Checking element value …\n• … correct calculations with attribute intelligence and storing\nExample program code:\nJava\npublic void Learn(){\nif(Element.equals(\"fire\") || Element.equals(\"water\")){\nsuper.SetIntelligence(super.GetIntelligence() * 1.2);\n}else if(Element.equals(\"earth\")){\nsuper.SetIntelligence(super.GetIntelligence() * 1.3);\n}else{\nsuper.SetIntelligence(super.GetIntelligence() * 1.1);\n}\n}\nVB.NET\nOverrides Sub Learn()\nIf Element = \"fire\" Or Element = \"water\" Then\nSetIntelligence(GetIntelligence() * 1.2)\nElseIf Element = \"earth\" Then\nSetIntelligence(GetIntelligence() * 1.3)\nElse\nSetIntelligence(GetIntelligence() * 1.1)\nEnd If\nEnd Sub\n© UCLES 2023 Page 32 of 34\n\n3(c)(ii) Python\ndef Learn(self):\nif(self.__Element == \"fire\" or self.__Element == \"water\"):\nsuper().SetIntelligence(super().GetIntelligence() * 1.2)\nelif self.__Element == \"earth\":\nsuper().SetIntelligence(super().GetIntelligence() * 1.3)\nelse:\nsuper().SetIntelligence(super().GetIntelligence() * 1.1)\n\n3(d)(i) One mark each: 2\n• Declaring MagicCharacter with identifier FirstMagic …\n• … with correct parameters\nExample program code:\nJava\nMagicCharacter FirstMagic = new MagicCharacter(\"fire\", \"Light\", new Date(2018,03,03), 75.0,\n22);\nVB.NET\nDim FirstMagic As MagicCharacter\nFirstMagic = New MagicCharacter(\"fire\", \"Light\", #3/3/2018#, 75, 22)\nPython\nFirstMagic = MagicCharacter(\"fire\", \"Light\", datetime.datetime(2018, 3, 3), 75, 22)\n© UCLES 2023 Page 33 of 34\n\n3(d)(ii) One mark for calling Learn() for FirstMagic and outputting all required data in appropriate message using gets. 1\nExample program code:\nJava\nFirstMagic.Learn();\nSystem.out.println(FirstMagic.GetName() + \" is \" + FirstMagic.ReturnAge() + \" years old and\nhas intelligence \" + FirstMagic.GetIntelligence());\nVB.NET\nFirstMagic.Learn()\nConsole.WriteLine(FirstMagic.GetName() & \" is \" & FirstMagic.ReturnAge() & \" years old and\nhas intelligence \" & FirstMagic.GetIntelligence())\nPython\nFirstMagic.Learn()\nprint(FirstMagic.GetName(), \"is\", FirstMagic.ReturnAge(), \"years old and has intelligence\",\nFirstMagic.GetIntelligence())\n\n3(d)(iii) One mark for screenshot e.g. 1\n© UCLES 2023 Page 34 of 34",
      "source_pages": [
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_42-p22.png",
        "../answer-assets/9618_w23_ms_42-p23.png",
        "../answer-assets/9618_w23_ms_42-p24.png",
        "../answer-assets/9618_w23_ms_42-p25.png",
        "../answer-assets/9618_w23_ms_42-p26.png",
        "../answer-assets/9618_w23_ms_42-p27.png",
        "../answer-assets/9618_w23_ms_42-p28.png",
        "../answer-assets/9618_w23_ms_42-p29.png",
        "../answer-assets/9618_w23_ms_42-p30.png",
        "../answer-assets/9618_w23_ms_42-p31.png",
        "../answer-assets/9618_w23_ms_42-p32.png",
        "../answer-assets/9618_w23_ms_42-p33.png",
        "../answer-assets/9618_w23_ms_42-p34.png"
      ]
    },
    {
      "id": "9618-2023-on-43-q01",
      "question_id": "9618-2023-on-43-q01",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 16,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) One mark each to max 5 5\n• Function header (and end where appropriate) taking one string parameter\n• Calculating length of parameter string\n• Looping correct number of times\n• Checking the first character against all vowels\n• Accessing the remainder of the string\n• Remainder of function correct with nothing extra i.e. totalling, must match structure of given algorithm\n© UCLES 2023 Page 4 of 37\n\n9618/43 Cambridge International AS & A Level – Mark Scheme October/November 2023\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nJava\npublic static Integer IterativeVowels(String Value){\nInteger Total = 0;\nInteger LengthString = Value.length();\nchar FirstCharacter;\nfor(Integer X = 0; X < LengthString; X++){\nFirstCharacter = Value.charAt(0);\nif(FirstCharacter == 'a' || FirstCharacter == 'e' || FirstCharacter =='i' || FirstCharacter == 'o'\n|| FirstCharacter == 'u'){\nTotal++;\n}\nValue = Value.substring(1, Value.length());\n}\nreturn Total;\n}\nVB.NET\nFunction IterativeVowels(Value)\nDim Total As Integer = 0\nDim FirstCharacter As Char\nFor x = 0 To Len(Value) - 1\nFirstCharacter = Left(Value, 1)\nIf FirstCharacter = \"a\" Or FirstCharacter = \"e\" Or FirstCharacter = \"i\" Or FirstCharacter = \"o\" Or\nFirstCharacter = \"u\" Then\nTotal = Total + 1\nEnd If\nValue = Right(Value, Len(Value) - 1)\nNext\nReturn Total\nEnd Function\n© UCLES 2023 Page 5 of 37\n\n1(a)(ii) One mark each 2\n• Calling the function with \"house\"\n• Outputting the return value\nExample program code:\nJava\nSystem.out.println(IterativeVowels(\"house\"));\nVB.NET\nConsole.WriteLine(IterativeVowels(\"house\"))\nPython\nprint(IterativeVowels(\"house\"))\n\n1(a)(iii) One mark for screenshot outputting 3 1\n\n1(b)(i) One mark each 6\n• Recursive call\n• Function header (and end where appropriate) taking string parameter (returning integer where given)\n• Base case checking (length is 0) and returning 0\n• Extracting first character and checking if a vowel …\n• … if it is a vowel, returning 1 + recursive call with 1 less character\n• … if not a vowel, return recursive call with 1 less character\n© UCLES 2023 Page 6 of 37\n\n9618/43 Cambridge International AS & A Level – Mark Scheme October/November 2023\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nJava\npublic static Integer RecursiveVowels(String Value){\nchar FirstCharacter;\nif(Value.length() == 0){\nreturn 0;\n}else{\nFirstCharacter = Value.charAt(0);\nif(FirstCharacter == 'a' || FirstCharacter == 'e' || FirstCharacter =='i' || FirstCharacter == 'o'\n|| FirstCharacter == 'u'){\nreturn 1 + RecursiveVowels(Value.substring(1, Value.length()));\n}else{\nreturn RecursiveVowels(Value.substring(1, Value.length()));\n}\n}\n}\nVB.NET\nFunction RecursiveVowels(Value)\nDim firstCharacter As Char\nIf Len(Value) = 0 Then\nReturn 0\nElse\nfirstCharacter = Left(Value, 1)\nIf firstCharacter = \"a\" Or firstCharacter = \"e\" Or firstCharacter = \"i\" Or firstCharacter = \"o\" Or\nfirstCharacter = \"u\" Then\nReturn 1 + RecursiveVowels(Right(Value, Len(Value) - 1))\nElse\nReturn RecursiveVowels(Right(Value, Len(Value) - 1))\n© UCLES 2023 Page 7 of 37\n\n1(b)(ii) One mark for calling recursive function with \"imagine\" and outputting return value 1\nExample program code:\nJava\nSystem.out.println(RecursiveVowels(\"imagine\"));\nVB.NET\nConsole.WriteLine(RecursiveVowels(\"imagine\"))\nPython\nprint(RecursiveVowels(\"imagine\"))\n\n1(b)(iii) One mark for screenshot showing 4 1\n© UCLES 2023 Page 8 of 37",
      "source_pages": [
        4,
        5,
        6,
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_43-p04.png",
        "../answer-assets/9618_w23_ms_43-p05.png",
        "../answer-assets/9618_w23_ms_43-p06.png",
        "../answer-assets/9618_w23_ms_43-p07.png",
        "../answer-assets/9618_w23_ms_43-p08.png"
      ]
    },
    {
      "id": "9618-2023-on-43-q02",
      "question_id": "9618-2023-on-43-q02",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 29,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) One mark each 2\n• (Global) array with identifier Queue with (minimum) 50 elements (of type string)\n• TailPointer (integer) initialised to 0, HeadPointer (integer) initialised to -1\nExample program code:\nJava\npublic static String[] Queue = new String[50];\npublic static Integer HeadPointer = -1;\npublic static Integer TailPointer = 0;\nVB.NET\nDim Queue(50) As String\nDim HeadPointer As Integer\nDim TailPointer As Integer\nSub Main(args As String())\nHeadPointer = -1\nTailPointer = 0\nEnd Sub\nPython\nglobal Queue #string 50 elements\nglobal HeadPointer\nglobal TailPointer\n#main\nQueue = []\nHeadPointer = -1\nTailPointer = 0\n© UCLES 2023 Page 9 of 37\n\n2(a)(ii) One mark each 4\n• Procedure Enqueue() header (and close where appropriate) with one (string) parameter\n• Checking if queue is full and outputting suitable message\n• … otherwise inserting parameter to next space\n• … increment TailPointer and set HeadPointer to 0 if first item (HeadPointer = -1)\nExample program code:\nJava\npublic static void Enqueue(String Value){\nif(TailPointer == 50){\nSystem.out.println(\"Queue full\");\n}else{\nQueue[TailPointer] = Value;\nTailPointer++;\nif(HeadPointer == -1){ HeadPointer = 0;}\n}\n}\nVB.NET\nSub Enqueue(Data)\nIf TailPointer = 50 Then\nConsole.WriteLine(\"Queue full\")\nElse\nQueue(TailPointer) = Data\nTailPointer = TailPointer + 1\nIf (HeadPointer = -1) Then\nHeadPointer = 0\nEnd If\nEnd If\nEnd Sub\n© UCLES 2023 Page 10 of 37\n\n2(a)(ii) Python\ndef Enqueue(Data):\nglobal TailPointer\nglobal HeadPointer\nglobal Queue\nif TailPointer == 50:\nprint(\"Queue full\")\nelse:\nQueue.append(Data)\nTailPointer +=1\nif HeadPointer == -1:\nHeadPointer = 0\n© UCLES 2023 Page 11 of 37\n\n2(a)(iii) One mark each to max 4 4\n• Function header Dequeue() (and end where appropriate) with no parameter\n• Checking if empty …\n• … outputting suitable message and returning \"Empty\"\n• (otherwise) incrementing head pointer\n• returning next value (at head pointer before incrementing)\nExample program code:\nJava\npublic static String Dequeue(){\nif(HeadPointer == -1 || HeadPointer == TailPointer){\nSystem.out.println(\"Queue empty\");\nreturn \"Empty\";\n}else{\nHeadPointer ++;\nreturn Queue[HeadPointer - 1];}}\nVB.NET\nFunction Dequeue()\nIf HeadPointer = -1 Or HeadPointer = TailPointer Then\nConsole.WriteLine(\"Queue empty\")\nReturn \"Empty\"\nElse\nHeadPointer = HeadPointer + 1\nReturn Queue(HeadPointer - 1)\nEnd If\nEnd Function\n© UCLES 2023 Page 12 of 37\n\n2(a)(iii) Python\ndef Dequeue():\nglobal Queue\nglobal HeadPointer\nif HeadPointer == -1 or HeadPointer == TailPointer:\nprint(\"Queue empty\")\nreturn \"Empty\"\nelse:\nHeadPointer +=1\nreturn Queue[HeadPointer - 1]\n© UCLES 2023 Page 13 of 37\n\n2(b) One mark each to max 6 6\n• Procedure header ReadData() with no parameters\n• Opening file …\n• … and closing file\n• Looping until EOF/set amount\n• Reading in each value\n• … calling Enqueue() with each value\n• Use of exception handling with appropriate output\nExample program code:\nJava\npublic static void ReadData(){\ntry{\nScanner Scanner1 = new Scanner(new File(\"QueueData.txt\"));\nwhile(Scanner1.hasNextLine()){\nEnqueue(Scanner1.next());\n}\nScanner1.close();\n}catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\n}\nVB.NET\nSub ReadData()\nTry\nDim DataReader As New System.IO.StreamReader(\"QueueData.txt\")\nDo Until DataReader.EndOfStream\nEnqueue(DataReader.ReadLine())\n© UCLES 2023 Page 14 of 37\n\n2(b) Loop\nDataReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"No file\")\nEnd Try\nEnd Sub\nPython\ndef ReadData():\ntry:\nDataFile = open(\"QueueData.txt\")\nfor Line in DataFile:\nEnqueue(Line.strip())\nDataFile.close()\nexcept IOError:\nprint(\"No file\")\n© UCLES 2023 Page 15 of 37\n\n2(c)(i) One mark each 2\n• Declaration of record type/class RecordData\n• ID as a string and total as an Integer\nExample program code:\nJava\nclass RecordData{\npublic String ID;\npublic Integer Total;\npublic RecordData(String IDP, Integer TotalP){\nID = IDP;\nTotal = TotalP;\n} }\nVB.NET\nStructure RecordData\nDim ID As String\nDim Total As Integer\nEnd Structure\nPython\nclass RecordData:\n#self. ID string\n#self. Total integer\ndef init (self, IDP, TotalP):\nself. ID = IDP\nself. Total = TotalP\n© UCLES 2023 Page 16 of 37\n\n2(c)(i) def SetID(self, Value):\nself. ID = Value\ndef GetID(self):\nreturn self. ID\ndef SetTotal(self, Value):\nself. Total = Value\ndef GetTotal(self): return self. Total\n\n2(c)(ii) One mark each 2\n• (global) 1D Array named Records of type RecordData\n• (global) NumberRecords declared as integer and initialised to 0\nExample program code:\nJava\npublic static RecordData[] Records = new RecordData[50]; public static Integer\nNumberRecords = 0;\nVB.NET\nDim Records(49) As RecordData Dim NumberRecords As Integer\nSub Main(args As String())\nNumberRecords = 0\nEnd Sub\nPython\n#main\nRecords = [] #50 elements of type RecordData NumberRecords = 0\n© UCLES 2023 Page 17 of 37\n\n2(c)(iii) One mark each to max 5 5\n• Incrementing NumberRecords each time (twice) a new record is added\n• Procedure header (and end) and using Dequeue() and storing/using return value\nDataAccessed  Dequeue()\n• Checking if NumberRecords is 0 and creating a new record with ID and total as 1:\nIF NumberRecords = 0 THEN\nRecords[NumberRecords].ID  DataAccessed\nRecords[NumberRecords].Total  1\nFlag  TRUE\n• Looping through all array elements to find matching ID and incrementing total if found\nFOR X  0 TO NumberRecords – 1 Check Python loop end\nIF Records[X].ID = DataAccessed THEN\nRecords[X].Total  Records[X].Total + 1\nFlag  TRUE\nENDIF\nNEXT X\n• Adding new record if record is not found, storing ID and total as 1\nIF Flag = FALSE THEN\nRecords[NumberRecords].ID  DataAccessed\nRecords[NumberRecords].Total  1\nNumberRecords  NumberRecords + 1\nENDIF\n© UCLES 2023 Page 18 of 37\n\n2(c)(iii) • Example program code:\nJava\npublic static void TotalData(){\nString DataAccessed = Dequeue();\nBoolean Flag = false;\nif(NumberRecords == 0){\nRecords[NumberRecords] = new RecordData(DataAccessed, 1);\nNumberRecords ++;\nFlag = true;\n}else{\nfor(Integer X = 0; X < NumberRecords; X++){\nif(Records[X].ID.equals(DataAccessed)){\nRecords[X].Total++;\nFlag = true;\n}\n}\n}\nif(Flag == false){\nRecords[NumberRecords] = new RecordData(DataAccessed, 1);\nNumberRecords ++;\n}\n}\nVB.NET\nSub TotalData()\nDim DataAccessed As String\nDim Flag As Boolean = False\nDataAccessed = Dequeue()\n© UCLES 2023 Page 19 of 37\n\n2(c)(iii) If NumberRecords = 0 Then\nRecords(NumberRecords).ID = DataAccessed\nRecords(NumberRecords).Total = Records(NumberRecords).Total + 1\nNumberRecords = NumberRecords + 1\nFlag = True\nElse\nFor X = 0 To NumberRecords – 1\nIf Records(X).ID = DataAccessed Then\nRecords(X).Total = Records(X).Total + 1\nFlag = True\nEnd If\nNext\nEnd If\nIf Flag = False Then\nRecords(NumberRecords).ID = DataAccessed\nRecords(NumberRecords).Total = Records(NumberRecords).Total + 1\nNumberRecords = NumberRecords + 1\nEnd If\nEnd Sub\nPython\ndef TotalData():\nglobal NumberRecords\nglobal Records\nFlag = False\nDataAccessed = Dequeue()\nif NumberRecords == 0:\nRecords.append(RecordData(DataAccessed, 1))\n© UCLES 2023 Page 20 of 37\n\n2(c)(iii) NumberRecords += 1\nFlag = True\nelse:\nfor X in range(0, NumberRecords):\nif(Records[X].GetID() == DataAccessed):\nRecords[X].SetTotal(Records[X].GetTotal() + 1)\nFlag = True\nif Flag == False:\nRecords.append(RecordData(DataAccessed, 1))\nNumberRecords += 1\n\n2(d) One mark each 1\n• Looping through all array elements and outputting ID and total in correct format\n© UCLES 2023 Page 21 of 37\n\n9618/43 Cambridge International AS & A Level – Mark Scheme October/November 2023\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nJava\npublic static void OutputRecords(){\nfor(Integer X = 0; X < NumberRecords; X++){\nSystem.out.println(\"ID \", Records[X].ID + \" Total \" + Records[X].Total);\n}\n}\nVB.NET\nSub OutputRecords()\nFor X = 0 To NumberRecords - 1\nConsole.WriteLine(\"ID \" & Records(X).ID & \" Total \" & Records(X).Total)\nNext\nEnd Sub\nPython\ndef OutputRecords():\nfor X in range(0, NumberRecords):\nprint(\"ID\", Records[X].GetID(), \" Total \", Records[X].GetTotal())\n© UCLES 2023 Page 22 of 37\n\n2(e)(i) One mark each 2\n• Calling ReadData() first and OutputRecords() last\n• Looping through all queue elements and calling TotalData() for each queue element\nExample program code:\nJava\npublic static void main(String args[]){\nReadData();\nwhile(HeadPointer != TailPointer){\nTotalData();\n}\nOutputRecords();\n}\nVB.NET\nSub Main(args As String())\nHeadPointer = 0\nTailPointer = 0\nReadData()\nNumberRecords = 0\nWhile HeadPointer <> TailPointer\nTotalData()\nEnd While\nOutputRecords()\nEnd Sub\n© UCLES 2023 Page 23 of 37\n\n2(e)(i) Python\n#main Queue = []\nRecords = []\nHeadPointer = 0\nTailPointer = 0\nReadData()\nNumberRecords = 0\nwhile HeadPointer != TailPointer:\nTotalData()\nOutputRecords()\n\n2(e)(ii) One mark for screenshot e.g. 1\n© UCLES 2023 Page 24 of 37",
      "source_pages": [
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23,
        24
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_43-p09.png",
        "../answer-assets/9618_w23_ms_43-p10.png",
        "../answer-assets/9618_w23_ms_43-p11.png",
        "../answer-assets/9618_w23_ms_43-p12.png",
        "../answer-assets/9618_w23_ms_43-p13.png",
        "../answer-assets/9618_w23_ms_43-p14.png",
        "../answer-assets/9618_w23_ms_43-p15.png",
        "../answer-assets/9618_w23_ms_43-p16.png",
        "../answer-assets/9618_w23_ms_43-p17.png",
        "../answer-assets/9618_w23_ms_43-p18.png",
        "../answer-assets/9618_w23_ms_43-p19.png",
        "../answer-assets/9618_w23_ms_43-p20.png",
        "../answer-assets/9618_w23_ms_43-p21.png",
        "../answer-assets/9618_w23_ms_43-p22.png",
        "../answer-assets/9618_w23_ms_43-p23.png",
        "../answer-assets/9618_w23_ms_43-p24.png"
      ]
    },
    {
      "id": "9618-2023-on-43-q03",
      "question_id": "9618-2023-on-43-q03",
      "subject": "9618",
      "year": 2023,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 30,
      "status": "available",
      "reason": null,
      "text": "3(a)(i) One mark each to max 4 4\n• Class header (and end where appropriate)\n• Three attributes with correct names and data types\n• Constructor header (and end where appropriate) with 3 parameters\n• Within constructor, assigns attributes to parameters\nExample program code:\nJava\nclass Character{\nprivate Integer XPosition;\nprivate Integer YPosition;\nprivate String Name;\npublic Character(Integer XPositionP, Integer YPositionP, String NameP){\nXPosition = XPositionP;\nYPosition = YPositionP;\nName = NameP;\n}\n}\nVB.NET\nClass Character\nPrivate XPosition As Integer\nPrivate YPosition As Integer\nPrivate Name As String\nSub New(XPositionP, YPositionP, NameP)\nXPosition = XPositionP\nYPosition = YPositionP\nName = NameP\nEnd Sub\nEnd Class\n© UCLES 2023 Page 25 of 37\n\n3(a)(i) Python\nclass Character:\n#self.XPosition integer\n#self.YPosition integer\n#self.Name string\ndef init (self, XPositionP, YPositionP, NameP):\nself.XPosition = XPositionP\nself.YPosition = YPositionP\nself.Name = NameP\n© UCLES 2023 Page 26 of 37\n\n3(a)(ii) One mark each 3\n• 1 get header with no parameter …\n• … returning correct value\n• 2nd get method\nExample program code:\nJava\npublic Integer GetXPosition(){\nreturn XPosition;\n}\npublic Integer GetYPosition(){\nreturn YPosition;\n}\nVB.NET\nFunction GetXPosition()\nReturn XPosition\nEnd Function\nFunction GetYPosition()\nReturn YPosition\nEnd Function\nPython\ndef GetXPosition(self):\nreturn self. XPosition\ndef GetYPosition(self):\nreturn self. YPosition\n© UCLES 2023 Page 27 of 37\n\n3(a)(iii) One mark each to max 4 4\n• 1 set method header (and end where appropriate) with parameter …\n• … adding parameter to X/Y Position attribute and storing in the X/Y attribute\n• If (resulting value is) more than 10 000 limiting to 10 000 and if less than 0 limiting to 0\n• Second correct set method\nExample program code:\nJava\npublic void SetXPosition(Integer Value){\nXPosition = XPosition + Value;\nif(XPosition > 10000){\nXPosition = 10000;\n}else if(XPosition < 0){\nXPosition = 0;\n}\n}\npublic void SetYPosition(Integer Value){\nYPosition = YPosition + Value;\nif(YPosition > 10000){\nYPosition = 10000;\n}else if(YPosition < 0){\nYPosition = 0;\n}\n}\nVB.NET\nFunction SetXPosition(Value)\nXPosition = XPosition + Value\nIf XPosition > 10000 Then\nXPosition = 10000\n© UCLES 2023 Page 28 of 37\n\n3(a)(iii) ElseIf XPosition < 0 Then\nXPosition = 0\nEnd If\nEnd Function\nFunction SetYPosition(Value)\nYPosition = YPosition + Value\nIf YPosition > 10000 Then\nYPosition = 10000\nElseIf YPosition < 0 Then\nYPosition = 0\nEnd If\nEnd Function\nPython\ndef SetXPosition(self, Value):\nself. XPosition = self. XPosition + Value\nif(self.XPosition > 10000):\nself.XPosition = 10000\nelif self.XPosition < 0:\nself.XPosition = 0\ndef SetYPosition(self, Value):\nself.YPosition = self.YPosition + Value\nif(self.YPosition > 10000):\nself.YPosition = 10000\nelif self.YPosition < 0:\nself.YPosition = 0\n© UCLES 2023 Page 29 of 37\n\n3(a)(iv) One mark each 4\n• Method header with (string) parameter\n• Checking parameter for direction …\n• … using SetYPosition() and SetXPosition() correctly …\n• … with correct parameters\nExample program code:\nJava\npublic void Move(String Direction){\nif(Direction.equals(\"up\")){\nSetYPosition(10);\n}else if(Direction.equals(\"down\")){\nSetYPosition(-10);\n}else if(Direction.equals(\"right\")){\nSetXPosition(10);\n}else{\nSetXPosition(-10);\n}\n}\nVB.NET\nOverridable Sub Move(Direction)\nIf Direction = \"up\" Then\nSetYPosition(10)\nElseIf Direction = \"down\" Then\nSetYPosition(-10)\nElseIf Direction = \"right\" Then\nSetXPosition(10)\nElseIf Direction = \"left\" Then\nSetXPosition(-10)\nEnd If\nEnd Sub\n© UCLES 2023 Page 30 of 37\n\n3(a)(iv) Python\ndef Move(self, Direction):\nif(Direction == \"up\"):\nself.SetYPosition(10)\nelif(Direction == \"down\"):\nself.SetYPosition(-10)\nelif(Direction == \"right\"):\nself.SetXPosition(10)\nelse:\nself.SetXPosition(-10)\n\n3(b) One mark each 2\n• New instance of Character created with identifier Jack …\n• … correct constructor called and values passed\nExample program code:\nJava\nCharacter Jack = new Character(50, 50, \"Jack\");\nVB.NET\nDim Jack As Character = New Character(50, 50, \"Jack\")\nPython\nJack = Character(50, 50, \"Jack\")\n© UCLES 2023 Page 31 of 37\n\n3(c)(i) One mark each 3\n• Class header inheriting from Character\n• Constructor taking all 3 parameters …\n• … calling parent/super constructor with the 3 parameters\nExample program code:\nJava\nclass BikeCharacter extends Character{\npublic BikeCharacter(Integer XPositionP, Integer YPositionP, String NameP){\nsuper(XPositionP, YPositionP, NameP);\n}\n}\nVB.NET\nClass BikeCharacter\nInherits Character\nSub New(XPositionP, YPositionP, NameP)\nMyBase.New(XPositionP, YPositionP, NameP)\nEnd Sub\nEnd Class\nPython\nclass BikeCharacter(Character):\ndef init (self, XPositionP, YPositionP, NameP):\nsuper(). init (XPositionP, YPositionP, NameP)\n© UCLES 2023 Page 32 of 37\n\n3(c)(ii) One mark each 2\n• Method header taking parameter and overriding parent/super Move()\n• Correct changes to method to update values by 20\nExample program code:\nJava\npublic void Move(String Direction){\nif(Direction.equals(\"up\")){\nsuper.SetYPosition(20);\n}else if(Direction.equals(\"down\")){\nsuper.SetYPosition(-20);\n}else if(Direction.equals(\"right\")){\nsuper.SetXPosition(20);\n}else{\nsuper.SetXPosition(-20);\n}\n}\nVB.NET\nOverrides Sub\nMove(Direction) If\nDirection = \"up\" Then\nSetYPosition(20)\nElseIf Direction = \"down\" Then\nSetYPosition(-20)\nElseIf Direction = \"right\" Then\nSetXPosition(20)\nElseIf Direction = \"left\" Then\nSetXPosition(-20)\nEnd If\nEnd Sub\n© UCLES 2023 Page 33 of 37\n\n3(c)(ii) Python\ndef Move(self, Direction):\nif(Direction == \"up\"):\nsuper().SetYPosition(20)\nelif(Direction == \"down\"):\nsuper().SetYPosition(-20)\nelif(Direction == \"right\"):\nsuper().SetXPosition(2)\nelse:\nsuper().SetXPosition(-20)\n\n3(d) One mark each 1\n• Declaring new BikeCharacter with correct values e.g.\nJava\nBikeCharacter Karla = new BikeCharacter(100, 50, \"Karla\");\nVB.NET\nDim Karla As BikeCharacter = New BikeCharacter(100, 50, \"Karla\")\nPython\nKarla = BikeCharacter(100, 50, \"Karla\")\n© UCLES 2023 Page 34 of 37\n\n3(e)(i) One mark each to max 5 5\n• Reading in both values (character and direction) with appropriate prompts\n• Character name is validated as e.g. Jack/Karla, and direction is validated as e.g. up/down/left/right\n• Calling Move() for the character input, with direction input as a parameter\n• Outputting character's new X and Y position in a suitable format …\n• … using get methods\nExample program code:\nJava\nSystem.out.println(\"Would you like to move Jack or Karla?\");\nCharacterToMove = (scanner.nextLine()).toLowerCase();\nwhile(CharacterToMove.equals(\"jack\") == false &&\nCharacterToMove.equals(\"karla\") == false){\nSystem.out.println(\"Invalid, try again\");\nCharacterToMove = (scanner.nextLine()).toLowerCase();\n}\nSystem.out.println(\"Which direction? Up, down, left or right?\");\nDirection = (scanner.nextLine()).toLowerCase();\nwhile(Direction.equals(\"up\") == false && Direction.equals(\"down\") == false\n&& Direction.equals(\"left\") == false && Direction.equals(\"right\")== false){\nSystem.out.println(\"Invalid, try again\");\nDirection = (scanner.nextLine()).toLowerCase();\n}\nif(CharacterToMove.equals(\"jack\")){\nJack.Move(Direction);\nSystem.out.println(\"Jack's new position is X = \"\n+ Jack.GetXPosition() + \" Y = \" + Jack.GetYPosition());\n}else{\nKarla.Move(Direction);\nSystem.out.println(\"Karla's new position is \" +\nKarla.GetXPosition()\n+ \" \" + Karla.GetYPosition());\n}\n© UCLES 2023 Page 35 of 37\n\n3(e)(i) VB.NET\nConsole.WriteLine(\"Would you like to move Jack or Karla?\")\nCharacterToMove = Console.ReadLine.ToLower()\nWhile CharacterToMove <> \"jack\" And CharacterToMove <> \"karla\"\nConsole.WriteLine(\"Invalid try again\")\nCharacterToMove = Console.ReadLine\nEnd While\nConsole.WriteLine(\"Which direction? Up, down, left or right\")\nDirection = Console.ReadLine.ToLower()\nWhile Direction <> \"up\" And Direction <> \"down\" And Direction <> \"left\" And Direction <>\n\"right\"\nConsole.WriteLine(\"Invalid try again\")\nDirection = Console.ReadLine\nEnd While\nIf CharacterToMove = \"jack\"\nThen Jack.Move(Direction)\nConsole.WriteLine(\"Jack's new position is X = \" & Jack.GetXPosition & \" Y = \" &\nJack.GetYPosition)\nElse\nKarla.Move(Direction)\nConsole.WriteLine(\"Karla's new position is X = \" & Karla.GetXPosition & \" Y = \" &\nKarla.GetYPosition)\nEnd If\nConsole.WriteLine(\"Would you like to Continue? Enter True to continue, or anything else to\nquit\")\n© UCLES 2023 Page 36 of 37\n\n3(e)(i) Python\nCharacterToMove = input(\"Would you like to move Jack or Karla?\").lower()\nwhile CharacterToMove != \"jack\" and CharacterToMove != \"karla\":\nCharacterToMove = input(\"Invalid try again\")\nDirection = input(\"Which direction? Up, down, left or right?\")\nwhile Direction != \"up\" and Direction != \"down\" and Direction != \"left\" and Direction !=\n\"right\":\nDirection = input(\"Invalid try again\")\nif CharacterToMove == \"jack\":\nJack.Move(Direction)\nprint(\"Jack's new position is X =\", Jack.GetXPosition(), \"Y =\", Jack.GetYPosition())\nelse:\nKarla.Move(Direction)\nprint(\"Karla's new position is X =\", Karla.GetXPosition(), \"Y =\", Karla.GetYPosition())\n\n3(e)(ii) One mark for each test 2\n© UCLES 2023 Page 37 of 37",
      "source_pages": [
        25,
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37
      ],
      "source_pdf": "_source-pdfs/2023-oct-nov/ms/9618_w23_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2023-Oct-Nov/9618_w23_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w23_ms_43-p25.png",
        "../answer-assets/9618_w23_ms_43-p26.png",
        "../answer-assets/9618_w23_ms_43-p27.png",
        "../answer-assets/9618_w23_ms_43-p28.png",
        "../answer-assets/9618_w23_ms_43-p29.png",
        "../answer-assets/9618_w23_ms_43-p30.png",
        "../answer-assets/9618_w23_ms_43-p31.png",
        "../answer-assets/9618_w23_ms_43-p32.png",
        "../answer-assets/9618_w23_ms_43-p33.png",
        "../answer-assets/9618_w23_ms_43-p34.png",
        "../answer-assets/9618_w23_ms_43-p35.png",
        "../answer-assets/9618_w23_ms_43-p36.png",
        "../answer-assets/9618_w23_ms_43-p37.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q01",
      "question_id": "9618-2024-mj-31-q01",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point (Max 3) 3\nMP1 conversion of exponent 001001 to 9\nMP2 application of exponent to mantissa to go from 0.100111100 to 100111100 // 256 + 32 + 16 + 8 + 4 seen // 64/128\n+ 8/128 + 4/128 + 2/128 + 1/128 = 79/128 // 1/2 + 1/16 + 1/32 + 1/64 + 1/128 = 79/128\nMP3 correct answer = 316\n\n1(b) One mark per mark point (Max 3) 3\nMP1 number converted to binary 10011001.01 // number converted to positive 102.75, reversed bits and 1 added.\n(0)1100110.11  10011001.00  10011001.01 // -128 + 16 + 8 + 1 + 0.25 = –102.75\nMP2 exponent = 7 // Moving binary point the correct number of places\nMP3 correct answer\nMantissa Exponent\n\n1 0 0 1 1 0 0 1 0 1 0 0 0 1 1 1\n© Cambridge University Press & Assessment 2024 Page 4 of 14",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q02",
      "question_id": "9618-2024-mj-31-q02",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 2,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) Two marks for all protocols in correct position 2\nOne mark for at least two protocols in correct position\nApplication\nTransport\nInternet\nLink\n\n2(b) One mark per mark point (Max 2) 2\nMP1 The transport layer is responsible for delivery of data from the source host to the destination host\nMP2 It is where data is broken up into packets and sent to the internet layer\nMP3 Adds the sequence number to the packet header\nMP4 It establishes end to end contact\nMP5 It ensures data arrives error free // It retransmits packets if lost.\n\n2(c) One mark for name of protocol and one mark for expansion (Max 2) 2\nHTTP(S) – responsible for correct transfer of files / hypertext documents that make up web pages on the world wide web\nFTP – used when transferring files from a server to a client on a network\nPOP3 – handles the receiving of emails\nIMAP – handles the receiving of emails\nSMTP – handles the sending of emails\nBitTorrent – provides peer-to-peer file sharing\n© Cambridge University Press & Assessment 2024 Page 5 of 14",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p05.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q03",
      "question_id": "9618-2024-mj-31-q03",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 3,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per mark point (Max 2) 3\nnon-composite data types\nMP1 Non-composite data types can both be user-defined or primitive\nMP2 Non-composite data types do not refer to other data types in their definition / contain one data type in their\ndefinition\nMP3 Non-composite data types can be primitive/enumerated/pointer\nOne mark per mark point (Max 2)\ncomposite data types\nMP4 Composite data types can be user-defined or primitive\nMP5 Composite data types refer to other data types in their definition/contain more than one data type in their\ndefinition\nMP6 Composite data types can be record/set/class\n\n3(b) One mark for TYPE FootballClub and ENDTYPE correct 4\nOne mark for every two correct declarations\nExample answer\nTYPE FootballClub\nDECLARE TeamName : STRING\nDECLARE DateOfJoining : DATE\nDECLARE MainTelephone : STRING\nDECLARE ManagerName : STRING\nDECLARE NumberOfMembers : INTEGER\nDECLARE LeaguePosition : INTEGER\nENDTYPE\n© Cambridge University Press & Assessment 2024 Page 6 of 14",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q04",
      "question_id": "9618-2024-mj-31-q04",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 4,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark per mark point (Max 2) 2\nMP1 Sequential access method searches for records one after the other\nMP2 … from the physical start of the file until the record is found/the end of file.\n\n4(b) One mark per mark point (Max 3) 3\nMP1 For serial files, records are stored in chronological order\nMP2 … every record needs to be checked until the record is found, or all records have been checked.\nMP3 For sequential files, records are stored in order of a key field/index, and it is the key field/index that is compared.\nMP4 … every record is checked until the record is found, or the key field of the current record is greater than the key\nfield of the target record.\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q05",
      "question_id": "9618-2024-mj-31-q05",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark per correct term (Max 3) 3\n(5 + 2)\n/ (9 – 3)\n* 3\nComplete correct answer\n((5 + 2) / (9 - 3)) * 3\n\n5(b) One mark 7 3 + 2\nOne mark 2 8 * - 6 /\nComplete answer\n7 3 + 2 8 * - 6 /\n© Cambridge University Press & Assessment 2024 Page 7 of 14\n\n5(c) One mark per ring (Max 4) 4\n3\n\n5 7 7 10 10\n17 17 12 12 12 12 120 120 12\n© Cambridge University Press & Assessment 2024 Page 8 of 14",
      "source_pages": [
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p07.png",
        "../answer-assets/9618_s24_ms_31-p08.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q06",
      "question_id": "9618-2024-mj-31-q06",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for working, all four columns P, Q, R and S 3\nOne mark for first four rows of column Z\nOne mark for second four rows of column Z\nWorking space\nA B C P Q R S Z\n0 0 0 1 0 0 1 1\n0 0 1 1 0 0 1 1\n0 1 0 0 0 0 0 0\n0 1 1 0 0 0 0 0\n1 0 0 1 0 0 0 0\n1 0 1 1 0 1 0 1\n1 1 0 0 0 0 1 1\n1 1 1 0 1 0 1 1\n\n6(b) Two marks for all five correct terms and no extras 2\nOne mark for any three correct terms\n(Z =) A.B.C + A.B.C + A.B.C + A.B.C + A.B.C\n© Cambridge University Press & Assessment 2024 Page 9 of 14\n\n6(c)(i) Two marks if all correct 2\nOne mark if one error present\nBC\n00 01 11 10\nA\n0 1 1 0 0\n1 1 1 1 1\n\n6(c)(ii) One mark for each correct loop (Max 2) 2\nBC\n00 01 11 10\nA\n0 1 1 0 0\n1 1 1 1 1\n\n6(c)(iii) A + B 1\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p09.png",
        "../answer-assets/9618_s24_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q07",
      "question_id": "9618-2024-mj-31-q07",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 7,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark per point (max 3) 3\nMP1 A digital certificate is an electronic/online document.\nMP2 used to authenticate/prove the identity of a website/the online identity of an individual/organisation\nMP3 typically issued by a CA\nMP4 For example: it contains information identifying a website owner/individual and a public key\n\n7(b) One mark per point (max 2) 2\nMP1 The digital certificate provides the public key\nMP2 … that can be used to validate the private key associated with the organisation/website/digital signature\n© Cambridge University Press & Assessment 2024 Page 10 of 14",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q08",
      "question_id": "9618-2024-mj-31-q08",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 8,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correctly completed clause (Max 3) 3\n(23) feature(sliding_doors).\n(24) available(sliding_doors, minivan).\n(25) unavailable(sliding_doors, hatchback).\n\n8(b) (Options =) sunroof, reversing_camera 1\n\n8(c) One mark per mark point (Max 4) 4\nMP1 feature(F)\nMP2 bodystyle(B)\nMP3 unavailable(F, B)\nMP4 all correct Boolean operators and punctuation (allow , for AND) and no additional lines of code\nExample answers\nmay_choose_option(F, B)\nIF\nfeature(F) AND bodystyle(B) AND NOT unavailable(F, B).\nfeature(F), bodystyle(B), NOT unavailable(F, B).\nQuestion Answer Marks",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p11.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q09",
      "question_id": "9618-2024-mj-31-q09",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 9,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "9 One mark per mark point (Max 3) 3\nMP1 Deep learning learns by finding hidden patterns that are undetectable to humans.\nMP2 It structures algorithms in layers: input layer, hidden layers and output layer.\nMP3 … to create an artificial neural network to learn and make intelligent decisions on its own.\nMP4 It is trained using large quantities of unlabelled data.\nMP5 Deep learning requires/uses a large number of hidden layers.\nMP6 … the larger the number of layers, the higher the level of success.\n© Cambridge University Press & Assessment 2024 Page 11 of 14",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p11.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q10",
      "question_id": "9618-2024-mj-31-q10",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 10,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark 1\nThe elements are sorted according to the compare function / in ascending / descending order.\n\n10(b) One mark for each correctly completed line (Max 5) 5\nDECLARE Names : ARRAY[1:100000] OF STRING\nDECLARE TopOfList : INTEGER\nDECLARE EndOfList : INTEGER\nDECLARE CurrentItem : INTEGER\nDECLARE ToFind : STRING\nDECLARE Found : BOOLEAN\nDECLARE NotInList : BOOLEAN\nTopOfList  1\nEndOfList  100000\nOUTPUT \"Which name do you wish to find? \"\nINPUT ToFind\nFound  FALSE\nNotInList  FALSE\nWHILE Found = FALSE AND NotInList = FALSE\nCurrentItem  (TopOfList + EndOfList) DIV 2\nIF ToFind = Names[CurrentItem]// Names[CurrentItem] = ToFind THEN\nFound  TRUE\nELSE\nIF TopOfList >= EndOfList THEN\nNotInList  TRUE\nELSE\nIF ToFind > Names[CurrentItem] THEN\nTopOfList  CurrentItem + 1\nELSE\nEndOfList  CurrentItem – 1\nENDIF\nENDIF\nENDIF\nENDWHILE\n© Cambridge University Press & Assessment 2024 Page 12 of 14\n\n10(b) IF Found = TRUE THEN\nOUTPUT \"Item found at position \", CurrentItem, \" in array\"\nELSE\nOUTPUT \"Item not in array\"\nENDIF\n\n10(c) One mark from 2\nMP1 Big O for a binary search is O(Log n).\n2\nMP2 Big O notation is used to indicate the time/space complexity of an algorithm.\nOne mark from\nMP3 The time taken to complete the search increases logarithmically as the number of search items increases linearly\nMP4 The time taken to complete the search increases linearly as the number of search items increases exponentially\nMP5 As the search field is repeatedly getting smaller, the number of comparisons made before the item is found, or the\nnumber of items runs out, is relatively small.\n© Cambridge University Press & Assessment 2024 Page 13 of 14",
      "source_pages": [
        12,
        13
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p12.png",
        "../answer-assets/9618_s24_ms_31-p13.png"
      ]
    },
    {
      "id": "9618-2024-mj-31-q11",
      "question_id": "9618-2024-mj-31-q11",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 11,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark per mark point (Max 2) 2\nMP1 Uses hard-wired code/control units\nMP2 Uses relatively few instructions / simple instructions\nMP3 Uses relatively few addressing modes\nMP4 Makes use of a single-cycle for each instruction\nMP5 Makes use of fixed length / fixed format instructions\nMP6 Makes use of general-purpose registers\nMP7 Pipelining is straightforward to apply\nMP8 The design emphasis is on the software\nMP9 Processor chips require few transistors.\n\n11(b) One mark per mark point (Max 3) 3\nMP1 Once the processor detects an interrupt at the start/end of the fetch-execute cycle\nMP2 … the current program is temporarily stopped and the status of each register stored on the stack.\nMP3 After the interrupt has been serviced/the Interrupt Service Routine (ISR) has been executed …\nMP4 … the registers can be restored to its original status before the interrupt was detected // … the data can be\nrestored from the stack.\n\n11(c) One mark per mark point (Max 3) 3\nMP1 Pipelining adds an additional complexity // there could be a number of instructions still in the pipeline when the\ninterrupt is received\nMP2 All the instructions currently in operation are usually discarded except for the last one/the one at write back\nMP3 … the interrupt handler routine is applied to the remaining instruction.\nMP4 Once the interrupt has been serviced the processor can restart with the next instruction in the sequence.\n© Cambridge University Press & Assessment 2024 Page 14 of 14",
      "source_pages": [
        14
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_31-p14.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q01",
      "question_id": "9618-2024-mj-32-q01",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point (Max 2) 2\nMP1 When the number of bits in the mantissa is raised, the precision / accuracy of the number represented increases //\nwhen the number of bits in the mantissa is lowered, the precision / accuracy of the number represented reduces.\nMP2 When the number of bits in the exponent is reduced, the range of numbers that can be represented is reduced //\nwhen the number of bits in the exponent is increased, the range of possible numbers that can be represented\nincreases.\nMP3 When the range increases the accuracy decreases // When the range decreases the accuracy increases.\n\n1(b) One mark per mark point (Max 3) 3\n number converted to binary e.g. 54.8125 = 00110110.1101 // Fractions method 1/2 + 1/4 + 1/16 + 1/32 + 1/128 + 1/256\n+ 1/1024 = 877/1024 // 32 + 16 + 4 + 2 + 0.5 + 0.25 + 0.0625 / (1/2 + 1/4 + 1/16)\n exponent = 6 // Moving binary point the correct number of places\n correct answer\nMantissa Exponent\n0 1 1 0 1 1 0 1 1 0 1 0 0 1 1 0\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q02",
      "question_id": "9618-2024-mj-32-q02",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 2,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark per mark point (Max 2) 2\nMP1 Protocols provide a standard set of rules that enables successful data transfer between devices.\nMP2 Allows communication between devices on different platforms.\nMP3 Makes communications independent of software and hardware.\n\n2(b) One mark per mark point 2\nMP1 Sending - SMTP\nMP2 Receiving – POP3 // IMAP // Post Office Protocol 3\n\n2(c) One mark per mark point (Max 3) 3\nMP1 BitTorrent allows the sharing of files between thousands of users who are connected together over the internet.\nMP2 It allows more users to share files with each other than would be the case with a peer-to-peer network.\nMP3 Users share files directly with each other // the users’ computers are acting as peers\nMP4 … no web server / central device is used // all users are of equal status.\n© Cambridge University Press & Assessment 2024 Page 4 of 14",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q03",
      "question_id": "9618-2024-mj-32-q03",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 3,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per mark point (Max 3) 3\nMP1 A data type that is defined without referencing another data type.\nMP2 It can be a primitive data type found in a programming language or a user-defined data type.\nMP3 Example – enumerated data type / pointer data type / allow a correct example of an enumerated or pointer data\ntype declaration.\n\n3(b) One mark per mark point (Max 4) 4\nMP1 Type statement fully correct\nMP2 DEFINE EvenNumbers\nMP3 Correct list of values in brackets\nMP4 : <set identifier> from Type statement used\nExample answer\nTYPE Numbers = SET OF INTEGER\nDEFINE EvenNumbers (2, 4, 6, 8, 10, 12): Numbers\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q04",
      "question_id": "9618-2024-mj-32-q04",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 4,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "4 One mark per mark point (Max 4) 4\nMP1 Sheila’s computer uses an algorithm to generate a matching pair of keys private and public\nMP2 Sheila’s computer sends Fred’s computer Sheila’s public key // Fred‘s computer acquires Sheila’s public key\nMP3 Fred’s computer encrypts the document/plain text using Sheila’s public key to create cipher text\nMP4 Fred’s computer sends the cipher text to Sheila’s computer The cipher text can only be decrypted using Sheila’s\nprivate key // Sheila’s computer uses Sheila’s private key to decrypt the cipher text.\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q05",
      "question_id": "9618-2024-mj-32-q05",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark 7 2 – 8 + 2\nOne mark 9 5 - /\nComplete answer\n7 2 – 8 + 9 5 - /\n© Cambridge University Press & Assessment 2024 Page 5 of 14\n\n5(b) One mark per ring (Max 4) 4\n3 7\n9 6 6 9 9 2",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p05.png",
        "../answer-assets/9618_s24_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q06",
      "question_id": "9618-2024-mj-32-q06",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "6 6 15 15 15 15 15 15 30\n5(c) One mark per correct term (Max 3) 3\n(a – c + b)\n* (d + b)\n/c\nComplete correct answer\n(((a – c) + b) * (d + b))/c\nOr\n(a – c + b) * (d + b)/c\n© Cambridge University Press & Assessment 2024 Page 6 of 14\n\n6(a) One mark for working, all five columns P, Q, R, S and T 3\nOne mark for first four rows of column Z\nOne mark for second four rows of column Z\nWorking space\nA B C P Q R S T Z\n0 0 0 1 1 1 1 1 0\n0 0 1 1 1 0 1 0 1\n0 1 0 1 0 1 1 0 1\n0 1 1 1 0 0 1 0 1\n1 0 0 0 1 1 0 0 0\n1 0 1 0 1 0 1 0 1\n1 1 0 0 0 1 1 0 1\n1 1 1 0 0 0 1 0 1\n\n6(b) Two marks for all six correct terms only 2\nOne mark for any three correct terms\n(Z = ) A.B.C + A.B.C + A.B.C + A.B.C + A.B.C + A.B.C\n© Cambridge University Press & Assessment 2024 Page 7 of 14\n\n6(c)(i) Two marks if all correct 2\nOne mark if only one error present\nBC\n00 01 11 10\nA\n0 1 0 1 1\n1 1 0 1 1\n\n6(c)(ii) One mark for each correct loop (Max 2) 2\nBC\n00 01 11 10\nA\n0\n0 1 1 1\n1 1 0 1 1\n\n6(c)(iii) B + C 1\nQuestion Answer Marks",
      "source_pages": [
        6,
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p06.png",
        "../answer-assets/9618_s24_ms_32-p07.png",
        "../answer-assets/9618_s24_ms_32-p08.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q07",
      "question_id": "9618-2024-mj-32-q07",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 7,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark per mark point (Max 2) 2\nMP1 Direct access allows a record to be found in a file without other records being read.\nMP2 Records are found by using the key field of the target record // the location of the record is found using a\nhashing algorithm.\n\n7(b)(i) One mark per mark point (Max 2) 2\nMP1 In sequential files, an index of all key fields is kept\nMP2 The index is searched for the address of the file location where the target record is stored.\n© Cambridge University Press & Assessment 2024 Page 8 of 14\n\n7(b)(ii) One mark per mark point (Max 2) 2\nMP1 A hashing algorithm is used on the key field of the record\nMP2 … to calculate the address of the memory location where the target record is expected to be stored.\nMP3 Method to find a record if it is not at the expected location e.g. linear probing, search overflow area etc.\n© Cambridge University Press & Assessment 2024 Page 9 of 14",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p08.png",
        "../answer-assets/9618_s24_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q08",
      "question_id": "9618-2024-mj-32-q08",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 8,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correctly completed line (Max 4) 4\nDECLARE Widgets : ARRAY[1:50000] OF STRING\nDECLARE TopOfList : INTEGER\nDECLARE EndOfList : INTEGER\nDECLARE Count : INTEGER\nDECLARE ToFind : STRING\nDECLARE Found : BOOLEAN\nDECLARE NotInList : BOOLEAN\nTopOfList  1\nEndOfList  50000\nOUTPUT \"Enter the name of the item you wish to find \"\nINPUT ToFind\nFound  FALSE\nNotInList  FALSE\nCount  TopOfList\nWHILE Found = FALSE AND NotInList = FALSE // Count <= EndOfList\nIF ToFind = Widgets[Count] // Widgets[Count] = ToFind THEN\nFound  TRUE\nENDIF\nCount  Count + 1\nIF Found = FALSE AND Count > EndOfList THEN\nNotInList  TRUE\nENDIF\nENDWHILE\nIF Found = TRUE THEN\nOUTPUT \"Item found at position \", Count - 1, \" in array\"\nELSE\nOUTPUT \"Item not in array\"\nENDIF\n© Cambridge University Press & Assessment 2024 Page 10 of 14\n\n8(b) Max 4 4\nOne mark per mark point (Max 3)\nMP1 Linear search sequentially checks each element of the array / list.\nMP2 … until the matching element is found, or the end of the array / list is reached.\nMP3 Binary search finds the mid-point of an array/list and determines which side contains the item to be found\nMP4 … it discards the half of the array/list not containing the search item // … it finds the position of a target value within\nan array / list by repeatedly halving the target search field.\nMP5 The binary search requires the elements to be sorted // The linear search does not require the elements to be\nsorted.\nMP6 The binary search will usually do many fewer comparisons of records/iterations against the target than a linear\nsearch before it finds its target.\nMP7 Linear search starts at the beginning of the array/list and binary search starts in the middle of the array/list.\nOne mark per mark point (Max 2)\nMP8 Big O for binary search is O (Log n)\n2\nMP9 Big O for linear search is O (n)\nMP10 Big O notation is used to indicate the time / space complexity of an algorithm\n© Cambridge University Press & Assessment 2024 Page 11 of 14",
      "source_pages": [
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p10.png",
        "../answer-assets/9618_s24_ms_32-p11.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q09",
      "question_id": "9618-2024-mj-32-q09",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 9,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark per mark point for up to two benefits (Max 2) 4\nMP1 COMPATIBILTY e.g. Applications that aren’t compatible with the host computer can be run on the virtual machine\n// It is possible to emulate old software on a new system by running a compatible guest operating system as a\nvirtual machine // Software can be tried on different OS on the same hardware.\nMP2 PROTECTION e.g. The guest operating system has no effect on anything outside the virtual machine other virtual\nmachines or the host computer//Virtual machines are useful for testing as they will not crash the host computer if\nsomething goes wrong // Easier to recover if software causes a system crash as virtual machine software protects\nthe host system.\nMP3 COST e.g. No need to buy extra computers / hardware as multiple virtual machines can be implemented on the\nsame hardware.\nOne mark per mark point for up to two limitations (Max 2)\nMP4 PERFORMANCE e.g. The performance of the guest operating system will not be as good on a virtual machine as\nit would be on its own compatible machine because of the extra code / using more RAM/memory space // The\nperformance of the VM is dependent on the capabilities of the host computer // Response times cannot be\naccurately measured using a virtual machine.\nMP5 COMPLEXITY e.g. Building an in-house virtual machine can be expensive, time consuming and complex to\nmaintain / set-up.\nMP6 HARDWARE/SOFTWARE ISSUES e.g. Some hardware/software can’t be emulated with a virtual machine //\nSome of the host machine’s hardware can’t be directly accessed by the virtual machine.\n\n9(b) One mark per mark point – host operating system (Max 2) 3\nMP1 The host operating system is the normal operating system for the host computer / machine.\nMP2 It has control of all the resources of the host computer / machine. // It can access the physical resources of the\nhost computer / machine.\nMP3 It provides a user interface to operate the virtual machine software.\nMP4 It also runs the virtual machine software.\nOne mark per mark point – guest operating system (Max 2)\nMP5 The guest operating system runs within the virtual machine.\nMP6 … it controls the virtual hardware/software during the emulation. // It accesses the actual hardware through the\nvirtual machine and host operating system.\nMP7 It provides a virtual user interface for the emulated hardware/software.\nMP8 The guest operating system runs under the control of the host operating system.\n© Cambridge University Press & Assessment 2024 Page 12 of 14",
      "source_pages": [
        12
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p12.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q10",
      "question_id": "9618-2024-mj-32-q10",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 10,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark for each correctly completed clause (Max 4) 4\nExample answer\n(25) client(jane).\n(26) activity(surfing).\n(27) choice(jane, surfing).\n(28) done(jane, sailing).\n\n10(b) (List =) frankie, erik, henry 1\n\n10(c) One mark per mark point (Max 4) 4\nMP1 client(C)\nMP2 activity(A)\nMP3 done(C, A)\nMP4 all correct Boolean operators and punctuation (allow , for AND). There must be the correct number of terms and\nno additional lines of code\nExample answers\nmay_choose_activity(C, A)\nIF\nclient(C) AND activity(A) AND NOT done(C, A).\nclient(C), activity(A), NOT (done(C, A)).\n© Cambridge University Press & Assessment 2024 Page 13 of 14",
      "source_pages": [
        13
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p13.png"
      ]
    },
    {
      "id": "9618-2024-mj-32-q11",
      "question_id": "9618-2024-mj-32-q11",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 11,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "11 One mark per mark point (Max 3) 3\nMP1 Reinforcement learning is a machine learning technique based on feedback / rewards / punishment.\nMP2 … in which an agent learns to behave in an environment by performing the actions and seeing the results of the\nactions.\nMP3 … for each good action, the agent gets positive feedback / reward and each bad action receives negative feedback\n/ punishment.\nMP4 The agent learns automatically using feedback without any labelled data / specific instructions.\nMP5 Adjust node weightings to achieve the correct outcome. // Using feedback to improve its performance at\naccomplishing similar tasks.\n© Cambridge University Press & Assessment 2024 Page 14 of 14",
      "source_pages": [
        14
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_32.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_32-p14.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q01",
      "question_id": "9618-2024-mj-33-q01",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point (Max 3) 3\nMP1 conversion of exponent 001001 to 9\nMP2 application of exponent to mantissa to go from 0.100111100 to 100111100 // 256 + 32 + 16 + 8 + 4 seen // 64/128\n+ 8/128 + 4/128 + 2/128 + 1/128 = 79/128 // 1/2 + 1/16 + 1/32 + 1/64 + 1/128 = 79/128\nMP3 correct answer = 316\n\n1(b) One mark per mark point (Max 3) 3\nMP1 number converted to binary 10011001.01 // number converted to positive 102.75, reversed bits and 1 added.\n(0)1100110.11  10011001.00  10011001.01 // -128 + 16 + 8 + 1 + 0.25 = –102.75\nMP2 exponent = 7 // Moving binary point the correct number of places\nMP3 correct answer\nMantissa Exponent\n\n1 0 0 1 1 0 0 1 0 1 0 0 0 1 1 1\n© Cambridge University Press & Assessment 2024 Page 4 of 14",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q02",
      "question_id": "9618-2024-mj-33-q02",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 2,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) Two marks for all protocols in correct position 2\nOne mark for at least two protocols in correct position\nApplication\nTransport\nInternet\nLink\n\n2(b) One mark per mark point (Max 2) 2\nMP1 The transport layer is responsible for delivery of data from the source host to the destination host\nMP2 It is where data is broken up into packets and sent to the internet layer\nMP3 Adds the sequence number to the packet header\nMP4 It establishes end to end contact\nMP5 It ensures data arrives error free // It retransmits packets if lost.\n\n2(c) One mark for name of protocol and one mark for expansion (Max 2) 2\nHTTP(S) – responsible for correct transfer of files / hypertext documents that make up web pages on the world wide web\nFTP – used when transferring files from a server to a client on a network\nPOP3 – handles the receiving of emails\nIMAP – handles the receiving of emails\nSMTP – handles the sending of emails\nBitTorrent – provides peer-to-peer file sharing\n© Cambridge University Press & Assessment 2024 Page 5 of 14",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p05.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q03",
      "question_id": "9618-2024-mj-33-q03",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 3,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per mark point (Max 2) 3\nnon-composite data types\nMP1 Non-composite data types can both be user-defined or primitive\nMP2 Non-composite data types do not refer to other data types in their definition / contain one data type in their\ndefinition\nMP3 Non-composite data types can be primitive/enumerated/pointer\nOne mark per mark point (Max 2)\ncomposite data types\nMP4 Composite data types can be user-defined or primitive\nMP5 Composite data types refer to other data types in their definition/contain more than one data type in their\ndefinition\nMP6 Composite data types can be record/set/class\n\n3(b) One mark for TYPE FootballClub and ENDTYPE correct 4\nOne mark for every two correct declarations\nExample answer\nTYPE FootballClub\nDECLARE TeamName : STRING\nDECLARE DateOfJoining : DATE\nDECLARE MainTelephone : STRING\nDECLARE ManagerName : STRING\nDECLARE NumberOfMembers : INTEGER\nDECLARE LeaguePosition : INTEGER\nENDTYPE\n© Cambridge University Press & Assessment 2024 Page 6 of 14",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q04",
      "question_id": "9618-2024-mj-33-q04",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 4,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark per mark point (Max 2) 2\nMP1 Sequential access method searches for records one after the other\nMP2 … from the physical start of the file until the record is found/the end of file.\n\n4(b) One mark per mark point (Max 3) 3\nMP1 For serial files, records are stored in chronological order\nMP2 … every record needs to be checked until the record is found, or all records have been checked.\nMP3 For sequential files, records are stored in order of a key field/index, and it is the key field/index that is compared.\nMP4 … every record is checked until the record is found, or the key field of the current record is greater than the key\nfield of the target record.\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q05",
      "question_id": "9618-2024-mj-33-q05",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark per correct term (Max 3) 3\n(5 + 2)\n/ (9 – 3)\n* 3\nComplete correct answer\n((5 + 2) / (9 - 3)) * 3\n\n5(b) One mark 7 3 + 2\nOne mark 2 8 * - 6 /\nComplete answer\n7 3 + 2 8 * - 6 /\n© Cambridge University Press & Assessment 2024 Page 7 of 14\n\n5(c) One mark per ring (Max 4) 4\n3\n\n5 7 7 10 10\n17 17 12 12 12 12 120 120 12\n© Cambridge University Press & Assessment 2024 Page 8 of 14",
      "source_pages": [
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p07.png",
        "../answer-assets/9618_s24_ms_33-p08.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q06",
      "question_id": "9618-2024-mj-33-q06",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for working, all four columns P, Q, R and S 3\nOne mark for first four rows of column Z\nOne mark for second four rows of column Z\nWorking space\nA B C P Q R S Z\n0 0 0 1 0 0 1 1\n0 0 1 1 0 0 1 1\n0 1 0 0 0 0 0 0\n0 1 1 0 0 0 0 0\n1 0 0 1 0 0 0 0\n1 0 1 1 0 1 0 1\n1 1 0 0 0 0 1 1\n1 1 1 0 1 0 1 1\n\n6(b) Two marks for all five correct terms and no extras 2\nOne mark for any three correct terms\n(Z =) A.B.C + A.B.C + A.B.C + A.B.C + A.B.C\n© Cambridge University Press & Assessment 2024 Page 9 of 14\n\n6(c)(i) Two marks if all correct 2\nOne mark if one error present\nBC\n00 01 11 10\nA\n0 1 1 0 0\n1 1 1 1 1\n\n6(c)(ii) One mark for each correct loop (Max 2) 2\nBC\n00 01 11 10\nA\n0 1 1 0 0\n1 1 1 1 1\n\n6(c)(iii) A + B 1\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p09.png",
        "../answer-assets/9618_s24_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q07",
      "question_id": "9618-2024-mj-33-q07",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 7,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark per point (max 3) 3\nMP1 A digital certificate is an electronic/online document.\nMP2 used to authenticate/prove the identity of a website/the online identity of an individual/organisation\nMP3 typically issued by a CA\nMP4 For example: it contains information identifying a website owner/individual and a public key\n\n7(b) One mark per point (max 2) 2\nMP1 The digital certificate provides the public key\nMP2 … that can be used to validate the private key associated with the organisation/website/digital signature\n© Cambridge University Press & Assessment 2024 Page 10 of 14",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q08",
      "question_id": "9618-2024-mj-33-q08",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 8,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each correctly completed clause (Max 3) 3\n(23) feature(sliding_doors).\n(24) available(sliding_doors, minivan).\n(25) unavailable(sliding_doors, hatchback).\n\n8(b) (Options =) sunroof, reversing_camera 1\n\n8(c) One mark per mark point (Max 4) 4\nMP1 feature(F)\nMP2 bodystyle(B)\nMP3 unavailable(F, B)\nMP4 all correct Boolean operators and punctuation (allow , for AND) and no additional lines of code\nExample answers\nmay_choose_option(F, B)\nIF\nfeature(F) AND bodystyle(B) AND NOT unavailable(F, B).\nfeature(F), bodystyle(B), NOT unavailable(F, B).\nQuestion Answer Marks",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p11.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q09",
      "question_id": "9618-2024-mj-33-q09",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 9,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "9 One mark per mark point (Max 3) 3\nMP1 Deep learning learns by finding hidden patterns that are undetectable to humans.\nMP2 It structures algorithms in layers: input layer, hidden layers and output layer.\nMP3 … to create an artificial neural network to learn and make intelligent decisions on its own.\nMP4 It is trained using large quantities of unlabelled data.\nMP5 Deep learning requires/uses a large number of hidden layers.\nMP6 … the larger the number of layers, the higher the level of success.\n© Cambridge University Press & Assessment 2024 Page 11 of 14",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p11.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q10",
      "question_id": "9618-2024-mj-33-q10",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 10,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark 1\nThe elements are sorted according to the compare function / in ascending / descending order.\n\n10(b) One mark for each correctly completed line (Max 5) 5\nDECLARE Names : ARRAY[1:100000] OF STRING\nDECLARE TopOfList : INTEGER\nDECLARE EndOfList : INTEGER\nDECLARE CurrentItem : INTEGER\nDECLARE ToFind : STRING\nDECLARE Found : BOOLEAN\nDECLARE NotInList : BOOLEAN\nTopOfList  1\nEndOfList  100000\nOUTPUT \"Which name do you wish to find? \"\nINPUT ToFind\nFound  FALSE\nNotInList  FALSE\nWHILE Found = FALSE AND NotInList = FALSE\nCurrentItem  (TopOfList + EndOfList) DIV 2\nIF ToFind = Names[CurrentItem]// Names[CurrentItem] = ToFind THEN\nFound  TRUE\nELSE\nIF TopOfList >= EndOfList THEN\nNotInList  TRUE\nELSE\nIF ToFind > Names[CurrentItem] THEN\nTopOfList  CurrentItem + 1\nELSE\nEndOfList  CurrentItem – 1\nENDIF\nENDIF\nENDIF\nENDWHILE\n© Cambridge University Press & Assessment 2024 Page 12 of 14\n\n10(b) IF Found = TRUE THEN\nOUTPUT \"Item found at position \", CurrentItem, \" in array\"\nELSE\nOUTPUT \"Item not in array\"\nENDIF\n\n10(c) One mark from 2\nMP1 Big O for a binary search is O(Log n).\n2\nMP2 Big O notation is used to indicate the time/space complexity of an algorithm.\nOne mark from\nMP3 The time taken to complete the search increases logarithmically as the number of search items increases linearly\nMP4 The time taken to complete the search increases linearly as the number of search items increases exponentially\nMP5 As the search field is repeatedly getting smaller, the number of comparisons made before the item is found, or the\nnumber of items runs out, is relatively small.\n© Cambridge University Press & Assessment 2024 Page 13 of 14",
      "source_pages": [
        12,
        13
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p12.png",
        "../answer-assets/9618_s24_ms_33-p13.png"
      ]
    },
    {
      "id": "9618-2024-mj-33-q11",
      "question_id": "9618-2024-mj-33-q11",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 11,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark per mark point (Max 2) 2\nMP1 Uses hard-wired code/control units\nMP2 Uses relatively few instructions / simple instructions\nMP3 Uses relatively few addressing modes\nMP4 Makes use of a single-cycle for each instruction\nMP5 Makes use of fixed length / fixed format instructions\nMP6 Makes use of general-purpose registers\nMP7 Pipelining is straightforward to apply\nMP8 The design emphasis is on the software\nMP9 Processor chips require few transistors.\n\n11(b) One mark per mark point (Max 3) 3\nMP1 Once the processor detects an interrupt at the start/end of the fetch-execute cycle\nMP2 … the current program is temporarily stopped and the status of each register stored on the stack.\nMP3 After the interrupt has been serviced/the Interrupt Service Routine (ISR) has been executed …\nMP4 … the registers can be restored to its original status before the interrupt was detected // … the data can be\nrestored from the stack.\n\n11(c) One mark per mark point (Max 3) 3\nMP1 Pipelining adds an additional complexity // there could be a number of instructions still in the pipeline when the\ninterrupt is received\nMP2 All the instructions currently in operation are usually discarded except for the last one/the one at write back\nMP3 … the interrupt handler routine is applied to the remaining instruction.\nMP4 Once the interrupt has been serviced the processor can restart with the next instruction in the sequence.\n© Cambridge University Press & Assessment 2024 Page 14 of 14",
      "source_pages": [
        14
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_33-p14.png"
      ]
    },
    {
      "id": "9618-2024-mj-41-q01",
      "question_id": "9618-2024-mj-41-q01",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 27,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark for: 1\n Declaration of (global) array with identifier DataStored (Integer and 20 spaces)\nand NumberItems (Integer)\ne.g.\nJava\npublic static Integer[] DataStored = new Integer[20];\npublic static Integer NumberItems= 0;\nVB.NET\nDim DataStored(19) As Integer\nDim NumberStored As Integer = 0\nPython\nglobal DataStored #integer\nglobal NumberItems #Integer 20 items\n© Cambridge University Press & Assessment 2024 Page 4 of 38\n\n1(b) 1 mark each 5\n Procedure heading (and close where appropriate) with no parameter.\n Prompt/output of suitable message to request the input of the quantity of numbers\nand reading in quantity of numbers and storing/using …\n … each input in next space in DataStored\ne.g.\nJava\npublic static void Initialise(){\nScanner scanner = new Scanner(System.in);\nInteger Quantity = 0;\ndo{\nSystem.out.println(\"How many numbers will you enter up to 20?\");\nQuantity = Integer.parseInt(scanner.nextLine());\n}while(Quantity <= 0 || Quantity > 20);\nfor(Integer X = 0; X < Quantity; X++){\nSystem.out.println(\"Enter number\");\nDataStored[NumberItems] = Integer.parseInt(scanner.nextLine());\nNumberItems++;\nVB.NET\nSub Initialise()\nConsole.WriteLine(\"How many numbers will you enter?\")\nDim Quantity As Integer\nDo\nQuantity = Console.ReadLine()\nLoop Until (Quantity > 0 And Quantity < 21)\nFor Count = 0 To Quantity - 1\nConsole.WriteLine(\"Enter number\")\nDataStored(NumberStored) = Console.ReadLine()\nNumberStored += 1\nNext\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 5 of 38\n\n1(b) Python\ndef Initialise():\nglobal DataStored\nglobal NumberItems\nValid = False\nwhile(Valid == False):\nNumberItems = int(input(\"How many numbers will you enter?\")) #loop until < 20\nif NumberItems > 0 and NumberItems< 21:\nValid = True\nfor Count in range(0, NumberItems):\nDataStored.append(int(input(\"Enter number\")))\n\n1(c)(i) 1 mark each: 2\n Storing 0 in NumberItems and then calling Initialise()\n Outputting all contents of array DataStored\ne.g.\nJava\npublic static Integer NumberItems= 0;\nInitialise();\nfor(Integer X = 0; X < NumberItems; X++){\nSystem.out.println(DataStored[X]);\nVB.NET\nNumberItems = 0\nInitialise()\nFor X = 0 To NumberItems - 1\nConsole.WriteLine(DataStored(X))\nNext\nPython\nNumberItems = 0\nInitialise()\nprint(DataStored)\n© Cambridge University Press & Assessment 2024 Page 6 of 38\n\n1(c)(ii) 1 mark each 2\n Output showing quantity entered twice (30 and 5) with first being invalid\n Array output 3 9 4 1 2\ne.g.\n© Cambridge University Press & Assessment 2024 Page 7 of 38\n\n1(d)(i) 1 mark each 4\n Procedure header (and end where appropriate)\nand looping through each array element\n Working inner loop …\n …comparison of elements…\n …swapping of elements\ne.g.\nJava\npublic static void BubbleSort(){\nInteger Temp = 0;\nfor(Integer Count = 0; Count < NumberItems; Count++){\nfor(Integer Count2 = 0; Count2 < NumberItems - 1; Count2++){\nif(DataStored[Count2] > DataStored[Count]){\nTemp = DataStored[Count2];\nDataStored[Count2] = DataStored[Count];\nDataStored[Count] = Temp;\n}\n}\n}\n}\nVB.NET\nSub BubbleSort()\nDim Temp As Integer\nFor Count = 0 To NumberStored - 1\nFor Count2 = 0 To NumberStored - 2\nIf (DataStored(Count2) > DataStored(Count)) Then\nTemp = DataStored(Count) DataStored(Count) = DataStored(Count2)\nDataStored(Count2) = Temp\nEnd If\nNext\nNext\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 8 of 38\n\n1(d)(i) Python\ndef BubbleSort():\nglobal DataStored\nglobal NumberItems\nfor Count in range(0, NumberItems):\nfor Count2 in range(0, NumberItems-1):\nif DataStored[Count2] > DataStored[Count]:\nDataStored[Count2], DataStored[Count] = DataStored[Count],\nDataStored[Count2]\n\n1(d)(ii) 1 mark for calling BubbleSort() and outputting array contents after 1\ne.g.\nVB.NET\nBubbleSort()\nFor X = 0 To NumberStored - 1\nConsole.WriteLine(DataStored(X))\nNext\ne.g. Java\nBubbleSort();\nfor(Integer X = 0; X < NumberItems; X++){\nSystem.out.println(DataStored[X]);\n}\ne.g. Python\nBubbleSort()\nprint(DataStored)\n\n1(d)(iii) 1 mark for screenshot showing the inputs and the values in the correct order 1\ne.g.\n© Cambridge University Press & Assessment 2024 Page 9 of 38\n\n1(e)(i) 1 mark each 6\n Function header BinarySearch taking DataToFind as a parameter\n Calculating the mid value (First + Last) \\ 2 or equivalent inside loop\n Checking if the data at mid is the parameter and returning mid inside loop\n If DataToFind < mid, updating Last/Upper with mid – 1 inside loop\n If DataToFind > mid, updating First/Lower with mid + 1 inside loop\n Returning -1 when not found and a suitable loop with end criteria\ne.g.\nJava\npublic static Integer BinarySearch(Integer DataToFind){\nInteger MidValue = 0;\nInteger First = 0;\nInteger Last = NumberItems;\nwhile (First <= Last){\nMidValue = (First + Last) / 2;\nif(DataToFind == DataStored[MidValue]){\nreturn MidValue;\n}\nif(DataToFind < DataStored[MidValue]){\nLast = MidValue - 1;\n}else{\nFirst = MidValue + 1;\n}\n}\nreturn -1;\n}\n© Cambridge University Press & Assessment 2024 Page 10 of 38\n\n1(e)(i) VB.NET\nFunction BinarySearch(DataToFind)\nDim First As Integer = 0\nDim Last As Integer = NumberItems\nDim MidValue As Integer\nWhile (First <= Last)\nMidValue = (First + Last) / 2\nIf DataToFind = DataStored(MidValue) Then\nReturn MidValue\nEnd If\nIf DataToFind < DataStored(MidValue) Then\nLast = MidValue - 1\nElse\nFirst = MidValue + 1\nEnd If\nEnd While\nReturn -1\nEnd Function\nPython\ndef BinarySearch(DataToFind):\nglobal DataStored\nglobal NumberItems\nFirst = 0\nLast= NumberItems\nwhile(First <= Last):\nMidValue = int((First + Last) / 2)\nif DataToFind == DataStored[MidValue]:\nreturn MidValue\nif DataToFind < DataStored[MidValue]:\nLast = MidValue - 1\nelse:\nFirst = MidValue + 1\nreturn -1\n© Cambridge University Press & Assessment 2024 Page 11 of 38\n\n1(e)(ii) 1 mark each: 3\n Taking number as input\n… calling BinarySearch with input\n Outputting value returned\ne.g.\nJava\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Enter a number to find\");\nInteger Search = Integer.parseInt(scanner.nextLine());\nSystem.out.println(BinarySearch(Search));\nVB.NET\nConsole.WriteLine(\"Enter a number to find\")\nDim Search As Integer = Console.ReadLine()\nConsole.WriteLine(BinarySearch(Search))\nPython\nSearch = int(input(\"Enter a number to find\"))\nprint(BinarySearch(Search))\n© Cambridge University Press & Assessment 2024 Page 12 of 38\n\n1(e)(iii) 1 mark for each test 2\ne.g.\nTest 1 – Accept found in index 16\nTest 2\n© Cambridge University Press & Assessment 2024 Page 13 of 38",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_41-p04.png",
        "../answer-assets/9618_s24_ms_41-p05.png",
        "../answer-assets/9618_s24_ms_41-p06.png",
        "../answer-assets/9618_s24_ms_41-p07.png",
        "../answer-assets/9618_s24_ms_41-p08.png",
        "../answer-assets/9618_s24_ms_41-p09.png",
        "../answer-assets/9618_s24_ms_41-p10.png",
        "../answer-assets/9618_s24_ms_41-p11.png",
        "../answer-assets/9618_s24_ms_41-p12.png",
        "../answer-assets/9618_s24_ms_41-p13.png"
      ]
    },
    {
      "id": "9618-2024-mj-41-q02",
      "question_id": "9618-2024-mj-41-q02",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 31,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) 1 mark each to max 4 4\n Class Tree declaration (and end where appropriate)\n All 5 attributes declared as private with correct identifiers and data types\n Constructor header (and end) taking 5 parameters\n Constructor assigns parameters to attributes\ne.g.\nJava\nclass Tree{\nprivate String TreeName;\nprivate Integer HeightGrowth;\nprivate Integer MaxWidth;\nprivate Integer MaxHeight;\nprivate String Evergreen;\npublic Tree(String Name, Integer HGrowth, Integer MaxH, Integer MaxW, String\nPEvergreen){\nTreeName = Name;\nHeightGrowth = HGrowth;\nMaxWidth = MaxW;\nMaxHeight = MaxH;\nEvergreen = PEvergreen;\n}}\n© Cambridge University Press & Assessment 2024 Page 14 of 38\n\n2(a)(i) VB.NET\nClass Tree\nPrivate TreeName As String\nPrivate HeightGrowth As Integer\nPrivate MaxHeight As Integer\nPrivate MaxWidth As Integer\nPrivate Evergreen As String\nSub New(Name, HGrowth, MaxH, MaxW, PEvergreen)\nTreeName = Name\nHeightGrowth = HGrowth\nMaxHeight = MaxH\nMaxWidth = MaxW\nEvergreen = PEvergreen\nEnd Sub\nEnd Class\nPython\nclass Tree:\ndef __init__(self, Name, HGrowth, MaxH, MaxW, PEvergreen):\nself.__TreeName = Name\nself.__HeightGrowth = HGrowth\nself.__MaxHeight = MaxH\nself.__MaxWidth = MaxW\nself.__Evergreen = PEvergreen\n© Cambridge University Press & Assessment 2024 Page 15 of 38\n\n2(a)(ii) 1 mark each 3\n 1 get method with no parameter …\n … returning correct attribute\n Remaining 4 correct\ne.g.\nJava\npublic String GetTreeName(){\nreturn TreeName;\n}\npublic Integer GetGrowth(){\nreturn HeightGrowth;\n}\npublic Integer GetMaxWidth(){\nreturn MaxWidth;\n}\npublic Integer GetMaxHeight(){\nreturn MaxHeight;\n}\npublic String GetEvergreen(){\nreturn Evergreen;\n}\n© Cambridge University Press & Assessment 2024 Page 16 of 38\n\n2(a)(ii) VB.NET\nFunction GetTreeName()\nReturn TreeName\nEnd Function\nFunction GetMaxHeight()\nReturn MaxHeight\nEnd Function\nFunction GetMaxWIdth()\nReturn MaxWidth\nEnd Function\nFunction GetGrowth()\nReturn HeightGrowth\nEnd Function\nFunction GetEvergreen()\nReturn Evergreen\nEnd Function\nPython\ndef GetTreeName(self):\nreturn self.__TreeName\ndef GetMaxHeight(self):\nreturn self.__MaxHeight\ndef GetMaxWidth(self):\nreturn self.__MaxWidth\ndef GetGrowth(self):\nreturn self.__HeightGrowth\ndef GetEvergreen(self):\nreturn self.__Evergreen\n© Cambridge University Press & Assessment 2024 Page 17 of 38\n\n2(b) VB.NET\nFunction ReadData()\nDim TreeObjects(10) As Tree\nDim TextFile As String = \"Trees.txt\"\ntry\nDim FileReader As New System.IO.StreamReader(TextFile)\nDim TreeData(10) As String\nDim TreeSplit() As String\nFor Count = 0 To 8\nTreeData(Count) = FileReader.ReadLine()\nNext Count\nFileReader.Close()\nFor X = 0 To 8\nTreeSplit = TreeData(X).Split(\",\")\nTreeObjects(X) = New Tree(TreeSplit(0), Integer.Parse(TreeSplit(1)),\nInteger.Parse(TreeSplit(2)), Integer.Parse(TreeSplit(3)), TreeSplit(4))\nNext X\nCatch ex As Exception\nConsole.WriteLine (\"invalid file\")\nEnd Try\nReturn TreeObjects\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 19 of 38\n\n2(b) Python\ndef ReadData():\nTreeObjects=[]\ntry:\nFile = open(\"Trees.txt\")\nTreeData = []\nTreeData = File.read().split(\"\\n\")\nSplitTrees = []\nfor Item in TreeData:\nSplitTrees.append(Item.split(\",\"))\nFile.close()\nfor Item in SplitTrees:\nTreeObjects.append(Tree(Item[0],int(Item[1]),int(Item[2]),int(Item[3]),Item[4]))\nexcept IOError:\nprint (\"invalid file\")\nreturn TreeObjects\n© Cambridge University Press & Assessment 2024 Page 20 of 38\n\n2(c) 1 mark each 4\n Procedure heading (and end) taking one parameter (of type Tree)\nand using get methods to access tree name, height, width, growth\n Outputs all 4 attributes (TreeName, MaxHeight, MaxWidth, GetGrowth)\n Checks if it is evergreen…\n… correct messages are output if evergreen and otherwise\ne.g.\nJava\npublic static void PrintTrees(Tree TreeItem){\nString Final = \"does not lose its leaves\";\nif((TreeItem.GetEvergreen()).compareTo(\"No\") == 0){\nFinal = \"loses its leaves each year\";\n}\nSystem.out.println(TreeItem.GetTreeName() + \" has a maximum height \" +\nTreeItem.GetMaxHeight() + \" a maximum width \" + TreeItem.GetMaxWidth() + \" and grows \" +\nTreeItem.GetGrowth() + \" cm a year. It \" + Final);\n}\nVB.NET\nSub PrintTrees(Item)\nDim Final As String = \"does not lose its leaves\"\nIf (Item.GetEvergreen() = \"No\") Then\nFinal = \"loses its leaves each year\"\nEnd If\nConsole.WriteLine(Item.GetTreeName() & \" has a maximum height \" &\nItem.GetMaxHeight() & \" a maximum width \" & Item.GetMaxWidth() & \" and grows \" &\nItem.GetGrowth() & \"cm a year. It\" & Final)\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 21 of 38\n\n2(c) Python\ndef PrintTrees(Item):\nFinal = \"does not lose its leaves\"\nif Item.GetEvergreen() == \"No\":\nFinal = \"loses its leaves each year\"\nprint(Item.GetTreeName(), \"has a maximum height\", Item.GetMaxHeight(),\"a maximum\nwidth\",Item.GetMaxWidth(),\"and grows\", Item.GetGrowth(),\"cm a year. It\",Final)\n\n2(d)(i)  1 mark each 2\n Calling ReadData() and storing/using return value (as array of type Tree)…\n…calling PrintTrees() with first object in returned array as parameter\ne.g.\nJava\nTree[] TreeData = new Tree[20];\nTreeData = ReadData();\nPrintTrees(TreeData[0]);\nVB.NET\nSub Main(args As String())\nDim TreeObjects(10) As Tree\nTreeObjects = ReadData()\nPrintTrees(Treeobjects(0))\nEnd Sub\nPython\nTreeObjects = ReadData()\nPrintTrees(TreeObjects[0])\n\n2(d)(ii) Screenshot showing output 1\n© Cambridge University Press & Assessment 2024 Page 22 of 38\n\n2(e)(i) 1 mark each to max 6 6\n Procedure header (and close) taking array of Tree objects as a parameter\nand reading evergreen, max height and max width once as input from the user\n Looping through each array object …\n … comparing each width input >= MaxWidth, height input >= MaxHeight\n … comparing each evergreen input with Evergreen\n… when all true (all requirements met) - appending object in new array\n Calling PrintTrees() with each valid object\n Outputting suitable message if no trees appropriate\ne.g.\nJava\npublic static void ChooseTree(Tree[] Trees){\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Do you want a tree that loses its leaves (enter lose), or keeps\nits leaves (enter keep)\") ;\nString Evergreen = (scanner.nextLine());\nSystem.out.println(\"What is the maximum tree height in cm\");\nInteger MaxHeight = Integer.parseInt(scanner.nextLine());\nSystem.out.println(\"What is the maximum tree width in cm\");\nInteger MaxWidth = Integer.parseInt(scanner.nextLine());\nTree[] Options = new Tree[20];\nString keep;\nTree Selected;\nBoolean Valid = false;\nif(((Evergreen.toLowerCase()).compareTo(\"keep\") == 0) ||\n((Evergreen.toLowerCase()).compareTo(\"keep leaves\") == 0) ||\n((Evergreen.toLowerCase()).compareTo(\"keeps its leaves\") == 0)){\nkeep = \"Yes\";\n}else{\nkeep = \"No\";\n}\nInteger Counter = 0;\nfor(Integer X = 0; X < 9; X++){\n© Cambridge University Press & Assessment 2024 Page 23 of 38\n\n2(e)(i) if((Trees[X].GetMaxHeight() <= MaxHeight) && (Trees[X].GetMaxWidth() <=\nMaxWidth) && (keep.compareTo(Trees[X].GetEvergreen())==0)){\nOptions[Counter] = Trees[X];\nPrintTrees(Trees[X]);\nCounter = Counter + 1;\n}\n}\nif(Counter == 0){\nSystem.out.println(\"No suitable trees\");\n}\n}\nVB.NET\nSub ChooseTree(Trees)\nConsole.WriteLine(\"Do you want a tree that loses its leaves (enter lose), or keeps\nits leaves (enter keep)\")\nDim Evergreen As String = Console.ReadLine()\nConsole.WriteLine(\"What is the maximum tree height in cm\")\nDim MaxHeight As Integer = Console.ReadLine()\nConsole.WriteLine(\"What is the maximum tree width in cm\")\nDim MaxWidth As Integer = Console.ReadLine()\nDim Options(0 To 9) As Tree\nDim keep As String\nDim Valid As Boolean\nDim Selected As Tree\nIf Evergreen.ToLower() = \"keep\" Or Evergreen.ToLower() = \"keep leaves\" Or\nEvergreen.ToLower() = \"keeps its leaves\" Then\nkeep = \"Yes\"\nElse\nkeep = \"No\"\n© Cambridge University Press & Assessment 2024 Page 24 of 38\n\n2(e)(i) End If\nDim count As Integer = 0\nFor x = 0 To 8\nIf Trees(x).GetMaxHeight() <= MaxHeight And Trees(x).GetMaxWidth() <= MaxWidth\nAnd keep = Trees(x).GetEvergreen() Then\nOptions(count) = Trees(x)\nPrintTrees(Trees(x))\ncount = count + 1\nEnd If\nNext x\nIf count = 0 Then\nConsole.WriteLine(\"No suitable trees\")\nEnd If\nEnd Sub\nPython\ndef ChooseTree(Trees):\nEvergreen = input(\"Do you want a tree that loses its leaves (enter lose), or keeps its\nleaves (enter keep)\")\nMaxHeight = int(input(\"What is the maximum tree height in cm\"))\nMaxWidth = int(input(\"What is the maximum tree width in cm\"))\nOptions = []\nif Evergreen.lower() == \"keep\" or Evergreen.lower() == \"keep leaves\" or\nEvergreen.lower() == \"keeps its leaves\":\nkeep = \"Yes\"\nelse:\nkeep = \"No\"\nfor Item in Trees:\nif Item.GetMaxHeight() <= MaxHeight and Item.GetMaxWidth() <= MaxWidth and keep ==\nItem.GetEvergreen():\nOptions.append(Item)\nPrintTrees(Item)\nif len(Options) == 0:\nprint(\"No suitable trees\")\n© Cambridge University Press & Assessment 2024 Page 25 of 38\n\n2(e)(ii) 1 mark each to max 2\n Taking tree name and initial height as input\n Finding the tree, calculating and outputting the number of years to get to maximum height\nVB.NET\nValid = False\nDim Start As Integer\nDim Years As Single\nDim Choice As String\nWhile Valid = False\nConsole.WriteLine(\"Enter the name of the tree you want\")\nChoice = Console.ReadLine()\nFor X = 0 To count - 1\nIf Options(X).GetTreeName() = Choice Then\nValid = True\nSelected = Options(X)\nConsole.WriteLine(\"Enter the height of the tree you would like to start with in\ncm\")\nStart = Console.ReadLine()\nYears = (Selected.GetMaxHeight() - Start) / Selected.GetGrowth()\nConsole.WriteLine(\"Your tree should be full height in approximately \" & Years &\n\" years\")\nEnd If\nNext X\nEnd While\n© Cambridge University Press & Assessment 2024 Page 26 of 38\n\n2(e)(ii) Java\nInteger Start;\nFloat Height;\nFloat Growth;\nFloat Years;\nwhile(Valid == false){\nSystem.out.println(\"Enter the name of the tree you want\");\nString Choice = scanner.nextLine();\nfor(Integer X = 0; X < Counter; X++){\nif((Options[X].GetTreeName()).compareTo(Choice)==0){\nValid = true;\nSelected = Options[X];\nSystem.out.println(\"Enter the height of the tree you would like to start\nwith in cm\");\nStart = Integer.parseInt(scanner.nextLine());\nHeight = (Selected.GetMaxHeight()).floatValue();\nGrowth = (Selected.GetGrowth()).floatValue();\nYears = (Height - Start) / Growth;\nSystem.out.println(\"Your tree should be full height in approximately \"+\nYears + \" years\");\n}\n}\n}\nPython:\nValid = False\nwhile Valid == False:\nChoice = input(\"Enter the name of the tree you want\")\nfor Item in Options:\nif Item.GetTreeName() == Choice:\nValid = True\nSelected = Item\nStart = int(input(\"Enter the height of the tree you would like to start with in\ncm\"))\nYears = (Selected.GetMaxHeight() - Start)/Selected.GetGrowth()\nprint(\"Your tree should be full height in approximately\", Years,\"years\")\n© Cambridge University Press & Assessment 2024 Page 27 of 38\n\n2(e)(iii) 1 mark each 2\n Screenshot shows the user requirements input (height 400, width 200, evergreen) and outputs the correct trees (Blue\nconifer and green conifer)\n Screenshot shows the tree selection input (Blue Conifer with height 100) and outputs the correct result (3 years / 3.75\n/ 4 years)\n© Cambridge University Press & Assessment 2024 Page 28 of 38",
      "source_pages": [
        14,
        15,
        16,
        17,
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_41-p14.png",
        "../answer-assets/9618_s24_ms_41-p15.png",
        "../answer-assets/9618_s24_ms_41-p16.png",
        "../answer-assets/9618_s24_ms_41-p17.png",
        "../answer-assets/9618_s24_ms_41-p19.png",
        "../answer-assets/9618_s24_ms_41-p20.png",
        "../answer-assets/9618_s24_ms_41-p21.png",
        "../answer-assets/9618_s24_ms_41-p22.png",
        "../answer-assets/9618_s24_ms_41-p23.png",
        "../answer-assets/9618_s24_ms_41-p24.png",
        "../answer-assets/9618_s24_ms_41-p25.png",
        "../answer-assets/9618_s24_ms_41-p26.png",
        "../answer-assets/9618_s24_ms_41-p27.png",
        "../answer-assets/9618_s24_ms_41-p28.png"
      ]
    },
    {
      "id": "9618-2024-mj-41-q03",
      "question_id": "9618-2024-mj-41-q03",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 17,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark each 1\n QueueData as 1D (string) array initialised to 20 null values\nand QueueHead initialised to -1, QueueTail initialised to -1\ne.g.\nJava\nclass Queue{\npublic static String[] QueueData = new String[20];\npublic static Integer QueueHead;\npublic static Integer QueueTail;\npublic static void main(String args[]){\nfor(Integer x = 0; x < 20; x++){\nQueueData[x] = \"\";\n}\nQueueHead = -1;\nQueueTail = -1;\n}\n}\nVB.NET\nDim QueueData(0 To 20) As String\nDim QueueHead As Integer = -1\nDim QueueTail As Integer = -1\nSub Main(args As String())\nFor x = 0 To 19\nQueueData(x) = \"\"\nNext\nEnd Sub\nPython\nglobal QueueData\nglobal QueueHead\nglobal QueueTail\nQueueData = []\nfor x in range(0, 20):\nQueueData.append(\"\")\nQueueHead = -1\nQueueTail = -1\n© Cambridge University Press & Assessment 2024 Page 29 of 38\n\n3(b) 1 mark each 4\n Function header (and end) taking one parameter and returns a Boolean value in all instances\n Checks if queue is full and returns FALSE\n (If not full) Inserts data item to QueueTail + 1\nand increments QueueTail\nand returns TRUE\n Assigns QueueHead to 0 when first element is entered (this can come from incrementing)\ne.g.\nJava\npublic static Boolean Enqueue(String DataToInsert){\nif(QueueTail == 19){\nreturn false;\n}else if(QueueHead == -1){\nQueueHead = 0;\n}\nQueueTail = QueueTail + 1;\nQueueData[QueueTail] = DataToInsert.substring(0,6);\nreturn true;\n}\nVB.NET\nFunction Enqueue(ByVal DataToInsert)\nIf QueueTail = 19 Then\nReturn False\nElseIf QueueHead = -1 Then\nQueueHead = 0\nEnd If\nQueueTail = QueueTail + 1\nQueueData(QueueTail) = DataToInsert\nReturn True\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 30 of 38\n\n3(b) Python\ndef Enqueue(DataToInsert):\nglobal QueueData\nglobal QueueHead\nglobal QueueTail\nif QueueTail == 19:\nreturn False\nelif QueueHead == -1:\nQueueHead = 0\nQueueTail = QueueTail + 1\nQueueData.append(DataToInsert)\nreturn True\n© Cambridge University Press & Assessment 2024 Page 31 of 38\n\n3(c) 1 mark each 3\n Dequeue function header (and end) returning a string in all cases\n Check if queue is empty\nand return \"false\"\n (otherwise) remove value at QueueHead\nand increment QueueHead\nand return value from array\ne.g.\nJava\npublic static String Dequeue(){\nif(QueueHead < 0 || QueueHead > 20 || QueueHead > QueueTail){\nreturn \"false\";\n}\nQueueHead++;\nreturn QueueData[QueueHead-1];\n}\nVB.NET\nFunction Dequeue()\nIf QueueHead < 0 Or QueueHead > 20 Or QueueHead > QueueTail Then\nReturn \"false\"\nElse\nQueueHead = QueueHead + 1\nReturn QueueData(QueueHead - 1)\nEnd If\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 32 of 38\n\n3(c) Python\ndef Dequeue():\nglobal QueueData\nglobal QueueHead\nglobal QueueTail\nif QueueHead < 0 or QueueHead > 20 or QueueHead > QueueTail:\nreturn False\nelse:\nQueueHead = QueueHead + 1\nreturn QueueData[QueueHead-1]\n\n3(d)(i) 1 mark each to max 6 6\n StoreItems header (function/procedure and end where appropriate)\nand takes 10 inputsi\n Input is split and first 6 characters used in calculation (as integers) …\n … multiplication by 1 and 3 alternately, adding to total, dividing by 10, rounding down/cast int …\n … comparing check digit to character in position 6\n … including comparison of X for 10\n Calling Enqueue with first 6 characters when valid\n … outputting appropriate message on return (for both inserted and queue full)\n Counts and outputs number of invalid inputs\ne.g.\nJava\npublic static void StoreItems(){\nInteger Count = 0;\nInteger Total = 0;\nString Data;\nBoolean Result;\nScanner scanner = new Scanner(System.in);\nfor(Integer X = 0; X < 10; X++){\nSystem.out.println(\"Enter data\");\nData = scanner.nextLine();\nTotal = Integer.parseInt(Data.substring(0,1)) +\n© Cambridge University Press & Assessment 2024 Page 33 of 38\n\n3(d)(i) Integer.parseInt(Data.substring(1,2)) * 3 + Integer.parseInt(Data.substring(2,3)) +\nInteger.parseInt(Data.substring(3,4)) * 3 + Integer.parseInt(Data.substring(4,5)) +\nInteger.parseInt(Data.substring(5,6)) * 3;\nTotal = Total / 10;\nif((Total == 10 && Data.substring(6).compareTo(\"X\")==0)){\nResult = Enqueue(Data);\nif(Result == true){\nSystem.out.println(\"Inserted item\");\n}else{\nSystem.out.println(\"Queue full\");\n}\n}else if(Total == Integer.parseInt(Data.substring(6,7))){\nResult = Enqueue(Data);\nif(Result == true){\nSystem.out.println(\"Inserted item\");\n}else{\nSystem.out.println(\"Queue full\");\n}\n}else{\nCount = Count + 1;\n}\n}\nSystem.out.println(\"There were \" + Count + \" invalid items\");\n}\nVB.NET\nSub StoreItems()\nDim Count As Integer = 0\nDim Total As Integer = 0\nDim Data As String\nDim Result As Boolean\nFor X = 0 To 9\nConsole.WriteLine(\"Enter data\")\nData = Console.ReadLine()\n© Cambridge University Press & Assessment 2024 Page 34 of 38\n\n3(d)(i) Total = Integer.Parse(Data.Substring(0, 1)) + Integer.Parse(Data.Substring(1, 1)) *\n\n3 + Integer.Parse(Data.Substring(2, 1)) + Integer.Parse(Data.Substring(3, 1)) * 3 +\nInteger.Parse(Data.Substring(4, 1)) + Integer.Parse(Data.Substring(5, 1)) * 3\nTotal = Total \\ 10\nIf (Total = 10 And Data.Substring(6, 1) = \"X\") Then\nResult = Enqueue(Data.Substring(0, 6))\nIf Result = True Then\nConsole.WriteLine(\"Inserted item\")\nElse\nConsole.WriteLine(\"Queue full\")\nEnd If\nElseIf Total = Integer.Parse(Data.Substring(6, 1)) Then\nResult = Enqueue(Data)\nIf Result = True Then\nConsole.WriteLine(\"Inserted item\")\nElse\nConsole.WriteLine(\"Queue full\")\nEnd If\nElse\nCount = Count + 1\nEnd If\nNext\nConsole.WriteLine(\"There were \" & Count & \" invalid items\")\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 35 of 38\n\n3(d)(i) Python\ndef StoreItems():\nglobal QueueData\nglobal QueueHead\nglobal QueueTail\nCount = 0\nfor X in range(0, 10):\nData = input(\"Enter data\")\nTotal= int(Data[0]) + int(Data[1]) * 3 + int(Data[2]) + int(Data[3]) * 3 +\nint(Data[4]) + int(Data[5]) * 3\nTotal = int(Total / 10)\nif((Total == 10 and Data[6] == \"X\") or (Total == int(Data[6]))):\nResult = Enqueue(Data[0:6])\nif(Result == True):\nprint(\"Inserted item\")\nelse:\nprint(\"Queue full\")\nelse:\nCount = Count + 1\nprint(\"There were\", Count,\"Invalid items\")\n© Cambridge University Press & Assessment 2024 Page 36 of 38\n\n3(d)(ii)  Calling StoreItems() 1\nand Dequeue() once\nand outputting a suitable message if the queue was empty\nand outputting the returned value if the queue was not empty\ne.g.\nJava\npublic static void main(String args[]){\nfor(Integer x = 0; x < 20; x++){\nQueueData[x] = \"\";\n}\nQueueHead = -1;\nQueueTail = -1;\nStoreItems();\nString Value = Dequeue();\nif(Value.compareTo(\"false\") == 0){\nSystem.out.println(\"No data items\");\n}else{\nSystem.out.println(\"Item code \" + Value);\n}\n}\nVB.NET\nSub Main(args As String())\nFor x = 0 To 19\nQueueData(x) = \"\"\nNext\nStoreItems()\nDim ReturnValue As String = Dequeue()\nIf (ReturnValue = \"false\") Then\nConsole.WriteLine(\"No data items\")\nElse\nConsole.WriteLine(\"Item code \" & ReturnValue)\nEnd If\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 37 of 38\n\n3(d)(ii) Python\nQueueData = []\nfor x in range(0, 20):\nQueueData.append(\"\")\nQueueHead = -1\nQueueTail = -1\nStoreItems()\nValue = Dequeue()\nif Value == False:\nprint(\"No data items\")\nelse:\nprint(\"Item code\", Value)\n\n3(d)(iii) 1 mark each 2\n Data input of 10 values and output a message saying there are 4 invalid items\n 999999 output\ne.g.\n© Cambridge University Press & Assessment 2024 Page 38 of 38",
      "source_pages": [
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37,
        38
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_41-p29.png",
        "../answer-assets/9618_s24_ms_41-p30.png",
        "../answer-assets/9618_s24_ms_41-p31.png",
        "../answer-assets/9618_s24_ms_41-p32.png",
        "../answer-assets/9618_s24_ms_41-p33.png",
        "../answer-assets/9618_s24_ms_41-p34.png",
        "../answer-assets/9618_s24_ms_41-p35.png",
        "../answer-assets/9618_s24_ms_41-p36.png",
        "../answer-assets/9618_s24_ms_41-p37.png",
        "../answer-assets/9618_s24_ms_41-p38.png"
      ]
    },
    {
      "id": "9618-2024-mj-42-q01",
      "question_id": "9618-2024-mj-42-q01",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 22,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark each to max 6 6\n Procedure declaration (and end where appropriate) taking (string) parameter\n Declaration of array to store the data read (type string, suitable number of elements e.g. 150)\n Opening file to read…\n ... using exception handling with try and catch and output\n Reading in the data for each line in that file and storing in array…\n … removing carriage return (Java, Python)\n Counting the number of words\n Closing the file (might be within the Python opening file statement)\ne.g.\nJava\npublic static void ReadWords(String FileName){\ntry{\nFileReader f = new FileReader(FileName);\ntry{\nBufferedReader Reader = new BufferedReader(f);\nString Line= Reader.readLine();\nwhile (Line != null){\nWordArray[NumberWords] = Line.replace(\"\\n\",\"\");\nNumberWords++;\nLine = Reader.readLine();\n}\nReader.close();\n}catch(IOException ex){}\n© Cambridge University Press & Assessment 2024 Page 4 of 50\n\n1(a) }catch(FileNotFoundException e){\nSystem.out.println(\"File not found\");\n}\n}\nVB.NET\nSub ReadWords(FileName As String)\nTry\nDim DataReader As StreamReader = New StreamReader(FileName)\nNumberWords = 0\nDo Until DataReader.EndOfStream\nWordArray(NumberWords) = DataReader.ReadLine()\nNumberWords = NumberWords + 1\nLoop\nDataReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\nPython\ndef ReadWords(FileName):\nglobal WordArray\nglobal NumberWords\nFile = open(FileName, 'r')\nDataRead = File.read().strip()\nFile.close()\nWordArray = DataRead.split()\nNumberWords = len(WordArray)\n© Cambridge University Press & Assessment 2024 Page 5 of 50\n\n1(b) 1 mark each 4\n Outputting message to ask user to enter easy, medium, hard\n Taking input from user\n Conversion of input to filename…\n … calling ReadWords() with correct filename in each case\ne.g.\nJava\npublic static void main(String args[]){\nNumberWords = 0;\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Easy, medium or hard?\");\nString Choice = scanner.nextLine();\nif(Choice.equals(\"Easy\")){\nReadWords(\"Easy.txt\");\n}else if(Choice.equals(\"medium\")){\nReadWords(\"Medium.txt\");\n}else{\nReadWords(\"Hard.txt\");\n}\n}\nVB.NET\nSub Main(args As String())\nConsole.WriteLine(\"Easy, medium or hard?\")\nDim FileName As String\nDim Choice As String = Console.ReadLine().ToLower()\nIf Choice = \"easy\" Then\nFileName = \"Easy.txt\"\nElseIf Choice = \"medium\" Then\nFileName = \"Medium.txt\"\nElse\n© Cambridge University Press & Assessment 2024 Page 6 of 50\n\n1(b) FileName = \"Hard.txt\"\nEnd If\nReadWords(FileName)\nEnd Sub\nPython\nWordArray = []\nNumberWords = 0\nChoice = input(\"Easy, medium or hard? \").lower()\nif Choice == \"easy\":\nFile = \"Easy.txt\"\nelif Choice == \"medium\":\nFile = \"Medium.txt\"\nelse:\nFile = \"Hard.txt\"\nReadWords(File)\n© Cambridge University Press & Assessment 2024 Page 7 of 50\n\n1(c)(i) 1 mark each 6\n Procedure (and end) taking array and number of answers as parameters and outputting the main word and the number\nof answers\n Loops until user requests to stop (enters \"no\") ….\n … takes word as input and compares input to each answer in array but not the main word\n … method of recording answers found e.g. replaces with \"\" (or appropriate null)\n … outputs if found and not found\n Counts the number of answers found (in loop, second array, any method)\ne.g.\nJava\npublic static void Play(){\nSystem.out.println(NumberWords);\nScanner scanner = new Scanner(System.in);\nString WordChosen = WordArray[0];\nSystem.out.println(\"The word is \" + WordChosen);\nSystem.out.println(\"There are \" + NumberWords + \" words that can be made with 3 or more\nletters\");\nWordArray[0] = \"\";\nBoolean Contin = true;\nInteger QuantityFound = 0;\nString WordInput;\nBoolean Found = false; String Answer = \"yes\";\nwhile(!(Answer.equals(\"no\"))){\nSystem.out.println(\"Enter your word or no to stop\");\nAnswer = scanner.nextLine();\nFound = false;\nif(!(Answer.equals(\"no\"))){\nfor(Integer x = 0; x <= NumberWords; x++){\nif(Answer.equals(WordArray[x])){\nWordArray[x] = \"\";\n© Cambridge University Press & Assessment 2024 Page 8 of 50\n\n1(c)(i) QuantityFound++;\nSystem.out.println(\"Correct, you have found \" + QuantityFound + \" words\");\nFound = true;\n}\n}\nif(Found == false){\nSystem.out.println(\"Sorry that was incorrect\");\n}\n}\n}\n}\nVB.NET\nSub Play()\nDim Word As String = WordArray(0)\nConsole.WriteLine(\"The word is: \" & Word)\nConsole.WriteLine(\"There are \" & NumberWords & \" words that can be made with 3 or more\nletters\")\nWordArray(0) = \"\"\nDim Contin As Boolean = True\nDim QuantityFound As Integer = 0\nDim Found As Boolean\nDim Answer As String = \"yes\"\nWhile Answer <> \"no\"\nConsole.WriteLine(\"Enter your word or no to stop\")\nAnswer = Console.ReadLine().ToLower()\nFound = False\nIf Answer <> \"Not\" Then\nFor x = 0 To NumberWords\nIf Answer = WordArray(x) Then\n© Cambridge University Press & Assessment 2024 Page 9 of 50\n\n1(c)(i) WordArray(x) = \"\"\nQuantityFound = QuantityFound + 1\nConsole.WriteLine(\"Correct, you have found \" & QuantityFound & \" words\")\nFound = True\nx = NumberWords + 1\nEnd If\nNext x\nIf Found = False Then\nConsole.WriteLine(\"Sorry that was incorrect\")\nEnd If\nEnd If\nEnd While\nEnd Sub\nPython\ndef Play():\nglobal WordArray\nglobal NumberWords\nWord = WordArray[0]\nprint(\"The word is: \", Word)\nprint(\"There are\", NumberWords-1,\"words that can be made with 3 or more letters\")\nWordArray[0] = \"\"\nAnswer = \"yes\"\nQuantityFound = 0\nwhile Answer != \"no\":\nAnswer = input(\"Enter your word or no to stop \").lower()\nFound = False\n© Cambridge University Press & Assessment 2024 Page 10 of 50\n\n1(c)(i) if Answer != \"no\":\nfor x in range(0, NumberWords):\nif Answer == WordArray[x]:\nWordArray[x] = \"\"\nQuantityFound = QuantityFound + 1\nprint(\"Correct, you have found\", QuantityFound, \"words\")\nFound = True\nif Found == False:\nprint(\"Sorry that was incorrect\")\n© Cambridge University Press & Assessment 2024 Page 11 of 50\n\n1(c)(ii) 1 mark each 3\n Calculates and outputs percentage of answers found (when ‘no’ is entered)\n Method of identifying answers not found (e.g. looping array and skipping null values)…\n … and outputting those answers\ne.g.\nJava\npublic static void Play(){\nSystem.out.println(NumberWords);\nScanner scanner = new Scanner(System.in);\nString WordChosen = WordArray[0];\nSystem.out.println(\"The word is \" + WordChosen);\nSystem.out.println(\"There are \" + NumberWords + \" words that can be made with 3 or\nmore letters\");\nWordArray[0] = \"\";\nBoolean Contin = true;\nInteger QuantityFound = 0;\nString WordInput;\nBoolean Found = false;\nString Answer = \"yes\";\nwhile(!(Answer.equals(\"no\"))){\nSystem.out.println(\"Enter your word or no to stop\");\nAnswer = scanner.nextLine();\nFound = false;\nif(!(Answer.equals(\"no\"))){\nfor(Integer x = 0; x <= NumberWords; x++){\nif(Answer.equals(WordArray[x])){\nWordArray[x] = \"\";\nQuantityFound++;\nSystem.out.println(\"Correct, you have found \" + QuantityFound + \"\nwords\");\n© Cambridge University Press & Assessment 2024 Page 12 of 50\n\n1(c)(ii) Found = true;\n}\n}\nif(Found == false){\nSystem.out.println(\"Sorry that was incorrect\");\n}\n}\n}\ndouble Correct = ((Double.valueOf(QuantityFound) / Double.valueOf(NumberWords)) *\n100.0);\nSystem.out.println(\"You found \" + Correct + \"%\");\nif(Correct < 100){\nSystem.out.println(\"The words you missed are\");\nfor(Integer x = 0; x <= NumberWords; x++){\nif(WordArray[x] != \"\"){\nSystem.out.println(WordArray[x]);\n}\n}\n}\n}\nVB.NET\nSub Play()\nDim Word As String = WordArray(0)\nConsole.WriteLine(\"The word is: \" & Word)\nConsole.WriteLine(\"There are \" & NumberWords & \" words that can be made with 3 or more\nletters\")\n© Cambridge University Press & Assessment 2024 Page 13 of 50\n\n1(c)(ii) WordArray(0) = \"\"\nDim Contin As Boolean = True\nDim QuantityFound As Integer = 0\nDim Found As Boolean\nDim Answer As String = \"yes\"\nWhile Answer <> \"no\"\nConsole.WriteLine(\"Enter your word or no to stop\")\nAnswer = Console.ReadLine().ToLower()\nFound = False\nIf Answer <> \"Not\" Then\nFor x = 0 To NumberWords\nIf Answer = WordArray(x) Then\nWordArray(x) = \"\"\nQuantityFound = QuantityFound + 1\nConsole.WriteLine(\"Correct, you have found \" & QuantityFound & \" words\")\nFound = True\nx = NumberWords + 1\nEnd If\nNext x\nIf Found = False Then\nConsole.WriteLine(\"Sorry that was incorrect\") End If\nEnd If\nEnd While\nDim Correct As Double\nCorrect = (QuantityFound / NumberWords) * 100\nConsole.WriteLine(\"You found \" & Correct & \"%\")\nIf Correct < 100 Then\nConsole.WriteLine(\"The words you missed are \")\nFor x = 0 To NumberWords\nIf WordArray(x) <> \"\" Then\n© Cambridge University Press & Assessment 2024 Page 14 of 50\n\n1(c)(ii) Console.WriteLine(WordArray(x))\nEnd If\nNext x\nEnd If\nEnd Sub\nPython\ndef Play():\nglobal WordArray\nglobal NumberWords\nWord = WordArray[0]\nprint(\"The word is: \", Word)\nprint(\"There are\", NumberWords-1,\"words that can be made with 3 or more letters\")\nWordArray[0] = \"\"\nAnswer = \"yes\"\nQuantityFound = 0\nwhile Answer != \"no\":\nAnswer = input(\"Enter your word or no to stop \").lower()\nFound = False\nif Answer != \"no\":\nfor x in range(0, NumberWords):\nif Answer == WordArray[x]:\nWordArray[x] = \"\"\nQuantityFound = QuantityFound + 1\nprint(\"Correct, you have found\", QuantityFound, \"words\")\nFound = True\nif Found == False:\nprint(\"Sorry that was incorrect\")\nCorrect = (QuantityFound / (NumberWords-1)) * 100\nprint(\"You found\", Correct,\"%\")\n© Cambridge University Press & Assessment 2024 Page 15 of 50\n\n1(c)(ii) if Correct < 100:\nprint(\"The words you missed are\")\nfor x in range(0, NumberWords-1):\nif WordArray[x] != \"\":\nprint(WordArray[x])\n© Cambridge University Press & Assessment 2024 Page 16 of 50\n\n1(d)(i) 1 mark for: 1\n Calling Play() with array and number of answers after all read in from file\ne.g.\nJava\npublic static void ReadWords(String FileName){\ntry{\nFileReader f = new FileReader(FileName);\ntry{\nBufferedReader Reader = new BufferedReader(f);\nString Line= Reader.readLine();\nwhile (Line != null){\nWordArray[NumberWords] = Line.replace(\"\\n\",\"\");\nNumberWords++;\nLine = Reader.readLine();\n}\nReader.close();\nPlay();\n}catch(IOException ex){}\n}catch(FileNotFoundException e){\nSystem.out.println(\"File not found\");\n}\n}\n© Cambridge University Press & Assessment 2024 Page 17 of 50\n\n1(d)(i) VB.NET\nSub ReadWords(FileName As String)\nTry\nDim DataReader As StreamReader = New StreamReader(FileName)\nNumberWords = 0\nDo Until DataReader.EndOfStream\nWordArray(NumberWords) = DataReader.ReadLine()\nNumberWords = NumberWords + 1\nLoop\nDataReader.Close()\nPlay()\nCatch ex As Exception\nConsole.WriteLine(\"Invalid file\")\nEnd Try\nEnd Sub\nPython\ndef ReadWords(FileName):\nglobal WordArray\nglobal NumberWords\nFile = open(FileName, 'r')\nDataRead = File.read().strip()\nFile.close()\nWordArray = DataRead.split()\nNumberWords = len(WordArray)\nPlay()\n© Cambridge University Press & Assessment 2024 Page 18 of 50\n\n1(d)(ii) 1 mark for screenshot showing the inputs \"easy\", \"she\", \"out\", \"no\" e.g. 1\n© Cambridge University Press & Assessment 2024 Page 19 of 50\n\n1(d)(iii) 1 mark for screenshot showing the inputs ‘hard’, ‘fine’, ‘fined’, ‘idea’, ‘no’ e.g. 1\n© Cambridge University Press & Assessment 2024 Page 20 of 50",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_42-p04.png",
        "../answer-assets/9618_s24_ms_42-p05.png",
        "../answer-assets/9618_s24_ms_42-p06.png",
        "../answer-assets/9618_s24_ms_42-p07.png",
        "../answer-assets/9618_s24_ms_42-p08.png",
        "../answer-assets/9618_s24_ms_42-p09.png",
        "../answer-assets/9618_s24_ms_42-p10.png",
        "../answer-assets/9618_s24_ms_42-p11.png",
        "../answer-assets/9618_s24_ms_42-p12.png",
        "../answer-assets/9618_s24_ms_42-p13.png",
        "../answer-assets/9618_s24_ms_42-p14.png",
        "../answer-assets/9618_s24_ms_42-p15.png",
        "../answer-assets/9618_s24_ms_42-p16.png",
        "../answer-assets/9618_s24_ms_42-p17.png",
        "../answer-assets/9618_s24_ms_42-p18.png",
        "../answer-assets/9618_s24_ms_42-p19.png",
        "../answer-assets/9618_s24_ms_42-p20.png"
      ]
    },
    {
      "id": "9618-2024-mj-42-q02",
      "question_id": "9618-2024-mj-42-q02",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 30,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) 1 mark each to max 4 4\n Class declaration (and end where appropriate) with identifier Node\n LeftPointer, Data and RightPointer, integer\n Constructor taking 1 parameter (within class) …\n … assigning parameter to Data initialising LeftPointer and RightPointer to –1\ne.g.\nJava\npublic class Node{\nprivate Integer LeftPointer;\nprivate Integer Data;\nprivate Integer RightPointer;\npublic Node(Integer PData){\nLeftPointer = -1;\nData = PData;\nRightPointer = -1;\n}\n}\nVB.NET\nClass Node\nPrivate LeftPointer As Integer\nPrivate Data As Integer\nPrivate RightPointer As Integer\nSub New(PData)\nLeftPointer = -1\nData = PData\nRightPointer = -1\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2024 Page 21 of 50\n\n2(a)(i) Python\nclass Node():\ndef init (self, PData):\nself. LeftPointer = -1 #int\nself. Data = PData #int\nself. RightPointer = -1 #int\n© Cambridge University Press & Assessment 2024 Page 22 of 50\n\n2(a)(ii) 1 mark each 3\n 1 get method with no parameter…\n …returning correct attribute\n Remaining 2 correct (FT minor errors)\ne.g.\nJava\npublic Integer GetLeft(){\nreturn LeftPointer;\n}\npublic Integer GetRight(){\nreturn RightPointer;\n}\npublic Integer GetData(){\nreturn Data;\n}\nVB.NET\nFunction GetLeft()\nReturn LeftPointer\nEnd Function\nFunction GetRight()\nReturn RightPointer\nEnd Function\nFunction GetData()\nReturn Data\nEnd Function\nPython\ndef GetLeft(self):\nreturn self. LeftPointer\n© Cambridge University Press & Assessment 2024 Page 23 of 50\n\n2(a)(ii) def GetRight(self):\nreturn self. RightPointer\ndef GetData(self):\nreturn self. Data\n© Cambridge University Press & Assessment 2024 Page 24 of 50\n\n2(a)(iii) 1 mark each 3\n 1 set method with parameter …\n … assigning to attribute\n Remaining 2 correct (FT minor errors)\ne.g.\nJava\npublic void SetLeft(Integer NewLeft){\nLeftPointer = NewLeft;\n}\npublic void SetRight(Integer NewRight){\nRightPointer = NewRight;\n}\npublic void SetData(Integer NewData){\nData = NewData;\n}\nVB.NET\nSub SetLeft(NewLeft)\nLeftPointer = NewLeft\nEnd Sub\nSub SetRight(NewRight)\nRightPointer = NewRight\nEnd Sub\nSub SetData(NewData)\nData = NewData\nEnd Sub\nPython\ndef SetLeft(self, NewLeft):\nself. LeftPointer = NewLeft\ndef SetRight(self, NewRight):\n© Cambridge University Press & Assessment 2024 Page 25 of 50\n\n2(a)(iii) self. RightPointer = NewRight\ndef SetData(self, NewData):\nself. Data = NewData\n© Cambridge University Press & Assessment 2024 Page 26 of 50\n\n2(b)(i) 1 mark each 4\n Class header (and end)\n Private array Tree of type Node with 20 elements, private FirstNode and private NumberNodes\n Constructor assigns –1 to FirstNode and 0 to NumberNodes\n … initialises all Tree (20) elements to Node object with data value –1\ne.g.\nJava\nclass TreeClass{\nprivate static Node[] Tree = new Node[20];\nprivate static Integer FirstNode;\nprivate static Integer NumberNodes;\npublic TreeClass(){\nFirstNode = -1;\nNumberNodes = 0;\nInteger MinusOne = -1;\nfor(Integer x = 0; x < 20; x++){\nTree[x] = new Node(MinusOne);\n}\n}\n}\nVB.NET\nClass TreeClass\nPrivate Tree(20) As Node\nPrivate FirstNode As Integer\nPrivate NumberNodes As Integer\nSub New()\nFirstNode = -1\nNumberNodes = 0\n© Cambridge University Press & Assessment 2024 Page 27 of 50\n\n2(b)(i) For x = 0 To 19\nTree(x) = New Node(-1)\nNext\nEnd Sub\nEnd Class\nPython\nclass TreeClass():\ndef init (self):\nself. Tree = [] #type node 20 spaces\nself. FirstNode = -1 #int\nself. NumberNodes = 0 #int\nfor x in range(20):\nself. Tree.append(Node(-1))\n© Cambridge University Press & Assessment 2024 Page 28 of 50\n\n2(b)(ii) 1 mark each: 6\n Method header and end, taking node as parameter and checking if empty and inserting in first position, updating\nFirstNode\n … otherwise inserting node in tree\n Accessing first node and comparing data …\n … checking whether to go left or right …\n … repeatedly until data found\n Updating left and right pointer for parent node\ne.g.\nJava\npublic void InsertNode(Node NewNode){\nInteger NodeAccess;\nInteger Previous = -1;\nString Direction;\nif(NumberNodes == 0){\nTree[0] = NewNode;\nFirstNode = 0;\nNumberNodes++;\n}else{\nTree[NumberNodes] = NewNode;\nNodeAccess = FirstNode;\nDirection = \"\";\nSystem.out.println(Tree[0].GetData());\nwhile(NodeAccess != -1){\nPrevious = NodeAccess;\nif(NewNode.GetData() < Tree[NodeAccess].GetData()){\nNodeAccess = Tree[NodeAccess].GetLeft();\nDirection = \"left\";\n© Cambridge University Press & Assessment 2024 Page 29 of 50\n\n2(b)(ii) }else if(NewNode.GetData() > Tree[NodeAccess].GetData()){\nNodeAccess = Tree[NodeAccess].GetRight();\nDirection = \"right\";\n}\n}\nif(Direction.equals(\"left\")){\nTree[Previous].SetLeft(NumberNodes);\n}else{\nTree[Previous].SetRight(NumberNodes);\n}\nNumberNodes++;\n}\n}\nVB.NET\nSub InsertNode(NewNode)\nDim NodeAccess As Integer\nDim Direction As String\nDim Previous As Integer\nIf NumberNodes = 0 Then\nTree(0) = NewNode\nFirstNode = 0\nNumberNodes += 1\nElse\nTree(NumberNodes) = NewNode\nNodeAccess = FirstNode\nDirection = \"\"\nWhile NodeAccess <> -1\nPrevious = NodeAccess\n© Cambridge University Press & Assessment 2024 Page 30 of 50\n\n2(b)(ii) If NewNode.GetData() < Tree(NodeAccess).GetData() Then\nNodeAccess = Tree(NodeAccess).GetLeft()\nDirection = \"left\"\nElseIf NewNode.GetData() > Tree(NodeAccess).GetData() Then\nNodeAccess = Tree(NodeAccess).GetRight()\nDirection = \"right\"\nEnd If\nEnd While\nIf Direction = \"left\" Then\nTree(Previous).SetLeft(NumberNodes)\nElse\nTree(Previous).SetRight(NumberNodes)\nEnd If\nNumberNodes += 1\nEnd If\nEnd Sub\nPython\ndef InsertNode(self, NewNode):\nif(self. NumberNodes == 0):\nself. Tree[0] = NewNode self. FirstNode = 0\nself. NumberNodes = self. NumberNodes + 1\nelse:\nself. Tree[self. NumberNodes] = NewNode\nNodeAccess = self. FirstNode\nDirection = \"\"\nwhile(NodeAccess != -1):\nPrevious = NodeAccess\nif NewNode.GetData() < self. Tree[NodeAccess].GetData():\n© Cambridge University Press & Assessment 2024 Page 31 of 50\n\n2(b)(ii) NodeAccess = self. Tree[NodeAccess].GetLeft()\nDirection = \"left\"\nelif NewNode.GetData() > self. Tree[NodeAccess].GetData():\nNodeAccess = self. Tree[NodeAccess].GetRight()\nDirection = \"right\"\nif(Direction == \"left\"):\nself. Tree[Previous].SetLeft(self. NumberNodes)\nelse:\nself. Tree[Previous].SetRight(self. NumberNodes)\nself. NumberNodes = self. NumberNodes + 1\n© Cambridge University Press & Assessment 2024 Page 32 of 50\n\n2(b)(iii) 1 mark each 4\n Procedure header (and end) with no parameter and if no nodes output ‘No nodes’\n (otherwise) Loop from index 0 to NumberNodes (or equivalent) …\n … Outputting LeftPointer, Data then RightPointer\n … using get methods\ne.g.\nJava\npublic void OutputTree(){\nif(NumberNodes == 0){\nSystem.out.println(\"No nodes\");\n}else{\nfor(Integer x = 0; x < NumberNodes; x++){\nSystem.out.println(Tree[x].GetLeft() + \" \" + Tree[x].GetData() + \" \" +\nTree[x].GetRight());\n}\n}\n}\nVB.NET\nSub OutputTree()\nIf NumberNodes = 0 Then\nConsole.WriteLine(\"No nodes\")\nElse\nFor x = 0 To NumberNodes - 1\nConsole.WriteLine(Tree(x).GetLeft() & \" \" & Tree(x).GetData() & \" \" &\nTree(x).GetRight())\nNext\nEnd If\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 33 of 50\n\n2(b)(iii) Python\ndef OutputTree(self):\nif self. NumberNodes == 0:\nprint(\"No nodes\")\nelse:\nfor x in range(0, self. NumberNodes):\nprint(self. Tree[x].GetLeft(), \" \", self. Tree[x].GetData(), \" \",self.\nTree[x].GetRight())\n\n2(c)(i) 1 mark for 1\n Instance of TreeClass created with identifier TheTree\ne.g.\nJava\npublic static void main(String args[]){\nTreeClass TheTree = new TreeClass();\n}\nVB.NET\nSub Main(args As String())\nDim TheTree As TreeClass = New TreeClass()\nEnd Sub\nPython\nTheTree = TreeClass()\n© Cambridge University Press & Assessment 2024 Page 34 of 50\n\n2(c)(ii) 1 mark each 4\n Creating one node with one correct value (e.g. 10)\n Calling InsertNode for TheTree with each new Node\n All nodes correctly assigned in order\n Calling OutputTree\ne.g.\nJava\npublic static void main(String args[]){\nTreeClass TheTree = new TreeClass();\nTheTree.InsertNode(new Node(10));\nTheTree.InsertNode(new Node(11));\nTheTree.InsertNode(new Node(5));\nTheTree.InsertNode(new Node(1));\nTheTree.InsertNode(new Node(20));\nTheTree.InsertNode(new Node(7));\nTheTree.InsertNode(new Node(15));\nTheTree.OutputTree();\n}\nVB.NET\nSub Main(args As String())\nDim TheTree As TreeClass = New TreeClass()\nTheTree.InsertNode(New Node(10))\nTheTree.InsertNode(New Node(11))\nTheTree.InsertNode(New Node(5))\nTheTree.InsertNode(New Node(1))\nTheTree.InsertNode(New Node(20))\nTheTree.InsertNode(New Node(7))\nTheTree.InsertNode(New Node(15))\nTheTree.OutputTree()\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 35 of 50\n\n2(c)(ii) Python\nTheTree = TreeClass()\nTheTree.InsertNode(Node(10))\nTheTree.InsertNode(Node(11))\nTheTree.InsertNode(Node(5))\nTheTree.InsertNode(Node(1))\nTheTree.InsertNode(Node(20))\nTheTree.InsertNode(Node(7))\nTheTree.InsertNode(Node(15))\nTheTree.OutputTree()\n\n2(c)(iii) 1 mark for correct output e.g. 1\n© Cambridge University Press & Assessment 2024 Page 36 of 50",
      "source_pages": [
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_42-p21.png",
        "../answer-assets/9618_s24_ms_42-p22.png",
        "../answer-assets/9618_s24_ms_42-p23.png",
        "../answer-assets/9618_s24_ms_42-p24.png",
        "../answer-assets/9618_s24_ms_42-p25.png",
        "../answer-assets/9618_s24_ms_42-p26.png",
        "../answer-assets/9618_s24_ms_42-p27.png",
        "../answer-assets/9618_s24_ms_42-p28.png",
        "../answer-assets/9618_s24_ms_42-p29.png",
        "../answer-assets/9618_s24_ms_42-p30.png",
        "../answer-assets/9618_s24_ms_42-p31.png",
        "../answer-assets/9618_s24_ms_42-p32.png",
        "../answer-assets/9618_s24_ms_42-p33.png",
        "../answer-assets/9618_s24_ms_42-p34.png",
        "../answer-assets/9618_s24_ms_42-p35.png",
        "../answer-assets/9618_s24_ms_42-p36.png"
      ]
    },
    {
      "id": "9618-2024-mj-42-q03",
      "question_id": "9618-2024-mj-42-q03",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 23,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark each 1\n NumberArray declared (in main) with the 7 correct values in order (integer) 100 85 644 22 15 8 1\ne.g.\nJava\npublic static void main(String args[]){\nInteger[] NumberArray = new Integer[7];\nNumberArray[0] = 100;\nNumberArray[1] = 85;\nNumberArray[2] = 644;\nNumberArray[3] = 22;\nNumberArray[4] = 15;\nNumberArray[5] = 8;\nNumberArray[6] = 1;\n}\nVB.NET\nSub Main(args As String())\nDim NumberArray(7) As Integer\nNumberArray(0) = 100\nNumberArray(1) = 85\nNumberArray(2) = 644\nNumberArray(3) = 22\nNumberArray(4) = 15\nNumberArray(5) = 8\nNumberArray(6) = 1\nEndSub\nPython\nNumberArray = [100, 85, 644, 22, 15, 8, 1]\n© Cambridge University Press & Assessment 2024 Page 37 of 50\n\n3(b)(i) 1 mark each 4\n Recursive function written with recursive call\n Correct base case and return\n Correct while loop control and internal\n All correct and structure followed\ne.g.\nJava\npublic static Integer[] RecursiveInsertion(Integer[] IntegerArray, Integer NumberElements){\nInteger LastItem;\nInteger CheckItem;\nif(NumberElements <= 1){\nreturn IntegerArray;\n}else{\nRecursiveInsertion(IntegerArray, NumberElements - 1);\nLastItem = IntegerArray[NumberElements - 1];\nCheckItem = NumberElements - 2;\n}\nBoolean LoopAgain = true;\nif(CheckItem < 0){\nLoopAgain = false;\n}else if(IntegerArray[CheckItem] < LastItem){\nLoopAgain = false;\n}\nwhile(LoopAgain){\nIntegerArray[CheckItem + 1] = IntegerArray[CheckItem];\nCheckItem = CheckItem - 1;\nif(CheckItem < 0){\nLoopAgain = false;\n© Cambridge University Press & Assessment 2024 Page 38 of 50\n\n3(b)(i) }else if(IntegerArray[CheckItem] <= LastItem){\nLoopAgain = false;\n}\n}\nIntegerArray[CheckItem + 1] = LastItem;\nreturn IntegerArray;\n}\nVB.NET\nFunction RecursiveInsertion(IntegerArray, NumberElements)\nDim LastItem, CheckItem As Integer\nIf NumberElements <= 1 Then\nReturn IntegerArray\nElse\nRecursiveInsertion(IntegerArray, NumberElements - 1)\nLastItem = IntegerArray(NumberElements - 1)\nCheckItem = NumberElements - 2\nEnd If\nDim LoopAgain As Boolean = True\nIf CheckItem < 0 Then\nLoopAgain = False\nElseIf IntegerArray(CheckItem) <= LastItem Then\nLoopAgain = False\nEnd If\nWhile LoopAgain\nIntegerArray(CheckItem + 1) = IntegerArray(CheckItem)\nCheckItem = CheckItem - 1\nIf CheckItem < 0 Then\nLoopAgain = False\nElseIf IntegerArray(CheckItem) <= LastItem Then\n© Cambridge University Press & Assessment 2024 Page 39 of 50\n\n3(b)(i) LoopAgain = False\nEnd If\nEnd While\nIntegerArray(CheckItem + 1) = LastItem\nReturn IntegerArray\nEnd Function\nPython\ndef RecursiveInsertion(IntegerArray, NumberElements):\nif NumberElements <= 1:\nreturn IntegerArray\nRecursiveInsertion(IntegerArray,NumberElements - 1)\nLastItem = IntegerArray[NumberElements - 1]\nCheckItem = NumberElements - 2\nLoopAgain = True\nif CheckItem < 0:\nLoopAgain = False\nelif IntegerArray[CheckItem] <= LastItem:\nLoopAgain = False\nwhile (LoopAgain):\nIntegerArray[CheckItem + 1] = IntegerArray[CheckItem]\nCheckItem = CheckItem - 1\nif CheckItem < 0:\nLoopAgain = False\nelif IntegerArray[CheckItem] <= LastItem:\nLoopAgain = False\nIntegerArray[CheckItem + 1] = LastItem return IntegerArray\n© Cambridge University Press & Assessment 2024 Page 40 of 50\n\n3(b)(ii) 1 mark each 2\n Calling RecursiveInsertion() with array and number of elements (7 or length)\n Outputting ‘recursive’ and then each element in returned array\ne.g.\nJava\nInteger[] SortedArray = new Integer[7];\nSortedArray = RecursiveInsertion(NumberArray, 7);\nSystem.out.println(\"Recursive\");\nfor(Integer x = 0; x < 7; x++){\nSystem.out.println(SortedArray[x]);\n}\nVB.NET\nSortedArray = RecursiveInsertion(NumberArray, 7)\nConsole.WriteLine(\"Recursive\")\nFor x = 0 To 6\nConsole.WriteLine(SortedArray(x))\nNext x\nPython\nSortedArray = RecursiveInsertion(NumberArray, len(NumberArray))\nprint(\"Recursive\", SortedArray)\n© Cambridge University Press & Assessment 2024 Page 41 of 50\n\n3(b)(iii) 1 mark for screenshot with: 1\nRecursive\n1\n8\n15\n22\n85\n100\n644\n© Cambridge University Press & Assessment 2024 Page 42 of 50\n\n3(c)(i) 1 mark each 4\n Insertion algorithm written with correct identifier – no recursion\n External loop while there are still elements left (e.g. NumberElements > 0)\n Internal loop and selection accurate\n Nothing additional added / logic changed\ne.g.\nJava\npublic static Integer[] IterativeInsertion(Integer[] IntegerArray, Integer NumberElements){\nInteger LastItem;\nInteger CheckItem;\nwhile(NumberElements > 0){\nLastItem = IntegerArray[NumberElements - 1];\nCheckItem = NumberElements - 2;\nBoolean LoopAgain = true;\nif(CheckItem < 0){\nLoopAgain = false;\n}else if(IntegerArray[CheckItem] < LastItem){\nLoopAgain = false;\n}\nwhile(LoopAgain){\nIntegerArray[CheckItem + 1] = IntegerArray[CheckItem];\nCheckItem = CheckItem - 1;\nif(CheckItem < 0){\nLoopAgain = false;\n}else if(IntegerArray[CheckItem] <= LastItem){\nLoopAgain = false;\n}\n}\n© Cambridge University Press & Assessment 2024 Page 43 of 50\n\n3(c)(i) IntegerArray[CheckItem + 1] = LastItem;\nNumberElements = NumberElements - 1;\n}\nreturn IntegerArray;\n}\nVB.NET\nFunction IterativeInsertion(IntegerArray, NumberElements)\nDim LastItem, CheckItem As Integer\nWhile NumberElements > 0\nLastItem = IntegerArray(NumberElements - 1)\nCheckItem = NumberElements - 2\nDim LoopAgain As Boolean = True\nIf CheckItem < 0 Then\nLoopAgain = False\nElseIf IntegerArray(CheckItem) <= LastItem Then\nLoopAgain = False\nEnd If\nWhile LoopAgain\nIntegerArray(CheckItem + 1) = IntegerArray(CheckItem)\nCheckItem = CheckItem - 1\nIf CheckItem < 0 Then\nLoopAgain = False\nElseIf IntegerArray(CheckItem) <= LastItem Then\nLoopAgain = False\nEnd If\nEnd While\nIntegerArray(CheckItem + 1) = LastItem\nNumberElements = NumberElements - 1\nEnd While\nReturn IntegerArray\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 44 of 50\n\n3(c)(i) Python\ndef IterativeInsertion(IntegerArray, NumberElements):\nwhile NumberElements > 0:\nLastItem = IntegerArray[NumberElements - 1]\nCheckItem = NumberElements - 2\nLoopAgain = True\nif CheckItem < 0:\nLoopAgain = False\nelif IntegerArray[CheckItem] <= LastItem:\nLoopAgain = False\nwhile(LoopAgain):\nIntegerArray[CheckItem + 1] = IntegerArray[CheckItem]\nCheckItem = CheckItem - 1\nif CheckItem < 0:\nLoopAgain = False\nelif IntegerArray[CheckItem] <= LastItem:\nLoopAgain = False\nIntegerArray[CheckItem + 1] = LastItem\nNumberElements = NumberElements - 1\nreturn IntegerArray\n© Cambridge University Press & Assessment 2024 Page 45 of 50\n\n3(c)(ii) 1 mark each 1\n Calling IterativeInsertion() with original unsorted array and outputting ‘iterative’ and the content of the returned\narray\ne.g.\nJava\nInteger[] Sorted2Array = new Integer[7];\nSorted2Array = IterativeInsertion(NumberArray, 7);\nSystem.out.println(\"iterative\");\nfor(Integer x = 0; x < 7; x++){\nSystem.out.println(Sorted2Array[x]);\n}\nVB.NET\nSorted2Array = IterativeInsertion(NumberArray, 7)\nConsole.WriteLine(\"iterative\")\nFor x = 0 To 6\nConsole.WriteLine(Sorted2Array(x))\nNext x\nPython\nSorted2Array = IterativeInsertion(NumberArray, len(NumberArray))\nprint(\"iterative\", Sorted2Array)\n\n3(c)(iii) 1 mark for Recursive 1\n1 8 15 22 85 100 644\nIterative\n1 8 15 22 85 100 644\n© Cambridge University Press & Assessment 2024 Page 46 of 50\n\n3(d)(i) 1 mark each to max 6 6\n Recursive function BinarySearch taking the 4 indicated parameters\n Suitable base case (e.g. First > Last) …\n … returning –1\n Calculating middle element\n Comparing ToFind with middle and returning Middle if found\n If ToFind less than middle, recursive call with Last as Middle – 1\n If ToFind more than middle, recursive call with First as Middle + 1\ne.g.\nJava\npublic static Integer BinarySearch(Integer[] IntegerArray, Integer First, Integer Last,\nInteger ToFind){\nInteger Middle;\nif(First > Last){;\nreturn -1;\n}else{\nMiddle = (Last + First) / 2;\nif(IntegerArray[Middle].equals(ToFind)){\nreturn Middle;\n}else if(IntegerArray[Middle] > ToFind){\nreturn BinarySearch(IntegerArray, First, Middle - 1, ToFind);\n}else{\nreturn BinarySearch(IntegerArray, Middle + 1, Last, ToFind);\n}\n}\n}\nVB.NET\nFunction BinarySearch(IntegerArray, First, Last, ToFind)\nDim Middle As Integer\nIf First > Last Then\n© Cambridge University Press & Assessment 2024 Page 47 of 50\n\n3(d)(i) Return -1\nElse\nMiddle = (Last + First) \\ 2\nIf IntegerArray(Middle) = ToFind Then\nReturn Middle\nElseIf IntegerArray(Middle) > ToFind Then\nReturn BinarySearch(IntegerArray, First, Middle - 1, ToFind)\nElse\nReturn BinarySearch(IntegerArray, Middle + 1, Last, ToFind)\nEnd If\nEnd If\nEnd Function\nPython\ndef BinarySearch(IntegerArray, First, Last, ToFind):\nif First > Last:\nreturn -1\nelse:\nMiddle = int((Last + First) / 2)\nif IntegerArray[Middle] == ToFind:\nreturn Middle\nelif IntegerArray[Middle] > ToFind:\nreturn BinarySearch(IntegerArray, First, Middle - 1, ToFind)\nelse:\nreturn BinarySearch(IntegerArray, Middle + 1, Last, ToFind)\n© Cambridge University Press & Assessment 2024 Page 48 of 50\n\n3(d)(ii) 1 mark each 2\n Calling BinarySearch function with sorted array, 0, 6/len(array)–1, 644 as parameters\n Checking return value and outputting ‘Not found’ if –1 and index otherwise\ne.g.\nJava\nPosition = BinarySearch(Sorted2Array, 0, 6, 644);\nif(Position == -1){\nSystem.out.println(\"Not found\");\n}else{\nSystem.out.println(Position);\n}\nVB.NET\nPosition = BinarySearch(Sorted2Array, 0, 6, 644)\nIf Position = -1 Then\nConsole.WriteLine(\"Not found\")\nElse\nConsole.WriteLine(Position)\nEnd If\nPython\nPosition = BinarySearch(Sorted2Array, 0, len(NumberArray)-1, 644)\nif Position == -1:\nprint(\"Not found\")\nelse:\nprint(Position)\n© Cambridge University Press & Assessment 2024 Page 49 of 50\n\n3(d)(iii) 1 mark for screenshot showing found in index 6 e.g. 1\n© Cambridge University Press & Assessment 2024 Page 50 of 50",
      "source_pages": [
        37,
        38,
        39,
        40,
        41,
        42,
        43,
        44,
        45,
        46,
        47,
        48,
        49,
        50
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_42-p37.png",
        "../answer-assets/9618_s24_ms_42-p38.png",
        "../answer-assets/9618_s24_ms_42-p39.png",
        "../answer-assets/9618_s24_ms_42-p40.png",
        "../answer-assets/9618_s24_ms_42-p41.png",
        "../answer-assets/9618_s24_ms_42-p42.png",
        "../answer-assets/9618_s24_ms_42-p43.png",
        "../answer-assets/9618_s24_ms_42-p44.png",
        "../answer-assets/9618_s24_ms_42-p45.png",
        "../answer-assets/9618_s24_ms_42-p46.png",
        "../answer-assets/9618_s24_ms_42-p47.png",
        "../answer-assets/9618_s24_ms_42-p48.png",
        "../answer-assets/9618_s24_ms_42-p49.png",
        "../answer-assets/9618_s24_ms_42-p50.png"
      ]
    },
    {
      "id": "9618-2024-mj-43-q01",
      "question_id": "9618-2024-mj-43-q01",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 27,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark for: 1\n Declaration of (global) array with identifier DataStored (Integer and 20 spaces)\nand NumberItems (Integer)\ne.g.\nJava\npublic static Integer[] DataStored = new Integer[20];\npublic static Integer NumberItems= 0;\nVB.NET\nDim DataStored(19) As Integer\nDim NumberStored As Integer = 0\nPython\nglobal DataStored #integer\nglobal NumberItems #Integer 20 items\n© Cambridge University Press & Assessment 2024 Page 4 of 38\n\n1(b) 1 mark each 5\n Procedure heading (and close where appropriate) with no parameter.\n Prompt/output of suitable message to request the input of the quantity of numbers\nand reading in quantity of numbers and storing/using …\n … each input in next space in DataStored\ne.g.\nJava\npublic static void Initialise(){\nScanner scanner = new Scanner(System.in);\nInteger Quantity = 0;\ndo{\nSystem.out.println(\"How many numbers will you enter up to 20?\");\nQuantity = Integer.parseInt(scanner.nextLine());\n}while(Quantity <= 0 || Quantity > 20);\nfor(Integer X = 0; X < Quantity; X++){\nSystem.out.println(\"Enter number\");\nDataStored[NumberItems] = Integer.parseInt(scanner.nextLine());\nNumberItems++;\nVB.NET\nSub Initialise()\nConsole.WriteLine(\"How many numbers will you enter?\")\nDim Quantity As Integer\nDo\nQuantity = Console.ReadLine()\nLoop Until (Quantity > 0 And Quantity < 21)\nFor Count = 0 To Quantity - 1\nConsole.WriteLine(\"Enter number\")\nDataStored(NumberStored) = Console.ReadLine()\nNumberStored += 1\nNext\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 5 of 38\n\n1(b) Python\ndef Initialise():\nglobal DataStored\nglobal NumberItems\nValid = False\nwhile(Valid == False):\nNumberItems = int(input(\"How many numbers will you enter?\")) #loop until < 20\nif NumberItems > 0 and NumberItems< 21:\nValid = True\nfor Count in range(0, NumberItems):\nDataStored.append(int(input(\"Enter number\")))\n\n1(c)(i) 1 mark each: 2\n Storing 0 in NumberItems and then calling Initialise()\n Outputting all contents of array DataStored\ne.g.\nJava\npublic static Integer NumberItems= 0;\nInitialise();\nfor(Integer X = 0; X < NumberItems; X++){\nSystem.out.println(DataStored[X]);\nVB.NET\nNumberItems = 0\nInitialise()\nFor X = 0 To NumberItems - 1\nConsole.WriteLine(DataStored(X))\nNext\nPython\nNumberItems = 0\nInitialise()\nprint(DataStored)\n© Cambridge University Press & Assessment 2024 Page 6 of 38\n\n1(c)(ii) 1 mark each 2\n Output showing quantity entered twice (30 and 5) with first being invalid\n Array output 3 9 4 1 2\ne.g.\n© Cambridge University Press & Assessment 2024 Page 7 of 38\n\n1(d)(i) 1 mark each 4\n Procedure header (and end where appropriate)\nand looping through each array element\n Working inner loop …\n …comparison of elements…\n …swapping of elements\ne.g.\nJava\npublic static void BubbleSort(){\nInteger Temp = 0;\nfor(Integer Count = 0; Count < NumberItems; Count++){\nfor(Integer Count2 = 0; Count2 < NumberItems - 1; Count2++){\nif(DataStored[Count2] > DataStored[Count]){\nTemp = DataStored[Count2];\nDataStored[Count2] = DataStored[Count];\nDataStored[Count] = Temp;\n}\n}\n}\n}\nVB.NET\nSub BubbleSort()\nDim Temp As Integer\nFor Count = 0 To NumberStored - 1\nFor Count2 = 0 To NumberStored - 2\nIf (DataStored(Count2) > DataStored(Count)) Then\nTemp = DataStored(Count) DataStored(Count) = DataStored(Count2)\nDataStored(Count2) = Temp\nEnd If\nNext\nNext\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 8 of 38\n\n1(d)(i) Python\ndef BubbleSort():\nglobal DataStored\nglobal NumberItems\nfor Count in range(0, NumberItems):\nfor Count2 in range(0, NumberItems-1):\nif DataStored[Count2] > DataStored[Count]:\nDataStored[Count2], DataStored[Count] = DataStored[Count],\nDataStored[Count2]\n\n1(d)(ii) 1 mark for calling BubbleSort() and outputting array contents after 1\ne.g.\nVB.NET\nBubbleSort()\nFor X = 0 To NumberStored - 1\nConsole.WriteLine(DataStored(X))\nNext\ne.g. Java\nBubbleSort();\nfor(Integer X = 0; X < NumberItems; X++){\nSystem.out.println(DataStored[X]);\n}\ne.g. Python\nBubbleSort()\nprint(DataStored)\n\n1(d)(iii) 1 mark for screenshot showing the inputs and the values in the correct order 1\ne.g.\n© Cambridge University Press & Assessment 2024 Page 9 of 38\n\n1(e)(i) 1 mark each 6\n Function header BinarySearch taking DataToFind as a parameter\n Calculating the mid value (First + Last) \\ 2 or equivalent inside loop\n Checking if the data at mid is the parameter and returning mid inside loop\n If DataToFind < mid, updating Last/Upper with mid – 1 inside loop\n If DataToFind > mid, updating First/Lower with mid + 1 inside loop\n Returning -1 when not found and a suitable loop with end criteria\ne.g.\nJava\npublic static Integer BinarySearch(Integer DataToFind){\nInteger MidValue = 0;\nInteger First = 0;\nInteger Last = NumberItems;\nwhile (First <= Last){\nMidValue = (First + Last) / 2;\nif(DataToFind == DataStored[MidValue]){\nreturn MidValue;\n}\nif(DataToFind < DataStored[MidValue]){\nLast = MidValue - 1;\n}else{\nFirst = MidValue + 1;\n}\n}\nreturn -1;\n}\n© Cambridge University Press & Assessment 2024 Page 10 of 38\n\n1(e)(i) VB.NET\nFunction BinarySearch(DataToFind)\nDim First As Integer = 0\nDim Last As Integer = NumberItems\nDim MidValue As Integer\nWhile (First <= Last)\nMidValue = (First + Last) / 2\nIf DataToFind = DataStored(MidValue) Then\nReturn MidValue\nEnd If\nIf DataToFind < DataStored(MidValue) Then\nLast = MidValue - 1\nElse\nFirst = MidValue + 1\nEnd If\nEnd While\nReturn -1\nEnd Function\nPython\ndef BinarySearch(DataToFind):\nglobal DataStored\nglobal NumberItems\nFirst = 0\nLast= NumberItems\nwhile(First <= Last):\nMidValue = int((First + Last) / 2)\nif DataToFind == DataStored[MidValue]:\nreturn MidValue\nif DataToFind < DataStored[MidValue]:\nLast = MidValue - 1\nelse:\nFirst = MidValue + 1\nreturn -1\n© Cambridge University Press & Assessment 2024 Page 11 of 38\n\n1(e)(ii) 1 mark each: 3\n Taking number as input\n… calling BinarySearch with input\n Outputting value returned\ne.g.\nJava\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Enter a number to find\");\nInteger Search = Integer.parseInt(scanner.nextLine());\nSystem.out.println(BinarySearch(Search));\nVB.NET\nConsole.WriteLine(\"Enter a number to find\")\nDim Search As Integer = Console.ReadLine()\nConsole.WriteLine(BinarySearch(Search))\nPython\nSearch = int(input(\"Enter a number to find\"))\nprint(BinarySearch(Search))\n© Cambridge University Press & Assessment 2024 Page 12 of 38\n\n1(e)(iii) 1 mark for each test 2\ne.g.\nTest 1 – Accept found in index 16\nTest 2\n© Cambridge University Press & Assessment 2024 Page 13 of 38",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_43-p04.png",
        "../answer-assets/9618_s24_ms_43-p05.png",
        "../answer-assets/9618_s24_ms_43-p06.png",
        "../answer-assets/9618_s24_ms_43-p07.png",
        "../answer-assets/9618_s24_ms_43-p08.png",
        "../answer-assets/9618_s24_ms_43-p09.png",
        "../answer-assets/9618_s24_ms_43-p10.png",
        "../answer-assets/9618_s24_ms_43-p11.png",
        "../answer-assets/9618_s24_ms_43-p12.png",
        "../answer-assets/9618_s24_ms_43-p13.png"
      ]
    },
    {
      "id": "9618-2024-mj-43-q02",
      "question_id": "9618-2024-mj-43-q02",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 31,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) 1 mark each to max 4 4\n Class Tree declaration (and end where appropriate)\n All 5 attributes declared as private with correct identifiers and data types\n Constructor header (and end) taking 5 parameters\n Constructor assigns parameters to attributes\ne.g.\nJava\nclass Tree{\nprivate String TreeName;\nprivate Integer HeightGrowth;\nprivate Integer MaxWidth;\nprivate Integer MaxHeight;\nprivate String Evergreen;\npublic Tree(String Name, Integer HGrowth, Integer MaxH, Integer MaxW, String\nPEvergreen){\nTreeName = Name;\nHeightGrowth = HGrowth;\nMaxWidth = MaxW;\nMaxHeight = MaxH;\nEvergreen = PEvergreen;\n}}\n© Cambridge University Press & Assessment 2024 Page 14 of 38\n\n2(a)(i) VB.NET\nClass Tree\nPrivate TreeName As String\nPrivate HeightGrowth As Integer\nPrivate MaxHeight As Integer\nPrivate MaxWidth As Integer\nPrivate Evergreen As String\nSub New(Name, HGrowth, MaxH, MaxW, PEvergreen)\nTreeName = Name\nHeightGrowth = HGrowth\nMaxHeight = MaxH\nMaxWidth = MaxW\nEvergreen = PEvergreen\nEnd Sub\nEnd Class\nPython\nclass Tree:\ndef __init__(self, Name, HGrowth, MaxH, MaxW, PEvergreen):\nself.__TreeName = Name\nself.__HeightGrowth = HGrowth\nself.__MaxHeight = MaxH\nself.__MaxWidth = MaxW\nself.__Evergreen = PEvergreen\n© Cambridge University Press & Assessment 2024 Page 15 of 38\n\n2(a)(ii) 1 mark each 3\n 1 get method with no parameter …\n … returning correct attribute\n Remaining 4 correct\ne.g.\nJava\npublic String GetTreeName(){\nreturn TreeName;\n}\npublic Integer GetGrowth(){\nreturn HeightGrowth;\n}\npublic Integer GetMaxWidth(){\nreturn MaxWidth;\n}\npublic Integer GetMaxHeight(){\nreturn MaxHeight;\n}\npublic String GetEvergreen(){\nreturn Evergreen;\n}\n© Cambridge University Press & Assessment 2024 Page 16 of 38\n\n2(a)(ii) VB.NET\nFunction GetTreeName()\nReturn TreeName\nEnd Function\nFunction GetMaxHeight()\nReturn MaxHeight\nEnd Function\nFunction GetMaxWIdth()\nReturn MaxWidth\nEnd Function\nFunction GetGrowth()\nReturn HeightGrowth\nEnd Function\nFunction GetEvergreen()\nReturn Evergreen\nEnd Function\nPython\ndef GetTreeName(self):\nreturn self.__TreeName\ndef GetMaxHeight(self):\nreturn self.__MaxHeight\ndef GetMaxWidth(self):\nreturn self.__MaxWidth\ndef GetGrowth(self):\nreturn self.__HeightGrowth\ndef GetEvergreen(self):\nreturn self.__Evergreen\n© Cambridge University Press & Assessment 2024 Page 17 of 38\n\n2(b) VB.NET\nFunction ReadData()\nDim TreeObjects(10) As Tree\nDim TextFile As String = \"Trees.txt\"\ntry\nDim FileReader As New System.IO.StreamReader(TextFile)\nDim TreeData(10) As String\nDim TreeSplit() As String\nFor Count = 0 To 8\nTreeData(Count) = FileReader.ReadLine()\nNext Count\nFileReader.Close()\nFor X = 0 To 8\nTreeSplit = TreeData(X).Split(\",\")\nTreeObjects(X) = New Tree(TreeSplit(0), Integer.Parse(TreeSplit(1)),\nInteger.Parse(TreeSplit(2)), Integer.Parse(TreeSplit(3)), TreeSplit(4))\nNext X\nCatch ex As Exception\nConsole.WriteLine (\"invalid file\")\nEnd Try\nReturn TreeObjects\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 19 of 38\n\n2(b) Python\ndef ReadData():\nTreeObjects=[]\ntry:\nFile = open(\"Trees.txt\")\nTreeData = []\nTreeData = File.read().split(\"\\n\")\nSplitTrees = []\nfor Item in TreeData:\nSplitTrees.append(Item.split(\",\"))\nFile.close()\nfor Item in SplitTrees:\nTreeObjects.append(Tree(Item[0],int(Item[1]),int(Item[2]),int(Item[3]),Item[4]))\nexcept IOError:\nprint (\"invalid file\")\nreturn TreeObjects\n© Cambridge University Press & Assessment 2024 Page 20 of 38\n\n2(c) 1 mark each 4\n Procedure heading (and end) taking one parameter (of type Tree)\nand using get methods to access tree name, height, width, growth\n Outputs all 4 attributes (TreeName, MaxHeight, MaxWidth, GetGrowth)\n Checks if it is evergreen…\n… correct messages are output if evergreen and otherwise\ne.g.\nJava\npublic static void PrintTrees(Tree TreeItem){\nString Final = \"does not lose its leaves\";\nif((TreeItem.GetEvergreen()).compareTo(\"No\") == 0){\nFinal = \"loses its leaves each year\";\n}\nSystem.out.println(TreeItem.GetTreeName() + \" has a maximum height \" +\nTreeItem.GetMaxHeight() + \" a maximum width \" + TreeItem.GetMaxWidth() + \" and grows \" +\nTreeItem.GetGrowth() + \" cm a year. It \" + Final);\n}\nVB.NET\nSub PrintTrees(Item)\nDim Final As String = \"does not lose its leaves\"\nIf (Item.GetEvergreen() = \"No\") Then\nFinal = \"loses its leaves each year\"\nEnd If\nConsole.WriteLine(Item.GetTreeName() & \" has a maximum height \" &\nItem.GetMaxHeight() & \" a maximum width \" & Item.GetMaxWidth() & \" and grows \" &\nItem.GetGrowth() & \"cm a year. It\" & Final)\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 21 of 38\n\n2(c) Python\ndef PrintTrees(Item):\nFinal = \"does not lose its leaves\"\nif Item.GetEvergreen() == \"No\":\nFinal = \"loses its leaves each year\"\nprint(Item.GetTreeName(), \"has a maximum height\", Item.GetMaxHeight(),\"a maximum\nwidth\",Item.GetMaxWidth(),\"and grows\", Item.GetGrowth(),\"cm a year. It\",Final)\n\n2(d)(i)  1 mark each 2\n Calling ReadData() and storing/using return value (as array of type Tree)…\n…calling PrintTrees() with first object in returned array as parameter\ne.g.\nJava\nTree[] TreeData = new Tree[20];\nTreeData = ReadData();\nPrintTrees(TreeData[0]);\nVB.NET\nSub Main(args As String())\nDim TreeObjects(10) As Tree\nTreeObjects = ReadData()\nPrintTrees(Treeobjects(0))\nEnd Sub\nPython\nTreeObjects = ReadData()\nPrintTrees(TreeObjects[0])\n\n2(d)(ii) Screenshot showing output 1\n© Cambridge University Press & Assessment 2024 Page 22 of 38\n\n2(e)(i) 1 mark each to max 6 6\n Procedure header (and close) taking array of Tree objects as a parameter\nand reading evergreen, max height and max width once as input from the user\n Looping through each array object …\n … comparing each width input >= MaxWidth, height input >= MaxHeight\n … comparing each evergreen input with Evergreen\n… when all true (all requirements met) - appending object in new array\n Calling PrintTrees() with each valid object\n Outputting suitable message if no trees appropriate\ne.g.\nJava\npublic static void ChooseTree(Tree[] Trees){\nScanner scanner = new Scanner(System.in);\nSystem.out.println(\"Do you want a tree that loses its leaves (enter lose), or keeps\nits leaves (enter keep)\") ;\nString Evergreen = (scanner.nextLine());\nSystem.out.println(\"What is the maximum tree height in cm\");\nInteger MaxHeight = Integer.parseInt(scanner.nextLine());\nSystem.out.println(\"What is the maximum tree width in cm\");\nInteger MaxWidth = Integer.parseInt(scanner.nextLine());\nTree[] Options = new Tree[20];\nString keep;\nTree Selected;\nBoolean Valid = false;\nif(((Evergreen.toLowerCase()).compareTo(\"keep\") == 0) ||\n((Evergreen.toLowerCase()).compareTo(\"keep leaves\") == 0) ||\n((Evergreen.toLowerCase()).compareTo(\"keeps its leaves\") == 0)){\nkeep = \"Yes\";\n}else{\nkeep = \"No\";\n}\nInteger Counter = 0;\nfor(Integer X = 0; X < 9; X++){\n© Cambridge University Press & Assessment 2024 Page 23 of 38\n\n2(e)(i) if((Trees[X].GetMaxHeight() <= MaxHeight) && (Trees[X].GetMaxWidth() <=\nMaxWidth) && (keep.compareTo(Trees[X].GetEvergreen())==0)){\nOptions[Counter] = Trees[X];\nPrintTrees(Trees[X]);\nCounter = Counter + 1;\n}\n}\nif(Counter == 0){\nSystem.out.println(\"No suitable trees\");\n}\n}\nVB.NET\nSub ChooseTree(Trees)\nConsole.WriteLine(\"Do you want a tree that loses its leaves (enter lose), or keeps\nits leaves (enter keep)\")\nDim Evergreen As String = Console.ReadLine()\nConsole.WriteLine(\"What is the maximum tree height in cm\")\nDim MaxHeight As Integer = Console.ReadLine()\nConsole.WriteLine(\"What is the maximum tree width in cm\")\nDim MaxWidth As Integer = Console.ReadLine()\nDim Options(0 To 9) As Tree\nDim keep As String\nDim Valid As Boolean\nDim Selected As Tree\nIf Evergreen.ToLower() = \"keep\" Or Evergreen.ToLower() = \"keep leaves\" Or\nEvergreen.ToLower() = \"keeps its leaves\" Then\nkeep = \"Yes\"\nElse\nkeep = \"No\"\n© Cambridge University Press & Assessment 2024 Page 24 of 38\n\n2(e)(i) End If\nDim count As Integer = 0\nFor x = 0 To 8\nIf Trees(x).GetMaxHeight() <= MaxHeight And Trees(x).GetMaxWidth() <= MaxWidth\nAnd keep = Trees(x).GetEvergreen() Then\nOptions(count) = Trees(x)\nPrintTrees(Trees(x))\ncount = count + 1\nEnd If\nNext x\nIf count = 0 Then\nConsole.WriteLine(\"No suitable trees\")\nEnd If\nEnd Sub\nPython\ndef ChooseTree(Trees):\nEvergreen = input(\"Do you want a tree that loses its leaves (enter lose), or keeps its\nleaves (enter keep)\")\nMaxHeight = int(input(\"What is the maximum tree height in cm\"))\nMaxWidth = int(input(\"What is the maximum tree width in cm\"))\nOptions = []\nif Evergreen.lower() == \"keep\" or Evergreen.lower() == \"keep leaves\" or\nEvergreen.lower() == \"keeps its leaves\":\nkeep = \"Yes\"\nelse:\nkeep = \"No\"\nfor Item in Trees:\nif Item.GetMaxHeight() <= MaxHeight and Item.GetMaxWidth() <= MaxWidth and keep ==\nItem.GetEvergreen():\nOptions.append(Item)\nPrintTrees(Item)\nif len(Options) == 0:\nprint(\"No suitable trees\")\n© Cambridge University Press & Assessment 2024 Page 25 of 38\n\n2(e)(ii) 1 mark each to max 2\n Taking tree name and initial height as input\n Finding the tree, calculating and outputting the number of years to get to maximum height\nVB.NET\nValid = False\nDim Start As Integer\nDim Years As Single\nDim Choice As String\nWhile Valid = False\nConsole.WriteLine(\"Enter the name of the tree you want\")\nChoice = Console.ReadLine()\nFor X = 0 To count - 1\nIf Options(X).GetTreeName() = Choice Then\nValid = True\nSelected = Options(X)\nConsole.WriteLine(\"Enter the height of the tree you would like to start with in\ncm\")\nStart = Console.ReadLine()\nYears = (Selected.GetMaxHeight() - Start) / Selected.GetGrowth()\nConsole.WriteLine(\"Your tree should be full height in approximately \" & Years &\n\" years\")\nEnd If\nNext X\nEnd While\n© Cambridge University Press & Assessment 2024 Page 26 of 38\n\n2(e)(ii) Java\nInteger Start;\nFloat Height;\nFloat Growth;\nFloat Years;\nwhile(Valid == false){\nSystem.out.println(\"Enter the name of the tree you want\");\nString Choice = scanner.nextLine();\nfor(Integer X = 0; X < Counter; X++){\nif((Options[X].GetTreeName()).compareTo(Choice)==0){\nValid = true;\nSelected = Options[X];\nSystem.out.println(\"Enter the height of the tree you would like to start\nwith in cm\");\nStart = Integer.parseInt(scanner.nextLine());\nHeight = (Selected.GetMaxHeight()).floatValue();\nGrowth = (Selected.GetGrowth()).floatValue();\nYears = (Height - Start) / Growth;\nSystem.out.println(\"Your tree should be full height in approximately \"+\nYears + \" years\");\n}\n}\n}\nPython:\nValid = False\nwhile Valid == False:\nChoice = input(\"Enter the name of the tree you want\")\nfor Item in Options:\nif Item.GetTreeName() == Choice:\nValid = True\nSelected = Item\nStart = int(input(\"Enter the height of the tree you would like to start with in\ncm\"))\nYears = (Selected.GetMaxHeight() - Start)/Selected.GetGrowth()\nprint(\"Your tree should be full height in approximately\", Years,\"years\")\n© Cambridge University Press & Assessment 2024 Page 27 of 38\n\n2(e)(iii) 1 mark each 2\n Screenshot shows the user requirements input (height 400, width 200, evergreen) and outputs the correct trees (Blue\nconifer and green conifer)\n Screenshot shows the tree selection input (Blue Conifer with height 100) and outputs the correct result (3 years / 3.75\n/ 4 years)\n© Cambridge University Press & Assessment 2024 Page 28 of 38",
      "source_pages": [
        14,
        15,
        16,
        17,
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_43-p14.png",
        "../answer-assets/9618_s24_ms_43-p15.png",
        "../answer-assets/9618_s24_ms_43-p16.png",
        "../answer-assets/9618_s24_ms_43-p17.png",
        "../answer-assets/9618_s24_ms_43-p19.png",
        "../answer-assets/9618_s24_ms_43-p20.png",
        "../answer-assets/9618_s24_ms_43-p21.png",
        "../answer-assets/9618_s24_ms_43-p22.png",
        "../answer-assets/9618_s24_ms_43-p23.png",
        "../answer-assets/9618_s24_ms_43-p24.png",
        "../answer-assets/9618_s24_ms_43-p25.png",
        "../answer-assets/9618_s24_ms_43-p26.png",
        "../answer-assets/9618_s24_ms_43-p27.png",
        "../answer-assets/9618_s24_ms_43-p28.png"
      ]
    },
    {
      "id": "9618-2024-mj-43-q03",
      "question_id": "9618-2024-mj-43-q03",
      "subject": "9618",
      "year": 2024,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 17,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark each 1\n QueueData as 1D (string) array initialised to 20 null values\nand QueueHead initialised to -1, QueueTail initialised to -1\ne.g.\nJava\nclass Queue{\npublic static String[] QueueData = new String[20];\npublic static Integer QueueHead;\npublic static Integer QueueTail;\npublic static void main(String args[]){\nfor(Integer x = 0; x < 20; x++){\nQueueData[x] = \"\";\n}\nQueueHead = -1;\nQueueTail = -1;\n}\n}\nVB.NET\nDim QueueData(0 To 20) As String\nDim QueueHead As Integer = -1\nDim QueueTail As Integer = -1\nSub Main(args As String())\nFor x = 0 To 19\nQueueData(x) = \"\"\nNext\nEnd Sub\nPython\nglobal QueueData\nglobal QueueHead\nglobal QueueTail\nQueueData = []\nfor x in range(0, 20):\nQueueData.append(\"\")\nQueueHead = -1\nQueueTail = -1\n© Cambridge University Press & Assessment 2024 Page 29 of 38\n\n3(b) 1 mark each 4\n Function header (and end) taking one parameter and returns a Boolean value in all instances\n Checks if queue is full and returns FALSE\n (If not full) Inserts data item to QueueTail + 1\nand increments QueueTail\nand returns TRUE\n Assigns QueueHead to 0 when first element is entered (this can come from incrementing)\ne.g.\nJava\npublic static Boolean Enqueue(String DataToInsert){\nif(QueueTail == 19){\nreturn false;\n}else if(QueueHead == -1){\nQueueHead = 0;\n}\nQueueTail = QueueTail + 1;\nQueueData[QueueTail] = DataToInsert.substring(0,6);\nreturn true;\n}\nVB.NET\nFunction Enqueue(ByVal DataToInsert)\nIf QueueTail = 19 Then\nReturn False\nElseIf QueueHead = -1 Then\nQueueHead = 0\nEnd If\nQueueTail = QueueTail + 1\nQueueData(QueueTail) = DataToInsert\nReturn True\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 30 of 38\n\n3(b) Python\ndef Enqueue(DataToInsert):\nglobal QueueData\nglobal QueueHead\nglobal QueueTail\nif QueueTail == 19:\nreturn False\nelif QueueHead == -1:\nQueueHead = 0\nQueueTail = QueueTail + 1\nQueueData.append(DataToInsert)\nreturn True\n© Cambridge University Press & Assessment 2024 Page 31 of 38\n\n3(c) 1 mark each 3\n Dequeue function header (and end) returning a string in all cases\n Check if queue is empty\nand return \"false\"\n (otherwise) remove value at QueueHead\nand increment QueueHead\nand return value from array\ne.g.\nJava\npublic static String Dequeue(){\nif(QueueHead < 0 || QueueHead > 20 || QueueHead > QueueTail){\nreturn \"false\";\n}\nQueueHead++;\nreturn QueueData[QueueHead-1];\n}\nVB.NET\nFunction Dequeue()\nIf QueueHead < 0 Or QueueHead > 20 Or QueueHead > QueueTail Then\nReturn \"false\"\nElse\nQueueHead = QueueHead + 1\nReturn QueueData(QueueHead - 1)\nEnd If\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 32 of 38\n\n3(c) Python\ndef Dequeue():\nglobal QueueData\nglobal QueueHead\nglobal QueueTail\nif QueueHead < 0 or QueueHead > 20 or QueueHead > QueueTail:\nreturn False\nelse:\nQueueHead = QueueHead + 1\nreturn QueueData[QueueHead-1]\n\n3(d)(i) 1 mark each to max 6 6\n StoreItems header (function/procedure and end where appropriate)\nand takes 10 inputsi\n Input is split and first 6 characters used in calculation (as integers) …\n … multiplication by 1 and 3 alternately, adding to total, dividing by 10, rounding down/cast int …\n … comparing check digit to character in position 6\n … including comparison of X for 10\n Calling Enqueue with first 6 characters when valid\n … outputting appropriate message on return (for both inserted and queue full)\n Counts and outputs number of invalid inputs\ne.g.\nJava\npublic static void StoreItems(){\nInteger Count = 0;\nInteger Total = 0;\nString Data;\nBoolean Result;\nScanner scanner = new Scanner(System.in);\nfor(Integer X = 0; X < 10; X++){\nSystem.out.println(\"Enter data\");\nData = scanner.nextLine();\nTotal = Integer.parseInt(Data.substring(0,1)) +\n© Cambridge University Press & Assessment 2024 Page 33 of 38\n\n3(d)(i) Integer.parseInt(Data.substring(1,2)) * 3 + Integer.parseInt(Data.substring(2,3)) +\nInteger.parseInt(Data.substring(3,4)) * 3 + Integer.parseInt(Data.substring(4,5)) +\nInteger.parseInt(Data.substring(5,6)) * 3;\nTotal = Total / 10;\nif((Total == 10 && Data.substring(6).compareTo(\"X\")==0)){\nResult = Enqueue(Data);\nif(Result == true){\nSystem.out.println(\"Inserted item\");\n}else{\nSystem.out.println(\"Queue full\");\n}\n}else if(Total == Integer.parseInt(Data.substring(6,7))){\nResult = Enqueue(Data);\nif(Result == true){\nSystem.out.println(\"Inserted item\");\n}else{\nSystem.out.println(\"Queue full\");\n}\n}else{\nCount = Count + 1;\n}\n}\nSystem.out.println(\"There were \" + Count + \" invalid items\");\n}\nVB.NET\nSub StoreItems()\nDim Count As Integer = 0\nDim Total As Integer = 0\nDim Data As String\nDim Result As Boolean\nFor X = 0 To 9\nConsole.WriteLine(\"Enter data\")\nData = Console.ReadLine()\n© Cambridge University Press & Assessment 2024 Page 34 of 38\n\n3(d)(i) Total = Integer.Parse(Data.Substring(0, 1)) + Integer.Parse(Data.Substring(1, 1)) *\n\n3 + Integer.Parse(Data.Substring(2, 1)) + Integer.Parse(Data.Substring(3, 1)) * 3 +\nInteger.Parse(Data.Substring(4, 1)) + Integer.Parse(Data.Substring(5, 1)) * 3\nTotal = Total \\ 10\nIf (Total = 10 And Data.Substring(6, 1) = \"X\") Then\nResult = Enqueue(Data.Substring(0, 6))\nIf Result = True Then\nConsole.WriteLine(\"Inserted item\")\nElse\nConsole.WriteLine(\"Queue full\")\nEnd If\nElseIf Total = Integer.Parse(Data.Substring(6, 1)) Then\nResult = Enqueue(Data)\nIf Result = True Then\nConsole.WriteLine(\"Inserted item\")\nElse\nConsole.WriteLine(\"Queue full\")\nEnd If\nElse\nCount = Count + 1\nEnd If\nNext\nConsole.WriteLine(\"There were \" & Count & \" invalid items\")\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 35 of 38\n\n3(d)(i) Python\ndef StoreItems():\nglobal QueueData\nglobal QueueHead\nglobal QueueTail\nCount = 0\nfor X in range(0, 10):\nData = input(\"Enter data\")\nTotal= int(Data[0]) + int(Data[1]) * 3 + int(Data[2]) + int(Data[3]) * 3 +\nint(Data[4]) + int(Data[5]) * 3\nTotal = int(Total / 10)\nif((Total == 10 and Data[6] == \"X\") or (Total == int(Data[6]))):\nResult = Enqueue(Data[0:6])\nif(Result == True):\nprint(\"Inserted item\")\nelse:\nprint(\"Queue full\")\nelse:\nCount = Count + 1\nprint(\"There were\", Count,\"Invalid items\")\n© Cambridge University Press & Assessment 2024 Page 36 of 38\n\n3(d)(ii)  Calling StoreItems() 1\nand Dequeue() once\nand outputting a suitable message if the queue was empty\nand outputting the returned value if the queue was not empty\ne.g.\nJava\npublic static void main(String args[]){\nfor(Integer x = 0; x < 20; x++){\nQueueData[x] = \"\";\n}\nQueueHead = -1;\nQueueTail = -1;\nStoreItems();\nString Value = Dequeue();\nif(Value.compareTo(\"false\") == 0){\nSystem.out.println(\"No data items\");\n}else{\nSystem.out.println(\"Item code \" + Value);\n}\n}\nVB.NET\nSub Main(args As String())\nFor x = 0 To 19\nQueueData(x) = \"\"\nNext\nStoreItems()\nDim ReturnValue As String = Dequeue()\nIf (ReturnValue = \"false\") Then\nConsole.WriteLine(\"No data items\")\nElse\nConsole.WriteLine(\"Item code \" & ReturnValue)\nEnd If\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 37 of 38\n\n3(d)(ii) Python\nQueueData = []\nfor x in range(0, 20):\nQueueData.append(\"\")\nQueueHead = -1\nQueueTail = -1\nStoreItems()\nValue = Dequeue()\nif Value == False:\nprint(\"No data items\")\nelse:\nprint(\"Item code\", Value)\n\n3(d)(iii) 1 mark each 2\n Data input of 10 values and output a message saying there are 4 invalid items\n 999999 output\ne.g.\n© Cambridge University Press & Assessment 2024 Page 38 of 38",
      "source_pages": [
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37,
        38
      ],
      "source_pdf": "_source-pdfs/2024-may-june/ms/9618_s24_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-May-June/9618_s24_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s24_ms_43-p29.png",
        "../answer-assets/9618_s24_ms_43-p30.png",
        "../answer-assets/9618_s24_ms_43-p31.png",
        "../answer-assets/9618_s24_ms_43-p32.png",
        "../answer-assets/9618_s24_ms_43-p33.png",
        "../answer-assets/9618_s24_ms_43-p34.png",
        "../answer-assets/9618_s24_ms_43-p35.png",
        "../answer-assets/9618_s24_ms_43-p36.png",
        "../answer-assets/9618_s24_ms_43-p37.png",
        "../answer-assets/9618_s24_ms_43-p38.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q01",
      "question_id": "9618-2024-on-31-q01",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point (Max 1) 3\n• correct answer\n• statement regarding number losing precision/rounding error\nOne mark per mark point for working (Max 2)\n• number converted to binary 201.125 = 11001001.001\n// 128 + 64 + 8 + 1 + 0.125 / 1/ seen\n8\n• use of the exponent e.g. moving the binary point 8 places /  28.\nMantissa Exponent\n0 1 1 0 0 1 0 0 1 0 0 0 1 0 0 0\n\n1(b) One mark per mark point (Max 2) 3\n• application of exponent to go from 1.010110011 to 101011.0011 // x 25 // movement of binary point 5 places seen\n• –32 + 8 + 2 + 1 + .125 + .0625 // –32 + 8 + 2 + 1 + 1/ + 1/ seen\n8 16\n// –1 + ¼ + 1/ + 1/ + 1/ + 1/ // –1 + 179/ // –333/\n16 32 256 512 512 512\nOne mark for correct answer (Max 1)\n• –20.8125 //\n–2013/\n16\n© Cambridge University Press & Assessment 2024 Page 4 of 17",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p04.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q02",
      "question_id": "9618-2024-on-31-q02",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 2,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "2 One mark per mark point (Max 4) 4\nMP1 low number of instruction formats //low number of instruction sets\nMP2 uses single-clock cycle instructions\nMP3 uses fixed length instructions\nMP4 uses many general-purpose registers\nMP5 works well with pipelining\nMP6 hard-wired control unit\nMP7 makes extensive use of RAM\nMP8 uses a low number of addressing modes\nMP9 the design emphasis is on the software.\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p05.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q03",
      "question_id": "9618-2024-on-31-q03",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per mark point (Max 3) 3\nMP1 A dedicated circuit / channel is required\nMP2 The circuit is established before the transmission begins\nMP3 The circuit lasts for the whole of the transmission // The circuit is closed at the end of the transmission\nMP4 Data travels in a continuous stream along the same route\nMP5 Transmission is usually bidirectional.\n© Cambridge University Press & Assessment 2024 Page 5 of 17\n\n3(b) One mark for a benefit (Max 1) 2\nMP1 No need for data to be reassembled // data / frames arrive in the same order in which they were sent\nMP2 Suitable for real time transmission // fast data transfer rate\nMP3 The whole of the bandwidth is available\nOne mark for a drawback (Max 1)\nMP4 No other transmission can use the same circuit when it is in use // Bandwidth can be wasted as it cannot be used by\nother messages\nMP5 Not secure // Can be intercepted as all data travelling along the same route\nMP6 If there is a problem with the route the transmission ends // No other route is available without first doing the setup\nMP7 The circuit is always there whether or not it’s being used\nMP8 Can take time to set up before transmission starts.\nQuestion Answer Marks",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p05.png",
        "../answer-assets/9618_w24_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q04",
      "question_id": "9618-2024-on-31-q04",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 4,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "4 One mark per mark point (Max 4) 4\nMP1 Each layer can only accept input from the next higher layer or the next lower layer\nMP2 There is an interface between the adjacent layers which is the only interaction between layers\nMP3 Data is added to the headers as the frames/packets pass through the layers\nMP4 The interactions are carried out by installed software\nMP5 User interaction takes place at the highest/Application layer of the stack through protocols associated with that layer\nof the stack\nMP6 Direct access to hardware takes place at the lowest/Link layer of the stack.\n© Cambridge University Press & Assessment 2024 Page 6 of 17",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q05",
      "question_id": "9618-2024-on-31-q05",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 5,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark per mark point (Max 3) 3\nMP1 A hashing algorithm is used in direct access methods on random and sequential files\nMP2 It is a mathematical formula\nMP3 … used to perform a calculation applied to the key field of the record being searched / stored\nMP4 The result of the calculation gives the address where the record should be found / stored.\n\n5(b) One mark per mark point (Max 2) 2\nMP1 The record is stored in the next free memory space after the one identified by the hashing algorithm // Use\nlinear progression\nMP2 An overflow area is set up and the record is stored in the next free memory space in the overflow area.\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q06",
      "question_id": "9618-2024-on-31-q06",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 6,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark per mark point (Max 3) 3\nMP1 A set user-defined data type is a composite data type\nMP2 … which includes a list of unordered elements\nMP3 Set theory operations, such as intersection and union, can be applied to these elements\nMP4 A set data type includes the type of data/data type it uses as part of its definition\nMP5 All the elements are of the same data type.\n© Cambridge University Press & Assessment 2024 Page 7 of 17\n\n6(b) One mark for each mark point (Max 4) 4\nMP1 TYPE SymbolSet/Operators =\nMP2 SET OF CHAR\nMP3 DEFINE Operators/SymbolSet\nMP4 ('+', '–', '*', '/', '^')\nMP5 : SymbolSet/Operators\nExample answers\nTYPE SymbolSet = SET OF CHAR\nDEFINE Operators ('+', '–', '*', '/', '^') : SymbolSet\nTYPE Operators = SET OF CHAR\nDEFINE SymbolSet ('+', '–', '*', '/', '^') : Operators\nQuestion Answer Marks",
      "source_pages": [
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p07.png",
        "../answer-assets/9618_w24_ms_31-p08.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q07",
      "question_id": "9618-2024-on-31-q07",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark for every two correct products (Max 3) 3\n(T =) A.B.C.D+A.B.C.D+A.B.C.D+ A.B.C.D+A.B.C.D+A.B.C.D\n© Cambridge University Press & Assessment 2024 Page 8 of 17\n\n7(b) Two marks if no errors present 2\nOne mark if one error present\nAB\nCD 00 01 11 10\n00 0 0 0 0\n01 1 0 1 1\n11 1 0 1 1\n10 0 0 0 0\n\n7(c) One mark for each correct loop (Max 2) 2\nAB\nCD 00 01 11 10\n00 0 0 0 0\n01 1 0 1 1\n11 1 0 1 1\n10 0 0 0 0\n© Cambridge University Press & Assessment 2024 Page 9 of 17\n\n7(d)(i) One mark for each mark point (Max 2) 2\n• Any correct Boolean term\n• Boolean terms and operator correct and no other terms present\n(T =) A.D+B.D // B.D.+ A.D\n\n7(d)(ii) One mark for simplest form (Max 1) 1\n(T =) D.(A.B)\nQuestion Answer Marks",
      "source_pages": [
        8,
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p08.png",
        "../answer-assets/9618_w24_ms_31-p09.png",
        "../answer-assets/9618_w24_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q08",
      "question_id": "9618-2024-on-31-q08",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 8,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark per mark point (Max 4) 4\nMP1 In segmented memory, the logical / virtual address space is broken into varying sized blocks called segments /\nsections.\nMP2 Each segment has a name and size.\nMP3 During execution segments from logical / virtual memory are loaded into physical memory.\nMP4 The address is specified by the user\nMP5 … it contains the segment name and offset value.\nMP6 Segments are numbered\nMP7 … and this number is used as an index in the segment map table.\nMP8 The offset value determines the size of the segment.\nMP9 A segment map table maps logical / virtual addresses to physical addresses / contains the segment number and\noffset.\n© Cambridge University Press & Assessment 2024 Page 10 of 17\n\n8(b) One mark per mark point (Max 3) 3\nMP1 Disk thrashing is a problem that may occur when virtual memory is being used.\nMP2 As the main memory fills up, more and more pages need to be swapped in and out of virtual memory.\nMP3 This swapping leads to a very high rate of hard disk access / excessive disk head movements.\nMP4 Moving a hard disk read/write head takes a relatively long time / long latency time.\nMP5 Eventually, more time is spent swapping pages than processing data thrash point, which can cause the program to\nfreeze or not run.\n© Cambridge University Press & Assessment 2024 Page 11 of 17",
      "source_pages": [
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p10.png",
        "../answer-assets/9618_w24_ms_31-p11.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q09",
      "question_id": "9618-2024-on-31-q09",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 9,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "9(a) To ensure that the attributes are only accessible using the class’s own methods/within the class. 1\n\n9(b) One mark per mark point (Max 5) 5\nMP1 Two correct attributes with sensible names and correct data types.\nMP2 Constructor present.\nMP3 Two correct setters with exact names and appropriate parameters and data types.\nMP4 Two correct getters with appropriate names.\nMP5 Name assigned to pet name getter matches the attribute.\nPet\nPetID : STRING\nPetType : STRING\nOwnerTelephone : STRING\nDateRegistered : DATE\nPetName : STRING\nOwnerName : STRING\nConstructor()\nSetPetID(APetID : STRING)\nSetDateRegistered(RegDate : DATE)\nGetPetName()\nGetOwnerTelephone()\n© Cambridge University Press & Assessment 2024 Page 12 of 17",
      "source_pages": [
        12
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p12.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q10",
      "question_id": "9618-2024-on-31-q10",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 10,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark per mark point (Max 4) 4\n• <operator> ::= + | – | * | /\n• <label> ::= <letter><digit>|<letter><digit><digit>\n• <equation> ::= <label> =\n• <label><operator><label>\n\n10(b)(i) One mark per mark point (Max 3) 3\nMP1 begin with either a letter or a symbol\nMP2 end with either one or two symbols\nMP3 digit and all other connections and label correct.\npassword\nletter digit symbol symbol\nsymbol\n© Cambridge University Press & Assessment 2024 Page 13 of 17\n\n10(b)(ii) One mark per mark point (Max 2) 2\n• <password> ::= <letter><digit><symbol>|\n• <letter><digit><symbol><symbol>|<symbol><digit><symbol>|\n<symbol><digit><symbol><symbol>\n<password> ::= <letter><digit><symbol>|\n<letter><digit><symbol><symbol>|<symbol><digit><symbol>|\n<symbol><digit><symbol><symbol>\nAlternative Answer\nOne mark per mark point (Max 2)\n• All three lines correct\n• Any two lines correct\n<first> ::= <letter>|<symbol>\n<last> ::= <symbol>|<symbol><symbol>\n<password> ::= <first><digit><last>\n© Cambridge University Press & Assessment 2024 Page 14 of 17",
      "source_pages": [
        13,
        14
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p13.png",
        "../answer-assets/9618_w24_ms_31-p14.png"
      ]
    },
    {
      "id": "9618-2024-on-31-q11",
      "question_id": "9618-2024-on-31-q11",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 11,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 12,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark per mark point (Max 4) 4\nMP1 Four additional nodes with correct data values\nMP2 Correct null pointers in all added nodes (6) with no extra null pointers where the arrow points to the next node\nMP3 Correct arrows to represent pointers joining parent nodes to child nodes\nMP4 All nodes in correct order and no extra data added to pointers.\nRootPtr\nLeftPtr Data RightPtr\nRed\nGreen Yellow -1\n-1 Blue -1 Orange -1\n-1 Indigo -1\n-1 Violet -1\n© Cambridge University Press & Assessment 2024 Page 15 of 17\n\n11(b) One mark per mark point (Max 4) 4\nMP1 Correct Red and Green rows\nMP2 Correct Yellow and Blue rows\nMP3 Correct Orange, Indigo and Violet rows\nMP4 Correct FreePtr with blank row 7\nRootPt RightPt\nIndex LeftPtr Data\nr r\n0 0 1 Red 2\n1 3 Green 4\n2 6 Yellow -1\n3 -1 Blue -1\n4 5 Orange -1\n5 -1 Indigo -1\nFreePt\n6 -1 Violet -1\nr\n7 7\n© Cambridge University Press & Assessment 2024 Page 16 of 17\n\n11(c) One mark for any correct row (Max 4) 4\nFUNCTION SearchTree(Item : STRING) RETURNS INTEGER\nNowPtr  RootPtr\nWHILE NowPtr <> -1\nIF BinTree[NowPtr].Data > Item THEN\nNowPtr  BinTree[NowPtr].LeftPtr\nELSE\nIF BinTree[NowPtr].Data < Item THEN\nNowPtr  BinTree[NowPtr].RightPtr\nELSE\nRETURN NowPtr\nENDIF\nENDIF\nENDWHILE\nRETURN NowPtr\nENDFUNCTION\n© Cambridge University Press & Assessment 2024 Page 17 of 17",
      "source_pages": [
        15,
        16,
        17
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_31-p15.png",
        "../answer-assets/9618_w24_ms_31-p16.png",
        "../answer-assets/9618_w24_ms_31-p17.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q01",
      "question_id": "9618-2024-on-32-q01",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 1,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point (Max 3) 3\nMP1 The data to be transmitted is divided into equal sized packets\nMP2 A packet header is attached to each packet containing key information\nMP3 … such as source/destination IP addresses, packet number, etc\nMP4 Packets are transmitted independently\nMP5 … and may travel though different routes/paths to the destination\nMP6 Routes are determined using a routing table//Packets take the optimum route depending on congestion\nMP7 The packets usually arrive out of order\nMP8 The packets are reassembled in the correct order at the destination // The packets are re-ordered using the\nsequence number/the header\nMP9 If packets are missing/corrupted a re-transmission request is sent / packets are re-sent.\n\n1(b) One mark for each benefit (Max 2) 4\nMP1 Packets are more likely to arrive because they can be re-routed if a problem occurs with one of the routes//Packets\nare more likely to arrive because if a packet is lost, it can be re-transmitted\nMP2 Bandwidth can be shared allowing packets from different messages to share the same path\nMP3 Considered secure as the packets generally travel via different routes\nMP4 High data transmission rate is possible\nOne mark for each drawback (Max 2)\nMP5 Time delay because packets need to be re-ordered/reassembled at the destination//Time delay caused by missing\npackets needing to be re-sent//Time delay because it has to share the bandwidth of the circuit / channel with\nother packets\nMP6 Requires a complex algorithm to function\nMP7 Needs lots of RAM to handle large amounts of data.\n© Cambridge University Press & Assessment 2024 Page 4 of 15",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q02",
      "question_id": "9618-2024-on-32-q02",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 2,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark per mark point (Max 2) 2\nMP1 Records are stored one after the other as they are collected // records are stored in chronological order\nMP2 New records are appended to the end of the file.\n\n2(b) One mark for a use (Max 1) 1\nMP1 Creating unsorted / temporary transaction files\nMP2 Creating data logging files\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q03",
      "question_id": "9618-2024-on-32-q03",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 3,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per mark point (Max 3) 3\nMP1 A user-defined record data type is a composite data type\nMP2 It uses other data types in its definition to form a single new data type\nMP3 The data types referenced may be primitive data types from a programming language or they may be other user-\ndefined data types.\nMP4 Includes related items\nMP5 Includes a fixed number of items.\n\n3(b) One mark for TYPE Order and ENDTYPE correct 4\nOne mark for correct use of DECLARE in all declarations seen\nOne mark for the two shaded declarations\nOne mark for the two unshaded declarations\nExample answer\nTYPE Order\nDECLARE AccountNumber : INTEGER\nDECLARE OrderNumber : INTEGER\nDECLARE OrderPrice : REAL\nDECLARE OrderDate : DATE\nENDTYPE\n© Cambridge University Press & Assessment 2024 Page 5 of 15",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q04",
      "question_id": "9618-2024-on-32-q04",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 4,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark for working 2\n• application of exponent to mantissa to go from 0.10001110111 to 01000111.0111 //\nmoving the binary point 7 places //\nmultiplying by 27/128 in the fractions method //\n64 + 4 + 2 +1 + .25+ .125 + .0625 seen\nOne mark for correct answer\n• 71.4375\n// 717/\n16\n\n4(b) One mark per mark point (Max 2) 4\n• correct mantissa – exact answer only\n• correct exponent – exact answer only\nMantissa Exponent\n1 0 0 1 1 1 0 1 1 0 1 0 0 1 1 0\nOne mark per mark point for working (Max 2)\n• number converted to binary e.g., positive binary version of 49.1875 = 0110001.0011 //\ntwo’s complement version bits flipped and 1 added = 1001110.1101 //\n–64 + 8 + 4 + 2 + .5 + .25 + .0625 //\n–64 + 14.8125\n• use of the exponent e.g. moving the binary point 6 places /  26.\n© Cambridge University Press & Assessment 2024 Page 6 of 15",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q05",
      "question_id": "9618-2024-on-32-q05",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 5,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark for each correct name (Max 2) 4\nOne mark for each correct corresponding expansion (Max 2)\nMP1 HTTP/HTTPS\nMP2 For sending and receiving / transferring web pages / hypertext\nMP3 FTP\nMP4 For sending and receiving files over a network / between devices\nMP5 POP3\nMP6 Pull protocol / for receiving / downloading emails\nMP7 IMAP\nMP8 Pull protocol / for receiving / downloading emails\nMP9 SMTP\nMP10 Push protocol / for sending / uploading emails\nMP11 BitTorrent\nMP12 Peer-to-peer file sharing over a network\n\n5(b) One mark per mark point (Max 3) 3\nMP1 The application layer provides access to all the programs that exchange data // Interacts directly with user.\nMP2 … used by, for example, web browsers, server software.\nMP3 Communicates/enables data transfer to/from Transport layer // It allows applications to access the services used in\nother TCP/IP layers.\nMP4 It defines the protocols that any application uses to allow the exchange of data.\n© Cambridge University Press & Assessment 2024 Page 7 of 15",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q06",
      "question_id": "9618-2024-on-32-q06",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "6(a) Three marks for all eight correct products and no additional products 3\nTwo marks for five, six or seven correct products\nOne mark for three or four correct products\n(X =) A.B.C.D+A.B.C.D+A.B.C.D.+ A.B.C.D+A.B.C.D+A.B.C.D+A.B.C.D+A.B.C.D\n\n6(b) Two marks if no errors present 2\nOne mark if one error present\nAB\nCD 00 01 11 10\n00 0 0 0 0\n01 1 1 1 1\n11 0 0 0 0\n10 1 1 1 1\n\n6(c) One mark for each correct loop (Max 2) 2\nAB\nCD 00 01 11 10\n00 0 0 0 0\n01 1 1 1 1\n11 0 0 0 0\n10 1 1 1 1\n© Cambridge University Press & Assessment 2024 Page 8 of 15\n\n6(d) One mark for each mark point (Max 2) 2\nMP1 Any correct relevant Boolean term\nMP2 Boolean terms with correct operator + and no other terms present\n(X =) C.D+C.D // C.D.+ C.D\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p08.png",
        "../answer-assets/9618_w24_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q07",
      "question_id": "9618-2024-on-32-q07",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 7,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark per mark point (Max 2) 2\nMP1 21 - a number must begin with an odd digit, 2 is even\nMP2 123 - a number can only be one or two digits in length not three\n\n7(b) One mark per mark point (Max 2) 2\nMP1 <symbol> ::= % | £ | # | @ | $\nMP2 <number> ::= <odd>|<odd><even>|<odd><odd>\n\n7(c)(i) One mark per mark point (Max 3) 3\nMP1 letter, number and symbol all included in correct order: letter first, followed by number, finishing with symbol\nMP2 provision for one or two numbers including relevant connectors\nMP3 all other connections and label correct and no additional data\nExample answer\ncode\nletter number number symbol\n© Cambridge University Press & Assessment 2024 Page 9 of 15\n\n7(c)(ii) One mark per correct line (Max 2) 2\n<code> ::= <letter><number><symbol>|\n<letter><number><number><symbol>\nOR\n<code> ::= <letter><number><number><symbol>|\n<letter><number><symbol>\nAlternative Answer\nOne mark per correct line (Max 2)\n<digits> ::= <number>|<number><number>\n<code> ::= <letter><digits><symbol>\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p09.png",
        "../answer-assets/9618_w24_ms_32-p10.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q08",
      "question_id": "9618-2024-on-32-q08",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 8,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "8 One mark per mark point (Max 4) 4\nMP1 many instruction formats possible\nMP2 large instruction set\nMP3 many addressing modes available\nMP4 uses variable length/multi-operation instructions\nMP5 multi-clock cycle instructions\nMP6 complex decoding of instructions\nMP7 uses complex circuits\nMP8 makes frequent use of cache memory\nMP9 uses programmable control unit // uses micro-programmed control unit // uses hardwired control unit\nMP10 hardware needs to be able to handle more complex instructions convert into sub-instructions // Design emphasis is\non the hardware.\n© Cambridge University Press & Assessment 2024 Page 10 of 15",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p10.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q09",
      "question_id": "9618-2024-on-32-q09",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 9,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark per mark point (Max 2) 2\nMP1 the kernel receives a signal when an interrupt is generated\nMP2 the kernel checks the priority and reviews the status/priority of the current interrupts\nMP3 system enters kernel mode if the type of interrupt is of higher priority than the current process\nMP4 the kernel consults the interrupt dispatch table / IDT\nMP5 … and saves the state of the interrupted process / contents of the registers on the kernel stack\nMP6 the kernel restores the process state e.g. contents of registers once the interrupt is serviced\n\n9(b)(i) One mark per mark point (Max 1) 1\nMP1 multi-tasking allows computers to carry out / seem to carry out more than one process at a time\n\n9(b)(ii) One mark per mark point (Max 2) 2\nMP1 processor time/common hardware and resources is/are shared between tasks\nMP2 scheduling is used to decide on the processes to be carried out to ensure multi-tasking operates correctly / efficiently\n/ without clashes\nMP3 one task of a higher priority can interrupt another task that is currently running\nQuestion Answer Marks",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p11.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q10",
      "question_id": "9618-2024-on-32-q10",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 10,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark per mark point (Max 3) 3\nMP1 Attributes/properties …\nMP2 … with their data types // … are variables bound to the class\nMP3 Methods …\nMP4 … that are subroutines / functions / procedures that act upon the attributes\nMP5 Getters/setters …\nMP6 … are methods that can fetch / update the contents of attributes\nMP7 A constructor …\nMP8 … that is used to create instances / objects of this class.\n© Cambridge University Press & Assessment 2024 Page 11 of 15\n\n10(b) One mark per mark point (Max 3) 3\nMP1 A class is only defined once but many objects can be created from that class // A class is a template / blueprint from\nwhich objects are created // An object is an instance of a class\nMP2 No memory is allocated when a class is defined, but objects are allocated memory space whenever they are created\nMP3 A class cannot be manipulated as it is not available in the memory, but objects can be manipulated\nMP4 A class is defined but an object is declared / created / instantiated.\nMP5 A class can use inheritance. An object cannot.\n© Cambridge University Press & Assessment 2024 Page 12 of 15",
      "source_pages": [
        11,
        12
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p11.png",
        "../answer-assets/9618_w24_ms_32-p12.png"
      ]
    },
    {
      "id": "9618-2024-on-32-q11",
      "question_id": "9618-2024-on-32-q11",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 11,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 12,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark per mark point (Max 4) 4\nMP1 Five additional nodes with correct data values\nMP2 Correct null pointers in all nodes (7) – no extra null pointers where the arrow points to the next node\nMP3 Correct arrows to represent pointers joining parent nodes to child nodes – must come from the correct left or right\npointer not the middle\nMP4 All nodes in correct order and no additional data in left/right pointer boxes.\nRootPtr\nLeftPtr Data RightPtr\n25\n4 -1 36\n-1 1 -1 16 -1 64 -1\n-1 9 -1 -1 49 -1\n© Cambridge University Press & Assessment 2024 Page 13 of 15\n\n11(b) First eight rows of table (Max 3) 4\nThree marks for all eight correct rows\nTwo marks for six or seven correct rows\nOne mark for three, four or five correct rows\nLast row of table and FreePtr (Max 1)\nOne mark for correct FreePtr with last row of table completely blank\nRootPt RightP\nIndex LeftPtr Data\nr tr\n0 0 1 25 2\n1 3 4 4\n2 -1 36 5\n3 -1 1 -1\n4 6 16 -1\n5 7 64 -1\nFreePt\n6 -1 9 -1\nr\n8 7 -1 49 -1\n8\n© Cambridge University Press & Assessment 2024 Page 14 of 15\n\n11(c) One mark for any correct row (Max 4) 4\nFUNCTION SearchList(Item : INTEGER) RETURNS INTEGER\nNullPtr  -1\nNowPtr  RootPtr\nWHILE NowPtr <> NullPtr\nIF LinkList[NowPtr].Data < Item THEN\nNowPtr  LinkList[NowPtr].RightPtr\nELSE\nIF LinkList[NowPtr].Data > Item THEN\nNowPtr  LinkList[NowPtr].LeftPtr\nELSE\nRETURN NowPtr\nENDIF\nENDIF\nENDWHILE\nRETURN NullPtr\nENDFUNCTION\n© Cambridge University Press & Assessment 2024 Page 15 of 15",
      "source_pages": [
        13,
        14,
        15
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_32-p13.png",
        "../answer-assets/9618_w24_ms_32-p14.png",
        "../answer-assets/9618_w24_ms_32-p15.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q01",
      "question_id": "9618-2024-on-33-q01",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 1,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point (Max 1) 3\n• correct answer\n• statement regarding number losing precision/rounding error\nOne mark per mark point for working (Max 2)\n• number converted to binary 201.125 = 11001001.001\n// 128 + 64 + 8 + 1 + 0.125 / 1/ seen\n8\n• use of the exponent e.g. moving the binary point 8 places /  28.\nMantissa Exponent\n0 1 1 0 0 1 0 0 1 0 0 0 1 0 0 0\n\n1(b) One mark per mark point (Max 2) 3\n• application of exponent to go from 1.010110011 to 101011.0011 // x 25 // movement of binary point 5 places seen\n• –32 + 8 + 2 + 1 + .125 + .0625 // –32 + 8 + 2 + 1 + 1/ + 1/ seen\n8 16\n// –1 + ¼ + 1/ + 1/ + 1/ + 1/ // –1 + 179/ // –333/\n16 32 256 512 512 512\nOne mark for correct answer (Max 1)\n• –20.8125 //\n–2013/\n16\n© Cambridge University Press & Assessment 2024 Page 4 of 17",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p04.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q02",
      "question_id": "9618-2024-on-33-q02",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 2,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "2 One mark per mark point (Max 4) 4\nMP1 low number of instruction formats //low number of instruction sets\nMP2 uses single-clock cycle instructions\nMP3 uses fixed length instructions\nMP4 uses many general-purpose registers\nMP5 works well with pipelining\nMP6 hard-wired control unit\nMP7 makes extensive use of RAM\nMP8 uses a low number of addressing modes\nMP9 the design emphasis is on the software.\nQuestion Answer Marks",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p05.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q03",
      "question_id": "9618-2024-on-33-q03",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per mark point (Max 3) 3\nMP1 A dedicated circuit / channel is required\nMP2 The circuit is established before the transmission begins\nMP3 The circuit lasts for the whole of the transmission // The circuit is closed at the end of the transmission\nMP4 Data travels in a continuous stream along the same route\nMP5 Transmission is usually bidirectional.\n© Cambridge University Press & Assessment 2024 Page 5 of 17\n\n3(b) One mark for a benefit (Max 1) 2\nMP1 No need for data to be reassembled // data / frames arrive in the same order in which they were sent\nMP2 Suitable for real time transmission // fast data transfer rate\nMP3 The whole of the bandwidth is available\nOne mark for a drawback (Max 1)\nMP4 No other transmission can use the same circuit when it is in use // Bandwidth can be wasted as it cannot be used by\nother messages\nMP5 Not secure // Can be intercepted as all data travelling along the same route\nMP6 If there is a problem with the route the transmission ends // No other route is available without first doing the setup\nMP7 The circuit is always there whether or not it’s being used\nMP8 Can take time to set up before transmission starts.\nQuestion Answer Marks",
      "source_pages": [
        5,
        6
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p05.png",
        "../answer-assets/9618_w24_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q04",
      "question_id": "9618-2024-on-33-q04",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 4,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "4 One mark per mark point (Max 4) 4\nMP1 Each layer can only accept input from the next higher layer or the next lower layer\nMP2 There is an interface between the adjacent layers which is the only interaction between layers\nMP3 Data is added to the headers as the frames/packets pass through the layers\nMP4 The interactions are carried out by installed software\nMP5 User interaction takes place at the highest/Application layer of the stack through protocols associated with that layer\nof the stack\nMP6 Direct access to hardware takes place at the lowest/Link layer of the stack.\n© Cambridge University Press & Assessment 2024 Page 6 of 17",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q05",
      "question_id": "9618-2024-on-33-q05",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 5,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark per mark point (Max 3) 3\nMP1 A hashing algorithm is used in direct access methods on random and sequential files\nMP2 It is a mathematical formula\nMP3 … used to perform a calculation applied to the key field of the record being searched / stored\nMP4 The result of the calculation gives the address where the record should be found / stored.\n\n5(b) One mark per mark point (Max 2) 2\nMP1 The record is stored in the next free memory space after the one identified by the hashing algorithm // Use\nlinear progression\nMP2 An overflow area is set up and the record is stored in the next free memory space in the overflow area.\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q06",
      "question_id": "9618-2024-on-33-q06",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 6,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark per mark point (Max 3) 3\nMP1 A set user-defined data type is a composite data type\nMP2 … which includes a list of unordered elements\nMP3 Set theory operations, such as intersection and union, can be applied to these elements\nMP4 A set data type includes the type of data/data type it uses as part of its definition\nMP5 All the elements are of the same data type.\n© Cambridge University Press & Assessment 2024 Page 7 of 17\n\n6(b) One mark for each mark point (Max 4) 4\nMP1 TYPE SymbolSet/Operators =\nMP2 SET OF CHAR\nMP3 DEFINE Operators/SymbolSet\nMP4 ('+', '–', '*', '/', '^')\nMP5 : SymbolSet/Operators\nExample answers\nTYPE SymbolSet = SET OF CHAR\nDEFINE Operators ('+', '–', '*', '/', '^') : SymbolSet\nTYPE Operators = SET OF CHAR\nDEFINE SymbolSet ('+', '–', '*', '/', '^') : Operators\nQuestion Answer Marks",
      "source_pages": [
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p07.png",
        "../answer-assets/9618_w24_ms_33-p08.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q07",
      "question_id": "9618-2024-on-33-q07",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark for every two correct products (Max 3) 3\n(T =) A.B.C.D+A.B.C.D+A.B.C.D+ A.B.C.D+A.B.C.D+A.B.C.D\n© Cambridge University Press & Assessment 2024 Page 8 of 17\n\n7(b) Two marks if no errors present 2\nOne mark if one error present\nAB\nCD 00 01 11 10\n00 0 0 0 0\n01 1 0 1 1\n11 1 0 1 1\n10 0 0 0 0\n\n7(c) One mark for each correct loop (Max 2) 2\nAB\nCD 00 01 11 10\n00 0 0 0 0\n01 1 0 1 1\n11 1 0 1 1\n10 0 0 0 0\n© Cambridge University Press & Assessment 2024 Page 9 of 17\n\n7(d)(i) One mark for each mark point (Max 2) 2\n• Any correct Boolean term\n• Boolean terms and operator correct and no other terms present\n(T =) A.D+B.D // B.D.+ A.D\n\n7(d)(ii) One mark for simplest form (Max 1) 1\n(T =) D.(A.B)\nQuestion Answer Marks",
      "source_pages": [
        8,
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p08.png",
        "../answer-assets/9618_w24_ms_33-p09.png",
        "../answer-assets/9618_w24_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q08",
      "question_id": "9618-2024-on-33-q08",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 8,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark per mark point (Max 4) 4\nMP1 In segmented memory, the logical / virtual address space is broken into varying sized blocks called segments /\nsections.\nMP2 Each segment has a name and size.\nMP3 During execution segments from logical / virtual memory are loaded into physical memory.\nMP4 The address is specified by the user\nMP5 … it contains the segment name and offset value.\nMP6 Segments are numbered\nMP7 … and this number is used as an index in the segment map table.\nMP8 The offset value determines the size of the segment.\nMP9 A segment map table maps logical / virtual addresses to physical addresses / contains the segment number and\noffset.\n© Cambridge University Press & Assessment 2024 Page 10 of 17\n\n8(b) One mark per mark point (Max 3) 3\nMP1 Disk thrashing is a problem that may occur when virtual memory is being used.\nMP2 As the main memory fills up, more and more pages need to be swapped in and out of virtual memory.\nMP3 This swapping leads to a very high rate of hard disk access / excessive disk head movements.\nMP4 Moving a hard disk read/write head takes a relatively long time / long latency time.\nMP5 Eventually, more time is spent swapping pages than processing data thrash point, which can cause the program to\nfreeze or not run.\n© Cambridge University Press & Assessment 2024 Page 11 of 17",
      "source_pages": [
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p10.png",
        "../answer-assets/9618_w24_ms_33-p11.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q09",
      "question_id": "9618-2024-on-33-q09",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 9,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "9(a) To ensure that the attributes are only accessible using the class’s own methods/within the class. 1\n\n9(b) One mark per mark point (Max 5) 5\nMP1 Two correct attributes with sensible names and correct data types.\nMP2 Constructor present.\nMP3 Two correct setters with exact names and appropriate parameters and data types.\nMP4 Two correct getters with appropriate names.\nMP5 Name assigned to pet name getter matches the attribute.\nPet\nPetID : STRING\nPetType : STRING\nOwnerTelephone : STRING\nDateRegistered : DATE\nPetName : STRING\nOwnerName : STRING\nConstructor()\nSetPetID(APetID : STRING)\nSetDateRegistered(RegDate : DATE)\nGetPetName()\nGetOwnerTelephone()\n© Cambridge University Press & Assessment 2024 Page 12 of 17",
      "source_pages": [
        12
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p12.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q10",
      "question_id": "9618-2024-on-33-q10",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 10,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark per mark point (Max 4) 4\n• <operator> ::= + | – | * | /\n• <label> ::= <letter><digit>|<letter><digit><digit>\n• <equation> ::= <label> =\n• <label><operator><label>\n\n10(b)(i) One mark per mark point (Max 3) 3\nMP1 begin with either a letter or a symbol\nMP2 end with either one or two symbols\nMP3 digit and all other connections and label correct.\npassword\nletter digit symbol symbol\nsymbol\n© Cambridge University Press & Assessment 2024 Page 13 of 17\n\n10(b)(ii) One mark per mark point (Max 2) 2\n• <password> ::= <letter><digit><symbol>|\n• <letter><digit><symbol><symbol>|<symbol><digit><symbol>|\n<symbol><digit><symbol><symbol>\n<password> ::= <letter><digit><symbol>|\n<letter><digit><symbol><symbol>|<symbol><digit><symbol>|\n<symbol><digit><symbol><symbol>\nAlternative Answer\nOne mark per mark point (Max 2)\n• All three lines correct\n• Any two lines correct\n<first> ::= <letter>|<symbol>\n<last> ::= <symbol>|<symbol><symbol>\n<password> ::= <first><digit><last>\n© Cambridge University Press & Assessment 2024 Page 14 of 17",
      "source_pages": [
        13,
        14
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p13.png",
        "../answer-assets/9618_w24_ms_33-p14.png"
      ]
    },
    {
      "id": "9618-2024-on-33-q11",
      "question_id": "9618-2024-on-33-q11",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 11,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 12,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark per mark point (Max 4) 4\nMP1 Four additional nodes with correct data values\nMP2 Correct null pointers in all added nodes (6) with no extra null pointers where the arrow points to the next node\nMP3 Correct arrows to represent pointers joining parent nodes to child nodes\nMP4 All nodes in correct order and no extra data added to pointers.\nRootPtr\nLeftPtr Data RightPtr\nRed\nGreen Yellow -1\n-1 Blue -1 Orange -1\n-1 Indigo -1\n-1 Violet -1\n© Cambridge University Press & Assessment 2024 Page 15 of 17\n\n11(b) One mark per mark point (Max 4) 4\nMP1 Correct Red and Green rows\nMP2 Correct Yellow and Blue rows\nMP3 Correct Orange, Indigo and Violet rows\nMP4 Correct FreePtr with blank row 7\nRootPt RightPt\nIndex LeftPtr Data\nr r\n0 0 1 Red 2\n1 3 Green 4\n2 6 Yellow -1\n3 -1 Blue -1\n4 5 Orange -1\n5 -1 Indigo -1\nFreePt\n6 -1 Violet -1\nr\n7 7\n© Cambridge University Press & Assessment 2024 Page 16 of 17\n\n11(c) One mark for any correct row (Max 4) 4\nFUNCTION SearchTree(Item : STRING) RETURNS INTEGER\nNowPtr  RootPtr\nWHILE NowPtr <> -1\nIF BinTree[NowPtr].Data > Item THEN\nNowPtr  BinTree[NowPtr].LeftPtr\nELSE\nIF BinTree[NowPtr].Data < Item THEN\nNowPtr  BinTree[NowPtr].RightPtr\nELSE\nRETURN NowPtr\nENDIF\nENDIF\nENDWHILE\nRETURN NowPtr\nENDFUNCTION\n© Cambridge University Press & Assessment 2024 Page 17 of 17",
      "source_pages": [
        15,
        16,
        17
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_33-p15.png",
        "../answer-assets/9618_w24_ms_33-p16.png",
        "../answer-assets/9618_w24_ms_33-p17.png"
      ]
    },
    {
      "id": "9618-2024-on-41-q01",
      "question_id": "9618-2024-on-41-q01",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 22,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark each to max 6: 6\n• Function declaration (and close where appropriate)\n• Declaration/use of an array (with space/initialised with 45 spaces/strings)\n• Opening the file Data.txt for read and closing in an appropriate place\n• Looping through all file contents/Looping 45 times and reading each line …\n• … storing all items from file into array\n• Returning the populated array\n• Exception handling with suitable try, catch and output\ne.g.\nPython\ndef ReadData():\nColours = []\ntry:\nFile = open(\"Data.txt\")\nColours = File.read().split(\"\\n\")\nFile.close()\nreturn Colours\nexcept:\nprint(\"No file found\")\nVB.NET\nFunction ReadData()\nDim TextFile As String = \"Data.txt\"\nDim Colours(45) As String\nTry\nDim FileReader As New System.IO.StreamReader(TextFile)\nFor x = 0 To 45\nColours(x) = FileReader.ReadLine()\n© Cambridge University Press & Assessment 2024 Page 4 of 37\n\n1(a) Next\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"No file found\")\nEnd Try\nReturn Colours\nEnd Function\nJava\npublic static String[] ReadData(){\nString TextFile = \"Data.txt\";\nString Colours[] = new String[45];\ntry{\nFileReader f = new FileReader(TextFile);\nBufferedReader Reader = new BufferedReader(f);\nfor(Integer X = 0; X < 45; X++){\ntry{\nColours[X] = Reader.readLine();\n}catch(IOException ex){}\n}\ntry{\nReader.close();\n}catch(IOException ex){}\nreturn Colours;\n}catch(FileNotFoundException e){\nSystem.out.println(\"File not found\");\n}\nreturn Colours;\n}\n© Cambridge University Press & Assessment 2024 Page 5 of 37\n\n1(b)(i) 1 mark each 2\n• Function header (and end where appropriate) taking (min) one parameter\n• Looping through each parameter array element, concatenating with space and returning\nPython\ndef FormatArray(DataArray):\nOutputText = \"\"\nfor x in range(0, 45):\nOutputText = OutputText + DataArray[x] + \" \"\nreturn OutputText\nVB.NET\nFunction FormatArray(DataArray)\nDim OutputText As String = \"\"\nFor X = 0 To 44\nOutputText = OutputText & DataArray(X) & \" \"\nNext\nReturn OutputText\nEnd Function\nJava\npublic static String FormatArray(String[] DataArray){\nString OutputText = \"\";\nfor(Integer X = 0; X < 45; X++){\nOutputText = OutputText + DataArray[X] + \" \";\n}\nreturn OutputText;\n}\n© Cambridge University Press & Assessment 2024 Page 6 of 37\n\n1(b)(ii) 1 mark each: 3\n• Calling ReadData() and storing returned array …\n• … calling FormatArray() with returned array\n• Outputting return value from FormatArray()\nPython\nColours = ReadData() #string array\nprint(FormatArray(Colours))\nVB.NET\nDim Colours(45) As String\nColours = ReadData()\nConsole.WriteLine(FormatArray(Colours))\nJava\nString[] Colours = new String[45];\nColours = ReadData();\nSystem.out.println(FormatArray(Colours));\n\n1(b)(iii) 1 mark for output showing all colours in one string 1\ne.g.\n© Cambridge University Press & Assessment 2024 Page 7 of 37\n\n1(c) 1 mark each 4\n• Function header (and close where appropriate) taking (min) two parameters and returns a value in all cases\n• Looping through each character in each string parameter …\n• … return 1 when first parameter  second\n• … return 2 when first parameter  second\ne.g.\nPython\ndef CompareStrings(First, Second):\nCount = 0\nwhile True:\nif First[Count] < Second[Count]:\nreturn 1\nelif First[Count] > Second[Count]:\nreturn 2\nelse:\nCount = Count + 1\nVB.NET\nFunction CompareStrings(FirstS, SecondS)\nDim Count As Integer = 1\nWhile (True)\nIf Mid(FirstS, Count, 1) < Mid(SecondS, Count, 1) Then\nReturn 1\nElseIf Mid(FirstS, Count, 1) > Mid(SecondS, Count, 1) Then\nReturn 2\nElse\nCount = Count + 1\nEnd If\nEnd While\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 8 of 37\n\n1(c) Java\npublic static Integer CompareStrings(String First, String Second){\nInteger Count = 0;\nwhile(true){\nif(First.substring(Count, Count + 1).compareTo(Second.substring(Count, Count +\n1)) < 0){\nreturn 1;\n}else if(First.substring(Count, Count + 1).compareTo(Second.substring(Count,\nCount + 1))>0){\nreturn 2;\n}else{\nCount++;\n}\n}\n}\n\n1(d)(i) 1 mark each 3\n• Bubble sort function header taking array parameter and returns sorted array in all cases\n• Comparing strings using CompareStrings() and correctly swapping values when needed\n• Correct bubble sort that sorts the data correctly\nPython\ndef Bubble(DataArray):\nArrayLength = len(DataArray)\nfor x in range(ArrayLength - 1):\nfor y in range(0, ArrayLength - x - 1):\nResult = CompareStrings(DataArray[y], DataArray[y + 1])\nif Result == 2:\nDataArray[y], DataArray[y+1] = DataArray[y+1], DataArray[y]\nreturn DataArray\n© Cambridge University Press & Assessment 2024 Page 9 of 37\n\n1(d)(i) VB.NET\nFunction Bubble(DataArray)\nDim ArrayLength As Integer = 45\nDim Result As Integer\nDim Temp As String\nFor X = 0 To ArrayLength - 1\nFor Y = 0 To ArrayLength - X - 2\nResult = CompareStrings(DataArray(Y), DataArray(Y + 1))\nIf Result = 2 Then\nTemp = DataArray(Y)\nDataArray(Y) = DataArray(Y + 1)\nDataArray(Y + 1) = Temp\nEnd If\nNext\nNext\nReturn DataArray\nEnd Function\nJava\npublic static String[] Bubble(String[] DataArray){\nInteger ArrayLength = 45;\nInteger Result;\nString Temp;\nfor(Integer X = 0; X < ArrayLength ; X++){\nfor(Integer Y = 0; Y < ArrayLength - X - 1; Y++){\nResult = CompareStrings(DataArray[Y], DataArray[Y+1]);\n© Cambridge University Press & Assessment 2024 Page 10 of 37\n\n1(d)(i) if (Result == 2){\nTemp = DataArray[Y];\nDataArray[Y] = DataArray[Y+1];\nDataArray[Y+1] = Temp;\n}\n}\n}\nreturn DataArray;\n}\n\n1(d)(ii) 1 mark each 2\n• Calling Bubble() with array as parameter and using/storing return value\n• Calling FormatArray() with return value from Bubble() and outputting return value\nPython\nBubbleSorted = Bubble(Colours)\nprint(FormatArray(BubbleSorted))\nVB.NET\nDim BubbleSorted(45) As String\nBubbleSorted = Bubble(Colours)\nConsole.WriteLine(FormatArray(BubbleSorted))\nJava\nString[] BubbleSorted = new String[45];\nBubbleSorted = Bubble(Colours);\nSystem.out.println(FormatArray(BubbleSorted));\n\n1(d)(iii) 1 mark for sorted data 1\ne.g.\n© Cambridge University Press & Assessment 2024 Page 11 of 37",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_41-p04.png",
        "../answer-assets/9618_w24_ms_41-p05.png",
        "../answer-assets/9618_w24_ms_41-p06.png",
        "../answer-assets/9618_w24_ms_41-p07.png",
        "../answer-assets/9618_w24_ms_41-p08.png",
        "../answer-assets/9618_w24_ms_41-p09.png",
        "../answer-assets/9618_w24_ms_41-p10.png",
        "../answer-assets/9618_w24_ms_41-p11.png"
      ]
    },
    {
      "id": "9618-2024-on-41-q02",
      "question_id": "9618-2024-on-41-q02",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 34,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) 1 mark each 4\n• Class Horse declaration (and end where appropriate)\n• All 3 attributes declared as private with appropriate data types (declaration or comment)\n• Constructor header (and end) taking 3 parameters (constructor must be within class) …\n• … constructor assigns parameters to attributes\ne.g.\nPython\nclass Horse:\ndef __init__(self, PName, PMaxFenceHeight, PPercentageSuccess):\nself.__Name = PName #String\nself.__MaxFenceHeight = PMaxFenceHeight #Integer\nself.__PercentageSuccess = PPercentageSuccess #Integer\nVB.NET\nClass Horse\nPrivate Name As String\nPrivate MaxFenceHeight As Integer\nPrivate PercentageSuccess As Integer\nSub New(PName, PMaxFenceHeight, PPercentageSuccess)\nName = PName\nMaxFenceHeight = PMaxFenceHeight\nPercentageSuccess = PPercentageSuccess\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2024 Page 12 of 37\n\n2(a)(i) Java\nclass Horse{\nprivate static String Name;\nprivate static Integer MaxFenceHeight;\nprivate static Integer PercentageSuccess;\npublic Horse(String PName, Integer PMaxFenceHeight, Integer PPercentageSuccess){\nName = PName;\nMaxFenceHeight = PMaxFenceHeight;\nPercentageSuccess = PPercentageSuccess;\n}\n}\n\n2(a)(ii) 1 mark each 3\n• 1 get method header with no parameter …\n• … returning correct attribute (without change)\n• 2nd get method correct\ne.g.\nPython\ndef GetName(self):\nreturn self.__Name\ndef GetMaxFenceHeight(self):\nreturn self.__MaxFenceHeight\nVB.NET\nFunction GetName()\nReturn Name\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 13 of 37\n\n2(a)(ii) Function GetMaxFenceHeight()\nReturn MaxFenceHeight\nEnd Function\nJava\npublic String GetName(){\nreturn Name;\n}\npublic Integer GetMaxFenceHeight(){\nreturn MaxFenceHeight;\n}\n\n2(b)(i) 1 mark each 5\n• Instantiating one object of type Horse with correct data …\n• … and storing in first element of a 1D array Horses\n• Instantiating second object of type Horse with correct data and storing in second index of the array\n• Outputting name of both horse objects from array …\n• … using GetName()\ne.g.\nPython\nHorses = []\nHorses.append(Horse(\"Beauty\", 150, 72))\nHorses.append(Horse(\"Jet\", 160, 65))\nprint(Horses[0].GetName())\nprint(Horses[1].GetName())\nVB.NET\nDim Horses(2) As Horse\nHorses(0) = New Horse(\"Beauty\", 150, 72)\nHorses(1) = New Horse(\"Jet\", 160, 65)\nConsole.WriteLine(Horses(0).GetName())\nConsole.WriteLine(Horses(1).GetName())\n© Cambridge University Press & Assessment 2024 Page 14 of 37\n\n2(b)(i) Java\nHorse[] Horses = new Horse[2];\nHorses[0] = new Horse(\"Beauty\", 150, 72);\nHorses[1] = new Horse(\"Jet\", 160, 65);\nSystem.out.println(Horses[0].GetName());\nSystem.out.println(Horses[1].GetName());\n\n2(b)(ii) 1 mark for both names output: 1\n\n2(c)(i) 1 mark each 4\n• Class Fence header (and end where appropriate) with no inheritance\n• Height and Risk private with integer data type\n• Constructor taking 2 parameters and storing in attributes (constructor must be within class)\n• 2 get methods (no parameter) returning correct attributes (within class)\ne.g.\nPython\nclass Fence:\ndef __init__(self, PHeight, PRisk):\nself.__Height = PHeight #integer\nself.__Risk = PRisk #integer\ndef GetHeight(self):\nreturn self.__Height\ndef GetRisk(self):\nreturn self.__Risk\n© Cambridge University Press & Assessment 2024 Page 15 of 37\n\n2(c)(i) VB.NET\nClass Fence\nDim Height As Integer\nDim Risk As Integer\nSub New(PHeight, PRisk)\nHeight = PHeight\nRisk = PRisk\nEnd Sub\nFunction GetHeight()\nReturn Height\nEnd Function\nFunction GetRisk()\nReturn Risk\nEnd Function\nEnd Class\nJava\nclass Fence{\nprivate Integer Height;\nprivate Integer Risk;\npublic Fence (Integer PHeight, Integer PRisk){\nHeight = PHeight;\nRisk = PRisk;\n}\n© Cambridge University Press & Assessment 2024 Page 16 of 37\n\n2(c)(i) public Integer GetHeight(){\nreturn Height;\n}\npublic Integer GetRisk(){\nreturn Risk;\n}\n}\n\n2(c)(ii) 1 mark each to max 5 5\n• Declaration/use of array Course of type Fence (with at least 4 elements)\n• Taking Height and Risk as input four times and store/use\n• Instantiating a Fence object for each set of valid input values and storing in array\n• Taking each height as input until it is between 70 and 180 (inclusive)\n• Taking each risk as input until it is between 1 and 5 (inclusive)\ne.g.\nPython\nCourse = []\nfor x in range(0, 4):\nValid = False\nwhile Valid == False:\nHeight = int(input(\"Enter the height in cm\"))\nif(Height >= 70 and Height <= 180):\nValid = True\nValid = False\nwhile Valid == False:\nRisk = int(input(\"Enter the risk between 1 (easy) and 5 (hard)\"))\nif(Risk >= 1 and Risk <= 5):\nValid = True\nCourse.append(Fence(Height, Risk))\n© Cambridge University Press & Assessment 2024 Page 17 of 37\n\n2(c)(ii) VB.NET\nDim Course(5) As Fence\nDim Height As Integer\nDim Risk As Integer\nFor x = 0 To 3\nDo\nConsole.WriteLine(\"Enter the height in cm\")\nHeight = Console.ReadLine()\nLoop Until Height >= 70 And Height <= 180\nDo\nConsole.WriteLine(\"Enter the risk between 1 (easy) and 5 (hard)\")\nRisk = Console.ReadLine()\nLoop Until Risk >= 1 And Risk <= 5\nCourse(x) = New Fence(Height, Risk)\nNext\nJava\nFence [] Course = new Fence [4];\nfor(Integer x = 0; x < 4; x++){\ndo {\nSystem.out.println(\"Enter the height in cm\");\nHeight = Integer.parseInt(scanner.nextLine());\n} while(Height <70 || Height > 180);\ndo{\nSystem.out.println(\"Enter the risk between 1 (easy) and 5 (hard)\");\nRisk = Integer.parseInt(scanner.nextLine());\n}while(Risk <1 || Risk > 5);\nCourse[x] = new Fence(Height, Risk);\n}\n© Cambridge University Press & Assessment 2024 Page 18 of 37\n\n2(d) 1 mark each 5\n• Method header taking 2 parameters (and end where appropriate, returning real)\n• Checking if fence height parameter is more than max attribute for that horse, if true multiplying percentage success by\n0.2\n• (Otherwise) selection checking risk value parameter between 1 and 5, multiplying modifier by percentage success\n• Returning correct value as a real number in all instances\n• Correct use of attributes and parameters throughout\ne.g.\nPython\ndef Success(self, Height, Risk):\nif Height > self.__MaxFenceHeight:\nreturn self.__PercentageSuccess * 0.2\nelse:\nif Risk == 1:\nreturn self.__PercentageSuccess\nelif Risk == 2:\nreturn self.__PercentageSuccess * 0.9\nelif Risk == 3:\nreturn self.__PercentageSuccess * 0.8\nelif Risk == 4:\nreturn self.__PercentageSuccess * 0.7\nelse:\nreturn self.__PercentageSuccess * 0.6\nVB.NET\nFunction Success(Height, Risk)\nIf Height > MaxFenceHeight Then\nReturn PercentageSuccess * 0.2\nElse\n© Cambridge University Press & Assessment 2024 Page 19 of 37\n\n2(d) If Risk = 1 Then\nReturn PercentageSuccess\nElseIf Risk = 2 Then\nReturn PercentageSuccess * 0.9\nElseIf Risk = 3 Then\nReturn PercentageSuccess * 0.8\nElseIf Risk = 4 Then\nReturn PercentageSuccess * 0.7\nElse\nReturn PercentageSuccess * 0.6\nEnd If\nEnd If\nEnd Function\nJava\npublic static Double Success(Integer Height, Integer Risk){\nif(Height > MaxFenceHeight){\nreturn Double.valueOf(PercentageSuccess) * 0.2;\n}else{\nif(Risk == 1){\nreturn Double.valueOf(PercentageSuccess);\n}else if (Risk == 2){\nreturn Double.valueOf(PercentageSuccess) * 0.9;\n}else if (Risk == 3){\nreturn Double.valueOf(PercentageSuccess) * 0.8;\n}else if (Risk == 4){\nreturn Double.valueOf(PercentageSuccess) * 0.7;\n}else{\nreturn Double.valueOf(PercentageSuccess) * 0.6;\n}\n}\n}\n© Cambridge University Press & Assessment 2024 Page 20 of 37\n\n2(e)(i) 1 mark each 3\n• Calling Success() for each horse with the height and risk of all 4 fences …\n• … using get methods for height and risk of each fence\n• … outputting the horse name, fence number and calculated success at fence in appropriate message\ne.g.\nPython\nfor y in range(0, 2):\nfor x in range(0, 4):\nChance = Horses[y].Success(Course[x].GetHeight(), Course[x].GetRisk())\nprint(Horses[y].GetName(), \"Fence\", x + 1, \"chance of success is\", Chance, \"%\")\nVB.NET\nDim Chance As Single\nFor y = 0 To 1\nFor x = 0 To 3\nChance = Horses(y).Success(Course(x).GetHeight(), Course(x).GetRisk())\nConsole.WriteLine(Horses(y).GetName() & \" Fence \" & x + 1 & \" chance of\nsuccess is \" & Chance & \"%\")\nNext\nNext\nJava\nDouble Chance = 0.0;\nfor(Integer y = 0; y < 2; y ++){\nfor(Integer x = 0; x < 4; x++){\nChance = Horses[y].Success(Course[x].GetHeight(), Course[x].GetRisk());\nSystem.out.println(Horses[y].GetName() + \" Fence \" + (x + 1) + \" chance of\nsuccess is \" + Chance + \"%\");\n}\n}\n© Cambridge University Press & Assessment 2024 Page 21 of 37\n\n2(e)(ii) 1 mark each 2\n• Calculating average of all 4 fences for each horse and outputting in suitable message\n• Identifying the highest percentage of success and outputting the horse's name in an appropriate message\ne.g.\nPython\nAverageSuccess = []\nfor y in range(0, 2):\nTotal = 0\nfor x in range(0, 4):\nChance = Horses[y].Success(Course[x].GetHeight(), Course[x].GetRisk())\nprint(Horses[y].GetName(), \"Fence\", x + 1, \"chance of success is\", Chance, \"%\")\nTotal = Total + Chance\nAverage = Total / 4\nAverageSuccess.append(Average)\nprint(Horses[y].GetName(), \"average success rate is\", Average, \"%\")\nHighest = AverageSuccess[0]\nWinner = -1\nfor x in range(1,2):\nif Highest < AverageSuccess[x]:\nWinner = x\nHighest = AverageSuccess[x]\nprint(Horses[Winner].GetName(), \" has the highest average chance of success \")\n© Cambridge University Press & Assessment 2024 Page 22 of 37\n\n2(e)(ii) VB.NET\nDim Total As Integer\nDim Chance As Single\nDim Average As Single\nFor y = 0 To 1\nTotal = 0\nFor x = 0 To 3\nChance = Horses(y).Success(Course(x).GetHeight(), Course(x).GetRisk())\nConsole.WriteLine(Horses(y).GetName() & \" Fence \" & x + 1 & \" chance of success is\n\" & Chance & \"%\")\nTotal = Total + Chance\nAverage = Total / 4\nAverageSuccess(y) = Average\nConsole.WriteLine(Horses(y).GetName() & \" average success rate is \" & Average &\n\"%\")\nNext\nNext\nDim Highest As Single\nDim Winner As Integer\nHighest = AverageSuccess(0)\nWinner = -1\nFor x = 1 To 1\nIf Highest < AverageSuccess(x) Then\nWinner = x\nHighest = AverageSuccess(x)\nEnd If\nNext x\nConsole.WriteLine(Horses(Winner).GetName() & \" has the highest average chance of success \")\n© Cambridge University Press & Assessment 2024 Page 23 of 37\n\n2(e)(ii) Java\nDouble Total = 0.0;\nDouble Chance = 0.0;\nDouble Average = 0.0;\nfor(Integer y = 0; y < 2; y ++){\nTotal = 0.0;\nfor(Integer x = 0; x < 4; x++){\nChance = Horses[y].Success(Course[x].GetHeight(), Course[y].GetRisk());\nSystem.out.println(Horses[y].GetName() + \" Fence \" + (x + 1) + \" chance of\nsuccess is \" + Chance + \"%\");\nTotal = Total + Chance;\n}\nAverage = Total / 4;\nAverageSuccess[y] = Average;\nSystem.out.println(Horses[y].GetName() + \" average success rate is \" + Average +\n\"%\");\n}\nDouble Highest = AverageSuccess[0];\nInteger Winner = 0;\nfor(Integer x = 1; x < 2; x++){\nif(Highest < AverageSuccess[x]){\nWinner = x;\nHighest = AverageSuccess[x];\n}\n}\nSystem.out.println(Horses[Winner].GetName() + \" has the highest average chance of\nsuccess\");\n© Cambridge University Press & Assessment 2024 Page 24 of 37\n\n2(e)(iii) 1 mark each 2\n• Outputting showing correct input values for all fences, and correct chance for each horse on each jump\n• Outputs of average chance of each horse and horse name with highest average\ne.g.\n© Cambridge University Press & Assessment 2024 Page 25 of 37",
      "source_pages": [
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23,
        24,
        25
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_41-p12.png",
        "../answer-assets/9618_w24_ms_41-p13.png",
        "../answer-assets/9618_w24_ms_41-p14.png",
        "../answer-assets/9618_w24_ms_41-p15.png",
        "../answer-assets/9618_w24_ms_41-p16.png",
        "../answer-assets/9618_w24_ms_41-p17.png",
        "../answer-assets/9618_w24_ms_41-p18.png",
        "../answer-assets/9618_w24_ms_41-p19.png",
        "../answer-assets/9618_w24_ms_41-p20.png",
        "../answer-assets/9618_w24_ms_41-p21.png",
        "../answer-assets/9618_w24_ms_41-p22.png",
        "../answer-assets/9618_w24_ms_41-p23.png",
        "../answer-assets/9618_w24_ms_41-p24.png",
        "../answer-assets/9618_w24_ms_41-p25.png"
      ]
    },
    {
      "id": "9618-2024-on-41-q03",
      "question_id": "9618-2024-on-41-q03",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 19,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark each 2\n• LinkedList declared as 2D array with (min) 20  2 elements (Integer) with all data initialised to -1, all nodes linked\ncorrectly\n• (Global) FirstNode (Int) initialised as -1 and (global) FirstEmpty (Int) initialised as 0\nVB.NET\nDim LinkedList(20, 2) As Integer\nDim FirstNode As Integer\nDim FirstEmpty As Integer\nSub Main(args As String())\nFirstNode = -1\nFirstEmpty = 0\nFor x = 0 To 18\nLinkedList(x, 0) = -1\nLinkedList(x, 1) = x + 1\nNext\nLinkedList(19, 0) = -1\nLinkedList(19, 1) = -1\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 26 of 37\n\n3(a) Python\nLinkedList = [] #global\nFirstNode = -1\nFirstEmpty = 0\nfor x in range(0, 19):\nLinkedList.append([-1, x + 1])\nLinkedList[19][0] = -1\nLinkedList[19][1] = -1\nJava\nprivate static Integer[][] LinkedList = new Integer[20][2];\nprivate static Integer FirstNode;\nprivate static Integer FirstEmpty;\npublic static void main(String args[]){\nFirstNode = -1;\nFirstEmpty = 0;\nfor(Integer X = 0; X < 19; X++){\nLinkedList[X][0] = -1;\nLinkedList[X][1] = X + 1;\n}\nLinkedList[19][0] = -1;\nLinkedList[19][1] = -1;\n}\n© Cambridge University Press & Assessment 2024 Page 27 of 37\n\n3(b) 1 mark each to max 6 6\n• Procedure header (and end) taking (min) 5 data items as input from the user\n• Checking if linked list is full (FirstEmpty = -1) …\n• …ending procedure/loop/not doing anything further\n• (otherwise) LinkedList[FirstEmpty, 0] = data input\n• LinkedList[FirstEmpty, 1] = FirstNode\n• FirstNode = FirstEmpty\n• FirstEmpty = LinkedList[FirstEmpty, 1] before any update to FirstEmpty ‘s pointer\ne.g.\nPython\ndef InsertData():\nglobal LinkedList\nglobal FirstNode\nglobal FirstEmpty\nfor _ in range(5):\nif FirstEmpty != -1:\nnextEmpty = LinkedList[FirstEmpty][1]\nLinkedList[FirstEmpty][0] = int(input(\"Value: \"))\nLinkedList[FirstEmpty][1] = FirstNode\nFirstNode = FirstEmpty\nFirstEmpty = nextEmpty\n© Cambridge University Press & Assessment 2024 Page 28 of 37\n\n3(b) VB.NET\nSub InsertData()\nDim NewItem As Integer\nDim NextEmpty As Integer\nFor x = 0 To 4\nConsole.WriteLine(\"Enter the next number\")\nNewItem = Console.ReadLine()\nIf FirstEmpty = -1 Then\nx = 5\nElse\nNextEmpty = LinkedList(FirstEmpty, 1)\nLinkedList(FirstEmpty, 0) = NewItem\nLinkedList(FirstEmpty, 1) = FirstNode\nFirstNode = FirstEmpty\nFirstEmpty = NextEmpty\nEnd If\nNext x\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 29 of 37\n\n3(b) Java\npublic static void InsertData(){\nInteger NewItem;\nInteger CurrentPointer = 0;\nInteger PreviousPointer = 0;\nScanner scanner = new Scanner(System.in);\nInteger NextEmpty;\nfor(Integer X = 0; X < 5; X++){\nSystem.out.println(\"Enter the next number\");\nNewItem = Integer.parseInt(scanner.nextLine());\nif(FirstEmpty == -1){\nX = 5;\n}else{\nNextEmpty = LinkedList[FirstEmpty][1];\nLinkedList[FirstEmpty][0] = NewItem;\nLinkedList[FirstEmpty][1] = FirstNode;\nFirstNode = FirstEmpty;\nFirstEmpty = NextEmpty;\n}\n}\n}\n© Cambridge University Press & Assessment 2024 Page 30 of 37\n\n3(c)(i) 1 mark each 2\n• Procedure header (and end) starting with node at index FirstNode and outputting data\nLinkedList[FirstNode,0]\n• Following pointers until end reached and outputting data for each node\nPython\ndef OutputLinkedList():\nglobal LinkedList\nglobal FirstNode\nglobal FirstEmpty\nCurrentPointer = FirstNode\nFlag = True\nwhile Flag:\nprint(LinkedList[CurrentPointer][0])\nCurrentPointer = LinkedList[CurrentPointer][1]\nif CurrentPointer == -1:\nFlag = False\nVB.NET\nSub OutputLinkedList()\nDim CurrentPointer As Integer = FirstNode\nDim Flag As Boolean = True\nWhile Flag\nConsole.WriteLine(LinkedList(CurrentPointer, 0))\nCurrentPointer = LinkedList(CurrentPointer, 1)\nIf CurrentPointer = -1 Then\nFlag = False\nEnd If\nEnd While\n© Cambridge University Press & Assessment 2024 Page 31 of 37\n\n3(c)(i) End Sub\nJava\npublic static void OutputLinkedList(){\nInteger CurrentPointer = FirstNode;\nBoolean Flag = true;\nwhile(Flag){\nSystem.out.println(LinkedList[CurrentPointer][0]);\nCurrentPointer = LinkedList[CurrentPointer][1];\nif(CurrentPointer == -1){Flag = false;}\n}\n}\n\n3(c)(ii) 1 mark for calling InsertData() then OutputLinkedList() 1\nPython\nInsertData()\nOutputLinkedList()\nVB.NET\nInsertData()\nOutputLinkedList()\nJava\nInsertData();\nOutputLinkedList();\n\n3(c)(iii) 1 mark for inputs of 5 1 2 3 8 and output of 8 3 2 1 5 1\n© Cambridge University Press & Assessment 2024 Page 32 of 37\n\n3(d)(i) 1 mark each to max 5 5\n• Procedure header (and end) with parameter\n• Checking data in FirstNode against parameter …\n• … (if found) updating FirstNode to LinkedList[FirstNode, 1]\n• (Otherwise) following pointers in loop/recursive call …\n• …comparing to data to remove each time\n• … storing previous pointer through each loop…\n• … when found, updating previous pointer to found node’s pointer\n• Adding deleted node to end of/start of empty list (and updating FirstEmpty if needed)\nPython\ndef RemoveData(ItemToRemove):\nglobal LinkedList\nglobal FirstNode\nglobal FirstEmpty\nif LinkedList[FirstNode][0] == ItemToRemove:\nNewFirst = LinkedList[FirstNode][1]\nLinkedList[FirstNode][1] = FirstEmpty\nFirstEmpty = FirstNode\nFirstNode = NewFirst\nelse:\nif FirstNode != -1:\nCurrentPointer = FirstNode\nPreviousNode = -1\nwhile(ItemToRemove != LinkedList[CurrentPointer][0] and CurrentPointer != -1):\nPreviousNode = CurrentPointer\nCurrentPointer = LinkedList[CurrentPointer][1]\nif ItemToRemove == LinkedList[CurrentPointer][0]:\nLinkedList[PreviousNode][1] = LinkedList[CurrentPointer][1]\nLinkedList[CurrentPointer][0] = -1\nLinkedList[CurrentPointer][1] = FirstEmpty\nFirstEmpty = CurrentPointer\n© Cambridge University Press & Assessment 2024 Page 33 of 37\n\n3(d)(i) VB.NET\nSub RemoveData(ItemToRemove)\nIf LinkedList(FirstNode, 0) = ItemToRemove Then\nDim NewFirst As Integer = LinkedList(FirstNode, 1)\nLinkedList(FirstNode, 1) = FirstEmpty\nFirstEmpty = FirstNode\nFirstNode = NewFirst\nElse\nIf FirstNode <> -1 Then\nDim CurrentPointer As Integer = FirstNode\nDim PreviousNode As Integer = -1\nDim Flag As Boolean = True\nDim Found As Boolean = False\nWhile Flag And Not (Found)\nIf (CurrentPointer <> -1) Then\nIf (ItemToRemove <> LinkedList(CurrentPointer, 0)) Then\nPreviousNode = CurrentPointer\nCurrentPointer = LinkedList(CurrentPointer, 1)\nElse\nFound = True\nEnd If\nElse\nFlag = False\nEnd If\nEnd While\nIf Found Then\nLinkedList(PreviousNode, 1) = LinkedList(CurrentPointer, 1)\nLinkedList(CurrentPointer, 0) = -1\nLinkedList(CurrentPointer, 1) = FirstEmpty\nFirstEmpty = CurrentPointer\nEnd If\nEnd If\nEnd If\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 34 of 37\n\n3(d)(i) Java\npublic static void RemoveData(Integer ItemToRemove){\nInteger CurrentPointer = 0;\nInteger PreviousNode = 0;\nInteger NewFirst = 0;\nif(LinkedList[FirstNode][0] == ItemToRemove){\nNewFirst = LinkedList[FirstNode][1];\nLinkedList[FirstNode][1] = FirstEmpty;\nFirstEmpty = FirstNode;\nFirstNode = NewFirst;\n}else{\nif (FirstNode != -1){\nCurrentPointer = FirstNode;\nPreviousNode = -1;\nwhile(ItemToRemove != LinkedList[CurrentPointer][0] && CurrentPointer\n!= -1){\nPreviousNode = CurrentPointer;\nCurrentPointer = LinkedList[CurrentPointer][1];\n}\nif(ItemToRemove == LinkedList[CurrentPointer][0]){\nLinkedList[PreviousNode][1] = LinkedList[CurrentPointer][1];\nLinkedList[CurrentPointer][0] = -1;\nLinkedList[CurrentPointer][1] = FirstEmpty;\nFirstEmpty = CurrentPointer;\n}\n}\n}\n}\n© Cambridge University Press & Assessment 2024 Page 35 of 37\n\n3(d)(ii) 1 mark for calling RemoveData(5), outputting \"After\", calling OutputLinkedList() 1\nPython\nLinkedList = []\nFirstNode = -1\nFirstEmpty = 0\nfor x in range(0, 19):\nLinkedList.append([-1, x + 1])\nInsertData()\nOutputLinkedList()\nRemoveData(5)\nprint(\"After\")\nOutputLinkedList()\nVB.NET\nSub Main(args As String())\nFirstNode = -1\nFirstEmpty = 0\nFor x = 0 To 19\nLinkedList(x, 0) = -1\nLinkedList(x, 1) = x + 1\nNext\nInsertData()\nOutputLinkedList()\nRemoveData(5)\nConsole.WriteLine(\"After\")\nOutputLinkedList()\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 36 of 37\n\n3(d)(ii) Java\npublic static void main(String args[]){\nFirstNode = -1;\nFirstEmpty = 0;\nfor(Integer X = 0; X < 20; X++){\nLinkedList[X][0] = -1;\nLinkedList[X][1] = X + 1;\n}\nInsertData();\nOutputLinkedList();\nRemoveData(5);\nSystem.out.println(\"After\");\nOutputLinkedList();\n}\n\n3(d)(iii) 1 mark for input and output. 1\nTest data 1:\nInput 5 6 8 9 5\n‘After’\nOutput: 9 8 6 5\nTest data 2:\nInput 10 7 8 5 6\n“After”\nOutput: 6 8 7 10\n© Cambridge University Press & Assessment 2024 Page 37 of 37",
      "source_pages": [
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_41-p26.png",
        "../answer-assets/9618_w24_ms_41-p27.png",
        "../answer-assets/9618_w24_ms_41-p28.png",
        "../answer-assets/9618_w24_ms_41-p29.png",
        "../answer-assets/9618_w24_ms_41-p30.png",
        "../answer-assets/9618_w24_ms_41-p31.png",
        "../answer-assets/9618_w24_ms_41-p32.png",
        "../answer-assets/9618_w24_ms_41-p33.png",
        "../answer-assets/9618_w24_ms_41-p34.png",
        "../answer-assets/9618_w24_ms_41-p35.png",
        "../answer-assets/9618_w24_ms_41-p36.png",
        "../answer-assets/9618_w24_ms_41-p37.png"
      ]
    },
    {
      "id": "9618-2024-on-42-q01",
      "question_id": "9618-2024-on-42-q01",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 29,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) 1 mark each 4\n• Class EventItem header (and end where appropriate)\n• 3 private attributes with suitable data types\n• Constructor header (and end where appropriate) with 3 (min) parameters within class declaration …\n• … assigning parameters to attributes within constructor\ne.g.\nPython\nclass EventItem():\ndef __init__(self, pName, pType, pDifficulty):\nself.__EventName = pName #String\nself.__EventType = pType #String\nself.__Difficulty = pDifficulty #Integer\nVB.NET\nClass EventItem\nPrivate EventName As String\nPrivate EventType As String\nPrivate Difficulty As Integer\nSub New(pName, pType, pDifficulty)\nEventName = pName\nEventType = pType\nDifficulty = pDifficulty\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2024 Page 4 of 39\n\n1(a)(i) Java\nclass EventItem{\nprivate String EventName;\nprivate String EventType;\nprivate Integer Difficulty;\npublic EventItem(String pName, String pType, Integer pDifficulty){\nEventName= pName;\nEventType = pType;\nDifficulty = pDifficulty;\n}\n}\n\n1(a)(ii) 1 mark each 3\n• 1 get method with no parameter …\n• … return correct attribute (without changing)\n• Remaining 2 correct get methods returning the attributes\ne.g.\nPython\ndef GetName(self):\nreturn self.__EventName\ndef GetEventType(self):\nreturn self.__EventType\ndef GetDifficulty(self):\nreturn self.__Difficulty\n© Cambridge University Press & Assessment 2024 Page 5 of 39\n\n1(a)(ii) VB.NET\nFunction GetName()\nReturn EventName\nEnd Function\nFunction GetEventType()\nReturn EventType\nEnd Function\nFunction GetDifficulty()\nReturn Difficulty\nEnd Function\nJava\npublic String GetName(){\nreturn EventName;\n}\npublic String GetEventType(){\nreturn EventType;\n}\npublic Integer GetDifficulty(){\nreturn Difficulty;\n}\n\n1(b)(i) 1 mark each: 1\n• 1D array name Group with (min 5 elements and of type EventItem)\ne.g.\nPython\nGroup = [] #type Event, 5 spaces\nVB.NET\nDim Group(4) As EventItem\nJava\nEventItem[] Group = new EventItem[5];\n© Cambridge University Press & Assessment 2024 Page 6 of 39\n\n1(b)(ii) 1 mark each 3\n• Any 1 instance of EventItem declared with values passed in correct order …\n• … stored in the array Group …\n• … remaining 4 correctly instantiated and stored in Group\ne.g.\nPython\nGroup.append(EventItem(\"Bridge\", \"jump\", 3))\nGroup.append(EventItem(\"Water wade\", \"swim\", 4))\nGroup.append(EventItem(\"100 mile run\", \"run\", 5))\nGroup.append(EventItem(\"Gridlock\", \"drive\", 2))\nGroup.append(EventItem(\"Wall on wall\", \"jump\", 4))\nVB.NET\nGroup(0) = New EventItem(\"Bridge\", \"jump\", 3)\nGroup(1) = New EventItem(\"Water wade\", \"swim\", 4)\nGroup(2) = New EventItem(\"100 mile run\", \"run\", 5)\nGroup(3) = New EventItem(\"Gridlock\", \"drive\", 2)\nGroup(4) = New EventItem(\"Wall on wall\", \"jump\", 4)\nJava\nGroup[0] = new EventItem(\"Bridge\", \"jump\", 3);\nGroup[1] = new EventItem(\"Water wade\", \"swim\", 4);\nGroup[2] = new EventItem(\"100 mile run\", \"run\", 5);\nGroup[3] = new EventItem(\"Gridlock\", \"drive\", 2);\nGroup[4] = new EventItem(\"Wall on wall\", \"jump\", 4);\n\n1(c) 1 mark each 4\n• Class Character declared (and end where appropriate)\n• 5 private attributes with correct data types\n• Constructor header (and end) taking (min) 5 parameters and parameters assigned to attributes\n• Get method (with no parameter) returning name attribute\n© Cambridge University Press & Assessment 2024 Page 7 of 39\n\n1(c) e.g.\nPython\nclass Character():\ndef __init__(self, pName, pJump, pSwim, pRun, pDrive):\nself.__CName = pName #string\nself.__Jump = pJump #integer chance of success\nself.__Swim = pSwim #integer chance of success\nself.__Run = pRun #integer chance of success\nself.__Drive = pDrive #integer chance of success\ndef GetName(self):\nreturn self.__CName #STRING\nVB.NET\nClass Character\nPrivate CName As String\nPrivate Jump As Integer\nPrivate Swim As Integer\nPrivate Run As Integer\nPrivate Drive As Integer\nSub New(pName, pJump, pSwim, pRun, pDrive)\nCName = pName\nJump = pJump\nSwim = pSwim\nRun = pRun\nDrive = pDrive\nEnd Sub\nFunction GetName()\nReturn CName\nEnd Function\nEnd Class\n© Cambridge University Press & Assessment 2024 Page 8 of 39\n\n1(c) Java\nclass Character{\nprivate String CName;\nprivate Integer Jump;\nprivate Integer Swim;\nprivate Integer Run;\nprivate Integer Drive;\npublic Character(String pName, Integer pJump, Integer pSwim, Integer pRun, Integer\npDrive){\nCName= pName;\nJump = pJump;\nSwim = pSwim;\nRun = pRun;\nDrive = pDrive;\n}\npublic String GetName(){\nreturn CName\n}\n}\n\n1(d) 1 mark each to max 4: 4\n• Method header CalculateScore (and end where appropriate) taking (min) 2 parameters\n• Selection on the type of event using the parameter\n• … if skill value is  = difficulty return 100\n• …otherwise subtracting skill value from the difficulty and return correct value 80 (diff 1), 60 (diff 2), 40 (diff 3) and 20\n(diff 4)\n• Using the correct attributes and parameters throughout\n© Cambridge University Press & Assessment 2024 Page 9 of 39\n\n1(d) e.g.\nPython\ndef CalculateScore(self, Type, Difficulty):\nif Type == \"jump\":\nChance = self.__Jump\nelif Type == \"swim\":\nChance = self.__Swim\nelif Type == \"run\":\nChance = self.__Run\nelse:\nChance = self.__Drive\nif Chance >= Difficulty:\nreturn 100\nelse:\nDifference = Difficulty - Chance\nif Difference == 1:\nreturn 80\nelif Difference == 2:\nreturn 60\nelif Difference == 3:\nreturn 40\nelif Difference == 4:\nreturn 20\nelse:\nreturn 0\n© Cambridge University Press & Assessment 2024 Page 10 of 39\n\n1(d) VB.NET\nFunction CalculateScore(Type, Difficulty)\nDim Chance As Integer\nDim Difference As Integer\nIf Type = \"jump\" Then\nChance = Jump\nElseIf Type = \"swim\" Then\nChance = Swim\nElseIf Type = \"run\" Then\nChance = Run\nElse\nChance = Drive\nEnd If\nIf Chance >= Difficulty Then\nReturn 100\nElse\nDifference = Difficulty - Chance\nIf Difference = 1 Then\nReturn 80\nElseIf Difference = 2 Then\nReturn 60\nElseIf Difference = 3 Then\nReturn 40\nElseIf Difference = 4 Then\nReturn 20\nElse\nReturn 0\nEnd If\nEnd If\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 11 of 39\n\n1(d) Java\npublic Integer CalculateScore(String Type, Integer Difficulty){\nInteger Chance = 0;\nInteger Difference = 0;\nif(Type.equals(\"jump\")){\nChance = Jump;\n}else if(Type.equals(\"swim\")){\nChance = Swim;\n}else if(Type.equals(\"run\")){\nChance = Run;\n}else{\nChance = Drive;\n}\nif(Chance >= Difficulty){\nreturn 100;\n}else{\nDifference = Difficulty - Chance;\nif(Difference == 1){\nreturn 80;\n}else if(Difference == 2){\nreturn 60;\n}else if(Difference == 3){\nreturn 40;\n}else if(Difference == 4){\nreturn 20;\n}\n}\n}\n© Cambridge University Press & Assessment 2024 Page 12 of 39\n\n1(e)(i) 1 mark each 2\n• Creating one new instance of Character with correct name and values for 1 character and storing\n• 2nd correct instance of Character and storing\ne.g.\nPython\nP1 = Character(\"Tarz\", 5, 3, 5, 1)\nP2 = Character(\"Geni\", 2, 2, 3, 4)\nVB.NET\nDim P1 As Character = New Character(\"Tarz\", 5, 3, 5, 1)\nDim P2 As Character = New Character(\"Geni\", 2, 2, 3, 4)\nJava\nCharacter P1 = new Character(\"Tarz\", 5, 3, 5, 1);\nCharacter P2 = new Character(\"Geni\", 2, 2, 3, 4);\n\n1(e)(ii) 1 mark each 7\n• Looping through each event in Group (or checking each of the 5 events manually)\n• Using CalculateScore() for each Character object with parameters of type and difficulty\n• …comparing the return values from the two function calls …\n• …incrementing points for winning player and outputting their name and message stating they have won for each\nevent.\n• …outputting message if it's a draw.\n• Comparing the total points for each character after all events checked and outputting name of player with most points\n(and their points) and outputting message if it's a draw\n• Using get methods correctly throughout\n© Cambridge University Press & Assessment 2024 Page 13 of 39\n\n1(e)(ii) e.g.\nPython\nP1Points = 0\nP2Points = 0\nfor x in range(0, 5):\nP1EventScore = P1.CalculateScore(Group[x].GetEventType(), Group[x].GetDifficulty())\nP2EventScore = P2.CalculateScore(Group[x].GetEventType(), Group[x].GetDifficulty())\nif P1EventScore > P2EventScore:\nP1Points = P1Points + 1\nprint(P1.GetName(), \"you win this event\")\nelif P2EventScore > P1EventScore:\nP2Points = P2Points + 1\nprint(P2.GetName(), \"you win this event\")\nelse:\nprint(\"This event is a draw\")\nif P1Points > P2Points:\nprint(P1.GetName(), \"you have won with\", P1Points)\nelif P2Points> P1Points:\nprint(P2.GetName(), \"you have won with\", P2Points)\nelse:\nprint(\"It's a draw\")\n© Cambridge University Press & Assessment 2024 Page 14 of 39\n\n1(e)(ii) VB.NET\nDim P1 As Character = New Character(\"Tarz\", 5, 3, 5, 1)\nDim P2 As Character = New Character(\"Geni\", 2, 2, 3, 4)\nDim P1Points As Integer = 0\nDim P2Points As Integer = 0\nDim P1EventScore As Integer = 0\nDim P2EventScore As Integer = 0\nFor x = 0 To 4\nP1EventScore = P1.CalculateScore(Group(x).GetEventType(), Group(x).GetDifficulty())\nP2EventScore = P2.CalculateScore(Group(x).GetEventType(), Group(x).GetDifficulty())\nIf P1EventScore > P2EventScore Then\nP1Points = P1Points + 1\nConsole.WriteLine(P1.GetName() & \" you win this event\")\nElseIf P2EventScore > P1EventScore Then\nP2Points = P2Points + 1\nConsole.WriteLine(P2.GetName() & \" you win this event\")\nElse\nConsole.WriteLine(\"This event is a draw\")\nEnd If\nNext x\nIf P1Points > P2Points Then\nConsole.WriteLine(P1.GetName() & \" you have won with \" & P1Points)\nElseIf P2Points > P1Points Then\nConsole.WriteLine(P2.GetName() & \" you have won with \" & P2Points)\nElse\nConsole.WriteLine(\"It's a draw\")\nEnd If\n© Cambridge University Press & Assessment 2024 Page 15 of 39\n\n1(e)(ii) Java\nInteger P1Points = 0;\nInteger P2Points = 0;\nInteger P1EventScore = 0;\nInteger P2EventScore = 0;\nfor(Integer x = 0; x < 5; x++){\nP1EventScore = P1.CalculateScore(Group[x].GetEventType(), Group[x].GetDifficulty());\nP2EventScore = P2.CalculateScore(Group[x].GetEventType(), Group[x].GetDifficulty());\nSystem.out.println(\"P1 \" + P1EventScore + \" P2 \" + P2EventScore);\nif(P1EventScore > P2EventScore){\nP1Points++;\nSystem.out.println(P1.GetName() + \" you win this event\");\n}else if(P2EventScore > P1EventScore){\nP2Points++;\nSystem.out.println(P2.GetName() + \" you win this event\");\n}else{\nSystem.out.println(\"This event is a draw\");\n}\n}\nif(P1Points > P2Points){\nSystem.out.println(P1.GetName() + \" you have won with \" + P1Points);\n}else if(P2Points > P1Points){\nSystem.out.println(P2.GetName() + \" you have won with \" + P2Points);\n}else{\nSystem.out.println(\"It's a draw\");\n}\n© Cambridge University Press & Assessment 2024 Page 16 of 39\n\n1(e)(iii) 1 mark for output showing the correct winner for each event, the final winner’s name (and their points) 1\ne.g.\n© Cambridge University Press & Assessment 2024 Page 17 of 39",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_42-p04.png",
        "../answer-assets/9618_w24_ms_42-p05.png",
        "../answer-assets/9618_w24_ms_42-p06.png",
        "../answer-assets/9618_w24_ms_42-p07.png",
        "../answer-assets/9618_w24_ms_42-p08.png",
        "../answer-assets/9618_w24_ms_42-p09.png",
        "../answer-assets/9618_w24_ms_42-p10.png",
        "../answer-assets/9618_w24_ms_42-p11.png",
        "../answer-assets/9618_w24_ms_42-p12.png",
        "../answer-assets/9618_w24_ms_42-p13.png",
        "../answer-assets/9618_w24_ms_42-p14.png",
        "../answer-assets/9618_w24_ms_42-p15.png",
        "../answer-assets/9618_w24_ms_42-p16.png",
        "../answer-assets/9618_w24_ms_42-p17.png"
      ]
    },
    {
      "id": "9618-2024-on-42-q02",
      "question_id": "9618-2024-on-42-q02",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 29,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark each to max 3\n• Record structure or class with constructor Queue (and end where appropriate) …\n• … containing a 1D array of (100) integers QueueArray\n• … containing HeadPointer and TailPointer as integers\ne.g.\nPython\nclass Queue:\ndef __init__(self):\nself.QueueArray = []\nHeadPointer = 0 #integer\nTailPointer = 0 #integer\nfor x in range(0, 100):\nself.QueueArray.append(-1)\nVB.NET\nStructure Queue\nDim QueueArray() As Integer\nDim HeadPointer As Integer\nDim TailPointer As Integer\nEnd Structure\nJava\nclass queue{\nprivate static Integer[] QueueArray = new Integer[100];\nprivate static Integer HeadPointer;\nprivate static Integer TailPointer;\npublic queue(){\n}\n}\n© Cambridge University Press & Assessment 2024 Page 18 of 39\n\n2(b) 1 mark each 3\n• New Queue record/object created/instance of class\n• Queue field/attribute head pointer initialised to –1, tail pointer to 0\n• All 100 array field/attribute elements initialised with –1\ne.g.\nPython\nclass Queue:\ndef __init__(self):\nself.QueueArray = []\nfor x in range(0, 100):\nself.QueueArray.append(-1)\nself.HeadPointer = -1\nself.TailPointer = 0\nTheQueue= Queue()\nVB.NET\nDim TheQueue As New Queue\nTheQueue.HeadPointer = -1\nTheQueue.TailPointer = 0\nReDim TheQueue.QueueArray(100)\nFor x = 0 To 99\nTheQueue.QueueArray(x) = -1\nNext\nJava\nclass queue{\nprivate static Integer[] QueueArray = new Integer[100];\nprivate static Integer HeadPointer;\nprivate static Integer TailPointer;\n© Cambridge University Press & Assessment 2024 Page 19 of 39\n\n2(b) public queue(){\nHeadPointer = -1;\nTailPointer = 0;\nfor(Integer x = 0; x < 100; x++){\nQueueArray[x] = -1;\n}\n}\n}\npublic static void main(String args[]){\nqueue TheQueue = new queue();\n}\n\n2(c) 1 mark for each completed statement to max 3 5\n1 mark for correct values returned in correct places\n1 mark for function header taking (at least) one parameter and the rest of function correct and using the record/class data\nstructure accurately.\nPseudocode\nFUNCTION Enqueue(BYREF AQueue : Queue, BYVAL TheData : INTEGER)\nRETURNS INTEGER\nIF AQueue.HeadPointer = -1 THEN\nAQueue.QueueArray[AQueue.TailPointer]  TheData\nAQueue.HeadPointer  0\nAQueue.TailPointer  AQueue.TailPointer + 1\nRETURN 1\nELSE\nIF AQueue.TailPointer > 99 THEN\nRETURN -1\nELSE\nAQueue.QueueArray[AQueue.TailPointer]  TheData\nAQueue.TailPointer  AQueue.TailPointer + 1\nRETURN 1\nENDIF\nENDIF\nENDFUNCTION\n© Cambridge University Press & Assessment 2024 Page 20 of 39\n\n2(c) e.g.\nPython\ndef Enqueue(AQueue, TheData):\nif AQueue.HeadPointer == -1:\nAQueue.HeadPointer = 0\nAQueue.QueueArray[AQueue.HeadPointer] = TheData\nAQueue.TailPointer +=1\nreturn AQueue, 1\nelif AQueue.TailPointer > 99:\nreturn AQueue, -1\nelse:\nAQueue.QueueArray[AQueue.TailPointer] = TheData\nAQueue.TailPointer = AQueue.TailPointer + 1\nreturn AQueue, 1\nVB.NET\nFunction Enqueue(ByRef AQueue As Queue, ByVal TheData As Integer)\nIf AQueue.HeadPointer = -1 Then\nAQueue.QueueArray(AQueue.TailPointer) = TheData\nAQueue.HeadPointer = 0\nAQueue.TailPointer += 1\nReturn 1\nElseIf AQueue.TailPointer > 99 Then\nReturn -1\nElse\nAQueue.QueueArray(AQueue.TailPointer) = TheData\nAQueue.TailPointer += 1\nReturn 1\nEnd If\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 21 of 39\n\n2(c) Java\npublic static Integer Enqueue(Integer TheData){\nif(GetHeadPointer() == -1){\nSetData(TheData);\nSetHeadPointer(0);\nSetTailPointer(GetTailPointer() + 1);\nreturn 1;\n}else if(GetTailPointer() > 99){\nreturn -1;\n}else{\nSetData(TheData);\nSetTailPointer(GetTailPointer() + 1);\nreturn 1;\n}\n}\n\n2(d) 1 mark each to max 3 3\n• Function header (and end) iterating through each element in the queue\n• Starting at HeadPointer and incrementing until TailPointer – 1 …\n• … concatenating and returning all integer values with a space between\ne.g.\nPython\ndef ReturnAllData(TheQueue):\nTemp = \"\"\nfor X in range(TheQueue.HeadPointer, TheQueue.TailPointer):\nTemp = Temp + str(TheQueue.QueueArray[X]) + \" \"\nreturn Temp\n© Cambridge University Press & Assessment 2024 Page 22 of 39\n\n2(d) VB.NET\nFunction ReturnAllData(AQueue As Queue)\nDim Temp As String = \"\"\nFor X = AQueue.HeadPointer To AQueue.TailPointer - 1\nTemp = Temp & AQueue.QueueArray(X).ToString() & \" \"\nNext X\nReturn Temp\nEnd Function\nJava\npublic static String ReturnAllData(){\nString Temp = \"\";\nInteger Counter = 0;\nfor(int X = HeadPointer; X < TailPointer; X++){\nTemp = Temp + Integer.toString(QueueArray[X]) + \" \";\n}\nreturn Temp;\n}\n\n2(e)(i) 1 mark each 5\n• Taking only 10 inputs in loop/one at a time\n• Calling Enqueue() with each input (min) and storing/using return value …\n• … only calling Enqueue() once when each input is an integer  = 0. Do not award if this validation stops 10 valid\ninputs being enqueued.\n• Outputting message if each item is inserted and outputting a message if queue is full\n• Calling ReturnAllData() and outputting return value at the end\n© Cambridge University Press & Assessment 2024 Page 23 of 39\n\n2(e)(i) e.g.\nPython\nfor x in range(0, 10):\nContinue = True\nwhile(Continue == True):\nDataInput = int(input(\"Enter an integer that is 0 or more\"))\nif DataInput > -1:\nContinue = False\nTheQueue, ReturnValue = Enqueue(TheQueue, DataInput)\nif(ReturnValue == -1):\nprint(\"Queue full\")\nelse:\nprint(\"Item inserted\")\nprint(ReturnAllData(TheQueue))\nVB.NET\nDim ContinueLoop As Boolean\nDim DataInput As Integer\nDim ReturnValue As Integer\nFor x = 0 To 9\nContinueLoop = True\nWhile ContinueLoop = True\nConsole.WriteLine(\"Enter an integer that is 0 or more\")\nDataInput = Console.ReadLine\nIf DataInput > -1 Then\nContinueLoop = False\n© Cambridge University Press & Assessment 2024 Page 24 of 39\n\n2(e)(i) End If\nEnd While\nReturnValue = Enqueue(TheQueue, DataInput)\nIf ReturnValue = 2 Then\nConsole.WriteLine(\"Queue full\")\nElse\nConsole.WriteLine(\"Item inserted\")\nEnd If\nNext\nConsole.WriteLine(ReturnAllData(TheQueue))\nJava\nBoolean Continue = true;\nInteger DataInput = -1;\nScanner scanner = new Scanner(System.in);\nInteger ReturnValue;\nfor(Integer x = 0; x < 10; x++){\nContinue = true;\nwhile(Continue == true){\nSystem.out.println(\"Enter an integer that is 0 or more\");\nDataInput = Integer.parseInt(scanner.nextLine());\nif(DataInput > -1){\nContinue = false;\n}\n}\nReturnValue = Enqueue(DataInput);\nif(ReturnValue == -1){\nSystem.out.println(\"Queue full\");\n}else{\nSystem.out.println(\"Item inserted\");\n}\n}\nSystem.out.println(ReturnAllData());\n© Cambridge University Press & Assessment 2024 Page 25 of 39\n\n2(e)(ii) 1 mark for each 2\n• All values input and 10 messages ‘Inserted’ (i.e. –1 is not inserted)\n• Screenshot show 10 9 8 7 6 5 4 3 2 1 on one line with a space between each number\ne.g.\n\n2(f) 1 mark each 4\n• Function Dequeue() (head and close), returning a value in all cases\n• Checking if empty and returning –1\n• Returning item at HeadPointer without deleting/changing it\n• Incrementing HeadPointer\nExample program code:\nPython\ndef Dequeue(AQueue):\nif AQueue.HeadPointer = 100 or AQueue.HeadPointer == -1 or AQueue.HeadPointer ==\nAQueue.TailPointer:\nreturn AQueue, -1\nelse:\nTemp = AQueue.QueueArray[AQueue.HeadPointer]\nAQueue.HeadPointer = AQueue.HeadPointer + 1\nreturn AQueue, Temp\n© Cambridge University Press & Assessment 2024 Page 26 of 39\n\n2(f) VB.NET\nFunction Dequeue(ByRef AQueue As Queue)\nIf AQueue.HeadPointer = 100 or AQueue.HeadPointer = -1 or AQueue.HeadPointer =\nAQueue.TailPointer Then\nReturn -1\nElse\nDim Temp As Integer = AQueue.QueueArray(AQueue.HeadPointer)\nAQueue.HeadPointer += 1\nReturn Temp\nEnd If\nEnd Function\nJava\npublic static Integer Dequeue(){\nif(GetHeadPointer() = 100 || GetTailpointer() == -1 || GetHeadPointer() ==\nGetTailpointer()){\nreturn -1;\n}else{\nInteger Temp = GetData(GetHeadPointer());\nSetHeadPointer(GetHeadPointer() + 1);\nreturn Temp;\n}\n}\n© Cambridge University Press & Assessment 2024 Page 27 of 39\n\n2(g)(i) 1 mark each 3\n• Calls Dequeue() twice and stores/uses return value\n• Outputs \"Queue empty\" when each return values is –1 and outputs return value otherwise\n• Calls ReturnAllData() at the end\ne.g.\nPython\nTheQueue, ReturnValue = Dequeue(TheQueue)\nif ReturnValue == -1:\nprint(\"Queue empty\")\nelse:\nprint(ReturnValue, \" is returned\")\nTheQueue, ReturnValue = Dequeue(TheQueue)\nif ReturnValue == -1:\nprint(\"Queue empty\")\nelse:\nprint(ReturnValue, \" is returned\")\nprint(ReturnAllData(TheQueue))\nVB.NET\nReturnValue = Dequeue(TheQueue)\nIf ReturnValue = -1 Then\nConsole.WriteLine(\"Queue empty\")\nElse\nConsole.WriteLine(ReturnValue, \" is returned\")\nEnd If\n© Cambridge University Press & Assessment 2024 Page 28 of 39\n\n2(g)(i) ReturnValue = Dequeue(TheQueue)\nIf ReturnValue = -1 Then\nConsole.WriteLine(\"Queue empty\")\nElse\nConsole.WriteLine(ReturnValue, \" is returned\")\nEnd If\nConsole.WriteLine(ReturnAllData(TheQueue))\nJava\nReturnValue = Dequeue();\nif(ReturnValue == -1){\nSystem.out.println(\"Queue empty\");\n}else{\nSystem.out.println(ReturnValue + \" is returned\");\n}\nReturnValue = Dequeue();\nif(ReturnValue == -1){\nSystem.out.println(\"Queue empty\");\n}else{\nSystem.out.println(ReturnValue + \" is returned\");\n}\nReturnAllData(TheQueue);\n© Cambridge University Press & Assessment 2024 Page 29 of 39\n\n2(g)(ii) 1 mark each 1\n• Screenshot shows the input of 10 9 8 7 6 5 4 3 2 1\nOutput for 10 returned\nOutput for 9 is returned\ne.g.\n© Cambridge University Press & Assessment 2024 Page 30 of 39",
      "source_pages": [
        18,
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_42-p18.png",
        "../answer-assets/9618_w24_ms_42-p19.png",
        "../answer-assets/9618_w24_ms_42-p20.png",
        "../answer-assets/9618_w24_ms_42-p21.png",
        "../answer-assets/9618_w24_ms_42-p22.png",
        "../answer-assets/9618_w24_ms_42-p23.png",
        "../answer-assets/9618_w24_ms_42-p24.png",
        "../answer-assets/9618_w24_ms_42-p25.png",
        "../answer-assets/9618_w24_ms_42-p26.png",
        "../answer-assets/9618_w24_ms_42-p27.png",
        "../answer-assets/9618_w24_ms_42-p28.png",
        "../answer-assets/9618_w24_ms_42-p29.png",
        "../answer-assets/9618_w24_ms_42-p30.png"
      ]
    },
    {
      "id": "9618-2024-on-42-q03",
      "question_id": "9618-2024-on-42-q03",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 17,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark each 2\n• HighScores created as 2D array, (of strings) with (min) 7  3 elements (local to main) …\n• … all elements initialised to empty string (\"\")\ne.g.\nPython\nHighScores = [] #String, 7 x 3\nHighScores = [['' for x in range(3)] for y in range(7)]\nVB.NET\nDim HighScores(7, 3) As String\nFor(X = 0 to 7)\nFor(Y = 0 to 3)\nHighScores(X, Y) = \"\"\nNext Y\nNext X\nJava\nString[][] HighScores = new String[7][3];\nfor(Int X = 0; X <7; X++){\nfor(Int Y = 0; Y < 3; Y++){\nHighScores[X][Y] = \"\";\n}\n}\n\n3(b) 1 mark each 5\n• Function header (and end where appropriate) that returns populated array\n• Opening text file to read and closing the file in an appropriate place\n• Looping through 7 players/to EOF/21 times …\n• … reading in each group of 3 data items and storing each in separate element in 2D array for each player\n• Exception handling with all file handling within the try, appropriate catch and an output\n© Cambridge University Press & Assessment 2024 Page 31 of 39\n\n3(b) e.g.\nPython\ndef ReadData():\nTemp = []\nHighScores = []\ntry:\nFile = open(\"HighScoreTable.txt\")\nTemp = File.read().split(\"\\n\")\nFile.close()\nexcept:\nprint(\"No file found\")\nNumberRecords = len(Temp)-1\nCounter = 0\nwhile Counter < NumberRecords:\nHighScores.append([Temp[Counter], Temp[Counter+1], Temp[Counter+2]])\nCounter = Counter + 3\nreturn HighScores\nVB.NET\nFunction ReadData()\nDim TextFile As String = \"HighScoreTable.txt\"\nDim HighScores(7, 3) As String\nTry\nDim FileReader As New System.IO.StreamReader(TextFile)\nDim Counter As Integer = 0\n© Cambridge University Press & Assessment 2024 Page 32 of 39\n\n3(b) While Counter < 8\nHighScores(Counter, 0) = FileReader.ReadLine()\nHighScores(Counter, 1) = FileReader.ReadLine()\nHighScores(Counter, 2) = FileReader.ReadLine()\nCounter = Counter + 1\nEnd While\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"No file found\")\nEnd Try\nReturn HighScores\nEnd Function\nJava\npublic static String[][] ReadData(){\nString TextFile = \"HighScoreTable.txt\";\nString[][] HighScores = new String[7][3];\ntry{\nFileReader f = new FileReader(TextFile);\nBufferedReader Reader = new BufferedReader(f);\nfor(Integer X = 0; X < 7; X++){\ntry{\n© Cambridge University Press & Assessment 2024 Page 33 of 39\n\n3(b) HighScores[X][0] = Reader.readLine();\nHighScores[X][1] = Reader.readLine();\nHighScores[X][2] = Reader.readLine();\n}catch(IOException ex){}\n}\ntry{\nReader.close();\n}catch(IOException ex){}\nreturn HighScores;\n}catch(FileNotFoundException e){\nSystem.out.println(\"File not found\");\n}\nreturn HighScores;\n}\n\n3(c) 1 mark each 2\n• Procedure (header and end) taking (min) 1 parameter (2D array), looping through each of the first dimension in array\n…\n• … outputting all data in correct format\ne.g.\nPython\ndef OutputHighScores(HighScores):\nfor x in range(0, len(HighScores)):\nprint(HighScores[x][0], \"reached level\", HighScores[x][1], \"with a score of\",\nHighScores[x][2])\nVB.NET\nSub OutputHighScores(HighScores(,))\nFor x = 0 To 6\nConsole.WriteLine(HighScores(x, 0) & \" reached level \" & HighScores(x, 1) & \"\nwith a score of \" & HighScores(x, 2))\nNext\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 34 of 39\n\n3(c) Java\npublic static void OutputHighScores(String[][] HighScores){\nfor(Integer x = 0; x < 7; x++){\nSystem.out.println(HighScores[x][0] + \" reached level \" + HighScores[x][1] + \"\nwith a score of \" + HighScores[x][2]);\n}\n}\n\n3(d) 1 mark each 4\n• Function header (and end taking array as parameter) returning sorted array.\n• Comparing the levels and swapping all dimensions when in incorrect order\n• Comparing scores when levels are the same and swapping all dimensions when in incorrect order\n• Correct loops and comparisons to put data in correct order\ne.g.\nPython\ndef SortScores(HighScores):\nCounter = 0\nArrayLength = len(HighScores)\nfor x in range(ArrayLength-1):\nfor y in range(0, ArrayLength-x-1):\nif int(HighScores[y][1]) < int(HighScores[y + 1][1]):\nHighScores[y], HighScores[y + 1] = HighScores[y + 1], HighScores[y]\nelif int(HighScores[y][1]) == int(HighScores[y+1][1]):\nif int(HighScores[y][2]) < int(HighScores[y+1][2]):\nHighScores[y], HighScores[y + 1] = HighScores[y + 1], HighScores[y]\nreturn HighScores\nVB.NET\nFunction SortScores(HighScores)\nDim ArrayLength As Integer = 6\nDim Temp1 As String\n© Cambridge University Press & Assessment 2024 Page 35 of 39\n\n3(d) Dim Temp2 As String\nDim Temp3 As String\nFor x = 0 To ArrayLength - 1\nFor y = 0 To ArrayLength - x - 1\nIf Integer.Parse(HighScores(y, 1)) < Integer.Parse(HighScores(y + 1, 1))\nThen\nTemp1 = HighScores(y, 0)\nTemp2 = HighScores(y, 1)\nTemp3 = HighScores(y, 2)\nHighScores(y, 0) = HighScores(y + 1, 0)\nHighScores(y, 1) = HighScores(y + 1, 1)\nHighScores(y, 2) = HighScores(y + 1, 2)\nHighScores(y + 1, 0) = Temp1\nHighScores(y + 1, 1) = Temp2\nHighScores(y + 1, 2) = Temp3\nElseIf Integer.Parse(HighScores(y, 1)) = Integer.Parse(HighScores(y + 1,\n1)) Then\nIf Int(HighScores(y, 2)) < Int(HighScores(y + 1, 2)) Then\nTemp1 = HighScores(y, 0)\nTemp2 = HighScores(y, 1)\nTemp3 = HighScores(y, 2)\nHighScores(y, 0) = HighScores(y + 1, 0)\nHighScores(y, 1) = HighScores(y + 1, 1)\nHighScores(y, 2) = HighScores(y + 1, 2)\nHighScores(y + 1, 0) = Temp1\nHighScores(y + 1, 1) = Temp2\nHighScores(y + 1, 2) = Temp3\nEnd If\nEnd If\nNext y\nNext x\nReturn HighScores\nEnd Function\nJava\npublic static String[][] SortScores(String[][] HighScores){\n© Cambridge University Press & Assessment 2024 Page 36 of 39\n\n3(d) Integer ArrayLength = 6;\nString Temp1;\nString Temp2;\nString Temp3;\nfor(Integer x = 0; x < ArrayLength; x++){\nfor(Integer y = 0; y < ArrayLength - x; y++){\nif(Integer.parseInt(HighScores[y][1]) <\nInteger.parseInt(HighScores[y+1][1])){\nTemp1 = HighScores[y][0];\nTemp2 = HighScores[y][1];\nTemp3 = HighScores[y][2];\nHighScores[y][0] = HighScores[y+1][0];\nHighScores[y][1] = HighScores[y+1][1];\nHighScores[y][2] = HighScores[y+1][2];\nHighScores[y+1][0] = Temp1;\nHighScores[y+1][1] = Temp2;\nHighScores[y+1][2] = Temp3;\n}else if(Integer.parseInt(HighScores[y][1]) ==\nInteger.parseInt(HighScores[y+1][1])){\nif(Integer.parseInt(HighScores[y][2]) <\nInteger.parseInt(HighScores[y+1][2])){\nTemp1 = HighScores[y][0];\nTemp2 = HighScores[y][1];\nTemp3 = HighScores[y][2];\nHighScores[y][0] = HighScores[y+1][0];\nHighScores[y][1] = HighScores[y+1][1];\nHighScores[y][2] = HighScores[y+1][2];\nHighScores[y+1][0] = Temp1;\nHighScores[y+1][1] = Temp2;\nHighScores[y+1][2] = Temp3;\n}\n}\n© Cambridge University Press & Assessment 2024 Page 37 of 39\n\n3(d) }\n}\nreturn HighScores;\n}\n\n3(e)(i) 1 mark each 2\n• Code statements in order:\nHighScores = ReadData()\nHighScores = SortScores(HighScores) // HighScores = SortScores()\n• Code statements in order:\nOUTPUT \"Before\"\nOutputHighScores(HighScores) unsorted\nOUTPUT \"After\"\nOutputHighScores(HighScores) sorted\ne.g.\nPython\nHighScores = []\nHighScores = ReadData()\nprint(\"Before\")\nOutputHighScores(HighScores)\nHighScores = SortScores(HighScores)\nprint(\"After\")\nOutputHighScores(HighScores)\nVB.NET\nSub Main(args As String())\nDim HighScores(7, 3) As String\nHighScores = ReadData()\nConsole.WriteLine(\"Before\")\nOutputHighScores(HighScores)\nHighScores = SortScores(HighScores)\nConsole.WriteLine(\"After\")\nOutputHighScores(HighScores)\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 38 of 39\n\n3(e)(i) Java\npublic static void main(String args[]){\nString[][] HighScores = new String[7][3];\nHighScores = ReadData();\nSystem.out.println(\"Before\");\nOutputHighScores(HighScores);\nHighScores = SortScores(HighScores);\nSystem.out.println(\"After\");\nOutputHighScores(HighScores);\n}\n\n3(e)(ii) Output showing ‘Before’ and players and scores in correct format before sorting 2\nOutput showing ‘After’ players and scores in correct order and format after sorting\ne.g.\n© Cambridge University Press & Assessment 2024 Page 39 of 39",
      "source_pages": [
        31,
        32,
        33,
        34,
        35,
        36,
        37,
        38,
        39
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_42-p31.png",
        "../answer-assets/9618_w24_ms_42-p32.png",
        "../answer-assets/9618_w24_ms_42-p33.png",
        "../answer-assets/9618_w24_ms_42-p34.png",
        "../answer-assets/9618_w24_ms_42-p35.png",
        "../answer-assets/9618_w24_ms_42-p36.png",
        "../answer-assets/9618_w24_ms_42-p37.png",
        "../answer-assets/9618_w24_ms_42-p38.png",
        "../answer-assets/9618_w24_ms_42-p39.png"
      ]
    },
    {
      "id": "9618-2024-on-43-q01",
      "question_id": "9618-2024-on-43-q01",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 22,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark each to max 6: 6\n• Function declaration (and close where appropriate)\n• Declaration/use of an array (with space/initialised with 45 spaces/strings)\n• Opening the file Data.txt for read and closing in an appropriate place\n• Looping through all file contents/Looping 45 times and reading each line …\n• … storing all items from file into array\n• Returning the populated array\n• Exception handling with suitable try, catch and output\ne.g.\nPython\ndef ReadData():\nColours = []\ntry:\nFile = open(\"Data.txt\")\nColours = File.read().split(\"\\n\")\nFile.close()\nreturn Colours\nexcept:\nprint(\"No file found\")\nVB.NET\nFunction ReadData()\nDim TextFile As String = \"Data.txt\"\nDim Colours(45) As String\nTry\nDim FileReader As New System.IO.StreamReader(TextFile)\nFor x = 0 To 45\nColours(x) = FileReader.ReadLine()\n© Cambridge University Press & Assessment 2024 Page 4 of 37\n\n1(a) Next\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"No file found\")\nEnd Try\nReturn Colours\nEnd Function\nJava\npublic static String[] ReadData(){\nString TextFile = \"Data.txt\";\nString Colours[] = new String[45];\ntry{\nFileReader f = new FileReader(TextFile);\nBufferedReader Reader = new BufferedReader(f);\nfor(Integer X = 0; X < 45; X++){\ntry{\nColours[X] = Reader.readLine();\n}catch(IOException ex){}\n}\ntry{\nReader.close();\n}catch(IOException ex){}\nreturn Colours;\n}catch(FileNotFoundException e){\nSystem.out.println(\"File not found\");\n}\nreturn Colours;\n}\n© Cambridge University Press & Assessment 2024 Page 5 of 37\n\n1(b)(i) 1 mark each 2\n• Function header (and end where appropriate) taking (min) one parameter\n• Looping through each parameter array element, concatenating with space and returning\nPython\ndef FormatArray(DataArray):\nOutputText = \"\"\nfor x in range(0, 45):\nOutputText = OutputText + DataArray[x] + \" \"\nreturn OutputText\nVB.NET\nFunction FormatArray(DataArray)\nDim OutputText As String = \"\"\nFor X = 0 To 44\nOutputText = OutputText & DataArray(X) & \" \"\nNext\nReturn OutputText\nEnd Function\nJava\npublic static String FormatArray(String[] DataArray){\nString OutputText = \"\";\nfor(Integer X = 0; X < 45; X++){\nOutputText = OutputText + DataArray[X] + \" \";\n}\nreturn OutputText;\n}\n© Cambridge University Press & Assessment 2024 Page 6 of 37\n\n1(b)(ii) 1 mark each: 3\n• Calling ReadData() and storing returned array …\n• … calling FormatArray() with returned array\n• Outputting return value from FormatArray()\nPython\nColours = ReadData() #string array\nprint(FormatArray(Colours))\nVB.NET\nDim Colours(45) As String\nColours = ReadData()\nConsole.WriteLine(FormatArray(Colours))\nJava\nString[] Colours = new String[45];\nColours = ReadData();\nSystem.out.println(FormatArray(Colours));\n\n1(b)(iii) 1 mark for output showing all colours in one string 1\ne.g.\n© Cambridge University Press & Assessment 2024 Page 7 of 37\n\n1(c) 1 mark each 4\n• Function header (and close where appropriate) taking (min) two parameters and returns a value in all cases\n• Looping through each character in each string parameter …\n• … return 1 when first parameter  second\n• … return 2 when first parameter  second\ne.g.\nPython\ndef CompareStrings(First, Second):\nCount = 0\nwhile True:\nif First[Count] < Second[Count]:\nreturn 1\nelif First[Count] > Second[Count]:\nreturn 2\nelse:\nCount = Count + 1\nVB.NET\nFunction CompareStrings(FirstS, SecondS)\nDim Count As Integer = 1\nWhile (True)\nIf Mid(FirstS, Count, 1) < Mid(SecondS, Count, 1) Then\nReturn 1\nElseIf Mid(FirstS, Count, 1) > Mid(SecondS, Count, 1) Then\nReturn 2\nElse\nCount = Count + 1\nEnd If\nEnd While\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 8 of 37\n\n1(c) Java\npublic static Integer CompareStrings(String First, String Second){\nInteger Count = 0;\nwhile(true){\nif(First.substring(Count, Count + 1).compareTo(Second.substring(Count, Count +\n1)) < 0){\nreturn 1;\n}else if(First.substring(Count, Count + 1).compareTo(Second.substring(Count,\nCount + 1))>0){\nreturn 2;\n}else{\nCount++;\n}\n}\n}\n\n1(d)(i) 1 mark each 3\n• Bubble sort function header taking array parameter and returns sorted array in all cases\n• Comparing strings using CompareStrings() and correctly swapping values when needed\n• Correct bubble sort that sorts the data correctly\nPython\ndef Bubble(DataArray):\nArrayLength = len(DataArray)\nfor x in range(ArrayLength - 1):\nfor y in range(0, ArrayLength - x - 1):\nResult = CompareStrings(DataArray[y], DataArray[y + 1])\nif Result == 2:\nDataArray[y], DataArray[y+1] = DataArray[y+1], DataArray[y]\nreturn DataArray\n© Cambridge University Press & Assessment 2024 Page 9 of 37\n\n1(d)(i) VB.NET\nFunction Bubble(DataArray)\nDim ArrayLength As Integer = 45\nDim Result As Integer\nDim Temp As String\nFor X = 0 To ArrayLength - 1\nFor Y = 0 To ArrayLength - X - 2\nResult = CompareStrings(DataArray(Y), DataArray(Y + 1))\nIf Result = 2 Then\nTemp = DataArray(Y)\nDataArray(Y) = DataArray(Y + 1)\nDataArray(Y + 1) = Temp\nEnd If\nNext\nNext\nReturn DataArray\nEnd Function\nJava\npublic static String[] Bubble(String[] DataArray){\nInteger ArrayLength = 45;\nInteger Result;\nString Temp;\nfor(Integer X = 0; X < ArrayLength ; X++){\nfor(Integer Y = 0; Y < ArrayLength - X - 1; Y++){\nResult = CompareStrings(DataArray[Y], DataArray[Y+1]);\n© Cambridge University Press & Assessment 2024 Page 10 of 37\n\n1(d)(i) if (Result == 2){\nTemp = DataArray[Y];\nDataArray[Y] = DataArray[Y+1];\nDataArray[Y+1] = Temp;\n}\n}\n}\nreturn DataArray;\n}\n\n1(d)(ii) 1 mark each 2\n• Calling Bubble() with array as parameter and using/storing return value\n• Calling FormatArray() with return value from Bubble() and outputting return value\nPython\nBubbleSorted = Bubble(Colours)\nprint(FormatArray(BubbleSorted))\nVB.NET\nDim BubbleSorted(45) As String\nBubbleSorted = Bubble(Colours)\nConsole.WriteLine(FormatArray(BubbleSorted))\nJava\nString[] BubbleSorted = new String[45];\nBubbleSorted = Bubble(Colours);\nSystem.out.println(FormatArray(BubbleSorted));\n\n1(d)(iii) 1 mark for sorted data 1\ne.g.\n© Cambridge University Press & Assessment 2024 Page 11 of 37",
      "source_pages": [
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_43-p04.png",
        "../answer-assets/9618_w24_ms_43-p05.png",
        "../answer-assets/9618_w24_ms_43-p06.png",
        "../answer-assets/9618_w24_ms_43-p07.png",
        "../answer-assets/9618_w24_ms_43-p08.png",
        "../answer-assets/9618_w24_ms_43-p09.png",
        "../answer-assets/9618_w24_ms_43-p10.png",
        "../answer-assets/9618_w24_ms_43-p11.png"
      ]
    },
    {
      "id": "9618-2024-on-43-q02",
      "question_id": "9618-2024-on-43-q02",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 34,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) 1 mark each 4\n• Class Horse declaration (and end where appropriate)\n• All 3 attributes declared as private with appropriate data types (declaration or comment)\n• Constructor header (and end) taking 3 parameters (constructor must be within class) …\n• … constructor assigns parameters to attributes\ne.g.\nPython\nclass Horse:\ndef __init__(self, PName, PMaxFenceHeight, PPercentageSuccess):\nself.__Name = PName #String\nself.__MaxFenceHeight = PMaxFenceHeight #Integer\nself.__PercentageSuccess = PPercentageSuccess #Integer\nVB.NET\nClass Horse\nPrivate Name As String\nPrivate MaxFenceHeight As Integer\nPrivate PercentageSuccess As Integer\nSub New(PName, PMaxFenceHeight, PPercentageSuccess)\nName = PName\nMaxFenceHeight = PMaxFenceHeight\nPercentageSuccess = PPercentageSuccess\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2024 Page 12 of 37\n\n2(a)(i) Java\nclass Horse{\nprivate static String Name;\nprivate static Integer MaxFenceHeight;\nprivate static Integer PercentageSuccess;\npublic Horse(String PName, Integer PMaxFenceHeight, Integer PPercentageSuccess){\nName = PName;\nMaxFenceHeight = PMaxFenceHeight;\nPercentageSuccess = PPercentageSuccess;\n}\n}\n\n2(a)(ii) 1 mark each 3\n• 1 get method header with no parameter …\n• … returning correct attribute (without change)\n• 2nd get method correct\ne.g.\nPython\ndef GetName(self):\nreturn self.__Name\ndef GetMaxFenceHeight(self):\nreturn self.__MaxFenceHeight\nVB.NET\nFunction GetName()\nReturn Name\nEnd Function\n© Cambridge University Press & Assessment 2024 Page 13 of 37\n\n2(a)(ii) Function GetMaxFenceHeight()\nReturn MaxFenceHeight\nEnd Function\nJava\npublic String GetName(){\nreturn Name;\n}\npublic Integer GetMaxFenceHeight(){\nreturn MaxFenceHeight;\n}\n\n2(b)(i) 1 mark each 5\n• Instantiating one object of type Horse with correct data …\n• … and storing in first element of a 1D array Horses\n• Instantiating second object of type Horse with correct data and storing in second index of the array\n• Outputting name of both horse objects from array …\n• … using GetName()\ne.g.\nPython\nHorses = []\nHorses.append(Horse(\"Beauty\", 150, 72))\nHorses.append(Horse(\"Jet\", 160, 65))\nprint(Horses[0].GetName())\nprint(Horses[1].GetName())\nVB.NET\nDim Horses(2) As Horse\nHorses(0) = New Horse(\"Beauty\", 150, 72)\nHorses(1) = New Horse(\"Jet\", 160, 65)\nConsole.WriteLine(Horses(0).GetName())\nConsole.WriteLine(Horses(1).GetName())\n© Cambridge University Press & Assessment 2024 Page 14 of 37\n\n2(b)(i) Java\nHorse[] Horses = new Horse[2];\nHorses[0] = new Horse(\"Beauty\", 150, 72);\nHorses[1] = new Horse(\"Jet\", 160, 65);\nSystem.out.println(Horses[0].GetName());\nSystem.out.println(Horses[1].GetName());\n\n2(b)(ii) 1 mark for both names output: 1\n\n2(c)(i) 1 mark each 4\n• Class Fence header (and end where appropriate) with no inheritance\n• Height and Risk private with integer data type\n• Constructor taking 2 parameters and storing in attributes (constructor must be within class)\n• 2 get methods (no parameter) returning correct attributes (within class)\ne.g.\nPython\nclass Fence:\ndef __init__(self, PHeight, PRisk):\nself.__Height = PHeight #integer\nself.__Risk = PRisk #integer\ndef GetHeight(self):\nreturn self.__Height\ndef GetRisk(self):\nreturn self.__Risk\n© Cambridge University Press & Assessment 2024 Page 15 of 37\n\n2(c)(i) VB.NET\nClass Fence\nDim Height As Integer\nDim Risk As Integer\nSub New(PHeight, PRisk)\nHeight = PHeight\nRisk = PRisk\nEnd Sub\nFunction GetHeight()\nReturn Height\nEnd Function\nFunction GetRisk()\nReturn Risk\nEnd Function\nEnd Class\nJava\nclass Fence{\nprivate Integer Height;\nprivate Integer Risk;\npublic Fence (Integer PHeight, Integer PRisk){\nHeight = PHeight;\nRisk = PRisk;\n}\n© Cambridge University Press & Assessment 2024 Page 16 of 37\n\n2(c)(i) public Integer GetHeight(){\nreturn Height;\n}\npublic Integer GetRisk(){\nreturn Risk;\n}\n}\n\n2(c)(ii) 1 mark each to max 5 5\n• Declaration/use of array Course of type Fence (with at least 4 elements)\n• Taking Height and Risk as input four times and store/use\n• Instantiating a Fence object for each set of valid input values and storing in array\n• Taking each height as input until it is between 70 and 180 (inclusive)\n• Taking each risk as input until it is between 1 and 5 (inclusive)\ne.g.\nPython\nCourse = []\nfor x in range(0, 4):\nValid = False\nwhile Valid == False:\nHeight = int(input(\"Enter the height in cm\"))\nif(Height >= 70 and Height <= 180):\nValid = True\nValid = False\nwhile Valid == False:\nRisk = int(input(\"Enter the risk between 1 (easy) and 5 (hard)\"))\nif(Risk >= 1 and Risk <= 5):\nValid = True\nCourse.append(Fence(Height, Risk))\n© Cambridge University Press & Assessment 2024 Page 17 of 37\n\n2(c)(ii) VB.NET\nDim Course(5) As Fence\nDim Height As Integer\nDim Risk As Integer\nFor x = 0 To 3\nDo\nConsole.WriteLine(\"Enter the height in cm\")\nHeight = Console.ReadLine()\nLoop Until Height >= 70 And Height <= 180\nDo\nConsole.WriteLine(\"Enter the risk between 1 (easy) and 5 (hard)\")\nRisk = Console.ReadLine()\nLoop Until Risk >= 1 And Risk <= 5\nCourse(x) = New Fence(Height, Risk)\nNext\nJava\nFence [] Course = new Fence [4];\nfor(Integer x = 0; x < 4; x++){\ndo {\nSystem.out.println(\"Enter the height in cm\");\nHeight = Integer.parseInt(scanner.nextLine());\n} while(Height <70 || Height > 180);\ndo{\nSystem.out.println(\"Enter the risk between 1 (easy) and 5 (hard)\");\nRisk = Integer.parseInt(scanner.nextLine());\n}while(Risk <1 || Risk > 5);\nCourse[x] = new Fence(Height, Risk);\n}\n© Cambridge University Press & Assessment 2024 Page 18 of 37\n\n2(d) 1 mark each 5\n• Method header taking 2 parameters (and end where appropriate, returning real)\n• Checking if fence height parameter is more than max attribute for that horse, if true multiplying percentage success by\n0.2\n• (Otherwise) selection checking risk value parameter between 1 and 5, multiplying modifier by percentage success\n• Returning correct value as a real number in all instances\n• Correct use of attributes and parameters throughout\ne.g.\nPython\ndef Success(self, Height, Risk):\nif Height > self.__MaxFenceHeight:\nreturn self.__PercentageSuccess * 0.2\nelse:\nif Risk == 1:\nreturn self.__PercentageSuccess\nelif Risk == 2:\nreturn self.__PercentageSuccess * 0.9\nelif Risk == 3:\nreturn self.__PercentageSuccess * 0.8\nelif Risk == 4:\nreturn self.__PercentageSuccess * 0.7\nelse:\nreturn self.__PercentageSuccess * 0.6\nVB.NET\nFunction Success(Height, Risk)\nIf Height > MaxFenceHeight Then\nReturn PercentageSuccess * 0.2\nElse\n© Cambridge University Press & Assessment 2024 Page 19 of 37\n\n2(d) If Risk = 1 Then\nReturn PercentageSuccess\nElseIf Risk = 2 Then\nReturn PercentageSuccess * 0.9\nElseIf Risk = 3 Then\nReturn PercentageSuccess * 0.8\nElseIf Risk = 4 Then\nReturn PercentageSuccess * 0.7\nElse\nReturn PercentageSuccess * 0.6\nEnd If\nEnd If\nEnd Function\nJava\npublic static Double Success(Integer Height, Integer Risk){\nif(Height > MaxFenceHeight){\nreturn Double.valueOf(PercentageSuccess) * 0.2;\n}else{\nif(Risk == 1){\nreturn Double.valueOf(PercentageSuccess);\n}else if (Risk == 2){\nreturn Double.valueOf(PercentageSuccess) * 0.9;\n}else if (Risk == 3){\nreturn Double.valueOf(PercentageSuccess) * 0.8;\n}else if (Risk == 4){\nreturn Double.valueOf(PercentageSuccess) * 0.7;\n}else{\nreturn Double.valueOf(PercentageSuccess) * 0.6;\n}\n}\n}\n© Cambridge University Press & Assessment 2024 Page 20 of 37\n\n2(e)(i) 1 mark each 3\n• Calling Success() for each horse with the height and risk of all 4 fences …\n• … using get methods for height and risk of each fence\n• … outputting the horse name, fence number and calculated success at fence in appropriate message\ne.g.\nPython\nfor y in range(0, 2):\nfor x in range(0, 4):\nChance = Horses[y].Success(Course[x].GetHeight(), Course[x].GetRisk())\nprint(Horses[y].GetName(), \"Fence\", x + 1, \"chance of success is\", Chance, \"%\")\nVB.NET\nDim Chance As Single\nFor y = 0 To 1\nFor x = 0 To 3\nChance = Horses(y).Success(Course(x).GetHeight(), Course(x).GetRisk())\nConsole.WriteLine(Horses(y).GetName() & \" Fence \" & x + 1 & \" chance of\nsuccess is \" & Chance & \"%\")\nNext\nNext\nJava\nDouble Chance = 0.0;\nfor(Integer y = 0; y < 2; y ++){\nfor(Integer x = 0; x < 4; x++){\nChance = Horses[y].Success(Course[x].GetHeight(), Course[x].GetRisk());\nSystem.out.println(Horses[y].GetName() + \" Fence \" + (x + 1) + \" chance of\nsuccess is \" + Chance + \"%\");\n}\n}\n© Cambridge University Press & Assessment 2024 Page 21 of 37\n\n2(e)(ii) 1 mark each 2\n• Calculating average of all 4 fences for each horse and outputting in suitable message\n• Identifying the highest percentage of success and outputting the horse's name in an appropriate message\ne.g.\nPython\nAverageSuccess = []\nfor y in range(0, 2):\nTotal = 0\nfor x in range(0, 4):\nChance = Horses[y].Success(Course[x].GetHeight(), Course[x].GetRisk())\nprint(Horses[y].GetName(), \"Fence\", x + 1, \"chance of success is\", Chance, \"%\")\nTotal = Total + Chance\nAverage = Total / 4\nAverageSuccess.append(Average)\nprint(Horses[y].GetName(), \"average success rate is\", Average, \"%\")\nHighest = AverageSuccess[0]\nWinner = -1\nfor x in range(1,2):\nif Highest < AverageSuccess[x]:\nWinner = x\nHighest = AverageSuccess[x]\nprint(Horses[Winner].GetName(), \" has the highest average chance of success \")\n© Cambridge University Press & Assessment 2024 Page 22 of 37\n\n2(e)(ii) VB.NET\nDim Total As Integer\nDim Chance As Single\nDim Average As Single\nFor y = 0 To 1\nTotal = 0\nFor x = 0 To 3\nChance = Horses(y).Success(Course(x).GetHeight(), Course(x).GetRisk())\nConsole.WriteLine(Horses(y).GetName() & \" Fence \" & x + 1 & \" chance of success is\n\" & Chance & \"%\")\nTotal = Total + Chance\nAverage = Total / 4\nAverageSuccess(y) = Average\nConsole.WriteLine(Horses(y).GetName() & \" average success rate is \" & Average &\n\"%\")\nNext\nNext\nDim Highest As Single\nDim Winner As Integer\nHighest = AverageSuccess(0)\nWinner = -1\nFor x = 1 To 1\nIf Highest < AverageSuccess(x) Then\nWinner = x\nHighest = AverageSuccess(x)\nEnd If\nNext x\nConsole.WriteLine(Horses(Winner).GetName() & \" has the highest average chance of success \")\n© Cambridge University Press & Assessment 2024 Page 23 of 37\n\n2(e)(ii) Java\nDouble Total = 0.0;\nDouble Chance = 0.0;\nDouble Average = 0.0;\nfor(Integer y = 0; y < 2; y ++){\nTotal = 0.0;\nfor(Integer x = 0; x < 4; x++){\nChance = Horses[y].Success(Course[x].GetHeight(), Course[y].GetRisk());\nSystem.out.println(Horses[y].GetName() + \" Fence \" + (x + 1) + \" chance of\nsuccess is \" + Chance + \"%\");\nTotal = Total + Chance;\n}\nAverage = Total / 4;\nAverageSuccess[y] = Average;\nSystem.out.println(Horses[y].GetName() + \" average success rate is \" + Average +\n\"%\");\n}\nDouble Highest = AverageSuccess[0];\nInteger Winner = 0;\nfor(Integer x = 1; x < 2; x++){\nif(Highest < AverageSuccess[x]){\nWinner = x;\nHighest = AverageSuccess[x];\n}\n}\nSystem.out.println(Horses[Winner].GetName() + \" has the highest average chance of\nsuccess\");\n© Cambridge University Press & Assessment 2024 Page 24 of 37\n\n2(e)(iii) 1 mark each 2\n• Outputting showing correct input values for all fences, and correct chance for each horse on each jump\n• Outputs of average chance of each horse and horse name with highest average\ne.g.\n© Cambridge University Press & Assessment 2024 Page 25 of 37",
      "source_pages": [
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23,
        24,
        25
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_43-p12.png",
        "../answer-assets/9618_w24_ms_43-p13.png",
        "../answer-assets/9618_w24_ms_43-p14.png",
        "../answer-assets/9618_w24_ms_43-p15.png",
        "../answer-assets/9618_w24_ms_43-p16.png",
        "../answer-assets/9618_w24_ms_43-p17.png",
        "../answer-assets/9618_w24_ms_43-p18.png",
        "../answer-assets/9618_w24_ms_43-p19.png",
        "../answer-assets/9618_w24_ms_43-p20.png",
        "../answer-assets/9618_w24_ms_43-p21.png",
        "../answer-assets/9618_w24_ms_43-p22.png",
        "../answer-assets/9618_w24_ms_43-p23.png",
        "../answer-assets/9618_w24_ms_43-p24.png",
        "../answer-assets/9618_w24_ms_43-p25.png"
      ]
    },
    {
      "id": "9618-2024-on-43-q03",
      "question_id": "9618-2024-on-43-q03",
      "subject": "9618",
      "year": 2024,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 19,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark each 2\n• LinkedList declared as 2D array with (min) 20  2 elements (Integer) with all data initialised to -1, all nodes linked\ncorrectly\n• (Global) FirstNode (Int) initialised as -1 and (global) FirstEmpty (Int) initialised as 0\nVB.NET\nDim LinkedList(20, 2) As Integer\nDim FirstNode As Integer\nDim FirstEmpty As Integer\nSub Main(args As String())\nFirstNode = -1\nFirstEmpty = 0\nFor x = 0 To 18\nLinkedList(x, 0) = -1\nLinkedList(x, 1) = x + 1\nNext\nLinkedList(19, 0) = -1\nLinkedList(19, 1) = -1\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 26 of 37\n\n3(a) Python\nLinkedList = [] #global\nFirstNode = -1\nFirstEmpty = 0\nfor x in range(0, 19):\nLinkedList.append([-1, x + 1])\nLinkedList[19][0] = -1\nLinkedList[19][1] = -1\nJava\nprivate static Integer[][] LinkedList = new Integer[20][2];\nprivate static Integer FirstNode;\nprivate static Integer FirstEmpty;\npublic static void main(String args[]){\nFirstNode = -1;\nFirstEmpty = 0;\nfor(Integer X = 0; X < 19; X++){\nLinkedList[X][0] = -1;\nLinkedList[X][1] = X + 1;\n}\nLinkedList[19][0] = -1;\nLinkedList[19][1] = -1;\n}\n© Cambridge University Press & Assessment 2024 Page 27 of 37\n\n3(b) 1 mark each to max 6 6\n• Procedure header (and end) taking (min) 5 data items as input from the user\n• Checking if linked list is full (FirstEmpty = -1) …\n• …ending procedure/loop/not doing anything further\n• (otherwise) LinkedList[FirstEmpty, 0] = data input\n• LinkedList[FirstEmpty, 1] = FirstNode\n• FirstNode = FirstEmpty\n• FirstEmpty = LinkedList[FirstEmpty, 1] before any update to FirstEmpty ‘s pointer\ne.g.\nPython\ndef InsertData():\nglobal LinkedList\nglobal FirstNode\nglobal FirstEmpty\nfor _ in range(5):\nif FirstEmpty != -1:\nnextEmpty = LinkedList[FirstEmpty][1]\nLinkedList[FirstEmpty][0] = int(input(\"Value: \"))\nLinkedList[FirstEmpty][1] = FirstNode\nFirstNode = FirstEmpty\nFirstEmpty = nextEmpty\n© Cambridge University Press & Assessment 2024 Page 28 of 37\n\n3(b) VB.NET\nSub InsertData()\nDim NewItem As Integer\nDim NextEmpty As Integer\nFor x = 0 To 4\nConsole.WriteLine(\"Enter the next number\")\nNewItem = Console.ReadLine()\nIf FirstEmpty = -1 Then\nx = 5\nElse\nNextEmpty = LinkedList(FirstEmpty, 1)\nLinkedList(FirstEmpty, 0) = NewItem\nLinkedList(FirstEmpty, 1) = FirstNode\nFirstNode = FirstEmpty\nFirstEmpty = NextEmpty\nEnd If\nNext x\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 29 of 37\n\n3(b) Java\npublic static void InsertData(){\nInteger NewItem;\nInteger CurrentPointer = 0;\nInteger PreviousPointer = 0;\nScanner scanner = new Scanner(System.in);\nInteger NextEmpty;\nfor(Integer X = 0; X < 5; X++){\nSystem.out.println(\"Enter the next number\");\nNewItem = Integer.parseInt(scanner.nextLine());\nif(FirstEmpty == -1){\nX = 5;\n}else{\nNextEmpty = LinkedList[FirstEmpty][1];\nLinkedList[FirstEmpty][0] = NewItem;\nLinkedList[FirstEmpty][1] = FirstNode;\nFirstNode = FirstEmpty;\nFirstEmpty = NextEmpty;\n}\n}\n}\n© Cambridge University Press & Assessment 2024 Page 30 of 37\n\n3(c)(i) 1 mark each 2\n• Procedure header (and end) starting with node at index FirstNode and outputting data\nLinkedList[FirstNode,0]\n• Following pointers until end reached and outputting data for each node\nPython\ndef OutputLinkedList():\nglobal LinkedList\nglobal FirstNode\nglobal FirstEmpty\nCurrentPointer = FirstNode\nFlag = True\nwhile Flag:\nprint(LinkedList[CurrentPointer][0])\nCurrentPointer = LinkedList[CurrentPointer][1]\nif CurrentPointer == -1:\nFlag = False\nVB.NET\nSub OutputLinkedList()\nDim CurrentPointer As Integer = FirstNode\nDim Flag As Boolean = True\nWhile Flag\nConsole.WriteLine(LinkedList(CurrentPointer, 0))\nCurrentPointer = LinkedList(CurrentPointer, 1)\nIf CurrentPointer = -1 Then\nFlag = False\nEnd If\nEnd While\n© Cambridge University Press & Assessment 2024 Page 31 of 37\n\n3(c)(i) End Sub\nJava\npublic static void OutputLinkedList(){\nInteger CurrentPointer = FirstNode;\nBoolean Flag = true;\nwhile(Flag){\nSystem.out.println(LinkedList[CurrentPointer][0]);\nCurrentPointer = LinkedList[CurrentPointer][1];\nif(CurrentPointer == -1){Flag = false;}\n}\n}\n\n3(c)(ii) 1 mark for calling InsertData() then OutputLinkedList() 1\nPython\nInsertData()\nOutputLinkedList()\nVB.NET\nInsertData()\nOutputLinkedList()\nJava\nInsertData();\nOutputLinkedList();\n\n3(c)(iii) 1 mark for inputs of 5 1 2 3 8 and output of 8 3 2 1 5 1\n© Cambridge University Press & Assessment 2024 Page 32 of 37\n\n3(d)(i) 1 mark each to max 5 5\n• Procedure header (and end) with parameter\n• Checking data in FirstNode against parameter …\n• … (if found) updating FirstNode to LinkedList[FirstNode, 1]\n• (Otherwise) following pointers in loop/recursive call …\n• …comparing to data to remove each time\n• … storing previous pointer through each loop…\n• … when found, updating previous pointer to found node’s pointer\n• Adding deleted node to end of/start of empty list (and updating FirstEmpty if needed)\nPython\ndef RemoveData(ItemToRemove):\nglobal LinkedList\nglobal FirstNode\nglobal FirstEmpty\nif LinkedList[FirstNode][0] == ItemToRemove:\nNewFirst = LinkedList[FirstNode][1]\nLinkedList[FirstNode][1] = FirstEmpty\nFirstEmpty = FirstNode\nFirstNode = NewFirst\nelse:\nif FirstNode != -1:\nCurrentPointer = FirstNode\nPreviousNode = -1\nwhile(ItemToRemove != LinkedList[CurrentPointer][0] and CurrentPointer != -1):\nPreviousNode = CurrentPointer\nCurrentPointer = LinkedList[CurrentPointer][1]\nif ItemToRemove == LinkedList[CurrentPointer][0]:\nLinkedList[PreviousNode][1] = LinkedList[CurrentPointer][1]\nLinkedList[CurrentPointer][0] = -1\nLinkedList[CurrentPointer][1] = FirstEmpty\nFirstEmpty = CurrentPointer\n© Cambridge University Press & Assessment 2024 Page 33 of 37\n\n3(d)(i) VB.NET\nSub RemoveData(ItemToRemove)\nIf LinkedList(FirstNode, 0) = ItemToRemove Then\nDim NewFirst As Integer = LinkedList(FirstNode, 1)\nLinkedList(FirstNode, 1) = FirstEmpty\nFirstEmpty = FirstNode\nFirstNode = NewFirst\nElse\nIf FirstNode <> -1 Then\nDim CurrentPointer As Integer = FirstNode\nDim PreviousNode As Integer = -1\nDim Flag As Boolean = True\nDim Found As Boolean = False\nWhile Flag And Not (Found)\nIf (CurrentPointer <> -1) Then\nIf (ItemToRemove <> LinkedList(CurrentPointer, 0)) Then\nPreviousNode = CurrentPointer\nCurrentPointer = LinkedList(CurrentPointer, 1)\nElse\nFound = True\nEnd If\nElse\nFlag = False\nEnd If\nEnd While\nIf Found Then\nLinkedList(PreviousNode, 1) = LinkedList(CurrentPointer, 1)\nLinkedList(CurrentPointer, 0) = -1\nLinkedList(CurrentPointer, 1) = FirstEmpty\nFirstEmpty = CurrentPointer\nEnd If\nEnd If\nEnd If\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 34 of 37\n\n3(d)(i) Java\npublic static void RemoveData(Integer ItemToRemove){\nInteger CurrentPointer = 0;\nInteger PreviousNode = 0;\nInteger NewFirst = 0;\nif(LinkedList[FirstNode][0] == ItemToRemove){\nNewFirst = LinkedList[FirstNode][1];\nLinkedList[FirstNode][1] = FirstEmpty;\nFirstEmpty = FirstNode;\nFirstNode = NewFirst;\n}else{\nif (FirstNode != -1){\nCurrentPointer = FirstNode;\nPreviousNode = -1;\nwhile(ItemToRemove != LinkedList[CurrentPointer][0] && CurrentPointer\n!= -1){\nPreviousNode = CurrentPointer;\nCurrentPointer = LinkedList[CurrentPointer][1];\n}\nif(ItemToRemove == LinkedList[CurrentPointer][0]){\nLinkedList[PreviousNode][1] = LinkedList[CurrentPointer][1];\nLinkedList[CurrentPointer][0] = -1;\nLinkedList[CurrentPointer][1] = FirstEmpty;\nFirstEmpty = CurrentPointer;\n}\n}\n}\n}\n© Cambridge University Press & Assessment 2024 Page 35 of 37\n\n3(d)(ii) 1 mark for calling RemoveData(5), outputting \"After\", calling OutputLinkedList() 1\nPython\nLinkedList = []\nFirstNode = -1\nFirstEmpty = 0\nfor x in range(0, 19):\nLinkedList.append([-1, x + 1])\nInsertData()\nOutputLinkedList()\nRemoveData(5)\nprint(\"After\")\nOutputLinkedList()\nVB.NET\nSub Main(args As String())\nFirstNode = -1\nFirstEmpty = 0\nFor x = 0 To 19\nLinkedList(x, 0) = -1\nLinkedList(x, 1) = x + 1\nNext\nInsertData()\nOutputLinkedList()\nRemoveData(5)\nConsole.WriteLine(\"After\")\nOutputLinkedList()\nEnd Sub\n© Cambridge University Press & Assessment 2024 Page 36 of 37\n\n3(d)(ii) Java\npublic static void main(String args[]){\nFirstNode = -1;\nFirstEmpty = 0;\nfor(Integer X = 0; X < 20; X++){\nLinkedList[X][0] = -1;\nLinkedList[X][1] = X + 1;\n}\nInsertData();\nOutputLinkedList();\nRemoveData(5);\nSystem.out.println(\"After\");\nOutputLinkedList();\n}\n\n3(d)(iii) 1 mark for input and output. 1\nTest data 1:\nInput 5 6 8 9 5\n‘After’\nOutput: 9 8 6 5\nTest data 2:\nInput 10 7 8 5 6\n“After”\nOutput: 6 8 7 10\n© Cambridge University Press & Assessment 2024 Page 37 of 37",
      "source_pages": [
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37
      ],
      "source_pdf": "_source-pdfs/2024-oct-nov/ms/9618_w24_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2024-Oct-Nov/9618_w24_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w24_ms_43-p26.png",
        "../answer-assets/9618_w24_ms_43-p27.png",
        "../answer-assets/9618_w24_ms_43-p28.png",
        "../answer-assets/9618_w24_ms_43-p29.png",
        "../answer-assets/9618_w24_ms_43-p30.png",
        "../answer-assets/9618_w24_ms_43-p31.png",
        "../answer-assets/9618_w24_ms_43-p32.png",
        "../answer-assets/9618_w24_ms_43-p33.png",
        "../answer-assets/9618_w24_ms_43-p34.png",
        "../answer-assets/9618_w24_ms_43-p35.png",
        "../answer-assets/9618_w24_ms_43-p36.png",
        "../answer-assets/9618_w24_ms_43-p37.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q01",
      "question_id": "9618-2025-mj-31-q01",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 1,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point 2\nMP1 TYPE Vehicle =\nMP2 (M100, M230, T101, T102, T120, T150)\nExample answer:\nTYPE Vehicle = (M100, M230, T101, T102, T120, T150)\n\n1(b) One mark per mark point 4\nMP1 TYPE Booking and ENDTYPE correct\nMP2 Declare used correctly for every field in the response\nMP3 Any four fields correct\nMP4 Remaining fields correct\nExample answer:\nTYPE Booking\nDECLARE BookingNumber : STRING\nDECLARE Destination : STRING\nDECLARE ClientName : STRING\nDECLARE ClientTelephone : STRING\nDECLARE DateOfDeparture : DATE\nDECLARE PickupAddress : STRING\nDECLARE TaxiUsed : Vehicle\nENDTYPE\n© Cambridge University Press & Assessment 2025 Page 6 of 15",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q02",
      "question_id": "9618-2025-mj-31-q02",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 2,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark per mark point 2\nMP1 Correct mantissa\nMP2 Correct exponent\nMantissa Exponent\n0 1 1 0 1 0 1 1 1 0 1 1 1 0 1 0\n\n2(b) One mark per mark point for working (Max 2) 4\n• number converted to binary e.g., positive binary version of 25.3125 = (0)11001.0101\n• two’s complement version\nbits flipped and 1 added = 100110.1011\n• -32 + 4 + 2 + 0.5 + 0.125 + 0.0625 // -32 + 4 + 2 + 1/2 + 1/8 + 1/16\n• movement of binary point seen (5 places)\nOne mark per mark point\n• correct mantissa\n• correct exponent\nMantissa Exponent\n1 0 0 1 1 0 1 0 1 1 0 0 0 1 0 1\n© Cambridge University Press & Assessment 2025 Page 7 of 15",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q03",
      "question_id": "9618-2025-mj-31-q03",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per mark point (Max 5) 5\nOne mark per mark point for purpose of Application Layer (Max 3)\nMP1 To provide services / interface with the user // access to applications, for example login, file transfer, network file\naccess, email, etc\nMP2 To provide mechanisms for securing communication e.g. encryption/authentication\nMP3 To define/provide protocols used to allow the exchange of data/communication // to contain programs that\nexchange data\nMP4 Error detection and recovery mechanisms to handle application specific errors\nOne mark per mark point for purpose of Transport Layer (Max 3)\nMP5 To provide logical communication between applications running on different hosts // To ensure that data is\ndelivered to the correct application process on the destination machine\nMP6 To ensure error-free, end-to-end delivery of data between a source and a destination, in sequence // to provide\nerror recovery techniques such as error detection codes and automatic repeat request\nMP7 To break data into segments when sent and to reconstruct when received // To reassemble segments at\ndestination\nMP8 To regulate network connections // to provide flow control mechanisms to prevent data loss.\n\n3(b) One mark per mark point (Max 4) 4\nMP1 Data are broken into equal sized packets\nMP2 Data packets have headers containing information such as the IP addresses of the sender and receiver\nMP3 Each packet of data is sent independently to the destination // Packets don’t necessarily follow the same route\nMP4 Each packet is sent via the most optimum path available\nMP5 Packets don’t necessarily arrive in the order they were sent // Packets are reconstructed at the destination in the\ncorrect order\nMP6 Missing / damaged packets are re-sent\n© Cambridge University Press & Assessment 2025 Page 8 of 15",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p08.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q04",
      "question_id": "9618-2025-mj-31-q04",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 4,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark per mark point 4\nMP1 Any two nodes added correctly with correct data (6, 15, 41, 66) and arrows\nMP2 Remaining two nodes added with correct data (6, 15, 41, 66) and all nodes with connecting arrows starting from\npointer boxes\nMP3 Correct null pointers (-1) added throughout\nMP4 … with no entries in other pointer boxes and all nodes correctly positioned and connected\nRoot pointer\nLeft pointer Data Right pointer\n36\n12 -1 40\n-1 3 -1 15 -1 -1 41\n-1 6 -1 -1 66 -1\n© Cambridge University Press & Assessment 2025 Page 9 of 15\n\n4(b) One mark per mark point 2\nMP1 A technique used to solve problems using a function/procedure/subroutine that calls itself (general case)\nMP2 … until the terminating condition / base case is achieved, when no further recursive calls are made\n\n4(c) One mark 1\n• Stack\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p09.png",
        "../answer-assets/9618_s25_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q05",
      "question_id": "9618-2025-mj-31-q05",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 5,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "5(a) Two marks for all six correct terms 2\nOne mark for any three correct terms\nZ = A.B.C.D + A.B.C.D + A.B.C.D + A.B.C.D + A.B.C.D + A.B.C.D\n\n5(b)(i) Two marks if no errors present 2\nOne mark if one error present\nAB\nCD 00 01 11 10\n00 1 0 0 1\n01 0 1 1 0\n11 0 1 1 0\n10 0 0 0 0\n© Cambridge University Press & Assessment 2025 Page 10 of 15\n\n5(b)(ii) One mark for each correct loop 2\nAB\nCD 00 01 11 10\n00 1 0 0 1\n01 0 1 1 0\n11 0 1 1 0\n10 0 0 0 0\n\n5(b)(iii) One mark for each mark point 2\n• One correct Boolean term\n• Boolean terms and operator correct and no other terms present\nZ = B.D + B.C.D // B.C.D + B.D\nQuestion Answer Marks",
      "source_pages": [
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p10.png",
        "../answer-assets/9618_s25_ms_31-p11.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q06",
      "question_id": "9618-2025-mj-31-q06",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 6,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "6 One mark for each mark point (Max 4) 4\nMP1 The interpreter translates the source code one line at a time\nMP2 If the line is syntax error free it is executed\nMP3 It is not stored in executable format\nMP4 If an error is found, the program halts with an error message\nMP5 Each line must be translated every time it is run, including lines running multiple times for example in loops\n© Cambridge University Press & Assessment 2025 Page 11 of 15",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p11.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q07",
      "question_id": "9618-2025-mj-31-q07",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 7,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark for each correct answer 2\n#Jd7 – must begin with a member of the group uppercase // cannot begin with a symbol\nC%6A – the fourth character cannot be a member of the group uppercase // the fourth character must be either a symbol,\ndigit or lowercase\n\n7(b) One mark per mark point 4\n<uppercase> ::= A | C | E | G | J\n<passcode> ::= <uppercase><code>\n<code> ::= <lowercase>|<symbol>|<digit>\n|<lowercase><code>|<symbol><code>|<digit><code>\nQuestion Answer Marks",
      "source_pages": [
        12
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p12.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q08",
      "question_id": "9618-2025-mj-31-q08",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 8,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark for each mark point 2\nMP1 Running multiple processes concurrently\nMP2 … which benefits process management by allowing more tasks to complete than would be the case if they had to\nrun one task after another.\n\n8(b) One mark for each mark point (Max 3) 4\nMP1 The processes are queued as they arrive\nMP2 Processes with the shortest burst time are executed first\nMP3 It is a pre-emptive scheduling function // When a process with a shorter burst time arrives the existing process is\nreplaced by the shorter process.\nMP4 The scheduler will continue to choose shorter processes over longer processes if they continue to be added to the\nqueue can cause starvation for longer jobs\nOne mark for benefit (Max 1) e.g.\nMP5 Processes with a short burst time are processed very quickly\nMP6 Waiting time is minimised\n© Cambridge University Press & Assessment 2025 Page 12 of 15",
      "source_pages": [
        12
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p12.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q09",
      "question_id": "9618-2025-mj-31-q09",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 9,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "9(a) One mark for each mark point (Max 2) 2\nMP1 Ensure security/privacy when using the internet\nMP2 Data encryption\nMP3 Identification / authentication of client and server\n\n9(b) One mark for each mark point (Max 2) 2\nMP1 When transmitting authentication data e.g. passwords, session cookies\nMP2 When transmitting data that must be protected from modification on its way to or from a server e.g. user input, or\nresults from the server\nMP3 When transmitting data classified as non-public.\nQuestion Answer Marks",
      "source_pages": [
        13
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p13.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q10",
      "question_id": "9618-2025-mj-31-q10",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 10,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark for each mark point (Max 2) 2\nMP1 A graph is used in AI to record relationships between entities\nMP2 … using vertices / nodes and edges\nMP3 for example, to represent places on a map and the distances between them, in order to find the shortest route.\n\n10(b) One mark for each mark point (Max 4) 4\nMP1 Artificial neural networks are designed to work in the same way as the human brain\nMP2 ANNs provide the architecture and algorithms for learning from the data\nMP3 They have a large number of connected processing units / nodes\nMP4 … that are arranged in layers / interconnected and work together to process data\nMP5 Deep learning models learn from data by adjusting the weights/biases of the connections between neurons\nMP6 They use multiple hidden layers to extract complex features and to make predictions\n© Cambridge University Press & Assessment 2025 Page 13 of 15",
      "source_pages": [
        13
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p13.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q11",
      "question_id": "9618-2025-mj-31-q11",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 11,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark per mark point 5\nMP1 Two correct attributes (PatientID : INTEGER and Doctor : STRING)\nMP2 SetTreatments(…) and SetMedications(…) seen\nMP3 … and appropriate parameters, with string data types\nMP4 GetPatientID() and GetDoctor() seen\nMP5 SetDateSeen(…) and GetDateSeen fully correct with appropriate parameter and correct data type in setter.\nAppointment\nDateSeen : DATE\nPatientID : INTEGER\nDoctor : STRING\nTreatments : STRING\nMedications : STRING\nSetDateSeen(NewDate : DATE)\nSetPatientID(PatientNumber : INTEGER)\nSetDoctor(DoctorID : STRING)\nSetTreatments(NewTreatments : STRING)\nSetMedications(NewMedications : STRING)\nGetDateSeen()\nGetPatientID()\nGetDoctor()\nGetTreatments()\nGetMedications()\n\n11(b)(i) Encapsulation 1\n\n11(b)(ii) One mark for each mark point (Max 2) 2\nMP1 Inheritance is where a derived class takes properties / behaviours attributes / methods\nMP2 … of a parent / super class / base class\nMP3 The attributes / methods / properties taken from the parent / super class / base class can also be extended /\ncopied / used / changed / overwritten / overridden in the subclass.\n© Cambridge University Press & Assessment 2025 Page 14 of 15",
      "source_pages": [
        14
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p14.png"
      ]
    },
    {
      "id": "9618-2025-mj-31-q12",
      "question_id": "9618-2025-mj-31-q12",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "31",
      "question_number": 12,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "12 One mark for each correctly completed line (Max 5) 5\nDECLARE Location : INTEGER\nDECLARE Item : STRING\nDECLARE Continue : BOOLEAN\nDECLARE Answer : CHAR\nContinue  TRUE\nOPENFILE \"StockList.dat\" FOR RANDOM\nWHILE Continue\nOUTPUT \"Enter a location between 1 and 500: \"\nINPUT Location\nSEEK \"StockList.dat\", Location\nGETRECORD \"StockList.dat\", Item\nIF Item = \"\" THEN\nOUTPUT \"This record is missing\"\nELSE\nOUTPUT \"The item in stock is \", Item\nENDIF\nOUTPUT \"Another location (Y or N)?\"\nINPUT Answer\nIF Answer <> 'Y' THEN\nContinue  FALSE\nENDIF\nENDWHILE\nCLOSEFILE \"StockList.dat\"\nOUTPUT \"End of program\"\n© Cambridge University Press & Assessment 2025 Page 15 of 15",
      "source_pages": [
        15
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_31-p15.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q01",
      "question_id": "9618-2025-mj-32-q01",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 1,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark for each mark point 3\nMP1 Use of correct Flight1 variable with given field names\nMP2 Correct assignments of four string data values\nMP3 Correct assignment of date data value\nExample answer\nFlight1.FlightNumber  \"SB2789\"\nFlight1.Destination  \"Dublin\"\nFlight1.FlightDate  30/07/2025\nFlight1.Gate  \"N03\"\nFlight1.Airline  \"Cambridge Airways\"\n\n1(b)(i) One mark per mark point 2\nMP1 TYPE GateID =\nMP2 (N01, N02, N03, W01, W02, W03, W04)\nExample answer\nTYPE GateID = (N01, N02, N03, W01, W02, W03, W04)\n\n1(b)(ii) DECLARE Gate : GateID 1\nQuestion Answer Marks",
      "source_pages": [
        4
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p04.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q02",
      "question_id": "9618-2025-mj-32-q02",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 2,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) Two marks for working 3\n• number converted to binary (0)1111100.0111\n• use of exponent = 7 // Moving binary point the correct number (7) of\nplaces\nOne mark for correct answer\nMantissa Exponent\n0 1 1 1 1 1 0 0 0 1 1 1 0 1 1 1\n© Cambridge University Press & Assessment 2025 Page 4 of 12\n\n2(b) Two marks for working 3\n• correct use of exponent seen\n• correct conversion method from binary to denary\nOne mark for correct answer\nWorking:\n1010001.01011 // moving bp 6 places to right\nEvaluation of two’s complement −64 +16 + 1 + 0.25 + 0.0625 + 0.03125 //\n−64 + 16 + 1 + 1/4 + 1/16 + 1/32 // Converting two’s complement back and\nevaluating positive binary number 32 + 8 + 4 + 2 + 0.5 + 0.125 + 0.03125 // 32\n+ 8 + 4 + 2 + 1/2 + 1/8 + 1/32\nFractions methods - award both working marks for either\n(– 2048 + 512 + 32 + 8 + 2 + 1) / 2048 x 26 = -1493 / 32\nOR\n– 1 + 1/4 + 1/64 + 1/ 256 + 1/1024 + 1/2048 x 26 = -1493 / 32\nAnswer:\n−46.65625 // −4621/\n32\nQuestion Answer Marks",
      "source_pages": [
        4,
        5
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p04.png",
        "../answer-assets/9618_s25_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q03",
      "question_id": "9618-2025-mj-32-q03",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "3(a) Two from 1\n• Application Layer\n• Transport Layer\n• Internet Layer\n• Link Layer\n\n3(b) One mark per mark point (Max 4) 4\nMP1 The TCP/IP suite can be viewed as layers within a stack\nMP2 Each layer can only accept input from the next higher or the next\nlower layer/adjacent layer\nMP3 The user/sender/computer interfaces with the top layer/application\nlayer to send/receive a message\nMP4 The message when sent passes from the top layer/application layer\nto the bottom layer/link layer\nMP5 The message when received passes from bottom layer/link layer to\nthe top layer/application layer\nMP6 The link layer interfaces directly with the network and sends/receives\nthe message.\n© Cambridge University Press & Assessment 2025 Page 5 of 12",
      "source_pages": [
        5
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p05.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q04",
      "question_id": "9618-2025-mj-32-q04",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 4,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "4 One mark for each benefit (Max 2) 4\nMP1 Suitable for long continuous transmission once the connection is\nmade, it is available until the end of the transmission\nMP2 No time lost in resending/rearranging packets as no loss of packets\nor out of order packets\nMP3 Steady/high rate of transmission because the whole of the bandwidth\nis available\nMP4 Data loss unlikely as all data follows the same path\nOne mark for each drawback (Max 2)\nMP5 Delays due to dedicated connection required to be set up/established\nbefore transmission can begin\nMP6 The dedicated connection cannot be used to transmit any other data\nMP7 System resources may be underutilised/inefficient/not very flexible\nbecause the bandwidth can’t be shared/high bandwidth is required //\nBandwidth may be wasted // May send empty frames // the circuit is always\nthere whether or not used\nMP8 There are no alternative routes if there is a failure or fault on the line\nMP9 Reduced security due to use of single path\nMP10 Scalability is difficult\nQuestion Answer Marks",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q05",
      "question_id": "9618-2025-mj-32-q05",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark per point 3\n• Running state\n• Ready state\n• Blocked state\n\n5(b) One mark per mark point (Max 3) 4\nMP1 The processes are queued as they arrive\nMP2 The process with the shortest time to complete/burst time is selected\nfirst and executed\nMP3 The process will continue until complete or put in a waiting state once\nexecution has begun // it is non-pre-emptive\nMP4 The scheduler will continue to choose shorter processes over longer\nprocesses if they continue to be added to the queue can cause starvation for\nlonger jobs\nOne mark for a benefit (Max 1)\nMP5 Shorter jobs don’t have to wait for longer jobs to complete before\nprocessing // Significantly reduces the average overall waiting time for\nprocesses // Ensures starvation doesn’t occur for process with shorter burst\ntimes\nMP6 Higher throughput of processes\n© Cambridge University Press & Assessment 2025 Page 6 of 12",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q06",
      "question_id": "9618-2025-mj-32-q06",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 6,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark per point (Max 2) 2\nMP1 A graph uses vertices/nodes to identify/represent entities such as\ndestinations, people, etc\nMP2 Edges are used to connect nodes and can represent possible paths\nbetween them // a path is the list of nodes connected by edges between two\ngiven nodes\nMP3 Nodes/edges can be labelled/weighted, and this is a weighting that\ncan be applied and used in the context of the application\nMP4 A cycle is a list of nodes that return to the same node.\n\n6(b) One mark per mark point (Max 4) 4\nMP1 Supervised learning uses labelled data // Unsupervised learning\nmakes use of unlabelled data.\nMP2 Labelled data means that known outcomes are applied to specific\ninputs to help the AI predict outcomes.\nMP3 Supervised learning requires initial human input/training //\nUnsupervised learning does not require human input/training.\nMP4 With unlabelled data in unsupervised learning, outcomes are not\nknown\nMP5 … the AI has to search for hidden patterns/structures/clusters\nMP6 … within the data in order to predict outcomes.\n© Cambridge University Press & Assessment 2025 Page 7 of 12",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q07",
      "question_id": "9618-2025-mj-32-q07",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 7,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark for working, (all four columns P, Q, R and S) 3\nOne mark for first eight rows of column Z (Shaded)\nOne mark for second eight rows of column Z (Unshaded)\nWorking space\nA B C D P Q R S Z\n0 0 0 0 1 0 0 1 0\n0 0 0 1 1 0 0 1 0\n0 0 1 0 0 1 0 1 0\n0 0 1 1 0 1 0 1 0\n0 1 0 0 1 0 0 1 0\n0 1 0 1 1 0 0 1 0\n0 1 1 0 0 0 0 0 1\n0 1 1 1 0 0 1 0 0\n1 0 0 0 1 0 0 1 0\n1 0 0 1 1 0 0 1 0\n1 0 1 0 0 0 0 0 1\n1 0 1 1 0 0 0 0 1\n1 1 0 0 1 0 0 1 0\n1 1 0 1 1 0 0 1 0\n1 1 1 0 0 0 0 0 1\n1 1 1 1 0 0 1 0 0\n\n7(b) One mark for correct answer (terms may be in any order) 1\nZ = A.B.C.D + A.B.C.D + A.B.C.D + A.B.C.D\n© Cambridge University Press & Assessment 2025 Page 8 of 12\n\n7(c) One mark for each mark point 4\n• Correct application of De Morgan’s laws\n• Correct application of Idempotent, Distributive or Absorption laws\n• Correct application of Idempotent, Distributive or Absorption laws\n• Correct final answer\n(A+B).(A.B+B.C)\n(A.B).(A+B+B+C) DeMorgan’s laws\n(A.B).(A+B+C) Idempotent laws\n(A.A+A.B+A.C).(B.A+B.B+B.C) Distributive laws\n(A+A.B+A.C).(A.B+B+B.C) Idempotent laws\n(A+A.C).(B+B.C) Absorption laws\nA.B // A + B Absorption laws / Final Answer\nQuestion Answer Marks",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p08.png",
        "../answer-assets/9618_s25_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q08",
      "question_id": "9618-2025-mj-32-q08",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 8,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "8 One mark per mark point (Max 4) 4\nMP1 It is the first stage of compilation\nMP2 White space and comments are removed\nMP3 It takes modified source code and breaks it into a series of tokens\nMP4 Each token is categorised and assigned types\nMP5 Identifiers are stored in a symbol table\nMP6 If the lexical analyser finds invalid tokens, it generates an error\nMP7 Acceptable data from the lexical analyser passes to the syntax\nanalyser\nQuestion Answer Marks",
      "source_pages": [
        9
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p09.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q09",
      "question_id": "9618-2025-mj-32-q09",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 9,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "9(a) Variables must begin with a letter / not a digit 1\n\n9(b) <operator> ::= + | - | * | / | ^ 1\n\n9(c) One mark per mark point 3\nMP1 Two variable boxes added to diagram\nMP2 One operator box added to diagram and all boxes in correct order\nMP3 Connections, arrows and return loop correctly added and no\nadditional boxes or connections\nexpression\nvariable = variable operator variable\n© Cambridge University Press & Assessment 2025 Page 9 of 12\n\n9(d) Answer must begin with a valid letter. It can then be followed by any number 1\nof valid digits and/or letters, as long as it is at least four characters in length.\nExample answer\nAC768\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p09.png",
        "../answer-assets/9618_s25_ms_32-p10.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q10",
      "question_id": "9618-2025-mj-32-q10",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 10,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "10 One mark for identifying a protocol and one mark for stating its purpose 4\nMP1 Handshake protocol\nMP2 To establish a secure and reliable connection between two devices,\nsystems or networks // Permits the web server and client to authenticate each\nother to make use of encryption algorithms\nMP3 Record protocol\nMP4 Provides a secure and reliable way to send and receive data over a\nnetwork // To exchange records between the client and server // Responsible\nfor securing application data end ensuring its integrity and authenticity during\ntransmission // Encrypts and authenticates data exchanged between a client\nand a server // Deals with the format for data transmission.\nQuestion Answer Marks",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p10.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q11",
      "question_id": "9618-2025-mj-32-q11",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 11,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark per mark point 4\nMP1 Any two nodes added correctly with correct data (Aa, Mm, Ss, Xx)\nMP2 Remaining two nodes added with correct data (Aa, Mm, Ss, Xx) and\nall nodes with connecting arrows starting from correct pointer boxes\nMP3 Correct null pointers (0) added throughout\nMP4 … with no entries in other pointer boxes and all nodes correctly\npositioned and connected.\nRoot pointer\nPp\nGg 0 Rr\n0 Aa 0 0 Kk 0 Ss\n0 Mm 0 0 Xx 0\n© Cambridge University Press & Assessment 2025 Page 10 of 12\n\n11(b) One mark for feature and one mark for example (Max 2) 2\n• Recursion is beneficial for algorithms when a problem naturally breaks\ndown into smaller versions of itself.\n• … such as calculating a factorial / mathematical series / Fibonacci /\ncompound interest / tree traversal / evaluation of RPN expressions.\nQuestion Answer Marks",
      "source_pages": [
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p10.png",
        "../answer-assets/9618_s25_ms_32-p11.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q12",
      "question_id": "9618-2025-mj-32-q12",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 12,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "12(a) One mark per mark point 5\nMP1 Two correct attributes (DateOfBirth : Date) and priority with a\nsensible name and integer data type\nMP2 SetPatientID(…) and SetDoctorID(…) seen\nMP3 … and appropriate parameters, with string data types\nMP4 GetPatientID() and GetDateOfBirth() seen\nMP5 Priority setter and getter fully correct with name matching Priority\nattribute, with appropriate parameter and correct data type.\nPatient\nPatientID : STRING\nName : STRING\nDateOfBirth : DATE\nPriority : INTEGER\nDoctorID : STRING\nSetPatientID(PatientNumber : STRING)\nSetName(FullName : STRING)\nSetDateOfBirth(DOB : DATE)\nSetPriority(Urgency : INTEGER)\nSetDoctorID(DocID : STRING)\nGetPatientID()\nGetName()\nGetDateOfBirth()\nGetPriority()\nGetDoctorID()\n\n12(b)(i) Instance // instantiation 1\n\n12(b)(ii) One mark for each mark point 2\nMP1 Polymorphism is when methods with the same name are redefined /\nbehave differently …\nMP2 … in derived / inherited classes / subclasses\n© Cambridge University Press & Assessment 2025 Page 11 of 12",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p11.png"
      ]
    },
    {
      "id": "9618-2025-mj-32-q13",
      "question_id": "9618-2025-mj-32-q13",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "32",
      "question_number": 13,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "13 One mark for each correctly completed line 5\nDECLARE Grade : StudentResult\nDECLARE Position : INTEGER\nOPENFILE \"CurrentResults.dat\" FOR RANDOM\nOPENFILE \"StoredResults.dat\" FOR RANDOM\nFOR Position  1 TO 50\nSEEK \"CurrentResults.dat\", Position\nGETRECORD \"CurrentResults.dat\", Grade\nIF Grade.ExamGrade = \"\" THEN\nGrade.ExamGrade  \"Missing grade\"\nENDIF\nSEEK \"StoredResults.dat\", Position\nPUTRECORD \"StoredResults.dat\", Grade\nNEXT Position\nCLOSEFILE \"CurrentResults.dat\"\nCLOSEFILE \"StoredResults.dat\"\n© Cambridge University Press & Assessment 2025 Page 12 of 12",
      "source_pages": [
        12
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_32-p12.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q01",
      "question_id": "9618-2025-mj-33-q01",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 1,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a) One mark per mark point 4\nMP1 TYPE VideoLibrary and ENDTYPE correct\nMP2 Declare used correctly for every field in the response\nMP3 All Three STRING fields correct (shaded)\nMP4 Remaining Three fields correct (unshaded)\nExample answer\nTYPE VideoLibrary\nDECLARE VideoID : STRING\nDECLARE Title : STRING\nDECLARE ReleaseYear : INTEGER\nDECLARE PurchaseDate : DATE\nDECLARE VideoFormat : STRING\nDECLARE RunningTime : INTEGER\nENDTYPE\n\n1(b) One mark for identification of field and one mark for reason 2\nVideoFormat\nThis field can have a fixed range of possible values\n© Cambridge University Press & Assessment 2025 Page 6 of 16",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q02",
      "question_id": "9618-2025-mj-33-q02",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 2,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark for two’s complement version and one mark for denary version 2\nMantissa Exponent\n0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1\n127  2120 // 0.9921875 x 2127 // 127/128 x 2127\n\n2(b) One mark per mark point for working (Max 2) 4\n• number converted to binary e.g., positive binary version of 3.59375 = (0)11.10011\n• negative two’s complement version -\nbits flipped and 1 added = 100.01101\n• -4 + 1/4 + 1/8 + 1/32 // -4 + 025 +0.125 + 0.03125 // -(64 + 32 + 16 + 2 + 1)/32\n• -22 + 2-2 + 2-3 + 2-5\n• 22 (- 20 + 2-4 + 2-5 + 2-7)\nOne mark per mark point\n• correct mantissa\n• correct exponent, with working seen.\nMantissa Exponent\n1 0 0 0 1 1 0 1 0 0 0 0 0 0 1 0\nQuestion Answer Marks",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q03",
      "question_id": "9618-2025-mj-33-q03",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 3,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "3(a) Two marks for all six correct terms 2\nOne mark for any four correct terms\nZ = A.B.C.D + A.B.C.D + A.B.C.D + A.B.C.D + A.B.C.D + A.B.C.D\n© Cambridge University Press & Assessment 2025 Page 7 of 16\n\n3(b)(i) Two marks if no errors present 2\nOne mark if one error present\nAB\nCD 00 01 11 10\n00 0 1 1 0\n01 0 0 0 0\n11 1 0 0 1\n10 1 0 0 1\n\n3(b)(ii) One mark for each correct loop (Max 2) 2\nAB\nCD 00 01 11 10\n00 0 1 1 0\n01 0 0 0 0\n11 1 0 0 1\n10 1 0 0 1\n© Cambridge University Press & Assessment 2025 Page 8 of 16\n\n3(b)(iii) One mark for each mark point 2\n• One correct Boolean term\n• Boolean terms and operator correct and no other terms present\nZ = B.C + B.C.D // B.C.D + B.C\nQuestion Answer Marks",
      "source_pages": [
        7,
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p07.png",
        "../answer-assets/9618_s25_ms_33-p08.png",
        "../answer-assets/9618_s25_ms_33-p09.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q04",
      "question_id": "9618-2025-mj-33-q04",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 4,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark per mark point (Max 5) 5\nOne mark per mark point for purpose of Internet Layer (Max 3)\nMP1 To identify the intended network and host.\nMP2 To add header containing IP addresses. // To address packets with their source and destination IP Addresses.\nMP3 To prepare packets for delivery by formatting them into datagrams.\nMP4 To route datagrams through the optimum route over a network.\nOne mark per mark point for purpose of Link Layer (Max 3)\nMP5 To prepare the next hop by managing the link between two directly connected devices. // To identify and move\ntraffic across local segments.\nMP6 To format datagrams into frames for transmission.\nMP7 To identify network protocols in the packet header. // To ensure correct network protocols are/is followed.\nMP8 To deliver frames to the receiving network. // To receive frames from the sending network. // To map IP addresses\nto MAC physical addresses.\nMP9 To provide error checking/error correction/recovery/reconstruction\nMP10 including resend requests.\n\n4(b) One mark for each correct marking point (Max 4) 4\nMP1 The router reads the IP address of the destination from the packet header.\nMP2 A router uses a routing table to find information …\nMP3 … about e.g., available hops / netmask / gateway used / adjacent routers / the status of the routers along the\nroute.\nMP4 The router determines the next hop / optimum route. // The router sends the packet on its next hop.\nMP5 The router manages the hop counter // The hop counter is reduced by 1 every time the packet passes a router.\n© Cambridge University Press & Assessment 2025 Page 9 of 16",
      "source_pages": [
        9
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p09.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q05",
      "question_id": "9618-2025-mj-33-q05",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 5,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "5 One mark per correct answer (Max 4) 4\nOOP Term Purpose\nGetter A method that accesses the value of a property\nSetter A method that changes the value of a property\nObject An instantiation / instance of a class\nMethod A programmed function / procedure / subroutine\n/ subprogram defined as part of a class\nQuestion Answer Marks",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q06",
      "question_id": "9618-2025-mj-33-q06",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 6,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for each mark point (Max 2) 2\n• Process scheduling is required to ensure that all processes are executed in a timely manner\n• … and enables multitasking/multiprogramming/multiprocessing\n• … to minimise CPU idle time\n• … to ensure that no process is starved of resources. // … to ensure fair access to resources.\n• … ensures jobs/processes are completed in order of priority.\n© Cambridge University Press & Assessment 2025 Page 10 of 16\n\n6(b) One mark for each mark point (Max 3) 4\nMP1 Processes are queued as they arrive.\nMP2 It is a pre-emptive scheduling routine.\nMP3 A fixed time quantum is given to each process. // Each process has an equal time slice.\nMP4 When a time slice ends, the status of the process is saved/queued so it can continue from where it left off in its\nnext time slice.\nMP5 and the next process is executed for its time slice; its previous state is reinstated/restored, if applicable.\nMP6 If a process completes within its time slice, the next process is executed for its time slice.\nOne mark for benefit (Max 1)\nMP7 Reduces average response time by limiting each process to a fixed amount of time.\nMP8 No issue with starvation of resources.\nQuestion Answer Marks",
      "source_pages": [
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p10.png",
        "../answer-assets/9618_s25_ms_33-p11.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q07",
      "question_id": "9618-2025-mj-33-q07",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 7,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "7 One mark for each correct marking point (Max 4) 4\nMP1 An SSL/TLS connection is initiated by an application/client.\nMP2 Every new session begins with a handshake as defined by the SSL/TLS protocols.\nMP3 The client requests the digital certificate from the server // The server sends the digital certificate to the client.\nMP4 The client verifies the server’s digital certificate\nMP5 … and obtains the server’s public key.\nMP6 The encryption algorithms are agreed. // The symmetric session keys are generated/defined.\nMP7 A secure session is established between client and server.\nQuestion Answer Marks",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p11.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q08",
      "question_id": "9618-2025-mj-33-q08",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 8,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "8 One mark per mark point (Max 4) 4\nMP1 It is the second stage of compilation // It’s the compilation stage after lexical analysis.\nMP2 It takes input from the lexical analyser in the form of token streams.\nMP3 The source code is analysed / parsed against the rules of the language to detect any errors in the code.\nMP4 The output from this phase is a parse tree.\nMP5 Syntax errors are reported.\n© Cambridge University Press & Assessment 2025 Page 11 of 16",
      "source_pages": [
        11
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p11.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q09",
      "question_id": "9618-2025-mj-33-q09",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 9,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "9(a) The second character must come from either lower or digit. It can’t be upper. 1\n\n9(b) Max 3 3\nOne mark\nMP1 <upper> ::= J | K | L | V | X | Z\nEither: fully written out answer\nMP2 Any two correct options for <passcode>\nMP3 Remaining two options correct for <passcode>\nExample answer\n<passcode> ::=\n<upper><lower><lower><digit>|\n<upper><lower><digit><digit>|\n<upper><digit><digit><digit>|\n<upper><digit><lower><digit>\nOr: answer with interim expression\nMP4 <passcode> ::= <upper><middle><middle><digit>\nMP5 <middle> ::= <lower>|<digit>\n\n9(c) One mark per mark point 2\nMP1 Box for upper in correct place with correct connections\nMP2 Correct repetition arrow for final digit\nlower lower\npasscode\nupper digit digit digit\nupper\n© Cambridge University Press & Assessment 2025 Page 12 of 16",
      "source_pages": [
        12
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p12.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q10",
      "question_id": "9618-2025-mj-33-q10",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 10,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "10(a) To find the path between two points on a graph using the algorithm. 1\n\n10(b) One mark per point (Max 2) 2\nMP1 A* tries to find a better path (between two points) by using a heuristic function // A* finds the adjacent route with the\nshortest path and continues this until the destination is reached\nMP2 … Dijkstra’s just explores all possible routes.\nMP3 The heuristic function on the A* algorithm gives priority to nodes that are supposed to be better than others / less\ncostly than others.\nMP4 Dijkstra’s algorithm cannot work with negative values/weights //A* algorithm can work with negative\nvalues/weights.\n\n10(c) One mark for each mark point (Max 3) 3\nMP1 Unsupervised learning uses algorithms to analyse / cluster\nMP2 … unlabelled data sets\nMP3 They discover hidden patterns / data groupings / clusters without the need for human intervention.\nMP4 It is able to discover similarities and differences in data / information.\n© Cambridge University Press & Assessment 2025 Page 13 of 16",
      "source_pages": [
        13
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p13.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q11",
      "question_id": "9618-2025-mj-33-q11",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 11,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "11 One mark for each correctly completed line 5\nDECLARE Location : INTEGER\nDECLARE NewStock : STRING\nDECLARE CurrentStock : STRING\nDECLARE Stored : BOOLEAN\nDECLARE Max : INTEGER\nMax  100000\nStored  FALSE\nLocation  1\nOPENFILE \"StockList.dat\" FOR RANDOM\nOUTPUT \"Enter the new item you wish to store\"\nINPUT NewStock\nWHILE NOT Stored AND Location <= Max\nSEEK \"StockList.dat\", Location\nGETRECORD \"StockList.dat\", CurrentStock\nIF CurrentStock = \"\" THEN\nPUTRECORD \"StockList.dat\", NewStock\nStored  TRUE\nELSE\nLocation  Location + 1\nENDIF\nENDWHILE\nIF Stored = FALSE THEN\nOUTPUT \"The new stock item has not been stored as the file was full\"\nENDIF\nCLOSEFILE \"StockList.dat\"\n© Cambridge University Press & Assessment 2025 Page 14 of 16",
      "source_pages": [
        14
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p14.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q12",
      "question_id": "9618-2025-mj-33-q12",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 12,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "12(a) One mark for any two correct ADTs (Max 1) 1\n• Binary tree\n• Graph\n• Linked list\n• Queue\n• Stack\n\n12(b) One mark for each marking point (Max 4) 4\nMP1 Temporary assignment of the element being ‘inserted’ before inner loop\nMP2 Appropriate inner loop\nMP3 Check if current DataArray content is > Value\nMP4 Moving data to adjacent element as required\nMP5 Appropriate updating of Position variable\nMP6 Re-insertion of the element outside the inner loop\nExample algorithm\nFOR Index  2 to 1000\nValue  DataArray[Index]\nPosition  Index – 1\nIF DataArray[Position] > Value THEN\nWHILE Position >= 1 AND DataArray[Position] > Value\nDataArray[Position + 1]  DataArray[Position]\nPosition  Position – 1\nENDWHILE\nDataArray[Position + 1]  Value\nENDIF\nNEXT Index\n\n12(c) One mark for each marking point 2\nMP1 The performance of a sorting routine should improve if the data is already partially sorted // The performance of a\nsorting routine is likely to be worse if the data is completely out of order\nMP2 The sort may take longer if the number of items to be sorted is larger // The sort may take less time if the number\nof items to be sorted is fewer.\n© Cambridge University Press & Assessment 2025 Page 15 of 16",
      "source_pages": [
        15
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p15.png"
      ]
    },
    {
      "id": "9618-2025-mj-33-q13",
      "question_id": "9618-2025-mj-33-q13",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 3,
      "variant": "33",
      "question_number": 13,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 114,
      "status": "available",
      "reason": null,
      "text": "13 One mark for each marking point 4\nMP1 Correct Index and Target columns\nMP2 Correct Numbers[5] column\nMP3 Correct Numbers[6] and Numbers[7] columns\nMP4 Correct Numbers[8] column and no incorrect data added to any other of columns [1, 2, 3, 4, 9, 10]\nNumbers\nIndex Target [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]\n1 15 2 3 7 11 15 17 19 23 0 0\n2\n3\n4\n5 17\n6 19\n7 23\n8 0\n9\n© Cambridge University Press & Assessment 2025 Page 16 of 16",
      "source_pages": [
        16
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_33-p16.png"
      ]
    },
    {
      "id": "9618-2025-mj-41-q01",
      "question_id": "9618-2025-mj-41-q01",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 20,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark each 2\n• (global) Declaration of 1D array Queue, 20 elements initialised with –1\n• (global) HeadPointer and TailPointer initialised to –1, NumberItems initialised with 0\n© Cambridge University Press & Assessment 2025 Page 7 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\nQueue = [-1 for x in range(20)]\nHeadPointer = -1\nTailPointer = -1\nNumberItems = 0\nVB.NET\nDim Queue(20) As Integer\nDim HeadPointer As Integer\nDim TailPointer As Integer\nDim NumberItems As Integer\nFor x = 0 To 19\nQueue(x) = -1\nNext\nHeadPointer = -1\nTailPointer = -1\nNumberItems = 0\nJava\npublic static Integer[] Queue = new Integer[20];\npublic static Integer HeadPointer;\npublic static Integer TailPointer;\npublic static Integer NumberItems;\npublic static void main(String args[]){\nfor(Integer X = 0; X < 20; X++){\nQueue[X] = -1;\n}\nHeadPointer = -1;\nTailPointer = -1;\nNumberItems = 0;\n}\n© Cambridge University Press & Assessment 2025 Page 8 of 43\n\n1(b) 1 mark each 6\n• Function header (and close) taking 1 (integer) parameter and returning a Boolean value in all cases\n• Checking if queue is full (NumberItems = 20) and returning FALSE\n• Checking if queue is empty (NumberItems = 0) then and updating TailPointer and HeadPointer appropriately\n• Incrementing TailPointer and NumberItems in appropriate place …\n• … looping back to 0 for TailPointer if at end of structure\n• Storing parameter in Queue[TailPointer] (after increment) and returning TRUE\n© Cambridge University Press & Assessment 2025 Page 9 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef Enqueue(InputData):\nglobal Queue\nglobal HeadPointer\nglobal TailPointer\nglobal NumberItems\nif NumberItems >= 20:\nreturn False\nif TailPointer <= -1:\nTailPointer = 0\nHeadPointer = 0\nQueue[TailPointer] = InputData\nelse:\nTailPointer = TailPointer + 1\nif TailPointer == 20:\nTailPointer = 0\nQueue[TailPointer] = InputData\nNumberItems +=1\nreturn True\nVB.NET\nFunction Enqueue(InputData)\nIf NumberItems >= 20 Then\nReturn False\nEnd If\nIf TailPointer <= -1 Then\nTailPointer = 0\nHeadPointer = 0\nQueue(TailPointer) = InputData\n© Cambridge University Press & Assessment 2025 Page 10 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nElse\nTailPointer = TailPointer + 1\nIf TailPointer = 20 Then\nTailPointer = 0\nEnd If\nQueue(TailPointer) = InputData\nEnd If\nNumberItems = NumberItems + 1\nReturn True\nEnd Function\nJava\npublic static Boolean Enqueue(Integer InputData){\nif(NumberItems >= 20){\nreturn false;\n}\nif(TailPointer <= -1){\nTailPointer = 0;\nHeadPointer = 0;\nQueue[TailPointer] = InputData;\n}else{\nTailPointer++;\nif(TailPointer == 20){\nTailPointer = 0;\n}\nQueue[TailPointer] = InputData;\n}\nNumberItems++;\nreturn true;\n}\n© Cambridge University Press & Assessment 2025 Page 11 of 43\n\n1(c) 1 mark each 3\n• Calling Enqueue() with 1 to 25 (inclusive) in order\n• … storing/using return value in selection …outputting Successful with integer and outputting Unsuccessful with\ninteger correctly\nExample program code:\nPython\nfor X in range(1, 26):\nReturnValue = Enqueue(X)\nif ReturnValue == True:\nprint(x,\"Successful\")\nelse:\nprint(x,\"Unsuccessful\")\nVB.NET\nDim ReturnValue As Boolean\nFor x = 1 To 25\nReturnValue = Enqueue(x)\nIf ReturnValue = True Then\nConsole.WriteLine(x & \"Successful \" )\nElse\nConsole.WriteLine(x & \"Unsuccessful \")\nEnd If\nNext x\nJava\nBoolean ReturnValue;\nfor(Integer X = 1; X < 26; X++){\nReturnValue = Enqueue(X);\nif(ReturnValue == true){\nSystem.out.println(X + \"Successful \");\n}else{\nSystem.out.println(X + \"Unsuccessful \");\n}\n}\n© Cambridge University Press & Assessment 2025 Page 12 of 43\n\n1(d) 1 mark each 6\n• Dequeue() header (and close) and checking if queue is empty (NumberItems = 0) and returning –1\n• Returning data at HeadPointer\n• Incrementing HeadPointer …\n• … and catching if = 20 to return to 0\n• Decrementing NumberItems\n• Resetting HeadPointer and TailPointer when queue is empty\n© Cambridge University Press & Assessment 2025 Page 13 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef Dequeue():\nglobal Queue\nglobal HeadPointer\nglobal TailPointer\nglobal NumberItems\nif NumberItems <= 0:\nreturn -1\nelse:\nReturnValue = Queue[HeadPointer]\nHeadPointer +=1\nif HeadPointer >= 20:\nHeadPointer = 0\nNumberItems -=1\nif NumberItems == 0:\nHeadPointer = -1\nTailPointer = -1\nreturn ReturnValue\nVB.NET\nFunction Dequeue()\nDim ReturnValue As Integer\nIf NumberItems <= 0 Then\nReturn -1\nElse\nReturnValue = Queue(HeadPointer)\nHeadPointer = HeadPointer + 1\nIf HeadPointer >= 20 Then\nHeadPointer = 0\nEnd If\nNumberItems = NumberItems – 1\nIf NumberItems = 0 Then\nHeadPointer = -1\nTailPointer = -1\n© Cambridge University Press & Assessment 2025 Page 14 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nEnd If\nReturn ReturnValue\nEnd If\nEnd Function\nJava\npublic static Integer Dequeue(){\nInteger ReturnValue;\nif(NumberItems <= 0){\nreturn -1;\n}else{\nReturnValue = Queue[HeadPointer];\nHeadPointer++;\nif(HeadPointer >= 20){\nHeadPointer = 0;\n}\nNumberItems--;\nif(NumberItems == 0){\nHeadPointer = -1;\nTailPointer = -1;\n}\nreturn ReturnValue;\n}\n}\n© Cambridge University Press & Assessment 2025 Page 15 of 43\n\n1(e)(i) 1 mark each 2\n• Calling Dequeue() twice\n• … outputting return value from both calls\nExample program code:\nPython\nNextValue = Dequeue()\nprint(NextValue)\nNextValue = Dequeue()\nprint(NextValue)\nVB.NET\nDim NextValue As Integer\nNextValue = Dequeue()\nConsole.WriteLine(NextValue)\nNextValue = Dequeue()\nConsole.WriteLine(NextValue)\nJava\nSystem.out.println(Dequeue());\nSystem.out.println(Dequeue());\n\n1(e)(ii) 1 mark for output showing: 1\n• 1 to 20 with Successful\n21 to 25 with Unsuccessful\n\n1 and 2 output\n© Cambridge University Press & Assessment 2025 Page 16 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\ne.g.\n© Cambridge University Press & Assessment 2025 Page 17 of 43",
      "source_pages": [
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_41-p07.png",
        "../answer-assets/9618_s25_ms_41-p08.png",
        "../answer-assets/9618_s25_ms_41-p09.png",
        "../answer-assets/9618_s25_ms_41-p10.png",
        "../answer-assets/9618_s25_ms_41-p11.png",
        "../answer-assets/9618_s25_ms_41-p12.png",
        "../answer-assets/9618_s25_ms_41-p13.png",
        "../answer-assets/9618_s25_ms_41-p14.png",
        "../answer-assets/9618_s25_ms_41-p15.png",
        "../answer-assets/9618_s25_ms_41-p16.png",
        "../answer-assets/9618_s25_ms_41-p17.png"
      ]
    },
    {
      "id": "9618-2025-mj-41-q02",
      "question_id": "9618-2025-mj-41-q02",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 25,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark each to max 7 7\n• Function header (and end)\n• Prompt to enter filename and reading input\n• Opening the file (to read) and closing the file in an appropriate place\n• Looping until EOF …\n• … reading each line in the file …\n• … (removing line break and) inserting in array\n• Returning populated array\n• Exception handling try catch with appropriate output\n© Cambridge University Press & Assessment 2025 Page 18 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef ReadData():\nDataList = []\nFileName = input(\"Enter the filename\")\ntry:\nFile = open(FileName)\nfor Line in File:\nDataList.append(Line)\nFile.close()\nexcept:\nprint(\"Cannot open file\")\nreturn DataList\nVB.NET\nFunction ReadData()\nDim DataList(100) As String\nConsole.WriteLine(\"Enter the filename\")\nDim FileName As String = Console.ReadLine()\nNumberItems = 0\nTry\nDim FileReader As New System.IO.StreamReader(FileName)\nWhile Not FileReader.EndOfStream\nDataList(NumberItems) = FileReader.ReadLine()\nNumberItems = NumberItems + 1\nEnd While\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Cannot open or read from file\")\nEnd Try\nReturn DataList\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 19 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nJava\npublic static String[] ReadData(){\nString[] DataList = new String[100];\nSystem.out.println(\"Enter the filename\");\nScanner scanner = new Scanner(System.in);\nString FileName = scanner.nextLine();\nNumberItems = 0;\ntry{\nFileReader f = new FileReader(FileName);\ntry{\nBufferedReader Reader = new BufferedReader(f);\nString Line = Reader.readLine();\nLine = Line.replace(\"\\n\",\"\");\nwhile (Line != null){\nDataList[NumberItems] = Line;\nNumberItems++;\nLine = Reader.readLine();\nif(Line != null){\nLine = Line.replace(\"\\n\",\"\");\n}\n}\nReader.close();\n}catch(IOException ex){\n}\n}catch(FileNotFoundException e){\nSystem.out.println(\"File not found\");\n}\nreturn DataList;\n}\n© Cambridge University Press & Assessment 2025 Page 20 of 43\n\n2(b) 1 mark each 6\n• Procedure header (and end) taking (1D array) DataArray (of strings) as a parameter\n• Declaration/use of 6 1D arrays (equivalent), one for each colour\n• Looping through each line in parameter DataArray …\n• … splitting by comma\n• Comparing 2nd value/colour to each colour to select array …\n• … storing 1st value/integer in correct array\n© Cambridge University Press & Assessment 2025 Page 21 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef SplitData(DataArray):\nRed = []\nGreen = []\nBlue = []\nOrange = []\nYellow = []\nPink = []\nfor Line in DataArray:\nSplitLine = Line.split(\",\")\nif SplitLine[1].strip() == \"red\":\nRed.append(SplitLine[0])\nelif SplitLine[1].strip() == \"green\":\nGreen.append(SplitLine[0])\nelif SplitLine[1].strip() == \"blue\":\nBlue.append(SplitLine[0])\nelif SplitLine[1].strip() == \"orange\":\nOrange.append(SplitLine[0])\nelif SplitLine[1].strip() == \"yellow\":\nYellow.append(SplitLine[0])\nelse:\nPink.append(SplitLine[0])\nVB.NET\nSub SplitData(DataArray())\nDim Red(30) As String\nDim Green(30) As String\nDim Blue(30) As String\nDim Orange(30) As String\nDim Yellow(30) As String\nDim Pink(30) As String\n© Cambridge University Press & Assessment 2025 Page 22 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nDim RedNumber As Integer = 0\nDim GreenNumber As Integer = 0\nDim BlueNumber As Integer = 0\nDim OrangeNumber As Integer = 0\nDim YellowNumber As Integer = 0\nDim PinkNumber As Integer = 0\nDim x As Integer = 0\nDim TempDataFromFile(1) As String\nDim DataList(100, 1) As String\nFor x = 0 To NumberItems - 1\nTempDataFromFile = (DataArray(x)).Split(\",\")\nDataList(x, 0) = TempDataFromFile(0)\nDataList(x, 1) = TempDataFromFile(1)\nNext x\nx = 0\nWhile DataList(x, 0) IsNot Nothing\nIf DataList(x, 1) = \"red\" Then\nRed(RedNumber) = DataList(x, 0)\nRedNumber = RedNumber + 1\nElseIf DataList(x, 1) = \"green\" Then\nGreen(GreenNumber) = DataList(x, 0)\nGreenNumber = GreenNumber + 1\nElseIf DataList(x, 1) = \"blue\" Then\nBlue(BlueNumber) = DataList(x, 0)\nBlueNumber = BlueNumber + 1\nElseIf DataList(x, 1) = \"orange\" Then\nOrange(OrangeNumber) = DataList(x, 0)\nOrangeNumber = OrangeNumber + 1\nElseIf DataList(x, 1) = \"yellow\" Then\nYellow(YellowNumber) = DataList(x, 0)\nYellowNumber = YellowNumber + 1\nElseIf DataList(x, 1) = \"pink\" Then\nPink(PinkNumber) = DataList(x, 0)\nPinkNumber = PinkNumber + 1\nEnd If\n© Cambridge University Press & Assessment 2025 Page 23 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nx = x + 1\nEnd While\nEnd Sub\nJava\npublic static void SplitData(String[] DataArray){\nString[] Red = new String[30];\nString[] Green = new String[30];\nString[] Blue = new String[30];\nString[] Orange = new String[30];\nString[] Yellow = new String[30];\nString[] Pink = new String[30];\nInteger RedNumber = 0;\nInteger GreenNumber = 0;\nInteger BlueNumber = 0;\nInteger OrangeNumber = 0;\nInteger YellowNumber = 0;\nInteger PinkNumber = 0;\nInteger x = 0;\nString[] TempDataFromFile;\nString[][] DataList = new String[100][2];\nfor(x = 0; x < 72; x++){\nTempDataFromFile = DataArray[x].split(\",\");\nDataList[x][0] = TempDataFromFile[0];\nDataList[x][1] = TempDataFromFile[1];\n}\nx = 0;\nwhile(DataList[x][0] != null){\nif (DataList[x][1].compareTo(\"red\") == 0) {\nRed[RedNumber] = DataList[x][0];\nRedNumber = RedNumber + 1;\n}else if (DataList[x][1].compareTo(\"green\") == 0) {\nGreen[GreenNumber] = DataList[x][0];\nGreenNumber = GreenNumber + 1;\n© Cambridge University Press & Assessment 2025 Page 24 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\n}else if (DataList[x][1].compareTo(\"blue\") == 0) {\nBlue[BlueNumber] = DataList[x][0];\nBlueNumber = BlueNumber + 1;\n}else if (DataList[x][1].compareTo(\"orange\") == 0) {\nOrange[OrangeNumber] = DataList[x][0];\nOrangeNumber = OrangeNumber + 1;\n}else if (DataList[x][1].compareTo(\"yellow\") == 0) {\nYellow[YellowNumber] = DataList[x][0];\nYellowNumber = YellowNumber + 1;\n}else if (DataList[x][1].compareTo(\"pink\") == 0) {\nPink[PinkNumber] = DataList[x][0];\nPinkNumber = PinkNumber + 1;\n}\nx = x + 1;\n}\n}\n© Cambridge University Press & Assessment 2025 Page 25 of 43\n\n2(c) 1 mark each 5\n• Procedure header taking (1D) array and filename as parameters, opening file to append and closing file (in appropriate\nplace)\n• Looping through each item in array parameter …\n• … writing to the file\n• … with new line break between each line\n• Using exception handling try and catch with suitable output\nExample program code:\nPython\ndef StoreData(DataToStore, FileName):\ntry:\nFile = open(FileName,\"a+\")\nfor Item in DataToStore:\nFile.write(Item)\nFile.write(\"\\n\")\nFile.close()\nexcept:\nprint(\"Cannot create or write to file\")\nVB.NET\nSub StoreData(DataToStore(), FileName)\nDim FileWriter As IO.StreamWriter = New IO.StreamWriter(FileName, False)\nDim x As Integer = 0\nTry\nWhile DataToStore(x) IsNot Nothing\nFileWriter.WriteLine(DataToStore(x))\nx = x + 1\nEnd While\nFileWriter.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Cannot open or write to file\")\nEnd Try\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 26 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nJava\npublic static void StoreData(String[] DataToStore, String FileName){\nFile TheFile = new File(FileName);\ntry{\nFileWriter FW = new FileWriter(TheFile, true);\nInteger X = 0;\nwhile(DataToStore[X] != null){\nFW.write(DataToStore[X]);\nX++;\nFW.write(\"\\n\");\n}\nFW.close();\n}catch(IOException ex){\nSystem.out.println(\"Cannot open or write to file\");\n}\n}\n© Cambridge University Press & Assessment 2025 Page 27 of 43\n\n2(d) 1 mark each 2\n• Calling StoreData with one array and filename\n• Calling StoreData with remaining 5 arrays and filename\nExample program code:\nPython\nStoreData(Red, \"Red.txt\")\nStoreData(Green, \"Green.txt\")\nStoreData(Blue, \"Blue.txt\")\nStoreData(Orange, \"Orange.txt\")\nStoreData(Yellow, \"Yellow.txt\")\nStoreData(Pink, \"Pink.txt\")\nVB.NET\nStoreData(Red, \"Red.txt\")\nStoreData(Green, \"Green.txt\")\nStoreData(Blue, \"Blue.txt\")\nStoreData(Orange, \"Orange.txt\")\nStoreData(Yellow, \"Yellow.txt\")\nStoreData(Pink, \"Pink.txt\")\nJava\nStoreData(Red, \"Red.txt\");\nStoreData(Green, \"Green.txt\");\nStoreData(Blue, \"Blue.txt\");\nStoreData(Orange, \"Orange.txt\");\nStoreData(Yellow, \"Yellow.txt\");\nStoreData(Pink, \"Pink.txt\");\n© Cambridge University Press & Assessment 2025 Page 28 of 43\n\n2(e)(i) 1 mark each 3\n• Calling ReadData() …\n• … and storing/using return value\n• Calling SplitData() with returned array as a parameter\nExample program code:\nPython\nDataFromFile = ReadData()\nSplitData(DataFromFile)\nVB.NET\nSub Main(args As String())\nDim DataFromFile(,) As String = ReadData()\nSplitData(DataFromFile)\nEnd Sub\nJava\npublic static void main(String args[]){\nString[][] DataFromFile = ReadData();\nSplitData(DataFromFile);\n}\n\n2(e)(ii) 1 mark screenshots showing 2\n• Prompt and input of filename TheData.txt\n• Screenshot of data in red file. Filename must be shown in same screenshot as data\n© Cambridge University Press & Assessment 2025 Page 29 of 43",
      "source_pages": [
        18,
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_41-p18.png",
        "../answer-assets/9618_s25_ms_41-p19.png",
        "../answer-assets/9618_s25_ms_41-p20.png",
        "../answer-assets/9618_s25_ms_41-p21.png",
        "../answer-assets/9618_s25_ms_41-p22.png",
        "../answer-assets/9618_s25_ms_41-p23.png",
        "../answer-assets/9618_s25_ms_41-p24.png",
        "../answer-assets/9618_s25_ms_41-p25.png",
        "../answer-assets/9618_s25_ms_41-p26.png",
        "../answer-assets/9618_s25_ms_41-p27.png",
        "../answer-assets/9618_s25_ms_41-p28.png",
        "../answer-assets/9618_s25_ms_41-p29.png"
      ]
    },
    {
      "id": "9618-2025-mj-41-q03",
      "question_id": "9618-2025-mj-41-q03",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "41",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 30,
      "status": "available",
      "reason": null,
      "text": "3(a)(i) 1 mark each 4\n• Class header (and end where appropriate)\n• Constructor header (and end where appropriate) with (min) one parameter (integer) within class\n• 3 attributes with correct data types\n• NodeData has parameter assigned, LeftNode and RightNode are assigned null within constructor\n© Cambridge University Press & Assessment 2025 Page 30 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\nclass Node:\ndef init (self, pNodeData):\nself. NodeData = pNodeData #integer\nself. LeftNode = None #node\nself. RightNode = None #node\nVB.NET\nClass Node\nPrivate NodeData As Integer\nPrivate LeftNode As Node\nPrivate RightNode As Node\nSub New(pNodeData)\nNodeData = pNodeData\nLeftNode = Nothing\nRightNode = Nothing\nEnd Sub\nEnd Class\nJava\nclass Node{\npublic Integer NodeData;\npublic Node LeftNode;\npublic Node RightNode;\npublic Node(Integer pNodeData){\nNodeData = pNodeData;\nLeftNode = null;\nRightNode = null;\n}\n}\n© Cambridge University Press & Assessment 2025 Page 31 of 43\n\n3(a)(ii) 1 mark each 3\n• 1 get method with no parameter …\n• … returning correct value\n• 2nd and 3rd correct get methods\nExample program code:\nPython\ndef GetLeft(self):\nreturn self. LeftNode\ndef GetRight(self):\nreturn self. RightNode\ndef GetData(self):\nreturn self. NodeData\nVB.NET\nFunction GetLeft()\nReturn LeftNode\nEnd Function\nFunction GetRight()\nReturn RightNode\nEnd Function\nFunction GetData()\nReturn NodeData\nEnd Function\nJava\npublic Integer GetData(){\nreturn NodeData;\n}\npublic Node GetLeft(){\nreturn LeftNode;\n}\npublic Node GetRight(){\nreturn RightNode;\n}\n© Cambridge University Press & Assessment 2025 Page 32 of 43\n\n3(a)(iii) 1 mark each 3\n• 1 set method taking parameter of type Node …\n• … assigning to correct attribute\n• 2nd correct set method\nExample program code:\nPython\ndef SetLeft(self, NewNode):\nself. LeftNode = NewNode\ndef SetRight(self, NewNode):\nself. RightNode = NewNode\nVB.NET\nSub SetLeft(NewNode)\nLeftNode = NewNode\nEnd Sub\nSub SetRight(NewNode)\nRightNode = NewNode\nEnd Sub\nJava\npublic void SetLeft(Node NewNode){\nLeftNode = NewNode;\n}\npublic void SetRight(Node NewNode){\nRightNode = NewNode;\n}\n© Cambridge University Press & Assessment 2025 Page 33 of 43\n\n3(b) 1 mark each 2\n• Creating 1 instance of Node with a correct value and storing the node …\n• … remaining 4 correct\nExample program code:\nPython\nFirstNode = Node(10)\nSecondNode = Node(20)\nThirdNode = Node(5)\nFourthNode = Node(15)\nFifthNode = Node(7)\nVB.NET\nDim FirstNode As Node = New Node(10)\nDim SecondNode As Node = New Node(20)\nDim ThirdNode As Node = New Node(5)\nDim FourthNode As Node = New Node(15)\nDim FifthNode As Node = New Node(7)\nJava\nNode FirstNode = new Node(10);\nNode SecondNode = new Node(20);\nNode ThirdNode = new Node(5);\nNode FourthNode = new Node(15);\nNode FifthNode = new Node(7);\n© Cambridge University Press & Assessment 2025 Page 34 of 43\n\n3(c)(i) 1 mark each 2\n• Class Tree header (and end) no inheritance and constructor header (and end) taking 1 node parameter within class …\n• … storing parameter in FirstNode declared as a Node data type\nExample program code:\nPython\nclass Tree:\ndef init (self, FirstNode):\nself. FirstNode = FirstNode #node\nVB.NET\nClass Tree\nPrivate FirstNode As Node\nSub New(pFirstNode)\nFirstNode = pFirstNode\nEnd Sub\nEnd Class\nJava\nclass Tree{\nprivate Node FirstNode;\npublic Tree(Node pFirstNode){\nFirstNode = pFirstNode;\n}\n}\n© Cambridge University Press & Assessment 2025 Page 35 of 43\n\n3(c)(ii) 1 mark for 1\n• Get method header (and end) with no parameter, returning FirstNode\nExample program code:\nPython\ndef GetRootNode(self):\nreturn self. FirstNode\nVB.NET\nFunction GetRootNode()\nReturn FirstNode\nEnd Function\nJava\npublic Node GetRootNode(){\nreturn FirstNode;\n}\n© Cambridge University Press & Assessment 2025 Page 36 of 43\n\n3(c)(iii) 1 mark each to max 6 6\n• Insert method header (and end) taking 1 node parameter\n• If parameter < first node, checking if there is a left node …\n• … storing node in left node if it is null\n• If parameter >= first node, checking if there is a right node …\n• … storing node in right node if it is null\n• Looping until correct position is found // recursive calls\n© Cambridge University Press & Assessment 2025 Page 37 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef Insert(self, NewNode):\nCurrentNode = self. FirstNode\nInserted = True\nwhile Inserted:\nif NewNode.GetData() < CurrentNode.GetData():\nif CurrentNode.GetLeft() == None:\nCurrentNode.SetLeft(NewNode)\nreturn True\nelse:\nCurrentNode = CurrentNode.GetLeft()\nelse:\nif CurrentNode.GetRight() == None:\nCurrentNode.SetRight(NewNode)\nreturn True\nelse:\nCurrentNode = CurrentNode.GetRight()\nVB.NET\nFunction Insert(NewNode)\nDim CurrentNode As Node\nCurrentNode = FirstNode\nDim Inserted As Boolean = True\nWhile Inserted\nIf NewNode.GetData() < CurrentNode.GetData() Then\nIf CurrentNode.GetLeft() Is Nothing Then\nCurrentNode.SetLeft(NewNode)\nReturn True\nElse\nCurrentNode = CurrentNode.GetLeft()\nEnd If\n© Cambridge University Press & Assessment 2025 Page 38 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nElse\nIf CurrentNode.GetRight() Is Nothing Then\nCurrentNode.SetRight(NewNode)\nReturn True\nElse\nCurrentNode = CurrentNode.GetRight()\nEnd If\nEnd If\nEnd While\nEnd Function\nJava\npublic Boolean Insert(Node NewNode){\nNode CurrentNode = FirstNode;\nBoolean Inserted = true;\nwhile(Inserted){\nif(NewNode.GetData() < CurrentNode.GetData()){\nif(CurrentNode.GetLeft() == null){\nCurrentNode.SetLeft(NewNode);\nreturn true;\n}else{\nCurrentNode = CurrentNode.GetLeft();\n}\n}else{\nif(CurrentNode.GetRight() == null){\nCurrentNode.SetRight(NewNode);\nreturn true;\n}else{\nCurrentNode = CurrentNode.GetRight();\n}\n}\n}\nreturn false;\n}\n© Cambridge University Press & Assessment 2025 Page 39 of 43\n\n3(d) 1 mark each 5\n• Procedure header (and end) taking node as parameter, that is recursive\n• Checking if left is null and recursive call if not null\n• Outputting node's data\n• Checking if right is null and recursive call if not null\n• Correct order\n© Cambridge University Press & Assessment 2025 Page 40 of 43\n\n3(e)(i) 1 mark each 3\n• Creation of Tree object with the Node with value 10 as parameter\n• Calling method Insert() for tree with the nodes for 20, 5, 15 and 7 in order\n• Calling OutputInOrder() with tree's root node as parameter\n© Cambridge University Press & Assessment 2025 Page 41 of 43\n\n9618/41 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\nFirstNode = Node(10)\nSecondNode = Node(20)\nThirdNode = Node(5)\nFourthNode = Node(15)\nFifthNode = Node(7)\nMyTree = Tree(FirstNode)\nMyTree.Insert(SecondNode)\nMyTree.Insert(ThirdNode)\nMyTree.Insert(FourthNode)\nMyTree.Insert(FifthNode)\nOutputInOrder(MyTree.GetRootNode())\nVB.NET\nSub Main(args As String())\nDim FirstNode As Node = New Node(10)\nDim SecondNode As Node = New Node(20)\nDim ThirdNode As Node = New Node(5)\nDim FourthNode As Node = New Node(15)\nDim FifthNode As Node = New Node(7)\nDim MyTree As Tree = New Tree(FirstNode)\nMyTree.Insert(SecondNode)\nMyTree.Insert(ThirdNode)\nMyTree.Insert(FourthNode)\nMyTree.Insert(FifthNode)\nOutputInOrder(MyTree.GetRootNode())\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 42 of 43\n\n3(e)(ii) Output of 1\n5\n7\n10\n15\n20\n© Cambridge University Press & Assessment 2025 Page 43 of 43",
      "source_pages": [
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37,
        38,
        39,
        40,
        41,
        42,
        43
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_41-p30.png",
        "../answer-assets/9618_s25_ms_41-p31.png",
        "../answer-assets/9618_s25_ms_41-p32.png",
        "../answer-assets/9618_s25_ms_41-p33.png",
        "../answer-assets/9618_s25_ms_41-p34.png",
        "../answer-assets/9618_s25_ms_41-p35.png",
        "../answer-assets/9618_s25_ms_41-p36.png",
        "../answer-assets/9618_s25_ms_41-p37.png",
        "../answer-assets/9618_s25_ms_41-p38.png",
        "../answer-assets/9618_s25_ms_41-p39.png",
        "../answer-assets/9618_s25_ms_41-p40.png",
        "../answer-assets/9618_s25_ms_41-p41.png",
        "../answer-assets/9618_s25_ms_41-p42.png",
        "../answer-assets/9618_s25_ms_41-p43.png"
      ]
    },
    {
      "id": "9618-2025-mj-42-q01",
      "question_id": "9618-2025-mj-42-q01",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 27,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark each 2\n• (Global) Stack as 1D array (of strings) with 20 elements initialised to string \"–1\"\n• (Global) TopOfStack initialised to –1\nExample program code:\nJava\npublic static String[] Stack = new String[20];\npublic static Integer TopOfStack;\npublic static void main(String args[]){\nfor(Integer X = 0; X < 20; X++){\nStack[X] = \"-1\";\n}\nTopOfStack = -1;\n}\nVB.NET\nDim Stack(19) As String\nDim TopOfStack As Integer\nFor x = 0 To 19\nStack(x) = \"-1\"\nNext\nTopOfStack = -1\nPython\nStack = []\nTopOfStack = -1\n#main\nfor x in range(20):\nStack.append(\"-1\")\n© Cambridge University Press & Assessment 2025 Page 7 of 45\n\n1(b) 1 mark each 4\n• Push function header (and end where appropriate) taking one (string) parameter\n• Checking if stack is full and returning integer –1\n• (Otherwise) Incrementing TopOfStack\n• Storing parameter in the incremented the stack at TopOfStack and returning integer 1\nExample program code:\nJava\npublic static Integer Push(String Data){\nif (TopOfStack == 19){\nreturn -1;\n}else{\nTopOfStack++;\nStack[TopOfStack] = Data;\nreturn 1;\n}\n}\nVB.NET\nFunction Push(ByVal Data)\nIf TopOfStack = 19 Then\nReturn -1\nElse\nTopOfStack = TopOfStack + 1\nStack(TopOfStack) = Data\nReturn 1\nEnd If\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 8 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nPython\ndef Push(Data):\nglobal Stack\nglobal TopOfStack\nif TopOfStack == 19:\nreturn -1\nelse:\nTopOfStack += 1\nStack[TopOfStack] = Data\nreturn 1\n© Cambridge University Press & Assessment 2025 Page 9 of 45\n\n1(c) 1 mark each 4\n• Function header (and end where appropriate) and returning a value in all cases.\n• Checking if stack is empty and returning string \"–1\"\n• (Otherwise) Decrementing TopOfStack\n• Returning element in stack at TopOfStack before TopOfStack is decremented\nExample program code:\nJava\npublic static String Pop(){\nif (TopOfStack == -1){\nreturn \"-1\";\n}else{\nString ReturnValue = Stack[TopOfStack];\nTopOfStack--;\nreturn ReturnValue;\n}\n}\nVB.NET\nFunction Pop()\nIf TopOfStack = -1 Then\nPop = \"-1\"\nElse\nPop = Stack(TopOfStack)\nTopOfStack = TopOfStack - 1\nEnd If\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 10 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nPython\ndef Pop():\nglobal Stack\nglobal TopOfStack\nif TopOfStack == -1:\nreturn \"-1\"\nelse:\nReturnValue = Stack[TopOfStack]\nTopOfStack -= 1\nreturn ReturnValue\n© Cambridge University Press & Assessment 2025 Page 11 of 45\n\n1(d) 1 mark each 6\n• Procedure header (and end where appropriate) taking one (string) parameter\n• Opening the file with the filename parameter and closing the file in an appropriate place\n• Looping through to end of file and reading in each line ...\n• … calling Push() once with each read in value …\n• … if any return value from Push() is integer –1 outputting \"Stack full\"\n• Exception handling for opening and reading from file with appropriate catch and output\nExample program code:\nJava\npublic static void ReadData(String FileName){\nInteger ReturnValue;\ntry{\nFileReader f = new FileReader(FileName);\ntry{\nBufferedReader Reader = new BufferedReader(f);\nString Line= Reader.readLine();\nLine = Line.replace(\"\\n\",\"\");\nwhile (Line != null){\nLine = Line.replace(\"\\n\",\"\");\nReturnValue = Push(Line);\nif (ReturnValue == -1){\nSystem.out.println(\"Stack full\");\n}\nLine = Reader.readLine();\n}\nReader.close();\n}catch(IOException ex){}\n}catch(FileNotFoundException e){\nSystem.out.println(\"File not found\");\n}\n}\n© Cambridge University Press & Assessment 2025 Page 12 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nVB.NET\nSub ReadData(ByVal FileName As String)\nDim ReturnValue As String\nTry\nDim FileReader As New System.IO.StreamReader(FileName)\nWhile Not FileReader.EndOfStream\nReturnValue = Push(FileReader.ReadLine())\nIf ReturnValue = \"-1\" Then\nConsole.WriteLine(\"Stack full\")\nEnd If\nEnd While\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Cannot open file\")\nEnd Try\nEnd Sub\nPython\ndef ReadData(FileName):\nglobal Stack\nglobal TopOfStack\ntry:\nFile = open(FileName)\nfor Line in File:\nReturnValue = Push(Line.strip())\nif ReturnValue == -1:\nprint(\"Stack full\")\nFile.close()\nexcept:\nprint(\"Cannot open file\")\n© Cambridge University Press & Assessment 2025 Page 13 of 45\n\n1(e) 1 mark for: 7\n• Calculate() function header (and end where appropriate)\n• Looping until the stack is empty\n• Calling Pop() repeatedly within loop and storing/using return value\n• … working out if return value from Pop() call is an operator or a number / alternating between operator and number\n• Select to determine if the operator is +, -, /, * or ^ and attempt the matching calculation\n• … performing correct calculation using operator, number\n• … updating total from previous loops and returning this final value\nExample program code:\nJava\npublic static Double Calculate(){\nDouble Total = Double.parseDouble(Pop());\nString ReturnValue = \"\";\nString LastOperator = \"\";\nBoolean OperatorFlag = true;\nInteger TheData = 0;\nwhile(ReturnValue != \"-1\"){\nReturnValue = Pop();\nif(OperatorFlag == false){\nTheData = Integer.parseInt(ReturnValue);\nif(LastOperator.compareTo(\"+\")==0){\nTotal = Total + TheData;\n}else if(LastOperator.compareTo(\"-\")==0){\nTotal = Total - TheData;\n}else if(LastOperator.compareTo(\"*\")==0){\nTotal = Total * TheData;\n}else if(LastOperator.compareTo(\"/\")==0){\nTotal = Total / TheData;\n}else if(LastOperator.compareTo(\"^\")==0){\nTotal = Math.pow(Total, TheData);\n}\nOperatorFlag = true;\n© Cambridge University Press & Assessment 2025 Page 14 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\n}else{\nLastOperator = ReturnValue;\nOperatorFlag = false;\n}\n}\nreturn Total;\n}\nVB.NET\nFunction Calculate()\nDim Total As Integer = Pop()\nDim ReturnValue As String = \"\"\nDim LastOperator As String = \"\"\nDim OperatorFlag As Boolean = True\nDim TheData As Integer = 0\nWhile (ReturnValue <> \"-1\")\nReturnValue = Pop()\nSelect Case OperatorFlag\nCase False\nTheData = ReturnValue\nSelect Case LastOperator\nCase \"+\"\nTotal = Total + TheData\nCase \"-\"\nTotal = Total - TheData\nCase \"*\"\nTotal = Total * TheData\nCase \"/\"\nTotal = Total / TheData\nCase \"^\"\nTotal = Total ^ TheData\nEnd Select\nOperatorFlag = True\nCase Else\nLastOperator = ReturnValue\n© Cambridge University Press & Assessment 2025 Page 15 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nOperatorFlag = False\nEnd Select\nEnd While\nReturn Total\nEnd Function\nPython\ndef Calculate():\nglobal Stack\nglobal TopOfStack\nTotal = Pop()\nTotal = int(Total)\nReturn = 0\nLastOperator = \"\"\nOperator = True\nwhile(Return != \"-1\"):\nReturn = Pop()\nif Operator == False:\nData = int(Return)\nif LastOperator == \"+\":\nTotal = Total + Data\nelif LastOperator == \"-\":\nTotal = Total - Data\nelif LastOperator == \"*\":\nTotal = Total * Data\nelif LastOperator == \"/\":\nTotal = Total / Data\nelif LastOperator == \"^\":\nTotal = Total ** Data\nOperator = True\nelse:\nLastOperator = Return\nOperator = False\nreturn Total\n© Cambridge University Press & Assessment 2025 Page 16 of 45\n\n1(f)(i) 1 mark each 2\n• Taking a filename as input and calling ReadData() with input\n• Calling Calculate() and outputting the return value\nExample program code:\nJava\nTopOfStack = -1;\nSystem.out.println(\"Enter the filename\");\nScanner scanner = new Scanner(System.in);\nString FileName = scanner.nextLine();\nReadData(FileName);\nDouble ReturnValue = Calculate();\nSystem.out.println(ReturnValue);\nVB.NET\nConsole.WriteLine(\"Enter the filename\")\nDim FileName As String = Console.ReadLine()\nReadData(FileName)\nDim ReturnValue As Single\nReturnValue = Calculate()\nConsole.WriteLine(ReturnValue)\nPython\nFileName = input(\"Enter the filename: \")\nReadData(FileName)\nReturnValue = Calculate()\nprint(ReturnValue)\n© Cambridge University Press & Assessment 2025 Page 17 of 45\n\n1(f)(ii) 1 mark for screenshot showing input of StackData.txt and output of 131 2\n\n1 mark for screenshot showing input of SecondStack.txt and output of 320\ne.g.\n© Cambridge University Press & Assessment 2025 Page 18 of 45",
      "source_pages": [
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_42-p07.png",
        "../answer-assets/9618_s25_ms_42-p08.png",
        "../answer-assets/9618_s25_ms_42-p09.png",
        "../answer-assets/9618_s25_ms_42-p10.png",
        "../answer-assets/9618_s25_ms_42-p11.png",
        "../answer-assets/9618_s25_ms_42-p12.png",
        "../answer-assets/9618_s25_ms_42-p13.png",
        "../answer-assets/9618_s25_ms_42-p14.png",
        "../answer-assets/9618_s25_ms_42-p15.png",
        "../answer-assets/9618_s25_ms_42-p16.png",
        "../answer-assets/9618_s25_ms_42-p17.png",
        "../answer-assets/9618_s25_ms_42-p18.png"
      ]
    },
    {
      "id": "9618-2025-mj-42-q02",
      "question_id": "9618-2025-mj-42-q02",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 22,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark each 2\n• Record/class NewRecord declared\n• 3 variables within structure (all integer)\nExample program code:\nJava\nclass NewRecord{\nprivate Integer Key;\nprivate Integer Item1;\nprivate Integer Item2;\npublic NewRecord(Integer pKey, Integer pItem1, Integer pItem2){\nKey = pKey;\nItem1 = pItem1;\nItem2 = pItem2;\n}\npublic Integer GetKey(){\nreturn Key;\n}\npublic Integer GetItem1(){\nreturn Item1;\n}\npublic Integer GetItem2(){\nreturn Item2;\n}}\nVB.NET\nStructure NewRecord\nDim Key As Integer\nDim Item1 As Integer\nDim Item2 As Integer\nEnd Structure\n© Cambridge University Press & Assessment 2025 Page 19 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nPython\nclass Record:\ndef __init__(self, pKey, pItem1, pItem2):\nself.__Key = pKey #integer\nself.__Item1 = pItem1 #integer\nself.__Item2 = pItem2 #integer\ndef GetKey(self):\nreturn self.__Key\ndef GetItem1(self):\nreturn self.__Item1\ndef GetItem2(self):\nreturn self.__Item2\n© Cambridge University Press & Assessment 2025 Page 20 of 45\n\n2(b)(i) 1 mark for 1\n• HashTable (200 records) and Spare (100 records) declared as (global) arrays\nExample program code:\nJava\npublic static NewRecord[] HashTable = new NewRecord[200];\npublic static NewRecord[] Spare = new NewRecord[100];\nVB.NET\nDim HashTable(199) As NewRecord\nDim Spare(99) As NewRecord\nPython\nHashTable = []\nSpare = []\n© Cambridge University Press & Assessment 2025 Page 21 of 45\n\n2(b)(ii) 1 mark each 2\n• Procedure Initialise() header (and close where appropriate) that initialises all elements in both arrays …\n• … to an empty record with –1 in each of the 3 fields/elements\nExample program code:\nJava\npublic static void Initialise(){\nNewRecord EmptyRecord = new NewRecord(-1,-1,-1);\nfor(Integer X = 0; X < 200; X++){\nHashTable[X] = EmptyRecord;\n}\nfor(Integer X = 0; X < 100; X++){\nSpare[X] = EmptyRecord;\n}\n}\nVB.NET\nSub Initialise()\nDim EmptyRecord As NewRecord\nEmptyRecord.Key = -1\nEmptyRecord.Item1 = -1\nEmptyRecord.Item2 = -1\nFor X = 0 To 199\nHashTable(X) = EmptyRecord\nNext\nFor X = 0 To 99\nSpare(X) = EmptyRecord\nNext\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 22 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nPython\ndef Initialise():\nglobal HashTable\nglobal Spare\nfor X in range(200):\nHashTable.append(Record(-1,-1,-1))\nfor X in range(100):\nSpare.append(Record(-1,-1,-1))\n© Cambridge University Press & Assessment 2025 Page 23 of 45\n\n2(c) 1 mark each 2\n• Function header (and close where appropriate), taking one (integer) parameter and returning the calculated value\n• Calculation of parameter MOD 200\nExample program code:\nJava\npublic static Integer CalculateHash(Integer TheKey){\nreturn(TheKey % 200);\n}\nVB.NET\nFunction CalculateHash(Key)\nReturn Key Mod 200\nEnd Function\nPython\ndef CalculateHash(Key):\nreturn Key % 200\n© Cambridge University Press & Assessment 2025 Page 24 of 45\n\n2(d) 1 mark each: 6\n• Procedure header (and end where appropriate) taking one record as a parameter\n• Calling CalculateHash() with key from parameter record and storing/using return value\n• Checking if HashTable at return value from CalculateHash is empty record …\n• … if it is empty, store parameter in location\n• … otherwise, locating next free space in Spare …\n• … and storing in that index only (i.e. not in all other free spaces)\n© Cambridge University Press & Assessment 2025 Page 25 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nJava\npublic static void InsertIntoHash(NewRecord TheRecord){\nInteger HashValue = CalculateHash(TheRecord.GetKey());\nif(HashTable[HashValue].GetKey().equals(-1)){\nHashTable[HashValue] = TheRecord;\n}else{\nfor(Integer X = 0; X < 99; X++){\nif(Spare[X].GetKey().equals(-1)){\nSpare[X] = TheRecord;\nX = 99;\n}\n}\n}\n}\nVB.NET\nSub InsertIntoHash(TheRecord)\nDim HashValue As Integer = CalculateHash(TheRecord.Key)\nIf HashTable(HashValue).Key = -1 Then\nHashTable(HashValue) = TheRecord\nElse\nFor X = 0 To 99\nIf Spare(X).Key = -1 Then\nSpare(X) = TheRecord\nX = 100\nEnd If\nNext\nEnd If\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 26 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nPython\ndef InsertIntoHash(TheRecord):\nglobal HashTable\nglobal Spare\nHashValue = CalculateHash(TheRecord.GetKey())\nif HashTable[HashValue].GetKey() == -1:\nHashTable[HashValue] = TheRecord\nelse:\nfor x in range(0, 100):\nif Spare[x].GetKey() == -1:\nSpare[x] = TheRecord\nbreak\n© Cambridge University Press & Assessment 2025 Page 27 of 45\n\n2(e) 1 mark each to max 5 5\n• Procedure header (and end where appropriate), opening and closing file HashData.txt\n• Reading in all lines of data …\n• … splitting each line by commas\n• Creating record with correct values with each line read in from file\n• Calling InsertIntoHash() with each record they have created\n• Exception handling for opening and reading from file with appropriate catch and output.\nExample program code:\nJava\npublic static void CreateHashTable(){\nString[] Data = new String[3];\nInteger NewKey;\nInteger NewItem1;\nInteger NewItem2;\ntry{\nFileReader File = new FileReader(\"HashData.txt\");\ntry{\nBufferedReader Reader = new BufferedReader(File);\nString Line= Reader.readLine();\nwhile (Line != null){\nLine = Line.replace(\"\\n\",\"\");\nData = Line.split(\",\");\nNewKey = Integer.parseInt(Data[0]);\nNewItem1 = Integer.parseInt(Data[1]);\nNewItem2 = Integer.parseInt(Data[2]);\nNewRecord ReadData = new NewRecord(NewKey, NewItem1, NewItem2);\nInsertIntoHash(ReadData);\nLine= Reader.readLine();\n}\nReader.close();\n}catch(IOException ex){}\n}catch(FileNotFoundException e){System.out.println(\"File not found\");}\n}\n© Cambridge University Press & Assessment 2025 Page 28 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nVB.NET\nSub CreateHashTable()\nDim Line As String\nDim Data(3) As String\nDim TheRecord As NewRecord\nTry\nDim FileReader As New System.IO.StreamReader(\"HashData.txt\")\nWhile Not FileReader.EndOfStream\nLine = FileReader.ReadLine()\nData = Split(Line, \",\")\nTheRecord.Key = Integer.Parse(Data(0))\nTheRecord.Item1 = Integer.Parse(Data(1))\nTheRecord.Item2 = Integer.Parse(Data(2))\nInsertIntoHash(TheRecord)\nEnd While\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Cannot open file\")\nEnd Try\nEnd Sub\nPython\ndef CreateHashTable():\nglobal HashTable\nglobal Spare\ntry:\nFile = open(\"HashData.txt\")\nfor Line in File:\nData = Line.strip()\nData = Line.split(\",\")\nInsertIntoHash(Record(int(Data[0]), int(Data[1]), int(Data[2])))\nFile.close()\nexcept:\nprint(\"Cannot open file\")\n© Cambridge University Press & Assessment 2025 Page 29 of 45\n\n2(f)(i) 1 mark each 2\n• Procedure header (and end where appropriate) and looping through each element in Spare …\n• … checking if record is empty and outputting key field if not empty\nExample program code:\nJava\npublic static void PrintSpare(){\nInteger X = 0;\nwhile(Spare[X].GetKey() != -1){\nSystem.out.println(Spare[X].GetKey());\nX++;\n}\n}\nVB.NET\nSub PrintSpare()\nDim X As Integer = 0\nWhile Spare(X).Key <> -1\nConsole.WriteLine(Spare(X).Key)\nX = X + 1\nEnd While\nEnd Sub\nPython\ndef PrintSpare():\nglobal Spare\nX = 0\nwhile Spare[X].GetKey() != -1:\nprint(Spare[X].GetKey())\nX +=1\n© Cambridge University Press & Assessment 2025 Page 30 of 45\n\n2(f)(ii) 1 mark for calling Initialise() then CreateHashTable() then PrintSpare() 1\nExample program code:\nJava\nInitialise();\nCreateHashTable();\nPrintSpare();\nVB.NET\nInitialise()\nCreateHashTable()\nPrintSpare()\nPython\nInitialise()\nCreateHashTable()\nPrintSpare()\n© Cambridge University Press & Assessment 2025 Page 31 of 45\n\n2(f)(iii) 1 mark for output 1\nFor example:\n© Cambridge University Press & Assessment 2025 Page 32 of 45",
      "source_pages": [
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30,
        31,
        32
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_42-p19.png",
        "../answer-assets/9618_s25_ms_42-p20.png",
        "../answer-assets/9618_s25_ms_42-p21.png",
        "../answer-assets/9618_s25_ms_42-p22.png",
        "../answer-assets/9618_s25_ms_42-p23.png",
        "../answer-assets/9618_s25_ms_42-p24.png",
        "../answer-assets/9618_s25_ms_42-p25.png",
        "../answer-assets/9618_s25_ms_42-p26.png",
        "../answer-assets/9618_s25_ms_42-p27.png",
        "../answer-assets/9618_s25_ms_42-p28.png",
        "../answer-assets/9618_s25_ms_42-p29.png",
        "../answer-assets/9618_s25_ms_42-p30.png",
        "../answer-assets/9618_s25_ms_42-p31.png",
        "../answer-assets/9618_s25_ms_42-p32.png"
      ]
    },
    {
      "id": "9618-2025-mj-42-q03",
      "question_id": "9618-2025-mj-42-q03",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "42",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 26,
      "status": "available",
      "reason": null,
      "text": "3(a)(i) 1 mark each 4\n• Class header (and end when appropriate)\n• Four attributes with appropriate data types\n• Constructor header (and end where appropriate) within class taking (min) 4 parameters …\n• … assigning each parameter to its attribute\n© Cambridge University Press & Assessment 2025 Page 33 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nJava\nclass Animal{\npublic String Name;\npublic String Sound;\npublic Integer Size;\npublic Integer Intelligence;\npublic Animal(String pName, String pSound, Integer pSize, Integer pIntelligence){\nName = pName;\nSound = pSound;\nSize = pSize;\nIntelligence = pIntelligence;\n}\n}\nVB.NET\nClass Animal\nPublic Name As String\nPublic Sound As String\nPublic Size As Integer\nPublic Intelligence As Integer\nSub New(pName, pSound, pSize, pIntelligence)\nName = pName\nSound = pSound\nSize = pSize\nIntelligence = pIntelligence\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2025 Page 34 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nPython\nclass Animal:\ndef __init__(self, pName, pSound, pSize, pIntelligence):\nself.Name = pName #string\nself.Sound = pSound #string\nself.Size = pSize #integer\nself.Intelligence = pIntelligence #integer\n© Cambridge University Press & Assessment 2025 Page 35 of 45\n\n3(a)(ii) 1 mark each 3\n• Description() method header (and end where appropriate) with no parameter\n• Concatenating the attributes with the given message …\n• … and returning the created message\nExample program code:\nJava\npublic String Description(){\nString Message = \"The animal's name is \" + Name + \", it makes a \" + Sound + \", its size is \" + Size\n+ \" and its intelligence level is \" + Intelligence;\nreturn Message;\n}\nVB.NET\nFunction Description()\nDim Message As String = \"The animal's name is \" & Name & \", it makes a \" & Sound & \", its size is \" &\nCStr(Size) & \" and its intelligence level is \" & CStr(Intelligence)\nReturn Message\nEnd Function\nPython\ndef Description(self):\nMessage = \"The animal's name is \" + self.Name + \", it makes a \" + self.Sound + \", its size is \" +\nstr(self.Size) + \" and its intelligence level is \" + str(self.Intelligence)\nreturn Message\n© Cambridge University Press & Assessment 2025 Page 36 of 45\n\n3(b)(i) 1 mark each 4\n• Class header (and end where appropriate) inherits from Animal\n• Constructor header (and end where appropriate) taking 6 parameters within class and calling parent constructor with\nthe four parameters …\n• … WingSpan and NumberWords attributes defined with data types and parameters assigned within constructor\n• ChangeNumberWords() method header (and end where appropriate) takes one parameter and adds parameter to\nattribute NumberWords\nExample program code:\nJava\nclass Parrot extends Animal{\npublic Integer WingSpan;\npublic Integer NumberWords;\npublic Parrot(String pName, String pSound, Integer pSize, Integer pIntelligence, Integer pWingSpan,\nInteger pNumberWords){\nsuper(pName, pSound, pSize, pIntelligence);\nWingSpan = pWingSpan;\nNumberWords = pNumberWords;\n}\npublic void ChangeNumberWords(Integer Change){\nNumberWords = NumberWords + Change;\n}}\nVB.NET\nClass Parrot\nInherits Animal\nDim WingSpan As Integer\nDim NumberWords As Integer\nSub New(pName, pSound, pSize, pIntelligence, pWingSpan, pNumberWords)\nMyBase.New(pName, pSound, pSize, pIntelligence)\nWingSpan = pWingSpan\nNumberWords = pNumberWords\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 37 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nSub ChangeNumberWords(Change)\nNumberWords = NumberWords + Change\nEnd Sub\nEnd Class\nPython\nclass Parrot(Animal):\ndef __init__(self, pName, pSound, pSize, pIntelligence, pWingSpan, pNumberWords):\nsuper().__init__(pName, pSound, pSize, pIntelligence)\nself.WingSpan = pWingSpan #integer\nself.NumberWords = pNumberWords #integer\ndef ChangeNumberWords(self, Change):\nself.NumberWords = self.NumberWords + Change\n© Cambridge University Press & Assessment 2025 Page 38 of 45\n\n3(b)(ii) 1 mark each 2\n• Description() method header (and end where appropriate) taking no parameters and\noverriding/overloads/extending/using parent method\n• Concatenating and returning the correct string\nExample program code:\nJava\npublic String Description(){\nString Message = \"The animal's name is \" + Name + \", it makes a \" + Sound + \", its size is \" + Size\n+ \" and its intelligence level is \" + Intelligence + \". It has a wingspan of \" + WingSpan + \"cm and can say\n\" + NumberWords + \" words.\";\nreturn Message;\n}\nVB.NET\nOverloads Function Description()\nDim Message As String = \"The animal's name is \" & Name & \", it makes a \" & Sound & \", its size is \" &\nCStr(Size) & \" and its intelligence level is \" & CStr(Intelligence) & \". It has a wingspan of \" &\nCStr(WingSpan) & \"cm and can say \" & CStr(NumberWords) & \" words.\"\nReturn Message\nEnd Function\nPython\ndef Description(self):\nMessage = \"The animal's name is \" + self.Name + \", it makes a \" + self.Sound + \", its size is \" +\nstr(self.Size) + \" and its intelligence level is \" + str(self.Intelligence) + \". It has a wingspan of \" +\nstr(self.WingSpan) + \"cm and can say \" + str(self.NumberWords) + \" words.\"\nreturn Message\n© Cambridge University Press & Assessment 2025 Page 39 of 45\n\n3(c)(i) 1 mark each 4\n• Class header (and end where appropriate) inherits from Animal\n• Constructor header (and end where appropriate) taking 5 parameters within class and calling parent constructor with\nparameters\n• Attribute Territory defined as int and parameter assigned within constructor\n• SetTerritory() method header (and end) takes 1 parameter and adds parameter to attribute TerritorySize\nExample program code:\nJava\nclass Wolf extends Animal{\npublic Integer TerritorySize;\npublic Wolf(String pName, String pSound, Integer pSize, Integer pIntelligence, Integer\npTerritorySize){\nsuper(pName, pSound, pSize, pIntelligence);\nTerritorySize = pTerritorySize;\n}\npublic void SetTerritorySize(Integer Change){\nTerritorySize = TerritorySize + Change;\n}}\nVB.NET\nClass Wolf\nInherits Animal\nDim TerritorySize As Integer\nSub New(pName, pSound, pSize, pIntelligence, pTerritory)\nMyBase.New(pName, pSound, pSize, pIntelligence)\nTerritorySize = pTerritory\nEnd Sub\nSub SetTerritorySize(Change)\nTerritorySize = TerritorySize + Change\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2025 Page 40 of 45\n\n9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nPython\nclass Wolf(Animal):\ndef __init__(self, pName, pSound, pSize, pIntelligence, pTerritorySize):\nsuper().__init__(pName, pSound, pSize, pIntelligence)\nself.TerritorySize = pTerritorySize #integer\ndef SetTerritorySize(self, Change):\nself.TerritorySize = self.TerritorySize + Change\n© Cambridge University Press & Assessment 2025 Page 41 of 45\n\n3(c)(ii) 1 mark each 2\n• Description() method header (and end where appropriate) taking no parameters and\noverriding/overloads/extending/using parent method\n• Concatenating and return correct message\nExample program code:\nJava\npublic String Description(){\nString Message = \"The animal's name is \" + Name + \", it makes a \" + Sound + \", its size is \" + Size\n+ \" and its intelligence level is \" + Intelligence + \". Its territory is \" + TerritorySize + \" square\nmiles.\";\nreturn Message;\n}\nVB.NET\nOverloads Function Description()\nDim Message As String = \"The animal's name is \" & Name & \", it makes a \" & Sound & \", its size is \" &\nCStr(Size) & \" and its intelligence level is \" & CStr(Intelligence) + \". Its territory is \" &\nCStr(TerritorySize) & \" square miles.\"\nReturn Message\nEnd Function\nPython\ndef Description(self):\nMessage = \"The animal's name is \" + self.Name + \", it makes a \" + self.Sound + \", its size is \" +\nstr(self.Size) + \" and its intelligence level is \" + str(self.Intelligence) + \" it's territory is \" +\nstr(self.TerritorySize) +\" square miles.\"\nreturn Message\n© Cambridge University Press & Assessment 2025 Page 42 of 45\n\n3(d)(i) 1 mark each 2\n• 1 correct instance created and stored in a suitable variable/structure\n• 2nd and 3rd correct instances created and stored in a suitable variable/structure\nExample program code:\nJava\nParrot Animal1 = new Parrot(\"Chewie\", \"Squawk\", 1, 10, 30, 29);\nWolf Animal2 = new Wolf(\"Nighteyes\", \"Howl\", 8, 7, 100);\nAnimal Animal3 = new Animal(\"Copper\", \"Neigh\", 10, 6);\nVB.NET\nDim Animal1 As Parrot\nAnimal1 = New Parrot(\"Chewie\", \"Squawk\", 1, 10, 30, 29)\nDim Animal2 As Wolf\nAnimal2 = New Wolf(\"Nighteyes\", \"Howl\", 8, 7, 100)\nDim Animal3 As Animal\nAnimal3 = New Animal(\"Copper\", \"Neigh\", 10, 6)\nPython\nAnimal1 = Parrot(\"Chewie\",\"Squawk\",1,10,30,29)\nAnimal2 = Wolf(\"Nighteyes\",\"Howl\",8,7,100)\nAnimal3 = Animal(\"Copper\", \"Neigh\", 10, 6)\n© Cambridge University Press & Assessment 2025 Page 43 of 45\n\n3(d)(ii) 1 mark each 3\n• Calling SetTerritorySize(-20) for instance of Nighteyes\n• Calling ChangeNumberWords(2) for instance of Chewie\n• Calling Description() for all 3 animals (after any updates) and outputting return values\nExample program code:\nJava\nAnimal2.SetTerritorySize(-20);\nAnimal1.ChangeNumberWords(2);\nSystem.out.println(Animal1.Description());\nSystem.out.println(Animal2.Description());\nSystem.out.println(Animal3.Description());\nVB.NET\nAnimal2.SetTerritorySize(-20)\nAnimal1.ChangeNumberWords(2)\nConsole.WriteLine(Animal1.Description())\nConsole.WriteLine(Animal2.Description())\nConsole.WriteLine(Animal3.Description())\nPython\nAnimal2.SetTerritorySize(-20)\nAnimal1.ChangeNumberWords(2)\nprint(Animal1.Description())\nprint(Animal2.Description())\nprint(Animal3.Description())\n© Cambridge University Press & Assessment 2025 Page 44 of 45\n\n3(d)(iii) 1 mark each: 2\n• All three messages accurate with all relevant values\n• … showing correctly updated territory for Nighteyes and words for Chewie\ne.g.\n© Cambridge University Press & Assessment 2025 Page 45 of 45",
      "source_pages": [
        33,
        34,
        35,
        36,
        37,
        38,
        39,
        40,
        41,
        42,
        43,
        44,
        45
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_42-p33.png",
        "../answer-assets/9618_s25_ms_42-p34.png",
        "../answer-assets/9618_s25_ms_42-p35.png",
        "../answer-assets/9618_s25_ms_42-p36.png",
        "../answer-assets/9618_s25_ms_42-p37.png",
        "../answer-assets/9618_s25_ms_42-p38.png",
        "../answer-assets/9618_s25_ms_42-p39.png",
        "../answer-assets/9618_s25_ms_42-p40.png",
        "../answer-assets/9618_s25_ms_42-p41.png",
        "../answer-assets/9618_s25_ms_42-p42.png",
        "../answer-assets/9618_s25_ms_42-p43.png",
        "../answer-assets/9618_s25_ms_42-p44.png",
        "../answer-assets/9618_s25_ms_42-p45.png"
      ]
    },
    {
      "id": "9618-2025-mj-43-q01",
      "question_id": "9618-2025-mj-43-q01",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 26,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark each 3\n• (Global) Queue array with 50 integer elements …\n• … all initialised to –1\n• (Global) HeadPointer and TailPointer initialised with –1\n© Cambridge University Press & Assessment 2025 Page 7 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\nQueue = [] #integer 50 elements\nHeadPointer = -1\nTailPointer = -1\n#main\nHeadPointer = -1\nTailPointer = -1\nfor x in range(50):\nQueue.append(-1)\nVB.NET\nDim Queue(49) As Integer\nDim HeadPointer As Integer\nDim TailPointer As Integer\nSub Main(args As String())\nHeadPointer = -1\nTailPointer = -1\nFor x = 0 To 49\nQueue(x) = -1\nNext\nEnd Sub\nJava\npublic static Integer[] Queue = new Integer[50];\npublic static Integer HeadPointer;\npublic static Integer TailPointer;\npublic static void main(String args[]){\nHeadPointer = -1;\nTailPointer = -1;\nfor(Integer x = 0; x < 50; x++){\nQueue[x] = -1;\n}\n}\n© Cambridge University Press & Assessment 2025 Page 8 of 45\n\n1(b) 1 mark each 6\n• Function Enqueue() header (and end) taking one (integer) parameter\n• Checking if Queue is full …\n• …returning FALSE if full and TRUE if not full\n• (Otherwise) storing data item at TailPointer + 1 (check incrementing)\n• Incrementing TailPointer\n• Checking if this is the first element and incrementing/storing 0 in HeadPointer\n© Cambridge University Press & Assessment 2025 Page 9 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef Enqueue(Data):\nglobal Queue\nglobal TailPointer\nglobal HeadPointer\nif TailPointer < 49:\nTailPointer = TailPointer + 1\nQueue[TailPointer] = Data\nif HeadPointer == -1:\nHeadPointer = 0\nreturn True\nelse:\nreturn False\nVB.NET\nFunction Enqueue(DataValue As Integer)\nIf TailPointer < 49 Then\nTailPointer = TailPointer + 1\nQueue(TailPointer) = DataValue\nIf HeadPointer = -1 Then\nHeadPointer = 0\nEnd If\nReturn True\nElse\nReturn False\nEnd If\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 10 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nJava\npublic static Boolean Enqueue(Integer DataValue){\nif (TailPointer < 49){\nTailPointer++;\nQueue[TailPointer] = DataValue;\nif(HeadPointer == -1){\nHeadPointer = 0;\n}\nreturn true;\n}else{\nreturn false;\n}\n}\n© Cambridge University Press & Assessment 2025 Page 11 of 45\n\n1(c) 1 mark each 5\n• Function Dequeue() header (and close) and returning appropriate value in all cases.\n• Checking if queue is empty …\n• … and returning –1 if empty\n• Accessing and returning element at Queue[HeadPointer] (before HeadPointer is incremented)\n• Incrementing HeadPointer\n© Cambridge University Press & Assessment 2025 Page 12 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef Dequeue():\nglobal Queue\nglobal HeadPointer\nif HeadPointer > -1 and HeadPointer <= TailPointer:\nReturnValue = Queue[HeadPointer]\nHeadPointer = HeadPointer + 1\nreturn ReturnValue\nelse:\nreturn -1\nVB.NET\nFunction Dequeue()\nDim ReturnValue As Integer\nIf HeadPointer > -1 And HeadPointer <= TailPointer Then\nReturnValue = Queue(HeadPointer)\nHeadPointer = HeadPointer + 1\nReturn ReturnValue\nElse\nReturn -1\nEnd If\nEnd Function\nJava\npublic static Integer Dequeue(){\nif (HeadPointer > -1 && HeadPointer <= TailPointer){\nInteger ReturnValue = Queue[HeadPointer];\nHeadPointer++;\nreturn ReturnValue;\n}else{\nreturn -1;\n}\n}\n© Cambridge University Press & Assessment 2025 Page 13 of 45\n\n1(d) 1 mark each 6\n• CreateQueue() header (and end) and opening the file to read and closing file in appropriate place\n• Looping until end of file\n• Reading in each/all lines (and converting to integer and removing new line)\n• … calling Enqueue() once with each value …\n• … checking return value and outputting \"Queue full\" if full (can output once or many times)\n• Exception try, catch with appropriate output. All file access within try\n© Cambridge University Press & Assessment 2025 Page 14 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef CreateQueue():\ntry:\nFile = open(\"QueueData.txt\")\nfor Line in File:\nReturnValue = Enqueue(int(Line))\nif ReturnValue == False:\nprint(\"Queue full\")\nbreak;\nFile.close()\nexcept:\nprint(\"Cannot open or read file\")\nVB.NET\nSub CreateQueue()\nDim ReturnValue As Boolean\nDim ReadData As Integer\nTry\nDim FileReader As New System.IO.StreamReader(\"QueueData.txt\")\nWhile Not FileReader.EndOfStream\nReadData = FileReader.ReadLine()\nReturnValue = Enqueue(ReadData)\nIf ReturnValue = False Then\nConsole.WriteLine(\"Queue full\")\nEnd If\nEnd While\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Cannot open or read file\")\nEnd Try\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 15 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nJava\npublic static void CreateQueue(){\nBoolean ReturnValue;\nInteger ReadData;\ntry{\nFileReader f = new FileReader(\"QueueData.txt\");\ntry{\nBufferedReader Reader = new BufferedReader(f);\nString Line = Reader.readLine();\nLine = Line.replace(\"\\n\",\"\");\nwhile (Line != null){\nLine = Line.replace(\"\\n\",\"\");\nReturnValue = Enqueue(Integer.parseInt(Line));\nif (ReturnValue == false){\nSystem.out.println(\"Queue full\");\n}\nLine = Reader.readLine();\n}\nReader.close();\n}catch(IOException ex){\n}\n}catch(FileNotFoundException e){ System.out.println(\"Cannot open or read file\");}\n}\n© Cambridge University Press & Assessment 2025 Page 16 of 45\n\n1(e)(i) 1 mark each 5\n• Calling CreateQueue()\n• Calling Dequeue() and storing/using return value …\n• … repeatedly until return value is –1\n• … adding together all return values to create a total within the loop …\n• … outputting the total\nExample program code:\nPython\nCreateQueue()\nTotal = 0\nReturnValue = 0\nwhile ReturnValue > -1:\nReturnValue = Dequeue()\nif ReturnValue != -1:\nTotal = Total + ReturnValue\nprint(\"The total is\", Total)\n© Cambridge University Press & Assessment 2025 Page 17 of 45\n\n1(e)(ii) 1 mark for screenshot showing 3059 1\n© Cambridge University Press & Assessment 2025 Page 18 of 45",
      "source_pages": [
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_43-p07.png",
        "../answer-assets/9618_s25_ms_43-p08.png",
        "../answer-assets/9618_s25_ms_43-p09.png",
        "../answer-assets/9618_s25_ms_43-p10.png",
        "../answer-assets/9618_s25_ms_43-p11.png",
        "../answer-assets/9618_s25_ms_43-p12.png",
        "../answer-assets/9618_s25_ms_43-p13.png",
        "../answer-assets/9618_s25_ms_43-p14.png",
        "../answer-assets/9618_s25_ms_43-p15.png",
        "../answer-assets/9618_s25_ms_43-p16.png",
        "../answer-assets/9618_s25_ms_43-p17.png",
        "../answer-assets/9618_s25_ms_43-p18.png"
      ]
    },
    {
      "id": "9618-2025-mj-43-q02",
      "question_id": "9618-2025-mj-43-q02",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 20,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark for array declared with data values: 0 3 4 56 67 44 43 32 31 345 45 6 54 1 1\nExample program code:\nPython\nDataArray = [0, 3, 4, 56, 67, 44, 43, 32, 31, 345, 45, 6, 54, 1]\nJava\nInteger[] DataArray = {0,3,4,56,67,44,43,32,31,345,45,6,54,1};\nVB.NET\nDim DataArray() As Integer = {0, 3, 4, 56, 67, 44, 43, 32, 31, 345, 45, 6, 54, 1}\n© Cambridge University Press & Assessment 2025 Page 19 of 45\n\n2(b) 1 mark each 5\n• InsertionSort() header (and close) taking array as a parameter and returning (attempt at) sorted array\n• Looping through/for each element\n• Extracting element and comparing to sorted list …\n• … moving elements in sorted list\n• … and inserting element in correct position (ascending order)\n© Cambridge University Press & Assessment 2025 Page 20 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef InsertionSort(DataArray):\nif (len(DataArray)) <= 1:\nreturn DataArray\nfor X in range(1, len(DataArray)):\nCurrentValue = DataArray[X]\nY = X-1\nwhile Y >=0 and CurrentValue < DataArray[Y]:\nDataArray[Y+1] = DataArray[Y]\nY = Y -1\nDataArray[Y+1] = CurrentValue\nreturn DataArray\nJava\npublic static Integer[] InsertionSort(Integer[] DataArray){\nInteger CurrentValue = 0;\nInteger Y = 0;\nif(DataArray.length <= 1){\nreturn DataArray;\n}\nfor(Integer X = 1; X <= DataArray.length -1; X++){\nCurrentValue = DataArray[X];\nY = X -1;\nwhile(Y >= 0 && CurrentValue < DataArray[Y]){\nDataArray[Y + 1] = DataArray[Y];\nY--;\n}\nDataArray[Y+1] = CurrentValue;\n}\nreturn DataArray;\n}\n© Cambridge University Press & Assessment 2025 Page 21 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nVB.NET\nFunction InsertionSort(DataArray)\nDim CurrentValue As Integer\nDim Y As Integer\nIf (DataArray.length()) <= 1 Then\nReturn DataArray\nEnd If\nFor X = 1 To DataArray.length() - 1\nCurrentValue = DataArray(X)\nY = X - 1\nWhile Y >= 0 AndAlso CurrentValue < DataArray(Y)\nDataArray(Y + 1) = DataArray(Y)\nY = Y - 1\nEnd While\nDataArray(Y + 1) = CurrentValue\nNext X\nReturn DataArray\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 22 of 45\n\n2(c) 1 mark each 2\n• OutputArray() header (and close) taking an array parameter and outputting the array contents …\n• … in correct format\n© Cambridge University Press & Assessment 2025 Page 23 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef OutputArray(DataArray):\nOutput = \"\"\nfor Item in DataArray:\nOutput = Output + str(Item) + \" \"\nprint(Output)\nJava\npublic static void OutputArray(Integer[] DataArray){\nString Output = \"\";\nInteger X = 0;\nwhile(X < DataArray.length){\nif(DataArray[X] != -1){\nOutput = Output + DataArray[X] + \" \";\n}\nX = X + 1;\n}\nSystem.out.println(Output);\n}\nVB.NET\nSub OutputArray(DataArray)\nDim Output As String = \"\"\nDim X As Integer = 0\nWhile X < DataArray.length\nIf DataArray(X) <> -1 Then\nOutput = Output & DataArray(X) & \" \"\nEnd If\nX = X + 1\nEnd While\nConsole.WriteLine(Output)\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 24 of 45\n\n2(d)(i) 1 mark each 2\n• Calling InsertionSort() with array parameter and storing/using return array\n• … calling OutputArray() with array parameter before and after InsertionSort()\nExample program code\nPython\nOutputArray(DataArray)\nDataArray = InsertionSort(DataArray)\nOutputArray(DataArray)\nJava\nOutputArray(DataArray);\nDataArray = InsertionSort(DataArray);\nOutputArray(DataArray);\nVB.NET\nOutputArray(DataArray)\nDataArray = InsertionSort(DataArray)\nOutputArray(DataArray)\n\n2(d)(ii) 1 mark for output showing unsorted then sorted array 1\ne.g.\n© Cambridge University Press & Assessment 2025 Page 25 of 45\n\n2(e) 1 mark each 6\n• Search() header (and close) taking array and integer as parameters\n• Looping/recursive calls until no elements left/Low<=High and returning –1 if not found\n• … calculating middle index and accessing this value\n• … comparison of array at middle value to integer parameter\n• … if they are equal return mid\n• … if array[mid] < parameter update low to middle + 1, if array[mid] > parameter update high to middle – 1 // recursive\ncall with updated low and updated high\n© Cambridge University Press & Assessment 2025 Page 26 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef Search(DataArray, ItemToFind):\nLow = 0\nHigh = len(DataArray) - 1\nMiddle = 0\nwhile Low <= High:\nMiddle = (High + Low) // 2\nif DataArray[Middle] < ItemToFind:\nLow = Middle + 1\nelif DataArray[Middle] > ItemToFind:\nHigh = Middle - 1\nelse:\nreturn Middle\nreturn -1\nJava\npublic static Integer Search(Integer[] DataArray, Integer ItemToFind){\nInteger Low = 0;\nInteger High = DataArray.length - 1;\nInteger Middle = 0;\nwhile(Low <= High){\nMiddle = (High + Low) / 2;\nif(DataArray[Middle] < ItemToFind){\nLow = Middle + 1;\n}else if(DataArray[Middle] > ItemToFind){\nHigh = Middle - 1;\n}else{\nreturn Middle;\n}\n}\nreturn -1;\n}\n© Cambridge University Press & Assessment 2025 Page 27 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nVB.NET\nFunction Search(DataArray, ItemToFind)\nDim Low As Integer = 0\nDim High As Integer = DataArray.length() - 1\nDim Middle As Integer = 0\nWhile Low <= High\nMiddle = (High + Low) \\ 2\nIf DataArray(Middle) < ItemToFind Then\nLow = Middle + 1\nElseIf DataArray(Middle) > ItemToFind Then\nHigh = Middle - 1\nElse\nReturn Middle\nEnd If\nEnd While\nReturn -1\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 28 of 45\n\n2(f)(i) 1 mark each 2\n• Calling Search() with all four sets of values 0 345 67 2\n• … outputting 'not found' or index in appropriate message each time\n© Cambridge University Press & Assessment 2025 Page 29 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\nLocation = Search(DataArray, 0)\nif Location == -1:\nprint(\"Data not found\")\nelse:\nprint(\"Data found at\", Location)\nLocation = Search(DataArray, 345)\nif Location == -1:\nprint(\"Data not found\")\nelse:\nprint(\"Data found at\", Location)\nLocation = Search(DataArray, 67)\nif Location == -1:\nprint(\"Data not found\")\nelse:\nprint(\"Data found at\", Location)\nLocation = Search(DataArray, 2)\nif Location == -1:\nprint(\"Data not found\")\nelse:\nprint(\"Data found at\", Location)\nJava\nInteger Location = Search(DataArray,0);\nif(Location == -1){\nSystem.out.println(\"Data not found\");\n}else{\nSystem.out.println(\"Data found at \" + Location);\n}\nLocation = Search(DataArray,345);\n© Cambridge University Press & Assessment 2025 Page 30 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nif(Location == -1){\nSystem.out.println(\"Data not found\");\n}else{\nSystem.out.println(\"Data found at \" + Location);\n}\nLocation = Search(DataArray,67);\nif(Location == -1){\nSystem.out.println(\"Data not found\");\n}else{\nSystem.out.println(\"Data found at \" + Location);\n}\nLocation = Search(DataArray,2);\nif(Location == -1){\nSystem.out.println(\"Data not found\");\n}else{\nSystem.out.println(\"Data found at \" + Location);\n}\nVB.NET\nDim Location As Integer = Search(DataArray, 0)\nIf Location = -1 Then\nConsole.WriteLine(\"Data not found\")\nElse\nConsole.WriteLine(\"Data found at \" & Location)\nEnd If\n© Cambridge University Press & Assessment 2025 Page 31 of 45\n\n2(f)(ii) 1 mark for output showing locations for first 3 and not found for 4th 1\ne.g.\n© Cambridge University Press & Assessment 2025 Page 32 of 45",
      "source_pages": [
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30,
        31,
        32
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_43-p19.png",
        "../answer-assets/9618_s25_ms_43-p20.png",
        "../answer-assets/9618_s25_ms_43-p21.png",
        "../answer-assets/9618_s25_ms_43-p22.png",
        "../answer-assets/9618_s25_ms_43-p23.png",
        "../answer-assets/9618_s25_ms_43-p24.png",
        "../answer-assets/9618_s25_ms_43-p25.png",
        "../answer-assets/9618_s25_ms_43-p26.png",
        "../answer-assets/9618_s25_ms_43-p27.png",
        "../answer-assets/9618_s25_ms_43-p28.png",
        "../answer-assets/9618_s25_ms_43-p29.png",
        "../answer-assets/9618_s25_ms_43-p30.png",
        "../answer-assets/9618_s25_ms_43-p31.png",
        "../answer-assets/9618_s25_ms_43-p32.png"
      ]
    },
    {
      "id": "9618-2025-mj-43-q03",
      "question_id": "9618-2025-mj-43-q03",
      "subject": "9618",
      "year": 2025,
      "session": "May/June",
      "session_code": "mj",
      "paper": 4,
      "variant": "43",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 29,
      "status": "available",
      "reason": null,
      "text": "3(a)(i) 1 mark each 4\n• Class Node header (and end)\n• TheData declared as Integer, NextNode declared as Node\n• Constructor header (and end) taking (min) 1 parameter …\n• … storing parameter to TheData within constructor and storing null value to NextNode within constructor\nExample program code:\nPython\nclass Node:\ndef init (self, NodeData):\nself. TheData = NodeData #Integer\nself. NextNode = None #Node\nJava\nclass Node{\npublic Integer TheData;\npublic Node NextNode;\npublic Node(Integer NodeData){\nTheData = NodeData;\nNextNode = null;\n}}\nVB.NET\nClass Node\nPublic TheData As Integer\nPublic NextNode As Node\nSub New(NodeData)\nTheData = NodeData\nNextNode = Nothing\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2025 Page 33 of 45\n\n3(a)(ii) 1 mark each 3\n• 1 get method header (and close) taking no parameters …\n• … returning correct value (without overwriting)\n• 2nd correct get method\nExample program code:\nPython\ndef GetData(self):\nreturn self. TheData\ndef GetNextNode(self):\nreturn self. NextNode\nJava\npublic Integer GetData(){\nreturn TheData;\n}\npublic Node GetNextNode(){\nreturn NextNode;\n}\nVB.NET\nFunction GetData()\nReturn TheData\nEnd Function\nFunction GetNextNode()\nReturn NextNode\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 34 of 45\n\n3(a)(iii) 1 mark each 2\n• SetNextNode() method header (and close) taking 1 parameter (of type Node) …\n• … storing parameter in NextNode\nExample program code:\nPython\ndef SetNextNode(self, pNextNode):\nself. NextNode = pNextNode\nJava\npublic void SetNextNode(Node pNextNode){\nNextNode = pNextNode;\n}\nVB.NET\nSub SetNextNode(pNextNode)\nNextNode = pNextNode\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 35 of 45\n\n3(b)(i) 1 mark each 2\n• Class LinkedList header (and close) and constructor header with no parameter (and close) …\n• … declaring HeadNode as type Node and storing null value in constructor\nExample program code:\nPython\nclass LinkedList:\ndef init (self):\nself. HeadNode = None #Node\nJava\nclass LinkedList{\npublic Node HeadNode;\npublic LinkedList(){\nHeadNode = null;\n}}\nVB.NET\nClass LinkedList\nPrivate HeadNode As Node\nSub New()\nHeadNode = Nothing\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2025 Page 36 of 45\n\n3(b)(ii) 1 mark each 4\n• InsertNode()method header (and close) taking one (integer) parameter\n• Creating new instance of Node with the parameter as the argument\n• Calling SetNextNode() for new node with HeadNode as parameter\n• Replacing HeadNode with new node\nExample program code:\nPython\ndef InsertNode(self, NodeData):\nTheNode = Node(NodeData)\nTheNode.SetNextNode(self. HeadNode)\nself. HeadNode = TheNode\nJava\npublic void InsertNode(Integer NodeData){\nNode TheNode = new Node(NodeData);\nTheNode.SetNextNode(HeadNode);\nHeadNode = TheNode;\n}\nVB.NET\nSub InsertNode(NodeData)\nDim TheNode As Node = New Node(NodeData)\nTheNode.SetNextNode(HeadNode)\nHeadNode = TheNode\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 37 of 45\n\n3(b)(iii) 1 mark each 3\n• Traverse() method header (and close) with no parameter and returns created string\n• Starts at head node and follows nodes using GetNextNode() until no nodes left …\n• … concatenates the data from each node and formats correctly\n© Cambridge University Press & Assessment 2025 Page 38 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef Traverse(self):\nReturnValue = \"\"\nCurrentNode = self. HeadNode\nwhile(CurrentNode != None):\nReturnValue = ReturnValue + str(CurrentNode.GetData())+ \" \"\nCurrentNode = CurrentNode.GetNextNode()\nreturn ReturnValue\nJava\npublic String Traverse(){\nString ReturnValue = \"\";\nNode CurrentNode = new Node(-1);\nCurrentNode = HeadNode;\nwhile(CurrentNode != null){\nReturnValue = ReturnValue + CurrentNode.GetData() + \" \";\nCurrentNode = CurrentNode.GetNextNode();\n}\nreturn ReturnValue;\n}\nVB.NET\nFunction Traverse()\nDim ReturnValue As String = \"\"\nDim CurrentNode As Node = HeadNode\nWhile CurrentNode IsNot Nothing\nReturnValue = ReturnValue & CurrentNode.GetData() & \" \"\nCurrentNode = CurrentNode.GetNextNode()\nEnd While\nReturn ReturnValue\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 39 of 45\n\n3(b)(iv) 1 mark each to max 6 6\n• RemoveNode() method header (and close) taking (integer) parameter and returning Boolean in all cases\n• Checking if head node is null and returning FALSE\n• Checking if head node equals parameter and returning TRUE if true …\n• … and updating HeadNode to HeadNode.GetNextNode()\n• Following nodes comparing data from each node to parameter …\n• ... if found updating next node and returning TRUE\n• … if end of list returning FALSE\n© Cambridge University Press & Assessment 2025 Page 40 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\ndef RemoveNode(self, DataToRemove):\nif self. HeadNode == None:\nreturn False\nelif self. HeadNode.GetData() == DataToRemove:\nself. HeadNode = self. HeadNode.GetNextNode()\nreturn True\nFound = False\nCurrentNode = self. HeadNode\nwhile not(Found) and CurrentNode != None:\nif ((CurrentNode).GetNextNode()).GetData() == DataToRemove:\nCurrentNode.SetNextNode(CurrentNode.GetNextNode().GetNextNode())\nFound = True\nelse:\nCurrentNode = CurrentNode.GetNextNode()\nJava\npublic Boolean RemoveNode(Integer DataToRemove){\nif(HeadNode == null){\nreturn false;\n}else if(HeadNode.GetData().equals(DataToRemove)){\nHeadNode = HeadNode.GetNextNode();\nreturn true;\n}\nBoolean Found = false;\nNode CurrentNode = new Node(-1);\nCurrentNode = HeadNode;\nNode NextNode = new Node(-1);\nwhile(! Found && CurrentNode != null){\nNextNode = CurrentNode.GetNextNode();\nif(NextNode.GetData().equals(DataToRemove)){\nCurrentNode.SetNextNode(NextNode.GetNextNode());\nreturn true;\n© Cambridge University Press & Assessment 2025 Page 41 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\n}else{\nCurrentNode = CurrentNode.GetNextNode();\n}\n}\nreturn false;\n}\nVB.NET\nFunction RemoveNode(DataToRemove)\nIf HeadNode Is Nothing Then\nReturn False\nElseIf HeadNode.GetData() = DataToRemove Then\nHeadNode = HeadNode.GetNextNode()\nReturn True\nEnd If\nDim Found As Boolean = False\nDim CurrentNode As Node = HeadNode\nWhile Not (Found) And CurrentNode IsNot Nothing\nIf ((CurrentNode).GetNextNode()).GetData() = DataToRemove Then\nCurrentNode.SetNextNode(CurrentNode.GetNextNode().GetNextNode())\nFound = True\nElse\nCurrentNode = CurrentNode.GetNextNode()\nEnd If\nEnd While\nReturn Found\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 42 of 45\n\n3(c)(i) 1 mark each 3\n• Creating new LinkedList object\n• Calling InsertNode() five times with correct data in correct order\n• Calling RemoveNode(30) and calling Traverse() and store/output the return value, before RemoveNode() and\nafter\nFull marks can be awarded to students who may have stored and/or outputted the return value from the function call.\n© Cambridge University Press & Assessment 2025 Page 43 of 45\n\n9618/43 Cambridge International AS & A Level – Mark Scheme May/June 2025\nPUBLISHED\nQuestion Answer Marks\nExample program code:\nPython\nCreateList = LinkedList()\nCreateList.InsertNode(10)\nCreateList.InsertNode(20)\nCreateList.InsertNode(30)\nCreateList.InsertNode(40)\nCreateList.InsertNode(50)\nReturnValue1 = (CreateList.Traverse())\nCreateList.RemoveNode(30)\nReturnValue2 = (CreateList.Traverse())\nJava\npublic static void main(String args[]){\nLinkedList CreateList = new LinkedList();\nString ReturnValue2;\nString ReturnValue1;\nCreateList.InsertNode(10);\nCreateList.InsertNode(20);\nCreateList.InsertNode(30);\nCreateList.InsertNode(40);\nCreateList.InsertNode(50);\nReturnValue1 = (CreateList.Traverse());\nCreateList.RemoveNode(30);\nReturnValue2 = (CreateList.Traverse());\n}\nVB.NET\nSub Main(args As String())\nDim CreateList As LinkedList = New LinkedList()\nDim ReturnValue1 As String\nDim ReturnValue2 As String\n© Cambridge University Press & Assessment 2025 Page 44 of 45\n\n3(c)(ii) 1 mark each 2\n• Output of linked list with 50 40 30 20 10\n• Output of 2nd linked list with 50 40 20 10\ne.g.\n© Cambridge University Press & Assessment 2025 Page 45 of 45",
      "source_pages": [
        33,
        34,
        35,
        36,
        37,
        38,
        39,
        40,
        41,
        42,
        43,
        44,
        45
      ],
      "source_pdf": "_source-pdfs/2025-may-june/ms/9618_s25_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-May-June/9618_s25_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_s25_ms_43-p33.png",
        "../answer-assets/9618_s25_ms_43-p34.png",
        "../answer-assets/9618_s25_ms_43-p35.png",
        "../answer-assets/9618_s25_ms_43-p36.png",
        "../answer-assets/9618_s25_ms_43-p37.png",
        "../answer-assets/9618_s25_ms_43-p38.png",
        "../answer-assets/9618_s25_ms_43-p39.png",
        "../answer-assets/9618_s25_ms_43-p40.png",
        "../answer-assets/9618_s25_ms_43-p41.png",
        "../answer-assets/9618_s25_ms_43-p42.png",
        "../answer-assets/9618_s25_ms_43-p43.png",
        "../answer-assets/9618_s25_ms_43-p44.png",
        "../answer-assets/9618_s25_ms_43-p45.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q01",
      "question_id": "9618-2025-on-31-q01",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 1,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) DECLARE Member1 : ClubMember 1\n\n1(a)(ii) One mark for each correct answer 2\nExample answer\nMember1.Code  984632\nMember1.FeesPaid  TRUE\n\n1(b)(i) One mark per mark point (Max 2) 2\nMP1 TYPE Activity=\nMP2 (Badminton, Football, Golf, Snooker, Swimming, Tennis)\nExample answer\nTYPE Activity = (Badminton, Football, Golf, Snooker, Swimming,\nTennis)\n\n1(b)(ii) DECLARE Choice : Activity 1\nQuestion Answer Marks Guidance",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p06.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q02",
      "question_id": "9618-2025-on-31-q02",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 2,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark per mark point (Max 2) 2\nMP1 Correct mantissa\nMP2 Correct exponent\nMantissa Exponent\n0 1 1 1 0 1 0 1 1 0 1 0 1 0 0 1\n© Cambridge University Press & Assessment 2025 Page 6 of 15\n\n2(b) One mark per mark point (Max 4) 4\nMP1 correct method to find the binary number\nMP2 additional working towards binary number\nMP3 correct use of exponent\nMP4 correct answer in the space provided\nTwo from:\ne.g.\n76.1875 = 64+8+4+0.125+0.0625\n(0)1001100.0011\n–76.1875 = –128+32+16+2+1+0.5+0.25+0.0625\n10110011.11 01\nOne mark\nmovement of binary point by 7 places // 1.011001111 01 x 27\nOne mark\nMantissa Exponent\n1 0 1 1 0 0 1 1 1 1 0 1 0 1 1 1\nQuestion Answer Marks Guidance",
      "source_pages": [
        6,
        7
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p06.png",
        "../answer-assets/9618_w25_ms_31-p07.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q03",
      "question_id": "9618-2025-on-31-q03",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 10,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per mark point (Max 2) 2\nMP1 Protocols set a standard for communication // Protocols establish a standard set\nof rules for communication\nMP2 Protocols enable compatibility between devices from different\nmanufacturers/platforms\nMP3 Two devices wouldn’t be able to communicate/send messages to each other if\nthey were using different protocols\n© Cambridge University Press & Assessment 2025 Page 7 of 15\n\n3(b) One mark for a protocol and one mark for a description (Max 4) 4\nExample answers:\nSMTP [1] a protocol used to send emails between mail servers // a protocol used to\nsend emails from a computer to a mail server [1]\nIMAP [1] allows users to access/read their emails from any device without removing\nthe message from the mail server // synchronises emails on any device [1]\n\n3(c) Two marks for each description mark as 2 x 2 (Max 4) 4\nExample answers:\nPackets checked at receiving end / on arrival [1]\n… if packets arrive damaged or don’t arrive at all, a re-send request is sent [1]\nPackets routed through different paths / sent individually [1]\n… if a route is blocked, the packet is sent through a different route to ensure it arrives [1]\nIf the packet’s hop count is exceeded [1]\n… the packet will be retired, which can generate a re-send request [1]\nQuestion Answer Marks Guidance",
      "source_pages": [
        7,
        8
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p07.png",
        "../answer-assets/9618_w25_ms_31-p08.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q04",
      "question_id": "9618-2025-on-31-q04",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 4,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark per scheduling routine (Max 2) from: 2\n• Round robin\n• Shortest job first\n• First come first served\n• Shortest remaining time\n© Cambridge University Press & Assessment 2025 Page 8 of 15\n\n4(b) One mark for identification and one mark for a description (Max 4) 4\nTwo from:\nProvision of a User Interface // Provision of a Graphical User Interface [1]\nAllows the user to interact with the computer in a more intuitive way // Icons and menus\nare used to control devices by simply ‘pointing and clicking’ [1]\nUse of device drivers [1]\nMakes it easier to control peripherals such as printers within the operating system of the\ncomputer rather than on the separate device itself [1]\nDevice mapping [1]\nDifferent devices (physical and virtual) are easy to identify on the network, check their\nstatus, or use [1]\nThe user interacts only with the Application / top layer (of the TCP/IP protocol suite) [1]\nleaving the lower layers and their complexities hidden from the user [1]\nQuestion Answer Marks Guidance",
      "source_pages": [
        8,
        9
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p08.png",
        "../answer-assets/9618_w25_ms_31-p09.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q05",
      "question_id": "9618-2025-on-31-q05",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 5,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "5(a) Two from: 2\n• Name of certificate holder // Subject\n• Serial number\n• Version number\n• Expiration date // Start date // Validity (not before/not after)\n• Certificate holder’s public key // Subject public key\n• Subject digital signature\n• Certificate Issuer // Digital signature of CA\n© Cambridge University Press & Assessment 2025 Page 9 of 15\n\n5(b) One mark per mark point (Max 3) 3\nMP1 A digital certificate provides a public key\nMP2 … which validates the private key used to create the digital signature\nMP3 It makes a digital signature virtually impossible to spoof // Provides evidence of\nsigner identity that the document was not altered and the signatures are valid\nMP4 Non repudiation.\nQuestion Answer Marks Guidance",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p09.png",
        "../answer-assets/9618_w25_ms_31-p10.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q06",
      "question_id": "9618-2025-on-31-q06",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "6(a) One mark for working, (all four columns P, Q, R and S) 3\nOne mark for first four rows of column Z\nOne mark for second four rows of column Z\nWorking space\nA B C P Q R S Z\n0 0 0 1 1 1 1 0\n0 0 1 1 0 1 0 0\n0 1 0 1 1 1 1 1\n0 1 1 1 0 1 1 1\n1 0 0 0 1 1 1 0\n1 0 1 0 0 0 1 0\n1 1 0 0 1 1 1 1\n1 1 1 0 0 1 1 1\n© Cambridge University Press & Assessment 2025 Page 10 of 15\n\n6(b)(i) Two marks if no errors present 2\nOne mark if only one error present\nBC\n00 01 11 10\nA\n0 0 0 1 1\n1 0 1 0 1\n\n6(b)(ii) One mark for each correct loop (Max 2) 2\nBC\n00 01 11 10\nA\n0 0 0 1 1\n1 0 1 0 1\n\n6(b)(iii) One mark for each mark point (Max 2) 2\n• One correct Boolean term with a + / OR sign\n• All Boolean terms and operators correct and no other terms present\nA.B + B.C + A.B.C\nQuestion Answer Marks Guidance",
      "source_pages": [
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p10.png",
        "../answer-assets/9618_w25_ms_31-p11.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q07",
      "question_id": "9618-2025-on-31-q07",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 7,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "7(a) One from: 1\n• A* algorithm\n• Dijkstra’s algorithm\n© Cambridge University Press & Assessment 2025 Page 11 of 15\n\n7(b) One mark for each mark point (Max 5) 5\nMP1 Deep learning is a branch of machine learning\nMP2 It makes use of artificial neural networks\nMP3 … to work in a similar manner to the human/biological brain // … neural\nnetworks can be trained to process data\nMP4 It is a structure consisting of many interconnected layers\nMP5 … input, hidden and output // the input layer feeds the first hidden layer, the last\nhidden layer feeds the output\nMP6 … gradually breaking down and analysing the data to find (hidden) patterns\nMP7 Deep leaning’s feature extraction/learning involves how to detect\nfeatures/categories from data\nMP8 … and can involve different types of supervision\nMP9 It works well with large data sets\nMP10 Deep learning uses back propagation of errors to adjust parameters/weightings\nto refine its results / improve its accuracy.\nQuestion Answer Marks Guidance",
      "source_pages": [
        11,
        12
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p11.png",
        "../answer-assets/9618_w25_ms_31-p12.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q08",
      "question_id": "9618-2025-on-31-q08",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 8,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) One mark per mark point (Max 2) 2\nMP1 To convert the high-level source code / program into a sequence of tokens\nMP2 … that can be sent to the parser for syntax analysis\nMP3 To create a symbol table\nMP4 To remove the unnecessary white space and comments from the code\n\n8(b) One mark 2 6 – 2\nOne mark 13 7 + * 5 /\nComplete answer\n2 6 – 13 7 + * 5 /\n© Cambridge University Press & Assessment 2025 Page 12 of 15\n\n8(c) One mark per ring (Max 4) 4\n12 6\n6 6 18 15 15 9\n5 5 5 5 90 90 90 90 10\nQuestion Answer Marks Guidance",
      "source_pages": [
        12,
        13
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p12.png",
        "../answer-assets/9618_w25_ms_31-p13.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q09",
      "question_id": "9618-2025-on-31-q09",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 9,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "9(a)(i) One mark for each correctly completed line (Max 5) 5\nFUNCTION Pop() RETURNS STRING\nDECLARE DataItem : STRING\nDataItem  \"\"\nIF Top > –1 // Top >= Base THEN\nDataItem  StackArray[Top]\nTop  Top – 1\nELSE\nDataItem  \"You cannot remove data; the stack is empty\"\nENDIF\nRETURN DataItem // StackArray[Top + 1]\nENDFUNCTION\n© Cambridge University Press & Assessment 2025 Page 13 of 15\n\n9(a)(ii) OUTPUT \"The data removed from the stack is \", Pop() 1\n\n9(b) One mark per mark point (Max 3) 3\nMP1 A recursive algorithm must call itself / have a general case\nMP2 It must have a base case / have a stopping condition\nMP3 It must change its state and move towards the base case\nQuestion Answer Marks Guidance",
      "source_pages": [
        13,
        14
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p13.png",
        "../answer-assets/9618_w25_ms_31-p14.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q10",
      "question_id": "9618-2025-on-31-q10",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 10,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "10 One mark per mark point (Max 2) 3\nMP1 Exception handling is a process that responds to unwanted / unexpected\nevents when a program runs\nMP2 … to prevent the program / computer from stopping unexpectedly\nOne mark for example (Max 1)\nMP3 Programming errors\nMP4 User errors\nMP5 Hardware failure // losing connection to a device such as a printer\n© Cambridge University Press & Assessment 2025 Page 14 of 15",
      "source_pages": [
        14
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p14.png"
      ]
    },
    {
      "id": "9618-2025-on-31-q11",
      "question_id": "9618-2025-on-31-q11",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "31",
      "question_number": 11,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "11(a) One mark per mark point (Max 6) 6\nMP1 LDM #100 seen\nMP2 Correct use of STO with labelled address (constant or answer)\nMP3 Correct use of LDD 632\nMP4 Correct use of SUB with labelled address (constant)\nOpcode Operand\nLDM #100\nSTO Constant\nLDD 632\nSUB Constant\nSTO Answer\nMP5 Storing 100 at a labelled address away from the code\nMP6 Labelling both addresses away from the code.\nLabel Contents\nConstant: 100\nAnswer:\n\n11(b) –55 1\n© Cambridge University Press & Assessment 2025 Page 15 of 15",
      "source_pages": [
        15
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_31.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_31.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_31-p15.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q01",
      "question_id": "9618-2025-on-32-q01",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 1,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) DECLARE Car1 : Car 1\n\n1(a)(ii) One mark for each correct answer 2\nExample answer\nCar1.Colour  \"Blue\"\nCar1.IntoStock  21/10/2025\n\n1(b)(i) One mark per mark point (Max 2) 2\nMP1 TYPE Body =\nMP2 (Convertible, Hatchback, Saloon, SUV)\nExample answer\nTYPE Body = (Convertible, Hatchback, Saloon, SUV)\n\n1(b)(ii) DECLARE BodyStyle : Body 1\n© Cambridge University Press & Assessment 2025 Page 6 of 17",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p06.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q02",
      "question_id": "9618-2025-on-32-q02",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 2,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) Two marks for working 3\n• correct calculation/application of exponent seen\n• correct method to find the final answer\nWorking:\nExponent = 8 + 2 + 1 = 11\n// =0.111100101 x 211\n// =11110010100.0 (moving bp 11 places to right)\nMethod to find the answer\n// 1024 + 512 + 256 + 128 + 16 + 4\nOne mark for correct answer\nDenary value: 1940\nExample of solution using fractions:\n\n2(b) One mark per mark point (Max 3) 3\nMP1 correct method to find the binary number\nMP2 correct use of exponent\nMP3 correct answer in the space provided\nWorking:\n26.6875 converted to binary (0)11010.1011 // 16+8+2+0.5+0.125+0.0625 movement of binary point by 5 places\nMantissa Exponent\n0 1 1 0 1 0 1 0 1 1 0 0 0 1 0 1\n© Cambridge University Press & Assessment 2025 Page 7 of 17",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p07.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q03",
      "question_id": "9618-2025-on-32-q03",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "3(a) One mark per mark point (Max 2) 2\n• HTTP to send and receive / transfer web pages / hypertext / images / videos\n• IMAP allows users to access/read their emails from any device without removing the message from the mail server\n// synchronises emails on any device\n\n3(b) One mark per mark point (Max 4) 4\nMP1 Files are shared over a peer-to-peer network\nMP2 A small file, a torrent (descriptor file), is initially created by a peer\nMP3 The torrent (descriptor file) contains metadata about the file to be shared\nMP4 The whole file must initially be located on at least one peer\nMP5 The file is broken into equal sized pieces\nMP6 Other peers who wish to download the file first obtain the torrent (descriptor file) and connect to a tracker\nMP7 A tracker acts like a server that holds all the data about all the computers connected to it / the swarm\nMP8 Each peer downloads parts of the file from other peers until the entire file has been downloaded\nMP9 As each peer receives a piece of the file, they become a source for that piece of the file\nMP10 A peer who has a complete file and is sharing it is a seed // Once a peer has completely downloaded the file\nand made the file available to others in the swarm, they become a seed.\n© Cambridge University Press & Assessment 2025 Page 8 of 17",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p08.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q04",
      "question_id": "9618-2025-on-32-q04",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 4,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "4(a) One mark for a benefit of circuit switching (Max 1) 2\nMP1 Once the connection is made, it is available until the end of the transmission (suitable for long continuous\ntransmission)\nMP2 The dedicated path ensures a steady rate of data transmission, once connection has been made (because the\nwhole bandwidth is available)\nMP3 The dedicated path ensures data is less likely to be lost.\nMP4 No intermediate delays once the circuit is established, enables real time transmission\nMP5 No additional time/delay to reorder needed because data arrives in the order it was sent / data sent as a\ncontinuous stream\nOne mark for a benefit of packet switching (Max 1)\nMP6 No need to tie up a communication line // path available to multiple users // bandwidth can be shared by multiple\nusers\nMP7 Possible to overcome failed / faulty / busy lines by re-routing packets\nMP8 Individual packets can be resent if lost/damaged\nMP9 Users only charged for the duration of connectivity\nMP10 High rate of data transmission possible\nMP11 Always uses digital networks so data is transmitted directly to the destination\nMP12 Good security because all packets can take different routes // A more secure method because all packets can take\ndifferent routes\n© Cambridge University Press & Assessment 2025 Page 9 of 17\n\n4(b) One mark per difference (Max 2) 2\nMP1 Circuit switching requires a dedicated line to be connected before the data transfer takes place, in packet\nswitching, data transfer commences directly/ straight away\nMP2 In circuit switching, each data unit knows the entire path address, but in packet switching, each data unit only\nknows the final address (routers decide intermediate paths)\nMP3 Circuit switching uses the whole bandwidth of the transmission path, but packet switching shares it with other users\n// circuit switching uses a constant high bandwidth. Packet switching has variable bandwidth\nMP4 In circuit switching each data unit follows the same route, but in packet switching, packets can follow any route\nMP5 In circuit switching data arrives in the correct order but in packet switching it has to be reordered\nMP6 Data remains intact / a continuous stream in circuit switching but is segmented in packet switching\nMP7 Lost data in circuit switching requires the whole transmission to be resent, but individual packets can be\nresent in packet switching\nMP8 Circuit switching doesn’t suffer data loss but packets can be lost in packet switching.\nQuestion Answer Marks",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p09.png",
        "../answer-assets/9618_w25_ms_32-p10.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q05",
      "question_id": "9618-2025-on-32-q05",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "5(a) One mark per mark point (Max 2) 2\nMP1 The low-level scheduler manages the handling of interrupts based on priority\nMP2 … ensuring that critical events are handled without delay\nMP3 It uses an Interrupt Vector Table (IVT) / Interrupt Descriptor/Despatch Table (IDT) / Interrupt Service Routine (ISR)\nlookup\nMP4 … to map the interrupt to the specific handling routine / ISR.\n\n5(b) One mark per correct answer (Max 3) 3\nProcess state Reason\nrunning CPU time has been allocated and the process is being executed.\nThe process is waiting (in the ready queue) for a slice of CPU time. It could run. // It has been displaced\nready\nby a higher priority process and could otherwise still run.\nblocked The process is waiting for an I/O operation / some event to take place / be completed.\n© Cambridge University Press & Assessment 2025 Page 10 of 17",
      "source_pages": [
        10
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p10.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q06",
      "question_id": "9618-2025-on-32-q06",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "6(a) • One mark for working, (all four columns P, Q, R and S) 3\n• One mark for first four rows of column Z\n• One mark for second four rows of column Z\nWorking space\nA B C P Q R S Z\n0 0 0 1 1 0 0 1\n0 0 1 1 1 1 1 1\n0 1 0 0 0 1 0 1\n0 1 1 0 0 0 0 0\n1 0 0 1 0 0 0 1\n1 0 1 1 0 1 0 1\n1 1 0 0 1 1 0 1\n1 1 1 0 1 0 0 0\n\n6(b)(i) Two marks if no errors present 2\nOne mark if only one error present\nBC\n00 01 11 10\nA\n0 0 1 1 0\n1 0 1 0 1\n© Cambridge University Press & Assessment 2025 Page 11 of 17\n\n6(b)(ii) One mark for each correct loop (Max 2) 2\nBC\n00 01 11 10\nA\n0 0 1 1 0\n1 0 1 0 1\n\n6(b)(iii) One mark for each mark point (Max 2) 2\n• One correct Boolean term with a + / OR sign\n• All Boolean terms and operators correct and no other terms present\n_ _ _\nA.C + B.C + A.B.C\n© Cambridge University Press & Assessment 2025 Page 12 of 17",
      "source_pages": [
        11,
        12
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p11.png",
        "../answer-assets/9618_w25_ms_32-p12.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q07",
      "question_id": "9618-2025-on-32-q07",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 7,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "7(a) One from 1\nSymmetric (cryptography / encryption)\nQuantum (cryptography)\n\n7(b) One mark per mark point (Max 4) 4\nMP1 The two keys held by the organisation are a private key and a public key\nMP2 The organisation makes the public key available to anyone who wishes to send them secure transmissions // The\nsender obtains the organisation’s public key\nMP3 The sender uses the organisation’s public key to encrypt the message / plain text // The sender uses the\norganisation’s public key to turn the message into cipher text\nMP4 The organisation uses its private key to decrypt the message.\nQuestion Answer Marks",
      "source_pages": [
        13
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p13.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q08",
      "question_id": "9618-2025-on-32-q08",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 8,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "8(a) To improve the code by making it use minimum resources (CPU, memory/storage, time) // Answer by example: To improve 1\nthe code by\n• minimising program storage\n• minimising CPU time\n• minimising memory use\n• minimising program execution time (includes peripheral use as well as CPU)\n\n8(b) One mark (a – b + c) 3\nOne mark * (c - a)\nOne mark / d\nComplete answer\n(a – b + c) * (c - a) / d\n© Cambridge University Press & Assessment 2025 Page 13 of 17\n\n8(c) One mark per ring (Max 4) 4\n6\n3 16 16 10 16",
      "source_pages": [
        13,
        14
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p13.png",
        "../answer-assets/9618_w25_ms_32-p14.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q09",
      "question_id": "9618-2025-on-32-q09",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 9,
      "topic": "Artificial intelligence (AI)",
      "topic_slug": "9618-topic-18-artificial-intelligence",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "9 9 3 3 3 3 30 30 46\nQuestion Answer Marks\n\n9(a)(i) One from: 1\ne.g.\n• Virtual assistants // AI Agents\n• Chatbots\n• Composing music\n• Self-driving cars\n• Natural language processing\n• Fraud detection\n• Image colouring // photograph enhancement\n• Visual/Image recognition/facial recognition\n• Text mining\n• Computer assisted translation\n• Large language models (LLMs)\n• Playing chess\n• Grading student exams\n• Weather forecasting\n\n9(a)(ii) Use / introduce more hidden layers 1\n© Cambridge University Press & Assessment 2025 Page 14 of 17\n\n9(b) One mark per mark point (Max 4) 4\nMP1 Initial outputs are compared to expected outputs\nMP2 … weightings are adjusted to minimise the difference between actual and expected outputs\nMP3 Calculus is used to find the error gradient in the obtained outputs\nMP4 … the results are fed back into the neural network\nMP5 … weightings of each neuron / node are adjusted as a result of the feedback\nMP6 … the process repeats until results are more accurate\nQuestion Answer Marks",
      "source_pages": [
        14,
        15
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-18-artificial-intelligence/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p14.png",
        "../answer-assets/9618_w25_ms_32-p15.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q10",
      "question_id": "9618-2025-on-32-q10",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 10,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark per mark point (Max 2) 2\nMP1 Use an exception handling routine (to respond to unwanted / unexpected events when the program is running)\nMP2 Use of try … except / catch // Generate some form of error message\n\n10(b) One mark per mark point (Max 2) 2\nMP1 Coding errors\nMP2 User errors\nMP3 Hardware failure // Losing connection to a device e.g. a printer\n© Cambridge University Press & Assessment 2025 Page 15 of 17",
      "source_pages": [
        15
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p15.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q11",
      "question_id": "9618-2025-on-32-q11",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 11,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "11 One mark per mark point (Max 7) 7\nMP1 LDD 300 seen\nMP2 Correct use of STO seen (at least once)\nMP3 Correct use of LDD 420 seen\nMP4 Correct use of LDI B\nMP5 Correct use of ADD A\nOpcode Operand\nLDD 300\nSTO A\nLDD 420\nSTO B\nLDI B\nADD A\nSTO Answer\nMP6 Correct labelling of three addresses A:, B: and Answer:\nMP7 Correct contents in A: and B:\nMP8 Correct value in Answer:\nLabel Contents\nA: 86\nB: 150\nAnswer: 112\n© Cambridge University Press & Assessment 2025 Page 16 of 17",
      "source_pages": [
        16
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p16.png"
      ]
    },
    {
      "id": "9618-2025-on-32-q12",
      "question_id": "9618-2025-on-32-q12",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "32",
      "question_number": 12,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "12(a)(i) One mark for each correctly completed line (Max 4) 4\nPROCEDURE Push(NewData : STRING)\nIF Top < Max – 1 THEN\nTop  Top + 1\nStackArray[Top]  NewData\nELSE\nOUTPUT \"Stack full; new data cannot be added\"\nENDIF\nENDPROCEDURE\n\n12(a)(ii) One mark per mark point (Max 2) 2\nMP1 Input with variable, with or without prompt\nMP2 Procedure call for Push with parameter used matching input variable\nExample answer\nINPUT MyData\nCALL Push(MyData)\n\n12(b) One mark per mark point (Max 3) 3\nMP1 Stacks store data in Last In First Out (LIFO) / First In Last Out (FILO) order\nMP2 Each time a recursive algorithm calls itself data is pushed onto the stack\nMP3 When the recursive algorithm reaches its base case / starts to unwind\nMP4 … data is popped from the stack in the reverse order to which it was pushed onto it.\n© Cambridge University Press & Assessment 2025 Page 17 of 17",
      "source_pages": [
        17
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_32.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_32.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_32-p17.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q01",
      "question_id": "9618-2025-on-33-q01",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 1,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) One mark per mark point (Max 2) 2\nMP1 TYPE Spectrum =\nMP2 (Red, Orange, Yellow, Green, Blue, Indigo, Violet)\nExample answer\nTYPE Spectrum = (Red, Orange, Yellow, Green, Blue,\nIndigo, Violet)\n\n1(a)(ii) One mark per mark point (Max 2) 2\nMP1 the list is ordered/ordinal\nMP2 the list contains all possible values\nMP3 no duplicate values in list\nMP4 all values are the same data type\n\n1(b) One mark for TYPE ColourData and ENDTYPE correct 4\nOne mark for correct use of DECLARE in all declarations\nOne mark for correct use of Spectrum in declaration\nOne mark for remaining four declarations correct (STRING, INTEGER,\nREAL, BOOLEAN)\nExample answer\nTYPE ColourData\nDECLARE ColourCode : STRING\nDECLARE Colour : Spectrum\nDECLARE Wavelength : INTEGER\nDECLARE Frequency : REAL\nDECLARE PrimaryColour : BOOLEAN\nENDTYPE\n© Cambridge University Press & Assessment 2025 Page 6 of 16",
      "source_pages": [
        6
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p06.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q02",
      "question_id": "9618-2025-on-33-q02",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 2,
      "topic": "Data representation",
      "topic_slug": "9618-topic-13-data-representation",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "2(a) One mark per mark point (Max 3) 3\nMP1 the precision of the number stored in the mantissa will be reduced\nMP2 the number of bits available for the exponent will increase to 6\nMP3 … this will increase the range of numbers that can be stored.\n\n2(b) One mark per mark point (Max 3) 3\nMP1 a process involving a calculation / the multiplication of two large\nnumbers could take place\nMP2 the result might be outside of the range of values possible to store\nin the given system\nMP3 … leading to the most significant bits of the mantissa/exponent\nbeing lost (which is an overflow).\nQuestion Answer Marks Guidance",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-13-data-representation/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q03",
      "question_id": "9618-2025-on-33-q03",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 3,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "3 One mark per mark point (Max 4) 4\nMP1 the message is divided into small chunks called packets\nMP2 each packet is given a header with important data including source\nand destination IP addresses\nMP3 each packet is sent independently // packets can be sent through\ndifferent routes\nMP4 packets are sent through the optimum route // packets can be re-\nrouted if a route is unavailable\nMP5 packets are reassembled at the destination into the whole message\n© Cambridge University Press & Assessment 2025 Page 7 of 16",
      "source_pages": [
        7
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p07.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q04",
      "question_id": "9618-2025-on-33-q04",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 4,
      "topic": "Communication and internet technologies",
      "topic_slug": "9618-topic-14-communication-and-internet-technologies",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "4 One mark for a correct protocol and one mark for a correct corresponding 6\ndescription (Max 6)\nThree from:\nHTTP/S [1] a protocol/secure protocol used to transfer hypermedia\ndocuments / web pages / (data) files between networked devices [1]\nFTP [1] a protocol to download, upload and transfer files from one location to\nanother on a network [1]\nPOP3 [1] a protocol used to retrieve/receive emails from a mail server to a\ncomputer [1]\nIMAP [1] allows users to access/read their emails from any device without\nremoving the message from the mail server // synchronises emails on any\ndevice [1]\nSMTP [1] a protocol used to send emails between mail servers // a protocol\nused to send emails from a computer to a mail server [1]\nBitTorrent [1] a communication protocol used for peer-to-peer file sharing [1]\nQuestion Answer Marks Guidance",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-14-communication-and-internet-technologies/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p08.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q05",
      "question_id": "9618-2025-on-33-q05",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 5,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "5(a) To enable multiple programs/processes to be executed at the same time 1\n\n5(b) One mark per mark point (Max 3) 3\nMP1 the operating system monitors the state of each task/process\nMP2 using scheduling to ensure hardware resources are used efficiently\nMP3 … and making sure that tasks/processes do not clash.\n© Cambridge University Press & Assessment 2025 Page 8 of 16",
      "source_pages": [
        8
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p08.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q06",
      "question_id": "9618-2025-on-33-q06",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 6,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 8,
      "status": "available",
      "reason": null,
      "text": "6(a)(i) One mark for each correct loop (Max 3) 3\nAB\nCD 00 01 11 10\n00\n0 0 0 0\n01 1 1 1 0\n11 0 1 1 1\n10 0 0 1 1\n\n6(a)(ii) One mark per mark point (Max 2) 2\nMP1 One correct Boolean term with an OR sign\nMP2 All three correct Boolean terms connected by OR signs and no\nother terms present.\nA.C.D + B.D + A.C\n© Cambridge University Press & Assessment 2025 Page 9 of 16\n\n6(b) One mark for correct use of De Morgan’s laws 3\nOne mark for correct use of any other Boolean algebra law\nX = A+B+C + B+C\n(X=) A.B.C + B.C ………………………………….(De Morgan’s)\n(X=) A.B.C + B.C ………………………………….(Double negation)\n(X=) C.(A.B + B) …………………………………..(Distributive)\nOne mark for correct answer\n(X=) C.(A + B) ……………………………………..(Redundancy)\nQuestion Answer Marks Guidance",
      "source_pages": [
        9,
        10
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p09.png",
        "../answer-assets/9618_w25_ms_33-p10.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q07",
      "question_id": "9618-2025-on-33-q07",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 7,
      "topic": "System software",
      "topic_slug": "9618-topic-16-system-software",
      "marks": 9,
      "status": "available",
      "reason": null,
      "text": "7(a) One mark per mark point (Max 2) 2\nMP1 To identify and remove redundant code / To simplify expressions /\nTo reorder the code\nMP2 … so that storage size/memory use/power consumption/program\nexecution time/CPU time is minimized.\n\n7(b) One mark per mark point (Max 2) 3\nMP1 6 12 +\nMP2 16 10 – /\nMP3 18 *\nFinal correct expression\n6 12 + 16 10 – / 18 *\n© Cambridge University Press & Assessment 2025 Page 10 of 16\n\n7(c) One mark per ring (Max 3) 4\nOne mark for the interim total (360) and the final total (10).\n6 24\n4 12 12 18 12 12 36\n24 24 20 20 20 20 360 360 360 360 10\n© Cambridge University Press & Assessment 2025 Page 11 of 16",
      "source_pages": [
        10,
        11
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-16-system-software/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p10.png",
        "../answer-assets/9618_w25_ms_33-p11.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q08",
      "question_id": "9618-2025-on-33-q08",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 8,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "8 One mark per mark point - working (Max 3) 5\nMay be seen on diagram or in working section\nMP1 Initialisation – setting Start to 0\nMP2 … and the rest of the towns to \nMP3 Evidence to show values at nodes being updated\nMP4 Evidence to show ‘visited node(s)’\nMP5 Evidence to show a correct calculation of at least one route\nMP6 Evidence to show more than one route has been calculated for at\nleast one town\nCorrect Answers (Max 2)\nTwo marks for all six correct values\nOne mark for four or five correct values.\nT V W X Y Z\n6 10 13 18 21 28\nQuestion Answer Marks Guidance",
      "source_pages": [
        12
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p12.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q09",
      "question_id": "9618-2025-on-33-q09",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 9,
      "topic": "Security",
      "topic_slug": "9618-topic-17-security",
      "marks": 4,
      "status": "available",
      "reason": null,
      "text": "9 One mark per mark point (Max 4) 4\nMP1 the company generates a public and private key pair locally using a\nweb browser and an RSA key generator tool, which may be part of\nthe CA’s web page\nMP2 the company requests a digital certificate from a Certificate\nAuthority (CA)\nMP3 the CA responds with its public key and digital certificate,\nMP4 … signed with its private key\nMP5 the company gathers authentication information e.g. its public key\nMP6 … and sends it to the CA signed with the company’s private key and\nencrypted with the CA’s public key\nMP7 the CA verifies the received information and generates/issues the\ndigital certificate.\n© Cambridge University Press & Assessment 2025 Page 12 of 16",
      "source_pages": [
        12
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-17-security/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p12.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q10",
      "question_id": "9618-2025-on-33-q10",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 10,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 6,
      "status": "available",
      "reason": null,
      "text": "10(a) One mark per mark point (Max 3) 3\nMP1 Correct declaration of constant Maximum\nMP2 Both correctly declared integers\nMP3 Correct array declaration\nExample answer\nCONSTANT Maximum = 100\nDECLARE Base : INTEGER\nDECLARE Top : INTEGER\nDECLARE StackArray : ARRAY[1:100] OF STRING\n\n10(b) One mark per mark point (Max 3) 3\nMP1 Correct procedure definition structure\nMP2 Base pointer with appropriate value (0 or 1)\nMP3 Top pointer with appropriate value (–1, 0, 1)\nExample answer\nPROCEDURE InitialiseStack()\nBase  0\nTop  0\nENDPROCEDURE\nQuestion Answer Marks Guidance",
      "source_pages": [
        13
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p13.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q11",
      "question_id": "9618-2025-on-33-q11",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 11,
      "topic": "Computational thinking and problem-solving",
      "topic_slug": "9618-topic-19-computational-thinking-and-problem-solving",
      "marks": 3,
      "status": "available",
      "reason": null,
      "text": "11 One mark per mark point (Max 3) 3\nMP1 Recursion is beneficial for problems that can be broken down into\nsmaller, repetitive problems\nMP2 … especially for problems that have many possible branches / are\ntoo complex for an iterative approach\nMP3 An example e.g. solving mathematical series, sorting a pile of\ndocuments, etc.\n© Cambridge University Press & Assessment 2025 Page 13 of 16",
      "source_pages": [
        13
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-19-computational-thinking-and-problem-solving/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p13.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q12",
      "question_id": "9618-2025-on-33-q12",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 12,
      "topic": "Further programming",
      "topic_slug": "9618-topic-20-further-programming",
      "marks": 5,
      "status": "available",
      "reason": null,
      "text": "12(a) One mark per mark point (Max 3) 3\nMP1 An exception is an unplanned / unexpected event that occurs\nwhen a program is running\nMP2 … due to an error in programming/logic that wasn’t detected during\nprogram construction/compilation\nMP3 The effect of an exception can be that the program halts\nunexpectedly.\n\n12(b) One mark per mark point (Max 2) 2\nMP1 One mark for an example of an exception (see list in guidance)\nMP2 One mark for the reason for the given exception\nExample answer\nDivision by zero\nThe processor will not be able to evaluate this answer because a number\ndivided by zero is infinity, so the program will crash.\n© Cambridge University Press & Assessment 2025 Page 14 of 16",
      "source_pages": [
        14
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-20-further-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p14.png"
      ]
    },
    {
      "id": "9618-2025-on-33-q13",
      "question_id": "9618-2025-on-33-q13",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 3,
      "variant": "33",
      "question_number": 13,
      "topic": "Hardware and virtual machines",
      "topic_slug": "9618-topic-15-hardware-and-virtual-machines",
      "marks": 7,
      "status": "available",
      "reason": null,
      "text": "13 One mark per mark point (Max 7) 7\nMP1 LDM #250 seen\nMP2 Correct use of LDD 563\nMP3 Correct use of ADD with labelled address X\nMP4 Correct use of SUB with address 899\nMP5 At least one correct use of STO\nOpcode Operand\nLDM #250\nSTO X\nLDD 563\nSTO Y\nADD X\nSUB 899\nSTO Total\n© Cambridge University Press & Assessment 2025 Page 15 of 16\n\n13 MP6 Correct setting up of at least one labelled address and its value\nMP7 Correct setting up of remaining two labelled addresses and their\nvalues\nLabel Contents\nX: 250\nY: 125\nTotal: 312\n© Cambridge University Press & Assessment 2025 Page 16 of 16",
      "source_pages": [
        15,
        16
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_33.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_33.pdf?download=true",
      "html": "9618-topic-15-hardware-and-virtual-machines/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_33-p15.png",
        "../answer-assets/9618_w25_ms_33-p16.png"
      ]
    },
    {
      "id": "9618-2025-on-41-q01",
      "question_id": "9618-2025-on-41-q01",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 20,
      "status": "available",
      "reason": null,
      "text": "1(a) 1 mark each 2\n• (Global) 1D array initialised with 30 null values\n• (Global) TopofStack initialised with –1\nExample program code\nJava\npublic static Integer[] Stack = new Integer[30];\npublic static Integer TopOfStack;\npublic static void main(String args[]){\nfor(Integer X = 0; X < 30; X++){\nStack[X] = null;\n}\nTopOfStack = -1;\n}\nVB.NET\nDim Stack(29) As Integer\nDim TopOfStack As Integer\nSub Main(args As String())\nFor x = 0 To 29\nStack(x) = Nothing\nNext\nTopOfStack = -1\nEnd Sub\nPython\nStack = [None for x in range(30)]\nTopOfStack = -1\n© Cambridge University Press & Assessment 2025 Page 6 of 36\n\n1(b) 1 mark each 4\n• Function header (and end) taking one parameter, returning Boolean in all instances\n• Checking if stack is full (TopOfStack = 29) and, if it is, returning FALSE\n• Incrementing TopofStack\n• (Otherwise) Storing parameter in incremented TopOfStack position and returning TRUE\nExample program code\nJava\npublic static Boolean Push(Integer DataToPush){\nif(TopOfStack < 29){\nTopOfStack++;\nStack[TopOfStack] = DataToPush;\nreturn true;\n}\nreturn false;\n}\nVB.NET\nFunction Push(DataToPush)\nIf TopOfStack < 29 Then\nTopOfStack = TopOfStack + 1\nStack(TopOfStack) = DataToPush\nReturn True\nEnd If\nReturn False\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 7 of 36\n\n1(b) Python\ndef Push(DataToPush):\nglobal Stack\nglobal TopOfStack\nif TopOfStack < 29:\nTopOfStack = TopOfStack + 1\nStack[TopOfStack] = DataToPush\nreturn True\nelse:\nreturn False\n© Cambridge University Press & Assessment 2025 Page 8 of 36\n\n1(c) 1 mark each 4\n• Function header (and end) returning integer in all cases\n• Checking if stack empty (TopofStack = –1) and returning -999 when true\n• (Otherwise) Accessing and returning item at TopOfStack (before it's decremented)\n• Decrementing TopofStack\nExample program code\nJava\npublic static Integer Pop(){\nInteger DataReturn;\nif(TopOfStack == -1){\nreturn -999;\n}\nDataReturn = Stack[TopOfStack];\nTopOfStack--;\nreturn DataReturn;\n}\nVB.NET\nFunction Pop()\nIf TopOfStack = -1 Then\nReturn -999\nElse\nDim DataReturn As Integer = Stack(TopOfStack)\nTopOfStack = TopOfStack - 1\nReturn DataReturn\nEnd If\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 9 of 36\n\n1(c) Python\ndef Pop():\nglobal Stack\nglobal TopOfStack\nif TopOfStack == -1:\nreturn -999\nelse:\nDataReturn = Stack[TopOfStack]\nTopOfStack = TopOfStack - 1\nreturn DataReturn\n© Cambridge University Press & Assessment 2025 Page 10 of 36\n\n1(d) 1 mark each 4\n• Looping 40 times\n• Generating random number between 0 and 1000 inclusive inside the loop\n• Calling Push() with each random number and storing/using return value … … if return value is FALSE output Stack\nfull and breaking out of loop\nExample program code\nJava\nfor(Integer X = 0; X < 40; X++){\nPushed = Push(RandomNumber.nextInt(1001));\nif(Pushed == false){\nSystem.out.println(\"Stack full\");\nX = 40;\n}\n}\nVB.NET\nFor x = 0 To 39\nPushed = Push(RandomNumber.Next(0, 1000))\nIf Pushed = False Then\nConsole.WriteLine(\"Stack full\")\nx = 40\nEnd If\nNext\nPython\nfor x in range(40):\nPushed = Push(random.randint(0,1000))\nif Pushed == False:\nprint(\"Stack full\")\nbreak\n© Cambridge University Press & Assessment 2025 Page 11 of 36\n\n1(e) 1 mark each 4\n• Procedure header (and end) and output of highest and lowest include appropriate messages\n• Calls Pop() until there are no items left in stack (return value = –999 // TopOfStack = -1) and\nstoring/using return values\n• Finds and outputs highest value from returned values\n• Finds and outputs lowest value from returned values\nExample program code\nJava\npublic static void FindValues(){\nInteger Highest;\nInteger Lowest;\nHighest = Pop();\nLowest = Highest;\nInteger ReturnValue = Highest;\nwhile(ReturnValue != -999){\nif(ReturnValue > Highest){\nHighest = ReturnValue;\n}\nif(ReturnValue < Lowest){\nLowest = ReturnValue;\n}\nReturnValue = Pop();\n}\nSystem.out.println(\"The highest value is \" + Highest + \" and the lowest value is \" +\nLowest);\n}\n© Cambridge University Press & Assessment 2025 Page 12 of 36\n\n1(e) VB.NET\nSub FindValues()\nDim Highest, Lowest As Integer\nHighest = Pop()\nLowest = Highest\nDim ReturnValue As Integer = Highest\nWhile ReturnValue <> -999\nIf ReturnValue > Highest Then\nHighest = ReturnValue\nEnd If\nIf ReturnValue < Lowest Then\nLowest = ReturnValue\nEnd If\nReturnValue = Pop()\nEnd While\nConsole.WriteLine(\"The highest value is \" & Highest & \" and the lowest value is \" &\nLowest)\nEnd Sub\nPython\ndef FindValues():\nHighest = Pop()\nLowest = Highest\nReturnValue = Lowest\nwhile(ReturnValue != -999):\nif ReturnValue > Highest:\nHighest = ReturnValue\nif ReturnValue < Lowest:\nLowest = ReturnValue\nReturnValue = Pop()\nprint(\"The highest value is\", Highest, \"and the lowest value is\", Lowest)\n© Cambridge University Press & Assessment 2025 Page 13 of 36\n\n1(f)(i) 1 mark for calling FindValues() 1\nExample program code\nJava\nFindValues();\nVB.NET\nFindValues()\nPython\nFindValues()\n\n1(f)(ii) 1 mark for a screenshot of output showing 1\nStack full output once\nLowest value output in an appropriate message\nHighest value output in an appropriate message\nLowest and Highest must be 0–1000 inclusive\n© Cambridge University Press & Assessment 2025 Page 14 of 36",
      "source_pages": [
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_41-p06.png",
        "../answer-assets/9618_w25_ms_41-p07.png",
        "../answer-assets/9618_w25_ms_41-p08.png",
        "../answer-assets/9618_w25_ms_41-p09.png",
        "../answer-assets/9618_w25_ms_41-p10.png",
        "../answer-assets/9618_w25_ms_41-p11.png",
        "../answer-assets/9618_w25_ms_41-p12.png",
        "../answer-assets/9618_w25_ms_41-p13.png",
        "../answer-assets/9618_w25_ms_41-p14.png"
      ]
    },
    {
      "id": "9618-2025-on-41-q02",
      "question_id": "9618-2025-on-41-q02",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 30,
      "status": "available",
      "reason": null,
      "text": "2(a)(i) 1 mark each 4\n• Class header (and end)\n• Declaration of 2 private attributes with correct data types\n• Constructor header (and end) within class with 2 parameters …\n• … assigning parameters to attributes\nExample program code\nJava\nclass Train{\nprivate String Number;\nprivate Integer Route;\npublic Train(String pNumber, Integer pRoute){\nNumber = pNumber;\nRoute = pRoute;\n}}\nVB.NET\nClass Train\nPrivate TrainIDNumber As String\nPrivate Route As Integer\nSub New(pNumber, pRoute)\nTrainIDNumber = pNumber\nRoute = pRoute\nEnd Sub\nEnd Class\nPython\nclass Train():\ndef __init__(self, pNumber, pRoute):\nself.__TrainIDNumber = pNumber #string\nself.__Route = pRoute #integer\n© Cambridge University Press & Assessment 2025 Page 15 of 36\n\n2(a)(ii) 1 mark each 3\n• One get method header (and end) with no parameter …\n• … returning correct attribute\n• Second correct get method\nExample program code\nJava\npublic String GetTrainNumber(){\nreturn Number;\n}\npublic Integer GetRoute(){\nreturn Route;\n}\nVB.NET\nFunction GetTrainIDNumber()\nReturn TrainIDNumber\nEnd Function\nFunction GetRoute()\nReturn Route\nEnd Function\nPython\ndef GetTrainIDNumber(self):\nreturn self.__TrainIDNumber\ndef GetRoute(self):\nreturn self.__Route\n© Cambridge University Press & Assessment 2025 Page 16 of 36\n\n2(b) 1 mark each 2\n• One instance of train with correct arguments and stored in a variable/structure\n• Remaining three instances correct\nExample program code\nJava\nTrain FirstTrain = new Train(\"12ADV\", 134);\nTrain SecondTrain = new Train(\"33ART\", 20);\nTrain ThirdTrain = new Train(\"9FKF\", 3);\nTrain FourthTrain = new Train(\"21VBC\", 24)\nVB.NET\nDim FirstTrain As Train = New Train(\"12ADV\", 134)\nDim SecondTrain As Train = New Train(\"33ART\", 20)\nDim ThirdTrain As Train = New Train(\"9FKF\", 3)\nDim FourthTrain As Train = New Train(\"21VBC\", 24)\nPython\nFirstTrain = Train(\"12ADV\",134)\nSecondTrain = Train(\"33ART\",20)\nThirdTrain = Train(\"9FKF\",3)\nFourthTrain = Train(\"21VBC\",24)\n© Cambridge University Press & Assessment 2025 Page 17 of 36\n\n2(c)(i) 1 mark each 3\n• Class header (and end) with four private attributes with appropriate data types\n• Constructor header (and end) within class taking 2 parameters …\n• … assigning parameters to attributes, initialising NumberTrains to 0, initialising Trains to an empty array\nExample program code\nJava\nclass Station{\nprivate String StationID;\nprivate Integer NumberPlatforms;\nprivate Train[] Trains = new Train[10];\nprivate Integer NumberTrains;\npublic Station(String pID, Integer pNumberOfPlatforms){\nStationID = pID;\nNumberPlatforms = pNumberOfPlatforms;\nNumberTrains = 0;\n}}\nVB.NET\nClass Station\nPrivate StationID As String\nPrivate NumberPlatforms As Integer\nPrivate Trains(9) As Train\nPrivate NumberTrains As Integer\nSub New(pID, pNumberOfPlatforms)\nStationID = pID\nNumberPlatforms = pNumberOfPlatforms\nNumberTrains = 0\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2025 Page 18 of 36\n\n2(c)(i) Python\nclass Station():\ndef __init__(self, pID, pNumberOfPlatforms):\nself.__StationID = pID #string\nself.__NumberPlatforms = pNumberOfPlatforms #integer\nself.__Trains = [] #train 10 elements\nself.__NumberTrains = 0 #integer\n© Cambridge University Press & Assessment 2025 Page 19 of 36\n\n2(c)(ii) 1 mark each 4\n• Method header (and close) taking one Train parameter\n• Checking if all platforms are full and returning FALSE\n• (Otherwise) Storing parameter in array Trains …\n• … incrementing NumberTrains and returning True\nExample program code\nJava\npublic Boolean AddTrain(Train NewTrain){\nif(NumberTrains >= NumberPlatforms){\nreturn false;\n}\nTrains[NumberTrains] = NewTrain;\nNumberTrains++;\nreturn true;\n}\nVB.NET\nFunction AddTrain(NewTrain)\nIf NumberTrains >= NumberPlatforms Then\nReturn False\nEnd If\nTrains(NumberTrains) = NewTrain\nNumberTrains = NumberTrains + 1\nReturn True\nEnd Function\nPython\ndef AddTrain(self, NewTrain):\nif self.__NumberTrains >= self.__NumberPlatforms:\nreturn False\nelse:\nself.__Trains.append(NewTrain)\nself.__NumberTrains += 1\nreturn True\n© Cambridge University Press & Assessment 2025 Page 20 of 36\n\n2(c)(iii) 1 mark each 6\n• Method header (and close) and returning a string in all cases\n• Checking if no trains and returning \"There are no trains\"\n• (Otherwise) Looping through each train in the station …\n• … accessing train ID number and route number using get methods\n• … creating a string with ID number and route number for each train\n• … returning correctly formatted string\nExample program code\nJava\npublic String GetTrains(){\nif(NumberTrains == 0){\nreturn \"There are no trains\";\n}\nString OutputLine = \"The trains at station \" + StationID + \" are: \\n\";\nfor(Integer x =0; x < NumberTrains; x++){\nOutputLine = OutputLine + Trains[x].GetTrainNumber() + \" on route number \" +\nTrains[x].GetRoute() + \"\\n\";\n}\nreturn OutputLine;\n}\nVB.NET\nFunction GetTrains()\nIf NumberTrains = 0 Then\nReturn \"There are no trains\"\nEnd If\nDim OutputLine As String = \"The trains at station \" & StationID & \" are:\" & vbNewLine\nFor x = 0 To NumberTrains - 1\nOutputLine = OutputLine & Trains(x). GetTrainIDNumber() & \" on route number \" &\nTrains(x).GetRoute() & vbNewLine\nNext\nReturn OutputLine\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 21 of 36\n\n2(c)(iii) Python\ndef GetTrains(self):\nif self.__NumberTrains == 0:\nreturn \"There are no trains\"\nOutputLine = \"The trains at station \" + self.__StationID + \" are: \\n\"\nfor x in range(self.__NumberTrains):\nOutputLine = OutputLine + self.__Trains[x]. GetTrainIDNumber() + \" on route number\n\" + str(self.__Trains[x].GetRoute()) + \"\\n\"\nreturn OutputLine\n\n2(d)(i) 1 mark each 2\n• One instance of Station created with correct arguments and stored\n• Second correct instance and stored\nExample program code\nJava\nStation SouthStation = new Station(\"STH\", 2);\nStation NorthStation = new Station(\"NTH\", 1);\nVB.NET\nDim SouthStation As Station = New Station(\"STH\", 2)\nDim NorthStation As Station = New Station(\"NTH\", 1)\nPython\nSouthStation = Station(\"STH\",2)\nNorthStation = Station(\"NTH\",1)\n© Cambridge University Press & Assessment 2025 Page 22 of 36\n\n2(d)(ii) 1 mark each 4\n• Calling AddTrain for 3 correct trains for station STH once\n• Calling AddTrain for 1 correct train for station NTH once\n• Outputting \"Station is full\" if any return value is FALSE\n• Calling GetTrains() for both stations and outputting return values\nExample program code\nJava\nBoolean ReturnValue = SouthStation.AddTrain(FirstTrain);\nif(ReturnValue == false) {\nSystem.out.println(\"Station is full\");\n}\nReturnValue = SouthStation.AddTrain(SecondTrain);\nif(ReturnValue == false) {\nSystem.out.println(\"Station is full\");\n}\nReturnValue = SouthStation.AddTrain(ThirdTrain);\nif(ReturnValue == false) {\nSystem.out.println(\"Station is full\");\n}\nReturnValue = NorthStation.AddTrain(FourthTrain);\nif(ReturnValue == false) {\nSystem.out.println(\"Station is full\");\n}\nSystem.out.println(SouthStation.GetTrains());\nSystem.out.println(NorthStation.GetTrains());\nVB.NET\nDim ReturnValue As Boolean = SouthStation.AddTrain(FirstTrain)\nIf ReturnValue = False Then\nConsole.WriteLine(\"Station is full\")\nEnd If\nReturnValue = SouthStation.AddTrain(SecondTrain)\nIf ReturnValue = False Then\n© Cambridge University Press & Assessment 2025 Page 23 of 36\n\n2(d)(ii) Console.WriteLine(\"Station is full\")\nEnd If\nReturnValue = SouthStation.AddTrain(ThirdTrain)\nIf ReturnValue = False Then\nConsole.WriteLine(\"Station is full\")\nEnd If\nReturnValue = NorthStation.AddTrain(FourthTrain)\nIf ReturnValue = False Then\nConsole.WriteLine(\"Station is full\")\nEnd If\nConsole.WriteLine(SouthStation.GetTrains())\nConsole.WriteLine(NorthStation.GetTrains())\nPython\nReturnValue = SouthStation.AddTrain(FirstTrain)\nif ReturnValue == False:\nprint(\"Station is full\")\nReturnValue = SouthStation.AddTrain(SecondTrain)\nif ReturnValue == False:\nprint(\"Station is full\")\nReturnValue = SouthStation.AddTrain(ThirdTrain)\nif ReturnValue == False:\nprint(\"Station is full\")\nReturnValue = NorthStation.AddTrain(FourthTrain)\nif ReturnValue == False:\nprint(\"Station is full\")\nprint(SouthStation.GetTrains())\nprint(NorthStation.GetTrains())\n© Cambridge University Press & Assessment 2025 Page 24 of 36\n\n2(d)(iii) 1 mark each, screenshot(s) showing: 2\n• One output of \"Station is full\"\n• Output of correct data for both stations (in correct format)\ne.g.\n© Cambridge University Press & Assessment 2025 Page 25 of 36",
      "source_pages": [
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23,
        24,
        25
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_41-p15.png",
        "../answer-assets/9618_w25_ms_41-p16.png",
        "../answer-assets/9618_w25_ms_41-p17.png",
        "../answer-assets/9618_w25_ms_41-p18.png",
        "../answer-assets/9618_w25_ms_41-p19.png",
        "../answer-assets/9618_w25_ms_41-p20.png",
        "../answer-assets/9618_w25_ms_41-p21.png",
        "../answer-assets/9618_w25_ms_41-p22.png",
        "../answer-assets/9618_w25_ms_41-p23.png",
        "../answer-assets/9618_w25_ms_41-p24.png",
        "../answer-assets/9618_w25_ms_41-p25.png"
      ]
    },
    {
      "id": "9618-2025-on-41-q03",
      "question_id": "9618-2025-on-41-q03",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "41",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 25,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark each 2\n• Class header (and end) and constructor header (and end) in class\n• Constructor takes two parameters and stores each in attributes\nExample program code\nJava\nclass Record{\npublic Integer Key;\npublic String Data;\npublic Record(Integer pKey, String pData){\nKey = pKey;\nData = pData;\n}\n}\nVB.NET\nClass Record\nDim Key As Integer\nDim Data As String\nSub New(pKey, pData)\nKey = pKey\nData = pData\nEnd Sub\nEnd Class\nPython\nclass Record:\ndef __init__(self, pKey, pData):\nself.Key = pKey #integer\nself.Data = pData #string\n© Cambridge University Press & Assessment 2025 Page 26 of 36\n\n3(b) 1 mark each 2\n• 2D array of 100  10 elements of type Record\n• Procedure InitialiseHashTable() header (and end) and initialises each element in the 2D array to an empty/null\nrecord in procedure\nExample program code\nJava\npublic static Record[][] HashTable = new Record[100][10];\npublic static void InitialiseHashTable(){\nRecord EmptyRecord = new Record(-1,\"-1\");\nfor(Integer X = 0; X < 100; X++){\nfor(Integer Y = 0; Y < 10; Y++){\nHashTable[X][Y] = EmptyRecord;\n}\n}\n}\nVB.NET\nDim HashTable(99, 9) As Record\nSub InitialiseHashTable()\nDim EmptyRecord As Record = New Record(-1, \"\")\nFor X = 0 To 99\nFor Y = 0 To 9\nHashTable(X, Y) = EmptyRecord\nNext\nNext\nEnd Sub\nPython\nHashTable = []\ndef InitialiseHashTable():\nglobal HashTable\nHashTable = [[Record(-1,\"\")]*10 for i in range(100)]\n© Cambridge University Press & Assessment 2025 Page 27 of 36\n\n3(c) 1 mark each 2\n• Function header (and end) taking one parameter and returning calculated hash\n• …. hash calculated correctly from parameter\nExample program code\nJava\npublic static Integer Hash(Integer TheKey){\nreturn(TheKey % 100);\n}\nVB.NET\nFunction Hash(Key)\nReturn Key Mod 100\nEnd Function\nPython\ndef Hash(Key):\nreturn Key % 100\n© Cambridge University Press & Assessment 2025 Page 28 of 36\n\n3(d) 1 mark each 4\n• Procedure header (and end) taking one Record parameter\n• Calling Hash() using key from parameter and storing/using return value\n• Accessing HashTable[return][0] and storing parameter if no collision … … if collision: iterating through 2nd\ndimension to find empty index and store parameter in that position\nExample program code\nJava\npublic static void InsertData(Record RecordData){\nInteger HashValue = Hash(RecordData.Key);\nfor(Integer X = 0; X < 10; X++){\nif(HashTable[HashValue][X].Key.equals(-1)){\nHashTable[HashValue][X] = RecordData;\nX = 10;\n}\n}\n}\nVB.NET\nFunction InsertData(RecordData)\nDim HashValue As Integer = Hash(RecordData.Key)\nFor X = 0 To 9\nIf HashTable(HashValue, X).Key = -1 Then\nHashTable(HashValue, X) = RecordData\nX= 10\nEnd If\nNext X\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 29 of 36\n\n3(d) Python\ndef InsertData(RecordData):\nglobal HashTable\nHashValue = Hash(RecordData.Key)\nfor X in range(0, 10):\nif HashTable[HashValue][X].Key == -1:\nHashTable[HashValue][X] = RecordData\n© Cambridge University Press & Assessment 2025 Page 30 of 36\n\n3(e) 1 mark each to max 5 5\n• Procedure header (and end), opening file and closing file (in appropriate place)\n• Iterating through each line in file // reading each line in from file\n• Splitting each line read in by comma …\n• … creating Record object with each key and data as arguments …\n• … calling InsertData() with each object\n• Try, catch with appropriate output and all file access within try\nExample program code\nJava\npublic static void ReadData(){\nString[] Data = new String[3];\nInteger NewKey;\nInteger NewItem1;\nInteger NewItem2;\nRecord TheRecord;\ntry{\nFileReader File = new FileReader(\"HashTableData.txt\");\ntry{\nBufferedReader Reader = new BufferedReader(File);\nString Line= Reader.readLine();\nwhile (Line != null){\nLine = Line.replace(\"\\n\",\"\");\nData = Line.split(\",\");\nTheRecord = new Record(Integer.parseInt(Data[0]), Data[1]);\nInsertData(TheRecord);\nLine= Reader.readLine();\n}\nReader.close();\n}catch(IOException ex){}\n}catch(FileNotFoundException e){System.out.println(\"File not found\");}\n}\n© Cambridge University Press & Assessment 2025 Page 31 of 36\n\n3(e) VB.NET\nSub ReadData()\nDim Line As String\nDim Data(3) As String\nDim TheRecord As Record\nDim FileReader As New System.IO.StreamReader(\"HashTableData.txt\")\nWhile Not FileReader.EndOfStream\nLine = FileReader.ReadLine()\nData = Split(Line, \",\")\nTheRecord = New Record(Integer.Parse(Data(0)), Data(1))\nInsertData(TheRecord)\nEnd While\nFileReader.Close()\nEnd Sub\nPython\ndef ReadData():\nglobal HashTable\nFile = open(\"HashTableData.txt\")\nfor Line in File:\nData = Line.strip()\nData = Line.split(\",\")\nInsertData(Record(int(Data[0]), Data[1]))\nFile.close()\n© Cambridge University Press & Assessment 2025 Page 32 of 36\n\n3(f) 1 mark each 5\n• Function header (and end) taking one parameter and returning string in all cases\n• Calling Hash() with parameter and storing/using return value\n• Iterating through 2nd dimension at HashTable[return value] and comparison to parameter …\n• … returning data if found/equal\n• … returning \"Not found\" if not found by the end of the dimension\nExample program code\nJava\npublic static String GetRecord(Integer Key){\nInteger HashValue = Hash(Key);\nfor(Integer X = 0; X < 10; X++){\nif(HashTable[HashValue][X].Key.equals(Key)){\nreturn(HashTable[HashValue][X].Data);\n}\n}\nreturn \"Not found\";\n}\nVB.NET\nFunction GetRecord(Key)\nDim HashValue As Integer = Hash(Key)\nFor X = 0 To 9\nIf HashTable(HashValue, X).Key = Key Then\nReturn HashTable(HashValue, X).Data\nEnd If\nNext X\nReturn \"Not found\"\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 33 of 36\n\n3(f) Python\ndef GetRecord(Key):\nglobal HashTable\nHashValue = Hash(Key)\nfor X in range(0, 10):\nif HashTable[HashValue][X].Key == Key:\nreturn HashTable[HashValue][X].Data\nreturn \"Not found\"\n© Cambridge University Press & Assessment 2025 Page 34 of 36\n\n3(g)(i) 1 mark each 3\n• Calling InitialiseHashTable() then ReadData()\n• Taking five (integer) inputs\n• Calling GetRecord() with each input and outputting return value\nExample program code\nJava\npublic static void main(String args[]){\nInitialiseHashTable();\nReadData();\nScanner scanner = new Scanner(System.in);\nfor(Integer X = 0; X < 5; X++){\nSystem.out.println(\"Enter key field\");\nSystem.out.println(GetRecord(Integer.parseInt(scanner.nextLine())));\n}\n}\nVB.NET\nSub Main(args As String())\nInitialiseHashTable()\nReadData()\nFor X = 0 To 5\nConsole.WriteLine(\"Enter key field\")\nConsole.WriteLine(GetRecord(Console.ReadLine()))\nNext\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 35 of 36\n\n3(g)(i) Python\nInitialiseHashTable()\nReadData()\nfor x in range(5):\nKey = int(input(\"Enter key field \"))\nprint(GetRecord(Key))\n\n3(g)(ii) 1 mark each for screenshot(s) showing 2\n• Input of the 4 integers and matching word output\n528 permission\n1128 peace\n1828 precedent\n1062 up\n• Input of 39 and output of Not found\ne.g.\n© Cambridge University Press & Assessment 2025 Page 36 of 36",
      "source_pages": [
        26,
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_41.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_41.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_41-p26.png",
        "../answer-assets/9618_w25_ms_41-p27.png",
        "../answer-assets/9618_w25_ms_41-p28.png",
        "../answer-assets/9618_w25_ms_41-p29.png",
        "../answer-assets/9618_w25_ms_41-p30.png",
        "../answer-assets/9618_w25_ms_41-p31.png",
        "../answer-assets/9618_w25_ms_41-p32.png",
        "../answer-assets/9618_w25_ms_41-p33.png",
        "../answer-assets/9618_w25_ms_41-p34.png",
        "../answer-assets/9618_w25_ms_41-p35.png",
        "../answer-assets/9618_w25_ms_41-p36.png"
      ]
    },
    {
      "id": "9618-2025-on-42-q01",
      "question_id": "9618-2025-on-42-q01",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 28,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) 1 mark each 4\n• Class header (and end)\n• 4 private attributes with correct data types\n• Constructor header (and end) taking 2 parameters within class …\n• … within constructor assigning parameters to Species and DistancePerHour and assigning 500.0 to XPosition\nand YPosition\nExample program code\nJava\nclass Bird{\nprivate String Species;\nprivate Double DistancePerHour;\nprivate Double XPosition;\nprivate Double YPosition;\npublic Bird(Double pDistancePerHour, String pSpecies){\nSpecies = pSpecies;\nDistancePerHour = pDistancePerHour;\nXPosition = 500.0;\nYPosition = 500.0;}}\nVB.NET\nClass Bird\nPrivate Species As String\nPrivate DistancePerHour As Single\nPrivate XPosition As Single\nPrivate YPosition As Single\nSub New(pDistancePerHour, pSpecies)\nSpecies = pSpecies\nDistancePerHour = pDistancePerHour\nXPosition = 500.0\nYPosition = 500.0\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2025 Page 6 of 38\n\n1(a)(i) Python\nclass Bird:\ndef __init__(self, pDistancePerHour, pSpecies):\nself.__Species = pSpecies #string\nself.__DistancePerHour = pDistancePerHour #real\nself.__XPosition = 500.0 #real\nself.__YPosition = 500.0 #real\n\n1(a)(ii) 1 mark each 2\n• Get method header (and end) with no parameter ….\n• … returning Species\nExample program code\nJava\npublic String GetSpecies(){\nreturn Species;\n}\nVB.NET\nFunction GetSpecies()\nReturn Species\nEnd Function\nPython\ndef GetSpecies(self):\nreturn self.__Species\n© Cambridge University Press & Assessment 2025 Page 7 of 38\n\n1(a)(iii) 1 mark each 3\n• Get method header (and end) with no parameter, returning a value\n• Creating correct string using attributes …\n• … returning this string\nExample program code\nJava\npublic String GetPosition(){\nString ReturnValue = \"X = \" + XPosition + \" Y = \" + YPosition;\nreturn ReturnValue;\n}\nVB.NET\nFunction GetPosition()\nDim ReturnValue As String = \"X = \" & XPosition & \" Y = \" & YPosition\nReturn ReturnValue\nEnd Function\nPython\ndef GetPosition(self):\nReturnValue = \"X = \" + str(self.__XPosition) + \" Y = \" + str(self.__YPosition)\nreturn ReturnValue\n© Cambridge University Press & Assessment 2025 Page 8 of 38\n\n1(a)(iv) 1 mark each 5\n• Method header (and end) taking direction and minutes flying as parameters\n• Calculation of distance using minutes flying parameter and attribute DistancePerHour\n• Selection based on direction parameter …\n• … north adding to YPosition and south subtracting from YPosition\n• … east adding to XPosition and west subtracting from XPosition\nExample program code\nJava\npublic Boolean Move(String Direction, Integer MinsFlying){\nif(Direction.compareTo(\"E\") == 0){\nXPosition = XPosition + ((DistancePerHour / 60) * MinsFlying);\n}else if(Direction.compareTo(\"W\") == 0){\nXPosition = XPosition - ((DistancePerHour / 60) * MinsFlying);\n}else if(Direction.compareTo(\"N\") == 0){\nYPosition = YPosition + ((DistancePerHour / 60) * MinsFlying);\n}else if(Direction.compareTo(\"S\") == 0){\nYPosition = YPosition - ((DistancePerHour / 60) * MinsFlying);\n}\n}\n© Cambridge University Press & Assessment 2025 Page 9 of 38\n\n1(a)(iv) VB.NET\nFunction Move(Direction, MinsFlying)\nIf Direction = \"E\" Then\nXPosition = XPosition + ((DistancePerHour / 60) * MinsFlying)\nElseIf Direction = \"W\" Then\nXPosition = XPosition - ((DistancePerHour / 60) * MinsFlying)\nElseIf Direction = \"N\" Then\nYPosition = YPosition + ((DistancePerHour / 60) * MinsFlying)\nElseIf Direction = \"S\" Then\nYPosition = YPosition - ((DistancePerHour / 60) * MinsFlying)\nEnd If\nEnd Function\nPython\ndef Move(self, Direction, MinsFlying):\nif Direction == \"E\":\nself.__XPosition = self.__XPosition + ((self.__DistancePerHour/60)*MinsFlying)\nelif Direction == \"W\":\nself.__XPosition = self.__XPosition - ((self.__DistancePerHour/60)*MinsFlying)\nelif Direction == \"N\":\nself.__YPosition = self.__YPosition + ((self.__DistancePerHour/60)*MinsFlying)\nelif Direction == \"S\":\nself.__YPosition = self.__YPosition - ((self.__DistancePerHour/60)*MinsFlying)\n© Cambridge University Press & Assessment 2025 Page 10 of 38\n\n1(b) 1 mark each 3\n• Cockatiel 71.0 instance of Bird created …\n• Macaw 56.0 instance of Bird created …\n• … both stored in variables/structures\nExample program code\nJava\nBird FirstBird = new Bird(71.0, \"Cockatiel\");\nBird SecondBird = new Bird(56.0, \"Macaw\");\nVB.NET\nDim FirstBird As Bird = New Bird(71.0, \"Cockatiel\")\nDim SecondBird As Bird = New Bird(56.0, \"Macaw\")\nPython\nFirstBird = Bird(71.0, \"Cockatiel\")\nSecondBird = Bird(56.0, \"Macaw\")\n© Cambridge University Press & Assessment 2025 Page 11 of 38\n\n1(c)(i) 1 mark each 8\n• Output species, X and Y position for both Bird objects in appropriate messages(s)\n• Prompt and input of bird choice, time and direction …\n• … validating all three inputs …\n• … looping until all three are valid\n• Calling Move() for chosen bird …\n• … with only input direction and input time as arguments\n• Outputting new position for the bird moved\n• Using get methods throughout where appropriate\nExample program code\nJava\nInteger Choice;\nInteger Time;\nString Direction;\nScanner scanner = new Scanner(System.in);\nChoice = 0;\nwhile(Choice != 1 && Choice != 2){\nSystem.out.println(\"Which bird do you want to move\");\nSystem.out.println(\"Enter 1 for \" + FirstBird.GetSpecies() + \" is currently at \" +\nFirstBird.GetPosition());\nSystem.out.println(\"Enter 2 for \" + SecondBird.GetSpecies() + \" is currently at \" +\nSecondBird.GetPosition());\nChoice = Integer.parseInt(scanner.nextLine());\n}\nTime = -1;\nwhile(Time < 0 or Time > 500){\nSystem.out.println(\"To the nearest minute how long as the bird been flying?\");\nTime = Integer.parseInt(scanner.nextLine());\n}\nBoolean Valid = false;\nwhile(Valid == false){\n© Cambridge University Press & Assessment 2025 Page 12 of 38\n\n1(c)(i) Valid = true;\nSystem.out.println(\"Which direction has the bird been flying, North, South, East or\nWest?\");\nDirection = scanner.nextLine().toUpperCase();\nif(Direction.compareTo(\"NORTH\") == 0 || Direction.compareTo(\"N\") == 0){\nif(Choice == 1){\nFirstBird.Move(\"N\",Time);\n}else{\nSecondBird.Move(\"N\", Time);\n}\n} else if(Direction.compareTo(\"SOUTH\")== 0 || Direction.compareTo(\"S\") == 0){\nif(Choice == 1){\nFirstBird.Move(\"S\",Time);\n}else{\nSecondBird.Move(\"S\", Time);\n}\n} else if(Direction.compareTo(\"EAST\")== 0 || Direction.compareTo(\"E\") == 0){\nif(Choice == 1){\nFirstBird.Move(\"E\",Time);\n}else{\nSecondBird.Move(\"E\", Time);\n}\n} else if(Direction.compareTo(\"WEST\")== 0 || Direction.compareTo(\"W\") == 0){\nif(Choice == 1){\nFirstBird.Move(\"W\",Time);\n}else{\nSecondBird.Move(\"W\", Time);\n}\n}else{\nValid = false;\n}\n}\nSystem.out.println(FirstBird.GetSpecies() + \" is currently at \" + FirstBird.GetPosition());\n© Cambridge University Press & Assessment 2025 Page 13 of 38\n\n1(c)(i) System.out.println(SecondBird.GetSpecies() + \" is currently at \" +\nSecondBird.GetPosition());\nVB.NET\nDim Choice As Integer\nDim Time As Integer\nDim Direction As String\nChoice = 0\nWhile Choice <> 1 And Choice <> 2\nConsole.WriteLine(\"Which bird do you want to move\")\nConsole.WriteLine(\"Enter 1 for \" & FirstBird.GetSpecies() & \" is currently at \" &\nFirstBird.GetPosition())\nConsole.WriteLine(\"Enter 2 for \" & SecondBird.GetSpecies() & \" is currently at \" &\nSecondBird.GetPosition())\nChoice = Console.ReadLine\nEnd While\nTime = -1\nWhile Time < 0 Or Time > 500\nConsole.WriteLine(\"To the nearest minute how long has the bird been flying \")\nTime = Console.ReadLine\nEnd While\nDim Valid As Boolean = False\nWhile (Valid = False)\nValid = True\nConsole.WriteLine(\"Which direction has the bird been flying, North, South, East or West\n\")\nDirection = Console.ReadLine().ToUpper\nIf Direction = \"NORTH\" Or Direction = \"N\" Then\nIf Choice = 1 Then\nFirstBird.Move(\"N\", Time)\nElse\nSecondBird.Move(\"N\", Time)\nEnd If\n© Cambridge University Press & Assessment 2025 Page 14 of 38\n\n1(c)(i) ElseIf Direction = \"SOUTH\" Or Direction = \"S\" Then\nIf Choice = 1 Then\nFirstBird.Move(\"S\", Time)\nElse\nSecondBird.Move(\"S\", Time)\nEnd If\nElseIf Direction = \"EAST\" Or Direction = \"E\" Then\nIf Choice = 1 Then\nFirstBird.Move(\"E\", Time)\nElse\nSecondBird.Move(\"E\", Time)\nEnd If\nElseIf Direction = \"WEST\" Or Direction = \"W\" Then\nIf Choice = 1 Then\nFirstBird.Move(\"W\", Time)\nElse\nSecondBird.Move(\"W\", Time)\nEnd If\nElse\nValid = False\nEnd If\nEnd While\nConsole.WriteLine(FirstBird.GetSpecies() & \" is currently at \" & FirstBird.GetPosition())\nConsole.WriteLine(SecondBird.GetSpecies() & \" is currently at \" & SecondBird.GetPosition())\nPython\nChoice = 0\nwhile Choice != 1 and Choice != 2:\nprint(\"Which bird do you want to move\")\nprint(\"Enter 1 for\", FirstBird.GetSpecies(), \"is currently at\",\nFirstBird.GetPosition())\nChoice = -1\nprint(\"Enter 2 for\", SecondBird.GetSpecies(), \"is currently at\",\nSecondBird.GetPosition())\n© Cambridge University Press & Assessment 2025 Page 15 of 38\n\n1(c)(i) Choice = int(input())\nTime = -1\nwhile Time < 0 || Time > 500:\nTime = int(input(\"To the nearest minute how long has the bird been flying \"))\nValid = False\nwhile Valid == False:\nValid = True\nDirection = input(\"Which direction has the bird been flying, North, South, East or West\n\").upper()\nif Direction == \"NORTH\" or Direction == \"N\":\nif Choice == 1:\nFirstBird.Move(\"N\",Time)\nelse:\nSecondBird.Move(\"N\",Time)\nelif Direction == \"SOUTH\" or Direction == \"S\":\nif Choice == 1:\nFirstBird.Move(\"S\",Time)\nelse:\nSecondBird.Move(\"S\",Time)\nelif Direction == \"EAST\" or Direction == \"E\":\nif Choice == 1:\nFirstBird.Move(\"E\",Time)\nelse:\nSecondBird.Move(\"E\",Time)\nelif Direction == \"WEST\" or Direction == \"W\":\nif Choice == 1:\nFirstBird.Move(\"W\",Time)\nelse:\nSecondBird.Move(\"W\",Time)\nelse:\nValid = False\nprint(FirstBird.GetSpecies(), \"is currently at\", FirstBird.GetPosition())\nprint(SecondBird.GetSpecies(), \"is currently at\", SecondBird.GetPosition())\n© Cambridge University Press & Assessment 2025 Page 16 of 38\n\n1(c)(ii) 1 mark for each: 3\n• screenshot showing inputs for one test with correct output\n• screenshot showing inputs for a second test with correct output\n• screenshot showing inputs for a third and fourth test with correct output\ne.g.\nTest 1:\nTest 2:\nTest 3:\nTest 4:\n© Cambridge University Press & Assessment 2025 Page 17 of 38",
      "source_pages": [
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_42-p06.png",
        "../answer-assets/9618_w25_ms_42-p07.png",
        "../answer-assets/9618_w25_ms_42-p08.png",
        "../answer-assets/9618_w25_ms_42-p09.png",
        "../answer-assets/9618_w25_ms_42-p10.png",
        "../answer-assets/9618_w25_ms_42-p11.png",
        "../answer-assets/9618_w25_ms_42-p12.png",
        "../answer-assets/9618_w25_ms_42-p13.png",
        "../answer-assets/9618_w25_ms_42-p14.png",
        "../answer-assets/9618_w25_ms_42-p15.png",
        "../answer-assets/9618_w25_ms_42-p16.png",
        "../answer-assets/9618_w25_ms_42-p17.png"
      ]
    },
    {
      "id": "9618-2025-on-42-q02",
      "question_id": "9618-2025-on-42-q02",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 26,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark each 3\n• Creation of 1D array …\n• … with 20 generated random integers between 0 and 100 (inclusive) …\n• … all 20 random integers are unique\nExample program code\nJava\npublic static void main(String args[]){\nInteger[] TheArray = new Integer[20];\nInteger Generated;\nInteger X = 0;\nRandom RandomNumber = new Random();\nwhile(X < 20){\nGenerated = RandomNumber.nextInt(101);\nif(Arrays.asList(TheArray).indexOf(Generated) < 0){\nTheArray[X] = Generated;\nX++;\n}\n}\n}\nVB.NET\nDim RandomNumber As Random = New Random()\nDim TheArray(19) As Integer\nDim Generated As Integer\nDim X As Integer = 0\nWhile X < 20\nGenerated = RandomNumber.Next(0, 100)\nIf Array.IndexOf(TheArray, Generated) < 0 Then\nTheArray(X) = Generated\nX = X + 1\nEnd If\nEnd While\n© Cambridge University Press & Assessment 2025 Page 18 of 38\n\n2(a) Python\nTheArray = []\nTheArray = random.sample(range(0,101),20)\n\n2(b) 1 mark each 3\n• Procedure header (and close) taking (array) as parameter\n• Outputting array contents once …\n• … on one line with a space between each integer\nExample program code\nJava\npublic static void PrintArray(Integer[] DataArray){\nString Output = \"\";\nfor(Integer X = 0; X < 20; X++){\nOutput += Integer.toString(DataArray[X]) + \" \";\n}\nSystem.out.println(Output);\n}\nVB.NET\nSub PrintArray(DataArray() As Integer)\nDim Output As String = \"\"\nFor X = 0 To 19\nOutput = Output + Str(DataArray(X)) + \" \"\nNext X\nConsole.WriteLine(Output)\nEnd Sub\nPython\ndef PrintArray(DataArray):\nOutput = \"\"\nfor Item in DataArray:\nOutput = Output + str(Item) + \" \"\nprint(Output)\n© Cambridge University Press & Assessment 2025 Page 19 of 38\n\n2(c) 1 mark each 5\n• Function header (and end) taking (array) parameter and returning a sorted array after sorting\n• Outer loop …\n• … inner loop ...\n• … comparing elements and swapping into ascending order\n• Sort must work for array of any length i.e. loops for length of parameter array\nExample program code\nJava\npublic static Integer[] BubbleSort(Integer[] DataArray){\nBoolean Swap = true;\nInteger Temp;\nwhile(Swap){\nSwap = false;\nfor(Integer X = 0; X < DataArray.length - 1; X++){\nif(DataArray[X] > DataArray[X+1]){\nTemp = DataArray[X];\nDataArray[X] = DataArray[X + 1];\nDataArray[X + 1] = Temp;\nSwap = true;\n}\n}\n}\nreturn DataArray;\n}\n© Cambridge University Press & Assessment 2025 Page 20 of 38\n\n2(c) VB.NET\nFunction BubbleSort(DataArray() As Integer)\nDim Swap As Boolean = True\nDim Temp As Integer\nWhile Swap = True\nSwap = False\nFor X = 0 To DataArray.Length - 2\nIf DataArray(X) > DataArray(X + 1) Then\nTemp = DataArray(X)\nDataArray(X) = DataArray(X + 1)\nDataArray(X + 1) = Temp\nSwap = True\nEnd If\nNext X\nEnd While\nReturn DataArray\nEnd Function\nPython\ndef BubbleSort(DataArray):\nSwap = True\nwhile Swap == True:\nSwap = False\nfor y in range(0, len(DataArray)-1):\nif DataArray[y] > DataArray[y+1]:\nDataArray[y], DataArray[y+1] = DataArray[y+1], DataArray[y]\nSwap = True\nreturn DataArray\n© Cambridge University Press & Assessment 2025 Page 21 of 38\n\n2(d)(i) 1 mark each 3\n• Calling PrintArray() with array as argument\n• Calling BubbleSort() with array as argument and storing/using return value\n• Outputting \"Sorted\" and calling PrintArray() with (returned) array as argument\nExample program code\nJava\nPrintArray(TheArray);\nInteger[] SortedArray = new Integer[20];\nSortedArray = BubbleSort(TheArray);\nSystem.out.println(\"Sorted\");\nPrintArray(SortedArray);\nVB.NET\nPrintArray(TheArray)\nDim SortedArray(19) As Integer\nSortedArray = BubbleSort(TheArray)\nConsole.WriteLine(\"Sorted\")\nPrintArray(SortedArray)\nPython\nPrintArray(TheArray)\nSortedArray = BubbleSort(TheArray)\nprint(\"Sorted\")\nPrintArray(SortedArray)\n\n2(d)(ii) 1 mark 1\n• Output shows unsorted array of 20 integers between 0 and 100 inclusive before sorting,\n“Sorted” output,\narray of the same integers sorting into ascending order.\nAll screenshots will be unique to the candidate\n© Cambridge University Press & Assessment 2025 Page 22 of 38\n\n2(e) 1 mark each 6\n• Function header (and end) taking four parameters and recursive function written\n• Calculating middle value\n• Comparing middle value to data parameter and returning index if equal\n• If middle is greater than, recursive call with middle –1 for upper\n• If middle is less than, recursive call with middle + 1 for lower\n• Checking if not found and returning –1\nExample program code\nJava\npublic static Integer RecursiveBinarySearch(Integer[] DataArray, Integer Lower, Integer\nUpper, Integer DataToFind){\nInteger Middle;\nif(Upper >= Lower){\nMiddle = Lower + (Upper - Lower) / 2;\nif(DataArray[Middle] == DataToFind){\nreturn Middle;\n}else if(DataArray[Middle] > DataToFind){\nreturn RecursiveBinarySearch(DataArray, Lower, Middle - 1, DataToFind);\n}else{\nreturn RecursiveBinarySearch(DataArray, Middle + 1, Upper, DataToFind);\n}\n}else{\nreturn -1;\n}\n}\n© Cambridge University Press & Assessment 2025 Page 23 of 38\n\n2(e) VB.NET\nFunction RecursiveBinarySearch(DataArray() As Integer, Lower As Integer, Upper As Integer,\nDataToFind As Integer)\nDim Middle As Integer\nIf Upper >= Lower Then\nMiddle = Lower + (Upper - Lower) \\ 2\nIf DataArray(Middle) = DataToFind Then\nReturn Middle\nElseIf DataArray(Middle) > DataToFind Then\nReturn RecursiveBinarySearch(DataArray, Lower, Middle - 1, DataToFind)\nElse\nReturn RecursiveBinarySearch(DataArray, Middle + 1, Upper, DataToFind)\nEnd If\nElse\nReturn -1\nEnd If\nEnd Function\nPython\ndef RecursiveBinarySearch(DataArray, Lower, Upper, DataToFind):\nif Upper >= Lower:\nMiddle = Lower + (Upper - Lower) // 2\nif DataArray[Middle] == DataToFind:\nreturn Middle\nelif DataArray[Middle] > DataToFind:\nreturn RecursiveBinarySearch(DataArray, Lower, Middle - 1, DataToFind)\nelse:\nreturn RecursiveBinarySearch(DataArray, Middle + 1, Upper, DataToFind)\nelse:\nreturn -1\n© Cambridge University Press & Assessment 2025 Page 24 of 38\n\n2(f)(i) 1 mark each 3\n• Prompt and input of integer\n• Call of RecursiveBinarySearch(SortedArray, 0, 19, input) and storing/using return value\n• Output of \"Not found\" if –1 returned and output \"Found at position\" with index returned if found\nExample program code\nJava\nSystem.out.println(\"Enter the number to find\");\nScanner scanner = new Scanner(System.in);\nInteger DataToFind = Integer.parseInt(scanner.nextLine());\nInteger Location = RecursiveBinarySearch(SortedArray, 0, 19, DataToFind);\nif(Location == -1){\nSystem.out.println(\"Not found\");\n}else{\nSystem.out.println(\"Found at position \" + Location);\n}\nVB.NET\nConsole.WriteLine(\"Enter the number to find \")\nDim DataToFind As Integer = Console.ReadLine()\nDim Location As Integer = RecursiveBinarySearch(SortedArray, 0, 19, DataToFind)\nIf Location = -1 Then\nConsole.WriteLine(\"Not found\")\nElse\nConsole.WriteLine(\"Found at position \" & Location)\nEnd If\nPython\nDataToFind = int(input(\"Enter the number to find \"))\nLocation = RecursiveBinarySearch(SortedArray, 0, 19, DataToFind)\nif Location == -1:\nprint(\"Not found\")\nelse:\nprint(\"Found at position\", Location)\n© Cambridge University Press & Assessment 2025 Page 25 of 38\n\n2(f)(ii) 1 mark each 2\n• screenshot showing smallest number in array input and found message with index 0 and screenshot showing highest\nnumber in array input and found message with index 19\n• screenshot showing a number not in the array input and an output of \"Not found\"\nAll screenshots will be unique to the candidate\n© Cambridge University Press & Assessment 2025 Page 26 of 38",
      "source_pages": [
        18,
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_42-p18.png",
        "../answer-assets/9618_w25_ms_42-p19.png",
        "../answer-assets/9618_w25_ms_42-p20.png",
        "../answer-assets/9618_w25_ms_42-p21.png",
        "../answer-assets/9618_w25_ms_42-p22.png",
        "../answer-assets/9618_w25_ms_42-p23.png",
        "../answer-assets/9618_w25_ms_42-p24.png",
        "../answer-assets/9618_w25_ms_42-p25.png",
        "../answer-assets/9618_w25_ms_42-p26.png"
      ]
    },
    {
      "id": "9618-2025-on-42-q03",
      "question_id": "9618-2025-on-42-q03",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "42",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 21,
      "status": "available",
      "reason": null,
      "text": "3(a) 1 mark each 3\n• (global) TreeArray declared as a 2D array with 50  3 elements …\n• … all initialised to –1\n• (global) RootPointer initialised to –1 and FreeNode initialised to 0\nExample program code\nJava\npublic static Integer FreeNode;\npublic static Integer RootPointer;\npublic static Integer[][] TreeArray = new Integer[50][3];\npublic static void main(String args[]){\nfor(Integer X = 0; X < 50; X++){\nTreeArray[X][0] = -1;\nTreeArray[X][1] = -1;\nTreeArray[X][2] = -1;\n}\nRootPointer = -1;\nFreeNode = 0;\n}\nVB.NET\nDim FreeNode As Integer\nDim TreeArray(0 To 49, 0 To 2) As Integer\nDim RootPointer As Integer\nSub Main(args As String())\nFor X = 0 To 49\nTreeArray(X, 0) = -1\nTreeArray(X, 1) = -1\nTreeArray(X, 2) = -1\nNext\nRootPointer = -1\nFreeNode = 0\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 27 of 38\n\n3(a) Python\nTreeArray = []\nfor x in range(50):\nTreeArray.append([-1,-1,-1])\nRootPointer = -1\nFreeNode = 0\n© Cambridge University Press & Assessment 2025 Page 28 of 38\n\n3(b) 1 mark each to max 7 7\n• Procedure header (and end) taking one (integer) parameter and storing parameter in array in index\nTreeArray[FreeNode][1]\n• Checking if tree is full (FreeNode = 50) and outputting \"The tree is full\"\n• Checking if tree is empty (RootPointer = -1 // FreeNode = 0) and if so, storing 0 in RootPointer\n• (if not empty) Comparing parameter to data at index TreeArray[RootPointer][1] …\n• … if less than, accessing left node …\n• … if greater than, accessing right node …\n• … until location found …\n• … updating parent node's appropriate pointer\n• Incrementing FreeNode\nExample program code\nJava\npublic static void AddNode(Integer NodeData){\nBoolean Placed;\nInteger CurrentNode;\nif(FreeNode <= 49){\nTreeArray[FreeNode][0] = -1;\nTreeArray[FreeNode][1] = NodeData;\nTreeArray[FreeNode][2] = -1;\nif(RootPointer == -1){\nRootPointer = 0;\n}else{\nPlaced = false;\nCurrentNode = RootPointer;\nwhile(Placed == false){\nif(NodeData < TreeArray[CurrentNode][1]){\nif(TreeArray[CurrentNode][0] == -1){\nTreeArray[CurrentNode][0] = FreeNode;\nPlaced = true;\n}else{\n© Cambridge University Press & Assessment 2025 Page 29 of 38\n\n3(b) CurrentNode = TreeArray[CurrentNode][0];\n}\n}else{\nif(TreeArray[CurrentNode][2] == -1){\nTreeArray[CurrentNode][2] = FreeNode;\nPlaced = true;\n}else{\nCurrentNode = TreeArray[CurrentNode][2];\n}\n}\n}\n}\nFreeNode++;\n}else{\nSystem.out.println(\"The tree is full\");\n}\n}\nVB.NET\nSub AddNode(NodeData)\nDim Placed As Boolean\nDim CurrentNode As Integer\nIf FreeNode <= 49 Then\nTreeArray(FreeNode, 0) = -1\nTreeArray(FreeNode, 1) = NodeData\nTreeArray(FreeNode, 2) = -1\nIf RootPointer = -1 Then\nRootPointer = 0\nElse\nPlaced = False\nCurrentNode = RootPointer\nWhile Placed = False\nIf NodeData < TreeArray(CurrentNode, 1) Then\nIf TreeArray(CurrentNode, 0) = -1 Then\nTreeArray(CurrentNode, 0) = FreeNode\n© Cambridge University Press & Assessment 2025 Page 30 of 38\n\n3(b) Placed = True\nElse\nCurrentNode = TreeArray(CurrentNode, 0)\nEnd If\nElse\nIf TreeArray(CurrentNode, 2) = -1 Then\nTreeArray(CurrentNode, 2) = FreeNode\nPlaced = True\nElse\nCurrentNode = TreeArray(CurrentNode, 2)\nEnd If\nEnd If\nEnd While\nEnd If\nFreeNode = FreeNode + 1\nElse\nConsole.WriteLine(\"The tree is full\")\nEnd If\nEnd Sub\nPython\ndef AddNode(NodeData):\nglobal FreeNode\nglobal TreeArray\nglobal RootPointer\nif FreeNode <= 49:\nTreeArray[FreeNode][0] = -1\nTreeArray[FreeNode][1] = NodeData\nTreeArray[FreeNode][2] = -1\nif RootPointer == -1:\nRootPointer = 0\nelse:\nPlaced = False\nCurrentNode = RootPointer\nwhile Placed == False:\nif NodeData < TreeArray[CurrentNode][1]:\n© Cambridge University Press & Assessment 2025 Page 31 of 38\n\n3(b) if TreeArray[CurrentNode][0] == -1:\nTreeArray[CurrentNode][0] = FreeNode\nPlaced = True\nelse:\nCurrentNode = TreeArray[CurrentNode][0]\nelse:\nif TreeArray[CurrentNode][2] == -1:\nTreeArray[CurrentNode][2] = FreeNode\nPlaced = True\nelse:\nCurrentNode = TreeArray[CurrentNode][2]\nFreeNode = FreeNode + 1\nelse:\nprint(\"The tree is full\")\n© Cambridge University Press & Assessment 2025 Page 32 of 38\n\n3(c) 1 mark each to max 4 4\n• Opening the file to read and closing the file in an appropriate place\n• Looping 50 times/through file/through each line/until EOF …\n• … reading in each line …\n• … calling AddNode() with each value read in\n• Exception handling try, catch, except with appropriate message\nExample program code\nJava\nInteger Line;\nString ReadData;\ntry{\nFileReader f = new FileReader(\"TreeData.txt\");\ntry{\nBufferedReader Reader = new BufferedReader(f);\nReadData = Reader.readLine();\nwhile (ReadData != null){\nLine = Integer.parseInt(ReadData);\nAddNode(Line);\nReadData = Reader.readLine();\n}\nReader.close();\n}catch(IOException ex){\n}\n}catch(FileNotFoundException e){\nSystem.out.println(\"File not found\");\n}\n© Cambridge University Press & Assessment 2025 Page 33 of 38\n\n3(c) VB.NET\nTry\nDim FileReader As New System.IO.StreamReader(\"TreeData.txt\")\nWhile Not FileReader.EndOfStream\nAddNode(FileReader.ReadLine())\nEnd While\nFileReader.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Cannot open file\")\nEnd Try\nPython\ntry:\nFile= open(\"TreeData.txt\")\nfor Line in File:\nAddNode(int(Line.strip()))\nFile.close()\nexcept:\nprint(\"Error cannot open file\")\n© Cambridge University Press & Assessment 2025 Page 34 of 38\n\n3(d) 1 mark each 5\n• Procedure header (and end) and with exception handling for writing to file: try, catch, except with appropriate message\n• Opening the file (Tree.txt) to write and closing the file in appropriate place\n• Looping through each element in array …\n• … creating correct string\n• … writing each string to the file\nExample program code\nJava\npublic static void WriteAllToFile(){\nFile TheFile = new File(\"Tree.txt\");\nString Line;\ntry{\nFileWriter FW = new FileWriter(TheFile, true);\nfor(Integer X = 0; X < 50; X++){\nLine = TreeArray[X][0] + \",\" + TreeArray[X][1] + \",\" + TreeArray[X][2];\nFW.write(Line);\nFW.write(\"\\n\");\n}\nFW.close();\n}catch(IOException ex){\nSystem.out.println(\"Cannot open file\");\n}\n}\n© Cambridge University Press & Assessment 2025 Page 35 of 38\n\n3(d) VB.NET\nSub WriteAllToFile()\nDim FileWriter As IO.StreamWriter = New IO.StreamWriter(\"Tree.txt\", False)\nDim Line As String\nTry\nFor x = 0 To 49\nLine = TreeArray(x, 0) & \",\" & TreeArray(x, 1) & \",\" & TreeArray(x, 2)\nFileWriter.WriteLine(Line)\nNext\nFileWriter.Close()\nCatch ex As Exception\nConsole.WriteLine(\"Cannot open or write to file\")\nEnd Try\nEnd Sub\nPython\ndef WriteAllToFile():\ntry:\nFile = open(\"Tree.txt\",\"a+\")\nfor x in range(0, 50):\nLine = str(TreeArray[x][0]) + \",\" + str(TreeArray[x][1])+ \",\" +\nstr(TreeArray[x][2]) + \"\\n\"\nFile.write(Line)\nFile.close()\nexcept:\nprint(\"Cannot write to file\")\n© Cambridge University Press & Assessment 2025 Page 36 of 38\n\n3(e)(i) 1 mark for calling WriteAllToFile() 1\nExample program code\nJava\nWriteAllToFile();\nVB.NET\nWriteAllToFile()\nPython\nWriteAllToFile()\n© Cambridge University Press & Assessment 2025 Page 37 of 38\n\n3(e)(ii) 1 mark for a screenshot that shows correct data stored, each node on a new line (in correct format). 1\nThe screenshot must include the filename.\ne.g.\n© Cambridge University Press & Assessment 2025 Page 38 of 38",
      "source_pages": [
        27,
        28,
        29,
        30,
        31,
        32,
        33,
        34,
        35,
        36,
        37,
        38
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_42.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_42.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_42-p27.png",
        "../answer-assets/9618_w25_ms_42-p28.png",
        "../answer-assets/9618_w25_ms_42-p29.png",
        "../answer-assets/9618_w25_ms_42-p30.png",
        "../answer-assets/9618_w25_ms_42-p31.png",
        "../answer-assets/9618_w25_ms_42-p32.png",
        "../answer-assets/9618_w25_ms_42-p33.png",
        "../answer-assets/9618_w25_ms_42-p34.png",
        "../answer-assets/9618_w25_ms_42-p35.png",
        "../answer-assets/9618_w25_ms_42-p36.png",
        "../answer-assets/9618_w25_ms_42-p37.png",
        "../answer-assets/9618_w25_ms_42-p38.png"
      ]
    },
    {
      "id": "9618-2025-on-43-q01",
      "question_id": "9618-2025-on-43-q01",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 1,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 31,
      "status": "available",
      "reason": null,
      "text": "1(a)(i) 1 mark each 5\n• Class header (and end where appropriate)\n• Declaring Code as string and Value as integer\n• Constructor header (and end where appropriate) within class …\n• … taking two parameters …\n• … assigning parameters to attributes\nExample program code.\nJava\nclass BoardObject{\npublic String Code;\npublic Integer Value;\npublic BoardObject(String pCode, Integer pValue){\nCode = pCode;\nValue = pValue;\n}\n}\nVB.NET\nPublic Class BoardObject\nPrivate Code As String\nPrivate Value As Integer\nSub New(pCode, pValue)\nCode = pCode\nValue = pValue\nEnd Sub\nEnd Class\nPython\nclass BoardObject():\ndef __init__(self, Code, Value):\nself.Code = Code #string\nself.Value = Value # integer\n© Cambridge University Press & Assessment 2025 Page 7 of 39\n\n1(a)(ii) 1 mark each 3\n• 1 get header (and end where appropriate) with no parameter …\n• … returning correct value without overriding\n• 2nd correct get method\nExample program code\nJava\npublic String GetCode(){\nreturn Code;\n}\npublic Integer GetValue(){\nreturn Value;\n}\nVB.NET\nFunction GetCode()\nReturn Code\nEnd Function\nFunction GetValue()\nReturn Value\nEnd Function\nPython\ndef GetCode(self):\nreturn self.Code\ndef GetValue(self):\nreturn self.Value\n© Cambridge University Press & Assessment 2025 Page 8 of 39\n\n1(a)(iii) 1 mark each 3\n• Creating one instance of BoardObject and storing in correct variable …\n• … with correct parameters\n• Remaining four created correctly and stored\nExample program code\nJava\nBoardObject Object1 = new BoardObject(\"A\",2);\nBoardObject Object2 = new BoardObject(\"B\",3);\nBoardObject Object3 = new BoardObject(\"C\",5);\nBoardObject Object4 = new BoardObject(\"D\",2);\nBoardObject Object5 = new BoardObject(\"E\",7);\nVB.NET\nDim Object1 As BoardObject = New BoardObject(\"A\", 2)\nDim Object2 As BoardObject = New BoardObject(\"B\", 3)\nDim Object3 As BoardObject = New BoardObject(\"C\", 5)\nDim Object4 As BoardObject = New BoardObject(\"D\", 2)\nDim Object5 As BoardObject = New BoardObject(\"E\", 7)\nPython\nObject1 = BoardObject(\"A\",2)\nObject2 = BoardObject(\"B\",3)\nObject3 = BoardObject(\"C\",5)\nObject4 = BoardObject(\"D\",2)\nObject5 = BoardObject(\"E\",7)\n© Cambridge University Press & Assessment 2025 Page 9 of 39\n\n1(b)(i) 1 mark each 4\n• Class header (and end where appropriate)\n• Constructor header (and end where appropriate) within class\n• Declaration of 2D array with 10  10 elements of type BoardObject\n• Storing BoardObject object with Code \"-\" and Value 0 in each array element\nExample program code\nJava\nclass Board{\nprivate BoardObject[][] TheBoard = new BoardObject[10][10];\npublic Board(){\nfor(Integer x = 0; x < 10; x++){\nfor(Integer y = 0; y < 10; y++){\nTheBoard[x][y] = new BoardObject(\"-\",0);\n}}}}\nVB.NET\nPublic Class Board\nPrivate TheBoard(9, 9) As BoardObject\nSub New()\nFor x = 0 To 9\nFor y = 0 To 9\nTheBoard(x, y) = New BoardObject(\"-\", 0)\nNext\nNext\nEnd Sub\nEnd Class\n© Cambridge University Press & Assessment 2025 Page 10 of 39\n\n1(b)(i) Python\nclass Board():\ndef __init__(self):\nself.TheBoard = [] #type BoardObject\nfor x in range(10):\nTempList = []\nfor y in range(10):\nTempList.append(BoardObject(\"-\",0))\nself.TheBoard.append(TempList)\n\n1(b)(ii) 1 mark each 2\n• Get method header taking 2 (integer) parameters …\n• … returning the BoardObject at Board position of parameters\nExample program code\nJava\npublic BoardObject GetObject(Integer Rowpos, Integer Columnpos){\nreturn TheBoard[Rowpos][Columnpos];\n}\nVB.NET\nFunction GetObject(Rowpos, Columnpos)\nReturn TheBoard(Rowpos, Columnpos)\nEnd Function\nPython\ndef GetObject(self, Rowpos, Columnpos):\nreturn self.TheBoard[Rowpos][Columnpos]\n© Cambridge University Press & Assessment 2025 Page 11 of 39\n\n1(b)(iii) 1 mark each 2\n• Set method header taking three parameters (TheObject, row, column) …\n• … storing parameter TheObject in TheBoard at parameters row and column\nExample program code\nJava\npublic void SetObject(BoardObject TheObject, Integer Rowpos, Integer Columnpos){\nTheBoard[Rowpos][Columnpos] = TheObject;\n}\nVB.NET\nSub SetObject(TheObject, Rowpos, Columnpos)\nTheBoard(Rowpos, Columnpos) = TheObject\nEnd Sub\nPython\ndef SetObject(self, TheObject, Rowpos, Columnpos):\nself.TheBoard[Rowpos][Columnpos] = TheObject\n© Cambridge University Press & Assessment 2025 Page 12 of 39\n\n1(b)(iv) 1 mark each 3\n• Method DisplayBoard() header (and end where appropriate) and using GetCode()\n• Outputting Code of all BoardObject elements in both indices (10  10)\n• … with each row on one line and space between each value\nExample program code\nJava\npublic void DisplayBoard(){\nString OutputLine;\nfor(Integer x = 0; x < 10; x++){\nOutputLine = \"\";\nfor(Integer y = 0; y < 10; y++){\nOutputLine = OutputLine + TheBoard[x][y].GetCode() + \" \";\n}\nSystem.out.println(OutputLine);\n}\n}\nVB.NET\nSub DisplayBoard()\nDim OutputLine As String\nFor x = 0 To 9\nOutputLine = \"\"\nFor y = 0 To 9\nOutputLine = OutputLine & TheBoard(x, y).GetCode() & \" \"\nNext\nConsole.WriteLine(OutputLine)\nNext\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 13 of 39\n\n1(b)(iv) Python\ndef DisplayBoard(self):\nfor x in range(10):\nOutputLine = \"\"\nfor y in range(10):\nOutputLine = OutputLine + str(self.TheBoard[x][y].GetCode()) + \" \"\nprint(OutputLine)\n© Cambridge University Press & Assessment 2025 Page 14 of 39\n\n1(c)(i) 1 mark each 3\n• Creating instance of Board and storing it\n• Storing all 5 objects in correct positions\n• Calling DisplayBoard()\nExample program code\nJava\nBoard GameBoard =new Board();\nBoardObject Object1 = new BoardObject(\"A\",2);\nBoardObject Object2 = new BoardObject(\"B\",3);\nBoardObject Object3 = new BoardObject(\"C\",5);\nBoardObject Object4 = new BoardObject(\"D\",2);\nBoardObject Object5 = new BoardObject(\"E\",7);\nGameBoard.SetObject(Object1, 0, 0);\nGameBoard.SetObject(Object2, 9, 9);\nGameBoard.SetObject(Object3, 4, 5);\nGameBoard.SetObject(Object4, 2, 2);\nGameBoard.SetObject(Object5, 8, 7);\nGameBoard.DisplayBoard();\nVB.NET\nDim GameBoard As Board = New Board()\nDim Object1 As BoardObject = New BoardObject(\"A\", 2)\nDim Object2 As BoardObject = New BoardObject(\"B\", 3)\nDim Object3 As BoardObject = New BoardObject(\"C\", 5)\nDim Object4 As BoardObject = New BoardObject(\"D\", 2)\nDim Object5 As BoardObject = New BoardObject(\"E\", 7)\nGameBoard.SetObject(Object1, 0, 0)\nGameBoard.SetObject(Object2, 9, 9)\nGameBoard.SetObject(Object3, 4, 5)\nGameBoard.SetObject(Object4, 2, 2)\nGameBoard.SetObject(Object5, 8, 7)\nGameBoard.DisplayBoard()\n© Cambridge University Press & Assessment 2025 Page 15 of 39\n\n1(c)(i) Python\nGameBoard = Board()\nObject1 = BoardObject(\"A\",2)\nObject2 = BoardObject(\"B\",3)\nObject3 = BoardObject(\"C\",5)\nObject4 = BoardObject(\"D\",2)\nObject5 = BoardObject(\"E\",7)\nGameBoard.SetObject(Object1, 0, 0)\nGameBoard.SetObject(Object2, 9, 9)\nGameBoard.SetObject(Object3, 4, 5)\nGameBoard.SetObject(Object4, 2, 2)\nGameBoard.SetObject(Object5, 8, 7)\nGameBoard.DisplayBoard()\n\n1(c)(ii) 1 mark for screenshot showing board contents 1\nExample\n© Cambridge University Press & Assessment 2025 Page 16 of 39\n\n1(d)(i) 1 mark each to max 4 4\n• Taking x-axis and y-axis as input repeatedly until each value is between 0 and 9 (inclusive)\n• Calling Board.GetObject() with input x-axis and y-axis values …\n• … checking if object exists e.g. if Code is \"-\"\n• … outputting \"Miss\" if no BoardObject and outputting Code and Value in an appropriate message if there is a\nBoardObject\nExample program code\nJava\nScanner scanner = new Scanner(System.in);\nInteger InputRow = -1;\nwhile(InputRow < 0 || InputRow > 9){\nSystem.out.println(\"Enter the row position between 0 and 9 \");\nInputRow = Integer.parseInt(scanner.nextLine());\n}\nInteger InputColumn = -1;\nwhile(InputColumn < 0 || InputColumn > 9){\nSystem.out.println(\"Enter the column position between 0 and 9 \");\nInputColumn = Integer.parseInt(scanner.nextLine());\n}\nBoardObject GuessObject = GameBoard.GetObject(InputRow, InputColumn);\nif((GuessObject.GetCode()).equals(\"-\")){\nSystem.out.println(\"Miss\");\n}else{\nSystem.out.println(\"You found \" + GuessObject.GetCode() + \" with value \" +\nGuessObject.GetValue());\n}\nVB.NET\nDim InputRow, InputColumn As Integer\nInputRow = -1\nInputColumn = -1\nWhile InputRow < 0 Or InputRow > 9\nConsole.WriteLine(\"Enter the row position between 0 and 9 \")\nInputRow = Console.ReadLine()\nEnd While\n© Cambridge University Press & Assessment 2025 Page 17 of 39\n\n1(d)(i) While InputColumn < 0 Or InputColumn > 9\nConsole.WriteLine(\"Enter the column position between 0 and 9 \")\nInputColumn = Console.ReadLine()\nEnd While\nDim GuessObject As BoardObject = GameBoard.GetObject(InputRow, InputColumn)\nIf GuessObject.GetCode() = \"-\" Then\nConsole.WriteLine(\"Miss\")\nElse\nConsole.WriteLine(\"You found \" & GuessObject.GetCode() & \" with value \" &\nGuessObject.GetValue())\nEnd If\nPython\nInputRow = -1\nwhile InputRow < 0 or InputRow > 9:\nInputRow = int(input(\"Enter the row position between 0 and 9 \"))\nInputColumn = -1\nwhile InputColumn < 0 or InputColumn > 9:\nInputColumn = int(input(\"Enter the column position between 0 and 9 \"))\nGuessObject = GameBoard.GetObject(InputRow, InputColumn)\nif GuessObject.GetCode() == \"-\":\nprint(\"Miss\")\nelse:\nprint(\"You found \" + str(GuessObject.GetCode()) + \" with value \" +\nstr(GuessObject.GetValue()))\n© Cambridge University Press & Assessment 2025 Page 18 of 39\n\n1(d)(ii) 1 mark for screenshot showing inputs and correct output 1\nRow 10 4\nColumn -1 5\nOutput C 5\nExample\n© Cambridge University Press & Assessment 2025 Page 19 of 39",
      "source_pages": [
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_43-p07.png",
        "../answer-assets/9618_w25_ms_43-p08.png",
        "../answer-assets/9618_w25_ms_43-p09.png",
        "../answer-assets/9618_w25_ms_43-p10.png",
        "../answer-assets/9618_w25_ms_43-p11.png",
        "../answer-assets/9618_w25_ms_43-p12.png",
        "../answer-assets/9618_w25_ms_43-p13.png",
        "../answer-assets/9618_w25_ms_43-p14.png",
        "../answer-assets/9618_w25_ms_43-p15.png",
        "../answer-assets/9618_w25_ms_43-p16.png",
        "../answer-assets/9618_w25_ms_43-p17.png",
        "../answer-assets/9618_w25_ms_43-p18.png",
        "../answer-assets/9618_w25_ms_43-p19.png"
      ]
    },
    {
      "id": "9618-2025-on-43-q02",
      "question_id": "9618-2025-on-43-q02",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 2,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 24,
      "status": "available",
      "reason": null,
      "text": "2(a) 1 mark each 2\n• Queue declared as a (global) 1D array of 100 string elements all initialised to \"\"\n• QueueHead and QueueTail initialised with –1, NumberItems initialised to 0\nExample program code\nJava\npublic static String[] Queue = new String[100];\npublic static Integer QueueHead;\npublic static Integer QueueTail;\npublic static Integer NumberItems;\nfor(int x = 0; x < 100; x++){\nQueue[x] = \"\";\n}\nQueueHead = -1;\nQueueTail = -1;\nNumberItems = 0;\nVB.NET\nDim Queue(99) As String\nDim QueueHead As Integer\nDim QueueTail As Integer\nDim NumberItems As Integer\nFor x = 0 To 99\nQueue(x) = \"\"\nNext\nQueueHead = -1\nQueueTail = -1\nNumberItems = 0\n© Cambridge University Press & Assessment 2025 Page 20 of 39\n\n2(a) Python\nglobal Queue, QueueHead, QueueTail, NumberItems\nQueue = []\nfor x in range(100):\nQueue.append(\"\")\nQueueHead = -1\nQueueTail = -1\nNumberItems = 0\n© Cambridge University Press & Assessment 2025 Page 21 of 39\n\n2(b) 1 mark each 5\n• Function header (and end where appropriate) taking one (string) parameter and checking full and returning FALSE\n• (otherwise) Storing parameter in QueueTail + 1\n• Incrementing QueueTail and NumberItems\n• (Dealing with first element) If QueueHead = –1 store 0 in QueueHead / increment QueueHead\n• Return TRUE in all cases when inserted\nExample program code.\nJava\npublic static Boolean Enqueue(String TheData){\nif(QueueHead == -1){\nQueue[0] = TheData;\nQueueHead = 0;\nQueueTail = 0;\nNumberItems++;\nreturn true;\n}else if(QueueTail >= 99){\nQueue[QueueTail+1] = TheData;\nQueueTail++;\nNumberItems++;\nreturn true;\n}else{\nreturn false;\n}\n}\n© Cambridge University Press & Assessment 2025 Page 22 of 39\n\n2(b) VB.NET\nFunction Enqueue(TheData)\nIf QueueHead = -1 Then\nQueue(0) = TheData\nQueueHead = 0\nQueueTail = 0\nNumberItems += 1\nReturn True\nElseIf QueueTail >= 99 Then\nQueue(QueueTail + 1) = TheData\nQueueTail += 1\nNumberItems += 1\nReturn True\nElse\nReturn False\nEnd If\nEnd Function\nPython\ndef Enqueue(TheData):\nglobal Queue, QueueHead, QueueTail, NumberItems\nif(QueueHead == -1){\nQueue[0] = TheData\nQueueHead = 0\nQueueTail = 0\nNumberItems +=1\nreturn True\nelif QueueTail >= 99:\nQueue[QueueTail+1] = TheData\nQueueTail +=1\nNumberItems +=1\nreturn True\nelse:\nreturn False\n© Cambridge University Press & Assessment 2025 Page 23 of 39\n\n2(c) 1 mark each 3\n• Function header (and end), checking if Queue is empty (NumberItems = 0 or QueueHead > QueueTail) and\nreturning \"False\"\n• (otherwise) returning Queue[QueueHead]\n• Incrementing QueueHead, decrementing NumberItems\nExample program code\nJava\npublic static String Dequeue(){\nString ReturnValue;\nif(NumberItems == 0){\nreturn \"False\";\n}else{\nReturnValue = Queue[QueueHead];\nQueueHead++;\nNumberItems--;\nreturn ReturnValue;\n}\n}\nVB.NET\nFunction Dequeue()\nIf NumberItems = 0 Then\nReturn \"False\"\nElse\nDequeue = Queue(QueueHead)\nQueueHead += 1\nNumberItems -= 1\nEnd If\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 24 of 39\n\n2(c) Python\ndef Dequeue():\nglobal Queue, QueueHead, QueueTail, NumberItems\nif NumberItems == 0:\nreturn \"False\"\nelse:\nReturnData = Queue[QueueHead]\nQueueHead += 1\nNumberItems -=1\nreturn ReturnData\n© Cambridge University Press & Assessment 2025 Page 25 of 39\n\n2(d) 1 mark each to max 5 5\n• Procedure header (and end where appropriate)\n• Opening the file and closing the file (in appropriate place)\n• Looping until EOF // looping through each line …\n• … read in each value …\n• … calling Enqueue() with read in value and store/use return value\n• Exception handling with try except and appropriate output with all file access within try\nExample program code\nJava\npublic static void ReadData(){\nBoolean ReturnValue;\nBoolean FinishLoop = false;\ntry{\nScanner Scanner1 = new Scanner(new File(\"BinaryData.txt\"));\nwhile(Scanner1.hasNextLine() && FinishLoop == false){\nReturnValue = Enqueue(Scanner1.nextLine());\nif(ReturnValue.equals(\"False\")){\nFinishLoop = true;\n}\n}\nScanner1.close();\n} catch(FileNotFoundException ex){\nSystem.out.println(\"No file found\");\n}\n}\n© Cambridge University Press & Assessment 2025 Page 26 of 39\n\n2(d) VB.NET\nSub ReadData()\nDim ReturnValue As String\nDim DataReader As New System.IO.StreamReader(\"BinaryData.txt\")\nDim FinishLoop As Boolean = True\nDo Until DataReader.EndOfStream Or FinishLoop = False\nReturnValue = Enqueue(DataReader.ReadLine())\nIf ReturnValue = False Then\nFinishLoop = False\nEnd If\nLoop\nDataReader.Close()\nEnd Sub\nPython\ndef ReadData():\nTheFile = open(\"BinaryData.txt\")\nfor Line in TheFile:\nReturnValue = Enqueue(Line.strip())\nif ReturnValue == False:\nbreak\nTheFile.close()\n© Cambridge University Press & Assessment 2025 Page 27 of 39\n\n2(e) 1 mark each 6\n• Procedure header (and end where appropriate), storing final string compressed data in global variable\n• Call Dequeue() and storing return value …\n• … repeatedly until the return value == \"False\"\n• Comparing new value with previous …\n• … maintaining counter of number of occurrences …\n• … appending digit and number of occurrences to a string without overriding\nExample program code\nJava\npublic static void Compress(){\nString First = Dequeue();\nString NewLine = \"\";\nInteger Count;\nString NextChar;\nwhile(NumberItems > 0 && First != \"False\"){\nCount = 1;\nNextChar = Dequeue();\nwhile(NextChar.equals(First)){\nCount++;\nFirst = NextChar;\nNextChar = Dequeue();\n}\nNewLine = First + Count;\nNewString = NewString + NewLine;\nFirst = NextChar;\n}}\n© Cambridge University Press & Assessment 2025 Page 28 of 39\n\n2(e) VB.NET\nSub Compress()\nDim First As String = Dequeue()\nDim NewLine As String = \"\"\nDim Count As Integer\nDim NextChar As String\nWhile NumberItems > 0 And First <> \"False\"\nCount = 1\nNextChar = Dequeue()\nWhile NextChar = First\nCount += 1\nFirst = NextChar\nNextChar = Dequeue()\nEnd While\nNewLine = First & Count\nNewString = NewString & NewLine\nFirst = NextChar\nEnd While\nPython\ndef Compress():\nglobal NewString\nFirst = Dequeue()\nNewString = \"\"\nwhile NumberItems > 0 and First != \"False\":\nCount = 1\nNextChar = Dequeue()\nwhile NextChar == First:\nCount += 1\nFirst = NextChar\nNextChar = Dequeue()\nNewLine = First + str(Count)\nNewString = NewString + NewLine\nFirst = NextChar\n© Cambridge University Press & Assessment 2025 Page 29 of 39\n\n2(f)(i) 1 mark each 2\n• Calling ReadData() then Compress()\n• Outputting compressed string\nExample program code\nJava\npublic static void main(String args[]){\nNewString = \"\";\nfor(int x = 0; x < 100; x++){\nQueue[x] = \"\";\n}\nQueueHead = -1;\nQueueTail = -1;\nNumberItems = 0;\nReadData();\nCompress();\nSystem.out.println(NewString);\n}\nVB.NET\nSub Main()\nNewString = \"\"\nFor x = 0 To 99\nQueue(x) = \"\"\nNext\nQueueHead = -1\nQueueTail = -1\nNumberItems = 0\nReadData()\nCompress()\nConsole.WriteLine(NewString)\nConsole.ReadLine()\nEnd Sub\n© Cambridge University Press & Assessment 2025 Page 30 of 39\n\n2(f)(i) Python\nNewString = \"\"\nQueue = []\nfor x in range(100):\nQueue.append(\"\")\nQueueHead = -1\nQueueTail = -1\nNumberItems = 0\nReadData()\nCompress()\nprint(NewString)\n\n2(f)(ii) 1 mark for screenshot showing output 1\nExample\n© Cambridge University Press & Assessment 2025 Page 31 of 39",
      "source_pages": [
        20,
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30,
        31
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_43-p20.png",
        "../answer-assets/9618_w25_ms_43-p21.png",
        "../answer-assets/9618_w25_ms_43-p22.png",
        "../answer-assets/9618_w25_ms_43-p23.png",
        "../answer-assets/9618_w25_ms_43-p24.png",
        "../answer-assets/9618_w25_ms_43-p25.png",
        "../answer-assets/9618_w25_ms_43-p26.png",
        "../answer-assets/9618_w25_ms_43-p27.png",
        "../answer-assets/9618_w25_ms_43-p28.png",
        "../answer-assets/9618_w25_ms_43-p29.png",
        "../answer-assets/9618_w25_ms_43-p30.png",
        "../answer-assets/9618_w25_ms_43-p31.png"
      ]
    },
    {
      "id": "9618-2025-on-43-q03",
      "question_id": "9618-2025-on-43-q03",
      "subject": "9618",
      "year": 2025,
      "session": "Oct/Nov",
      "session_code": "on",
      "paper": 4,
      "variant": "43",
      "question_number": 3,
      "topic": "Practical programming",
      "topic_slug": "9618-practical-programming",
      "marks": 20,
      "status": "available",
      "reason": null,
      "text": "3(a)(i) 1 mark each 6\n• Function header (and end) taking three parameters\n• Checking number of elements for 0 and returning 0 (e.g. ArrayCopy = [] // len(ArrayCopy) == 0)\n• (otherwise) comparing first array element to parameter DataToFind …\n• … if match return recursive call adding 1\n• … if no match return recursive call without adding 1\n• … all recursive calls have array without first element, NumberElements-1 and DataToFind\nExample program code\nJava\npublic static Integer RecursiveCount(Integer DataToFind, Integer[] ArrayCopy, Integer\nNumberElements){\nif(NumberElements > 0){\nInteger[] NewArray = new Integer[NumberElements-1];\nfor(Integer x = 1; x < NumberElements; x++){\nNewArray[x-1]= ArrayCopy[x];\n}\nif(ArrayCopy[0] == DataToFind){\nreturn 1 + RecursiveCount(DataToFind, NewArray, NumberElements - 1);\n}else{\nreturn RecursiveCount(DataToFind, NewArray, NumberElements - 1);\n}\n}else{\nreturn 0;\n}\n}\n© Cambridge University Press & Assessment 2025 Page 32 of 39\n\n3(a)(i) VB.NET\nFunction RecursiveCount(DataToFind As Integer, ArrayCopy() As Integer, NumberElements As\nInteger)\nIf NumberElements > 0 Then\nDim NewArray(NumberElements - 1) As Integer\nFor x = 1 To NumberElements - 1\nNewArray(x - 1) = ArrayCopy(x)\nNext x\nIf ArrayCopy(0) = DataToFind Then\nReturn 1 + RecursiveCount(DataToFind, NewArray, NumberElements - 1)\nElse\nReturn RecursiveCount(DataToFind, NewArray, NumberElements - 1)\nEnd If\nElse\nReturn 0\nEnd If\nEnd Function\nPython\ndef RecursiveCount(DataToFind, ArrayCopy, NumberElements):\nif NumberElements > 0:\nNewArray = ArrayCopy[1:]\nif ArrayCopy[0] == DataToFind:\nreturn 1 + RecursiveCount(DataToFind, NewArray, NumberElements - 1)\nelse:\nreturn RecursiveCount(DataToFind, NewArray, NumberElements - 1)\nelse:\nreturn 0\n© Cambridge University Press & Assessment 2025 Page 33 of 39\n\n3(a)(ii) 1 mark each 3\n• Storing the correct data in an array\n• Calling RecursiveCount() with the correct parameters\n• Outputting the return value\nExample program code\nJava\nInteger[] MyArray = new Integer[]{0, 5, 1, 2, 5, 9, 9, 6, 5, 0};\nSystem.out.println(RecursiveCount(0, MyArray, 10));\nVB.NET\nDim MyArray() As Integer = {0, 5, 1, 2, 5, 9, 9, 6, 5, 0}\nConsole.WriteLine(RecursiveCount(0, MyArray, 10))\nPython\nMyArray = [0,5,1,2,5,9,9,6,5,0]\nprint(RecursiveCount(0, MyArray, 10))\n\n3(a)(iii) 1 mark for screenshot showing correct output of 2 1\nExample\n\n3(b)(i) 1 mark for storing the string in a variable 1\nExample program code\nJava\nString Code = \"x=0;y=1;x=x+y;y++;\";\nVB.NET\nDim Code As String = \"x=0;y=1;x=x+y;y++;\"\nPython\nCode = \"x=0;y=1;x=x+y;y++;\"\n© Cambridge University Press & Assessment 2025 Page 34 of 39\n\n3(b)(ii) 1 mark each 6\n• Function header, taking one string parameter\n• Loop e.g. four times/through each character in parameter\n• Comparing character from parameter to ';' …\n• … concatenate current character to a string until ';' is found\n• … when ';' found storing string in array\n• Returning string array without semicolons\nExample program code\nJava\npublic static String[] SplitData(String DataString){\nString[] SplitDataArray = new String[10];\nInteger Count = 0;\nString TempString = \"\";\nString Character = \"\";\nInteger LastElement = 0;\nfor(Integer x = 0; x < 4; x++){\nTempString = \"\";\ntry{\nCharacter = String.valueOf(DataString.charAt(Count));\nwhile(Character.equals(\";\") == false){\nTempString = TempString + Character;\nCount++;\nCharacter = String.valueOf(DataString.charAt(Count));\n}\nSplitDataArray[LastElement] = TempString;\nLastElement++;\n}finally{}\nCount++;\n}\nreturn SplitDataArray;\n}\n© Cambridge University Press & Assessment 2025 Page 35 of 39\n\n3(b)(ii) VB.NET\nFunction SplitData(DataString)\nDim SplitDataArray(10) As String\nDim Count As Integer = 0\nDim TempString As String = \"\"\nDim Character As String = \"\"\nDim LastElement As Integer = 0\nFor x = 0 To 3\nTempString = \"\"\nTry\nCharacter = DataString(Count)\nWhile Character <> \";\"\nTempString = TempString + Character\nCount = Count + 1\nCharacter = DataString(Count)\nEnd While\nSplitDataArray(LastElement) = TempString\nLastElement = LastElement + 1\nCatch\nConsole.WriteLine(\"No more character\")\nEnd Try\nCount = Count + 1\nNext\nReturn SplitDataArray\nEnd Function\n© Cambridge University Press & Assessment 2025 Page 36 of 39\n\n3(b)(ii) Python\ndef SplitData(DataString):\nSplitDataArray = []\nCount = 0\nfor x in range(4):\nTempString = \"\"\ntry:\nCharacter = DataString[Count]\nwhile Character != \";\":\nTempString = TempString + (Character)\nCount += 1\nCharacter = DataString[Count]\nSplitDataArray.append(TempString)\nexcept:\nprint(\"No more characters\")\nCount += 1\nreturn SplitDataArray\n© Cambridge University Press & Assessment 2025 Page 37 of 39\n\n3(b)(iii) 1 mark each 2\n• Calling SplitData() with array as argument and storing/using return value\n• Outputting each element of the returned array on a new line\nExample program code\nJava\nString Code = \"x=0;y=1;x=x+y;y++;\";\nString[] SplitDataArray = new String[10];\nSplitDataArray = SplitData(Code);\nfor(Integer x = 0; x < 4; x++){\nSystem.out.println(SplitDataArray[x]);\n}\nVB.NET\nDim Code As String = \"x=0;y=1;x=x+y;y++;\"\nDim SplitDataArray() As String = SplitData(Code)\nFor x = 0 To 3\nConsole.WriteLine(SplitDataArray(x))\nNext\nPython\nCode = \"x=0;y=1;x=x+y;y++;\"\nSplitDataArray = SplitData(Code)\nfor x in range(4):\nprint(SplitDataArray[x])\n© Cambridge University Press & Assessment 2025 Page 38 of 39\n\n3(b)(iv) 1 mark for output 1\nx=0\ny=1\nx=x+y\ny++\nExample\n© Cambridge University Press & Assessment 2025 Page 39 of 39",
      "source_pages": [
        32,
        33,
        34,
        35,
        36,
        37,
        38,
        39
      ],
      "source_pdf": "_source-pdfs/2025-oct-nov/ms/9618_w25_ms_43.pdf",
      "source_pdf_url": "https://pastpapers.co/api/file/caie/A-Level/Computer%20Science%20%28for%20first%20examination%20in%202021%29%20%289618%29/2025-Oct-Nov/9618_w25_ms_43.pdf?download=true",
      "html": "9618-practical-programming/answers.html",
      "image_paths": [
        "../answer-assets/9618_w25_ms_43-p32.png",
        "../answer-assets/9618_w25_ms_43-p33.png",
        "../answer-assets/9618_w25_ms_43-p34.png",
        "../answer-assets/9618_w25_ms_43-p35.png",
        "../answer-assets/9618_w25_ms_43-p36.png",
        "../answer-assets/9618_w25_ms_43-p37.png",
        "../answer-assets/9618_w25_ms_43-p38.png",
        "../answer-assets/9618_w25_ms_43-p39.png"
      ]
    }
  ]
}