System: You are ChatGPT, a large language model trained by OpenAI.
User: I will send you a body of text, I will then state what you do next.
User: 7 Data structures and abstract data types507Data structures and abstract data types INTRODUCTIONThere is a difference between what is required for AS and A level here and this chapter has been split accordingly. AS-level students need only study to the end of the section on binary ﬁ  les. A-level students need to be aware of a much wider range of data structures  and abstract data types and als o understand how to implement them in a programming language: •Chapters 7–11 explain the data structures required for A level,including coding on how to implement them. •Chapters 12–16 cover some common algorithms required for A level,including how to implement the abstract data types described in Chapters 7–11.In Chapter 1 we looked at the different ways individual items of data might be stored. For example, we looked at storing a person’s age as an integer and their name as a string. These are known as data types. In this chapter we will look at the ways of storing larger volumes of data in formats that make it easy for programs and users to access and analyse. These are called data structures and abstract data types.LEARNING OBJECTIVES In this chapter you will learn: •what data structures and abstract data types are •what an array is and how to use one to store and access data•what a ﬁ  le is and how it is used to store data •the difference between text ﬁ  les and binary ﬁ  les•how to read and write data to and from csv and binary ﬁ  les.A- level students will learn: •what static and dynamic data structures are•the different characteristics of static and dynamic data structures.SPECIFICATION COVERAGE 3.2.1.1 Data structures3.2.1.2 Single- and multi-dimensional arrays (or equivalent)3.2.1.3 Fields, records and ﬁ  les 3.2.1.4 Abstract data types/data structuresKEYWORDS Data structure: a common format for storing large volumes of related data, which is an  implementation of an abstract data type.
 Abstract data type: a conceptual model of ho w data can be stored and the operations that can be carried out on the data.51ARRAYS ●Data structure and abstract data typeA data structure is any method used to store data in an organised and accessible format. Data structures normally contain data that are relatedand the way that the data are organised enables different programs tomanipulate them in different ways. Different data structures tend to lendthemselves to different types of applications. For example, a text filemay be s uitable for a database whereas a stack is suitable for handlingexceptions.An abstract data type is a conceptual model of how the data are stored and the operations that can be performed upon them. The data structure is animplementation of this in a particular programming language. ●ArraysWe came across the concept of an array  in Chapter 1. An array is a list or table of data that has a variable name that identifies the list or table. Each item in the table is called an element. An array can have many dimensionsbut most arrays are either one-dimensional in which case they form a list orcan be visualised as a two-dimensional table.
 Lists and arrays are static data structures that are created by theprogrammer to store tables of data. In some programming languagesprogrammers need to define just how big an array is going to be at the startof their program. This means that the size of the array and the amount ofmemory put aside for it does not change. You might find that you want to store a sequence of data in some way. Forexample you might want to store the names of pupils in a class: Name1 = "Derrick"Name2 = "Peter"Name3 = "Jill"Name4 = "Lynn"Carrying out any sort of work even on just these four names is going to bevery cumbersome. Imagine how difficult this would be if you wanted tostore 30 names or 3000 names. The best solution to this problem is to usean array. In the example above, we could call the array StudentName . Each element of the array can now be accessed using its position. Forexample, the third element in the array is Jill (assuming indexing starts at 1and not 0). This would be shown as: StudentName(3) = "Jill"Another example could be to set up a one-dimensional array called DaysInMonth . The third element would be set to 31 as that is the numberof days in March. As this table contains just one row of data it could also bedescribed as a list.
 Element in DaysInMonthContents of that element131228331430531630731831930103111301231 Figure 7.1 A one-dimensional array or listKEYWORDFile: a collection of related data. KEYWORDArray: a set of related data items stored under a single identifier. Can work on one or more dimensions.52 7 Data structures and abstract data typesAn array has one or more dimensions – for example you might want to store the mock exam results of a group of pupils. The array then might be called Results  and it would have two dimensions, one for the pupils and the other for the subjects and might look something like this: 1 23 451 2 3 4 5 6 7 54 67 76 65 75 32 1932 45 98 32 53 59 95 2671 12 32 54 5632 2147 65 12 4335 9922 1614 882 41 15 Figure 7.2 A two-dimensional arrayYou will note that the rows/columns are not labelled – it is up to the programmer to remember which axis refers to the pupil and which to the subject. In this diagram the 65 might represent the mark obtained by Hilary in the French exam. If the table were called Results  then Hilary’s French mark would be stored in Results(4, 1)  where the 4 identifies the pupil and the 1 identifies the subject.It is possible to work with multi-dimensional arrays. If you take the mock  exam paper array further, you might decide to store the exam results for each exam paper. In this case the value in Results(4, 1, 2)  could store the mark Hilary got in the second paper of the French exam. In fact you can have many more dimensions than this – a four-dimensional array might store the marks gained for each question in each paper, so Results(4, 1, 2, 12)  might store the mark Hilary was given for question 12 in paper 2 of the French mocks. As you add more and more dimensions to the array it becomes increasingly difficult to conceptualise.
 ●FilesYou will already be familiar with the concept of a file to store data. Thereare hundreds of different file types, all of which have their own structuredepending on the specific use of the file. Some files are very specific in thatthey can only be used on certain applications. Many file formats howeverare portable, which means they can be used in a wide range of programs.Two common portable formats that can be used when programming aretext files  and binary files .A text f ile is one that simply contains lines of text or other human-readable characters, where each line is usually referred to as a record . There may bediff erent items of data stored and these are referred to as fields .
 They m ay contain a header, which explains the content and structure of the file and an end of file (EOF) marker so that the programs using the fileknow when to stop. Common text file formats include txt used for non-formatted or plain text and csv (comma separated variables), both of whichare used for transferring data between programs.
 All files have an internal structure. For example, a csv file has fields thatare split up using commas. Most text files are delimited like this in someway so that when the file is being used, the program knows where to lookfor each item of data in the file. The following examples show a typicalKEYWORDS Text file: a file that contains human-re adable characters.
 Binary  file: stores data as sequences of 0s and 1s. Record: one line of a text file. Field: an item of data.FILES53structure where each row represents a record and the fields are separated either by tabs or commas: A tab-delimited text (txt) file: John Smith 22 Acacia Avenue LE11 1AAMary Jones 1 High Street LE12 5BDImran Siddiqi 12 Harrow Road LE13 1GGYin Li 24 Royal Road LE1 1AAA comma separate variable (csv): John,Smith,22 Acacia Avenue,LE11 1AAMary,Jones,1 High Street,LE12 5BDImran,Siddiqi,12 Harrow Road,LE13 1GGYin,Li,24 Royal Road,LE1 1AAThe two main actions you might want to carry out when working with text  files are: ●to write data from the program into a text file●to read data into the program from a text file. The following extract of Visual Basic-based code shows how you would write data to a text file. In this case, data is being written from a two-dimensional array called ArrayStore: FileOpen(1, "NewTable.csv", OpenMode.Output)‘ look at each row/record in turnFor RecordCount = 1 to 30  ‘ load first field from the next record into  the temporary stringRecordString = ArrayStore(recordcount,1)  ‘ concatenate all the other fields For FieldCount = 2 To 4     Recordstring = recordstring & "," & Arraystore (Recordcount,fieldcount)  Next ‘ write ‘record’ to file     Print(1, OutputString)NextFileClose(1)The following extract of code shows how you would read data from a text file into a program using Visual Basic as an example: ‘load csv file from folderFileOpen(1, "C: \Users\NameList.csv" , OpenMode .Input)Do54 7 Data structures and abstract data types grdTableIn.Rows.Add(1)  grdTableOut.Rows.Add(1) Input(1, DownLoadText) grdTableIn.Rows(RowCount).Cells(0).Value = DownLoadText & RowCount  RowCount = RowCount + 1Loop Until  EOF(1)FileC lose(1)●Binary filesA binary file is one that stores data as a series of 0s and 1s. Binary representation is one of the cornerstones of how computers work and iscovered in detail in Chapter 25. At this stage it is important to understandthat all program code and all of the data that you might use in a programincluding text, graphics and sound are all made up of 0s and 1s. These areusually organised into groups of 8 bits, called bytes. Binary files contain binary codes and usually contain some headerinformation that describes what these represent. As you can see fromFigure 7.3, binary files are not easily readable by a human, but can quicklybe interpreted by a program. 11101111 10111011 10111111 00111100 01101110 01101111 01100100 0110010100100000 01101001 01100100 00111101 00100010 00110001 00110000 0011011100110000 00100010 00100000 01110110 01100101 01110010 01110011 0110100101101111 01101110 00111101 00100010 01100101 01100010 01100011 0011011101100010 01100011 01100001 00110001 00101101 00110011 01100001 0110011001100010 00101101 00110100 01100001 01100001 00110001 00101101 0011100101100001 00110100 01100101 00101101 01100110 01100100 00110000 0110010000110110 00110011 00110110 00110011 01100011 01100010 01100011 0011011100100010 00100000 01110000 01100001 01110010 01100101 01101110 0111010001001001 01000100 00111101 00100010 00101101 00110001 00100010 0010000001101100 01100101 01110110 01100101 01101100 00111101 00100010 0011000100100010 00100000 01110111 01110010 01101001 01110100 01100101 0111001001001001 01000100 00111101 00100010 00110000 00100010 00100000 0110001101110010 01100101 01100001 01110100 01101111 01110010 01001001 0100010000111101 00100010 00110000 00100010 00100000 01101110 01101111 0110010001100101 01010100 01111001 01110000 01100101 00111101 00100010 0011000100110000 00110101 00110110 00100010 00100000 01110100 01100101 0110110101110000 01101100 01100001 01110100 01100101 00111101 00100010 0011000100110000 00110100 00110010 00100010 00100000 01110011 01101111 0111001001110100 01001111 01110010 01100100 01100101 01110010 00111101 0010001000110010 00100010 00100000 01100011 01110010 01100101 01100001 0111010001100101 01000100 01100001 01110100 01100101 00111101 00100010 0011001000110000 00110000 00110111 00101101 00110000 00110100 00101101 0011001000110101 01010100 00110001 00111000 00111010 00110010 00111000 0011101000110010 00110110 00100010 00100000 01110101 01110000 01100100 0110000101110100 01100101 01000100 01100001 01110100 01100101 00111101 00100010 Figure 7.3 Output from a binary ﬁ  leFor example, the PNG image file is a binary file, can be used in a range of applications and requires less memory than some other image formats. Many program files (executables) are created as binary files so that they can be used on other platforms.
 The two main actions you might want to carry out when working with binary files are: ●to write data from the program into a binary file●to read data into the program from a binary file.STATIC AND DYNAMIC DATA  STRUCTURES 55The following code shows how you would write data to a binary file: OpenFile ("DemoFile.bin", Binary) For Output as # 1Write 1, "Help"Write 1,  TrueWrite 1,  3.123Write 1,  5Close #1The following code shows how you would read data from a binary file into a program: Dim TTData as BinaryOpen "TTFile" For Binary As #2  ReDim TTData(1 To LOF(2)) As Byte  Get 2, 1, TTDataClose #2●Static and dynamic data structuresThe way that data can be stored can be split into two broad categories – dynamic and static. This reflects the fact that sometimes the programmer will know how big a data structure will get and therefore how much memory is needed to store it. More often than not, the amount of data stored within a data structure will vary while the program is being run. Different data structures such as queues  and stacks  can be implemented either as static or dynamic structures. ●Static: A static data structure  sto res a set amount of data whichis us ually defined by the programmer. This is done by allocating a set amount of memory to the data structure. Accessing individualelements of data within a static structure is very quick as theirmemory location is fixed. However, the data structure will takeup memory even if it doesn’t need it. Records and some arrays areexamples of static data structures.
 ●Dynamic: The word ‘dynamic’ means changeable. Dyna mic datastruc tures  can use more or less memory as needed through theuse of a heap . In basic terms, unused blocks of memory are placedon a heap, which are then usable within a program. A dynamic data structure is able to take more memory off the heap if it is neededand also put blocks of unused memory back onto the heap if it is notneeded. This is a much more efficient use of resources and a moreflexible solution as elements can be added and removed much moreeasily. Stacks, queues and binary trees are often implemented asdynamic structures. The programmer will normally put a limit on the maximum amount of memory that any one data structure needs. However, it can lead to errors if elements are removed from empty structures or added to full ones. There is more on this in the following chapters.A level onlyKEYWORDS Queue: a data structure where the first item added is the first item removed. Stack: a data structure where the last item added is the first item removed.Static data structure: a method of stor ing data where the amount of data stored (and memory used to store it) is fixed. Dynamic data structure: a method of storing data where the amount of data stored (and memory used to store it) will vary as the program is being run. Heap: a pool of unused memory that can b e allocated to a dynamic data structure.56 7 Data structures and abstract data typesKEY POINTS•A data structure is any method used to store data inan organised and accessibleformat. •An abstract data type is aconceptual mo del of howdata are organised and theoperations on them. •An array is a data structurethat contains data of the same type using a single identifier.•A one-dimensional array isalso  known as a list.
 •Arrays can be multi-dimensional. •Files are used to store data.•A text file is one that simplycont ains lines of text or otherhuman-readable characters.•A binary file is one that storesdata as a s eries of 0s and 1s. •Static data structures storea set amount of data whichis usually defined by theprogrammer. •Dynamic data structures canuse m ore or less memory asneeded through the use of aheap.STUDY / RESEARCH TASKS1 Write code that will: a)write data to a text ﬁle / read data from a text ﬁle b)write data to a binary ﬁle / read data from a binary ﬁle.2 Write code that will: a)create an array b)read data from an array.3 Find out how a stack is used to manage a memory heap.
 4 PNG is a common binary format. Find out about other commonly used  binary ﬁles.5 Why might programmers create executable ﬁles as binary ﬁles?TASKS1 How can you access each element in an array? 2 Explain how you could use an array to keep track of personal best  times for the members of an athletic club. Your solution may require several dimensions.3 Explain the terms file, record and field in relation to data structures.
 4 What are the typical uses of text files?5 What are the typical uses of binary ﬁles? 6 Identify two examples of: a)dynamic data structures b)static data structures.7 Identify two advantages of using dynamic data structures.
 8 Identify two disadvantages of using dynamic data structures.
 9 Why are stack and queues considered to be dynamic data structures?Static data structures Dynamic data structures Inefficient as memory is allocated that may not be needed.Efficient as the amount of memory varies as needed. Fast access to each element of data as the memory location is fixed when the program is written.Slower access to each element as the memory location is allocated at run-time. Memory addresses allocated will be contiguous so quicker to access.Memory addresses allocated may be fragmented so slower to access.
 Structures are a fixed size, making them more predictable to work with. For example, they can contain a header.Structures vary in size so there needs to be a mechanism for knowing the size of the current structure.
 The relationship between different elements of data does not change.The relationship between different elements of data will change as the program is run.
 Table 7.1 Comparison of static and dynamic data structuresPractice questions can be found at the end of the section on page 90.
User: Make the following text more clear.
Format it properly.
Do NOT change the meaning of the words or methods used to obtain the answer or anything like that.
This is for AQA A(S)-Level Computer Science. I repeat, do not alter the words as it could have an effect on the marks acquired from the marking scheme.
However, remove any redundant information or USELESS examples that are not needed for a student to know, or simplify unnecessary information (if it has a definition or keywords, it is not unnecessary).
If you can, use different values for the examples.
For things that will not score a mark or are generally useless, for example, "we will cover" or a fun fact, change the wording. This is for AS Level, do not include information about topics that are ONLY A-Level Content (if it says it is)
Link the 'sections' of your answer to the following spec-points (by title):
e.g. "**Topic** (Spec Points: a.b.c. Whatever)
3.2.1.3 Fields, records and ﬁ les
Content
Additional information
Be able to read/write from/to a text file.
Be able to read/write data from/to a binary (non-text) file.

3.2.1.1 Data structures
Content
Additional information
Be familiar with the concept of data structures.
It may be helpful to set the concept of a data structure in various contexts that students may already be familiar with. It may also be helpful to suggest/demonstrate how data structures could be used in a practical setting.

3.2.1.2 Single- and multi-dimensional arrays (or equivalent)
Content
Additional information
Use arrays (or equivalent) in the design of solutions to simple problems.
A one-dimensional array is a useful way of representing a vector. A two-dimensional array is a useful way of representing a matrix. More generally, an
n
-dimensional array is a set of elements with the same data type that are indexed by a tuple of
n
integers, where a tuple is an ordered list of elements.


You MUST make sure they are ALL met. Everything it says on there you should meet.
SOMETIMES the specification does not always mention everything. If you encounter something from the body of text that is not necessarily mentioned on the specification point, still try to include it but condense it. Do not make the notes unecessary or useless.

*If* the exam question has an image or any exam question has an image that may potentially increase the understanding and reliability of the notes, just link the image.

I already provided the available exam questions you MAY choose to add on to the notes, with 'des' explaining what it's about, and 'fil' meaning the Question ID.
The content, too. Delivered in the form 'fil', JSON
Ignore exam questions that contain 'Skeleton Program'. Do not only put like 2 exam questions, try to put more!
For the exam questions, in the original text, there is a label named 'Tasks'. Those (usually) six questions are NOT the exa questions. The exam questions are the ones that were given in JSON form to you, do NOT do the 'Tasks'. Do the exam questions that contain HTML in JSON!

In the markscheme, a ';' typically means that a mark was gained.
When mentioning exam questions, you *must* answer them, according to the markscheme, scoring full marks. No 'do it yourself'.

Include ALL definitions (KEYWORDS) from the original text I sent in your notes. When I mean all, I mean ALL.

If necessary for scoring marks, try to embed the exam-questions into your notes, sometimes without even referencing the fact that it is an exam question. For example, if an exam question is a definition or benefits, use the answer in your notes.
Remember. DO NOT ADD USELESS STUFF. Your task is to create the MOST EFFICIENT (SHORTEST [for an explanation] BUT STILL SCORES ALL MARKS) possible notes resource, which will score all marks easily, so its wording has to be mostly like that of the exam questions. By any means, if necessary, please include examples and exam questions! At the end you can have a 'try these exam questions' thing.
At the end of your answer, you will give a 'breakdown'/'summary' of each thing you covered which will tell the most concise FULLY MARK-SCORING explanation possible.

In summary, your answer must:

* Be efficient, useful
* For topics in an exam that may require some form of mathematical working, always show an example of a question.
* Be clear – provide clear, step-by-step examples/instructions when needed.
* Follow the entire specification and everything it says.
* Link your section to a spec point. E.g. **Topic** (Spec Points: a.b.c Whatever)
* Score ALL marks.
* Include ALL exam questions S at the end (except ones that contain 'Skeleton Program'), with the same wording as the original ones in the JSONs sent to you – and INCLUDE THE QUESTION CONTENT, AND THE ANSWERS/MARK SCHEME. Only the ones that I provided to you, include Question IDs.
* Remove redundant, unnecessary and useless information that would not be brought up in an exam answer.
* Be helpful to the reader
* Provide the full notes, covering ALL spec-points (and showing the spec-points covered in each section).
* Include ALL definitions (KEYWORDS, usually represented explicitly and specifically in the original text as Keyword: Definition), do not change the wording (unless that definition is an exam question). MAKE ALL THE DEFINITIONS FULL (yet consice, as they can sometimes even be 2 marks). Incorporate the definitons into the notes.
* Include a seperate section named 'Definitions' that covers the keywords and their simplest definition that scores all marks. These are (usually) found in the original text.
* Include a summary at the end (after definitions) that goes through everything you need to score all marks.

At the end of the formatted text, after everything is done, fill out the JSON:
Remove the type clarification.
{
"chapter": (int),
"page": (int),
"chapter_name": (str),
"topics": (list)
}

User: And these are the available exam questions, with 'des' explaining what it's about, and 'fil' meaning the Question ID.
{'S2$.1.c': [{'index1': '|D.A$|K$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.i | S2$.1.c', 'index5': '|12$|', 'index6': 'Q20S1B07', 'qid': 'Q20S1B07', 'des': 'Describe two possible file errors that could cause exception in Skeleton Program', 'index7': '', 'marks': '2 marks', 'time': '2', 'ttext': 'Programming concepts | Preliminary material', 'fld': 'AA_COM', 'fil': 'Q20S1B07', 'year': 2020, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Section_B_Summer2020.html', 'flag1': None}, {'index1': '|C.B$|F.A$|', 'index2': '|1$|', 'index3': '3$', 'index4': 'S1$.1.a | S2$.1.c | S7$.4.a | L1$.1.a | L2$.1.c | L7$.4.a', 'index5': '|', 'index6': 'QS0326A', 'qid': 'QS0326A', 'des': 'I/O hardware; fields; hashing', 'index7': '', 'marks': '9 marks', 'time': '14', 'ttext': 'Input and output devices | Files and validation', 'fld': 'AA_COM', 'fil': 'QS0326A', 'year': 2003, 'res': '', 'flag1': 0}, {'index1': '|D.A$|K$|', 'index2': '|2$|', 'index3': '3$', 'index4': 'S1$.1.g | S1$.1.k | S2$.1.c', 'index5': '|12$|', 'index6': 'Q20S1B09', 'qid': 'Q20S1B09', 'des': 'State purpose of a parameter and describe how data processed in Skeleton Program', 'index7': '', 'marks': '4 marks', 'time': '5', 'ttext': 'Programming concepts | Preliminary material', 'fld': 'AA_COM', 'fil': 'Q20S1B09', 'year': 2020, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Section_B_Summer2020.html', 'flag1': None}], 'S2$.1.a': [{'index1': '|D.A$|D.D$|K$|', 'index2': '|2$|', 'index3': '3$', 'index4': 'S2$.1 | S2$.1.a | S2$.1.b | S2$.1.c', 'index5': '|12$|', 'index6': 'Q20S1B05', 'qid': 'Q20S1B05', 'des': 'State the identifiers of data structures in Skeleton Program; array; record', 'index7': '', 'marks': '2 marks', 'time': '2', 'ttext': 'Programming concepts | Data structures | Preliminary material', 'fld': 'AA_COM', 'fil': 'Q20S1B05', 'year': 2020, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Section_B_Summer2020.html', 'flag1': None}, {'index1': '|D.B$|D.D$|', 'index2': '|1$|', 'index3': '3$', 'index4': 'S1$.1 | S2$.1.a | S4$.1.a | S4$.1.b | L1$.1 | L2$.1.a | L3$.4 | L4$.1.a | L4$.1.b', 'index5': '|', 'index6': 'QW06110', 'qid': 'QW06110', 'des': 'Array processing', 'index7': '', 'marks': '9 marks', 'time': '12', 'ttext': 'Algorithms | Data structures', 'fld': 'AA_COM', 'fil': 'QW06110', 'year': 2006, 'res': '', 'flag1': 0}, {'index1': '|D.D$|K$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.a | S2$.1.a | S2$.1.c', 'index5': '|2$|', 'index6': 'QS19S1B05', 'qid': 'QS19S1B05', 'des': 'Data structure with multiple types; records', 'index7': '', 'marks': '1 marks', 'time': '1', 'ttext': 'Data structures | Preliminary material', 'fld': 'AA_COM', 'fil': 'QS19S1B05', 'year': 2019, 'res': '/RESOURCES/AA_COM/RESOURCES/AS_P1_Summer2019.html', 'flag1': 1}], 'S2$.1.b': [{'index1': '|D|D.A$|D.C$|D.D$|H.B$|K$|', 'index2': '|2$|', 'index3': '1$', 'index4': 'S1$.1 | S1$.1.a | S1$.1.b | S1$.1.c | S1$.1.d | S1$.1.e | S1$.1.f | S1$.1.j | S1$.1.k | S1$.1.l | S2$.1.b | S3$.1.d', 'index5': '|19$|', 'index6': 'Q22S1C13', 'qid': 'Q22S1C13', 'des': 'Create subroutine to stop duplicate digits being used to solve puzzle; testing', 'index7': '', 'marks': '9 marks', 'time': '13', 'ttext': 'Programming | Programming concepts | Practical programming | Data structures | Testing | Preliminary material', 'fld': 'AA_COM', 'fil': 'Q22S1C13', 'year': 2023, 'res': '/RESOURCES/AA_COM/RESOURCES/2022_AS_SectionC_resources.html', 'flag1': None}, {'index1': '|D.A$|D.C$|D.D$|H.B$|K$|', 'index2': '|2$|', 'index3': '1$', 'index4': 'S1$.1.b | S1$.1.k | S1$.1.l | S2$.1.b | S3$.1.d | S4$.1.a', 'index5': '|1$|', 'index6': 'Q23S1C12', 'qid': 'Q23S1C12', 'des': 'Accumulator; parameter; subroutine', 'index7': '', 'marks': '5 marks', 'time': '7', 'ttext': 'Programming concepts | Practical programming | Data structures | Testing | Preliminary material', 'fld': 'AA_COM', 'fil': 'Q23S1C12', 'year': 2023, 'res': '/RESOURCES/AA_COM/RESOURCES/2023_AS_SectionC_resources.html', 'flag1': 0}, {'index1': '|D.A$|D.B$|', 'index2': '|2$|', 'index3': '2$', 'index4': 'S1$.1.b | S1$.1.d | S2$.1.b | S4$.1.b', 'index5': '|', 'index6': 'Q23S1A02', 'qid': 'Q23S1A02', 'des': 'Trace table; pseudo-code', 'index7': '', 'marks': '5 marks', 'time': '7', 'ttext': 'Programming concepts | Algorithms', 'fld': 'AA_COM', 'fil': 'Q23S1A02', 'year': 2023, 'res': '', 'flag1': 0}]}

User: These are the content of said exam questions, these are the ONLY exam questions, you will use these later, delivered in form 'fil', JSON: {'Q20S1B07': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">This question refers to the subroutine <span class="comp">LoadGreyScaleImage</span></p>\r\n<p class="indent1new">Describe <b>two</b> possible errors that could cause an exception in this subroutine.</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 2 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>All marks for AO2 (analyse)</b> </p>\r\n<p class="indent1new indentright"><span class="comp">NextPixel</span> is not (a string that can be converted to) an integer;</p>\r\n<p class="indent1new indentright m-t-0">File no longer available; <b>R.</b> file could not be opened as already open</p>\r\n<p class="indent1new indentright m-t-0">Pixel data stored in wrong format, <b>R.</b> file does not have .txt extension;</p>\r\n<p class="indent1new indentright m-t-0">Not enough lines in the file <b>N.E.</b> Empty file<b>;</b> </p>\r\n<p class="indent1new indentright m-t-0">Not enough characters in a line;</p>\r\n<p class="indent1new indentright m-t-0"><b>A.</b> Not enough data in file for given size of image; if neither of the 2 points above have been given</p>\r\n<p class="indent1new indentright m-t-0"><u>Header</u> height larger than <span class="comp">MAX_HEIGHT</span>, <b>A.</b> larger than 100;</p>\r\n<p class="indent1new indentright m-t-0"><u>Header</u> width larger than <span class="comp">MAX_WIDTH</span>, <b>A.</b> larger than 100;</p>\r\n<p class="indent1new indentright"><b>Max 2</b></p>\r\n<p class="mark">[2]</p></h5>', 'examinerreport': '', 'notes': '', 'resources': ''}, 'QS0326A': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">A multi-storey car park is controlled by a computer system as follows.</p>  \r<p class="indent1new">For a vehicle arriving at the barrier-controlled <i>entrance</i>:</p>  \r<p class="indent1">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the computer system generates an integer number at random from a set of unused numbers which identifies the vehicle to the system</p>  \r<p class="indent1 m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the vehicle’s driver collects a ticket containing this number from a machine at the barrier</p>  \r<p class="indent1 m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; after a short interval a barrier is raised to enable the car to enter the car park</p>  \r<p class="indent1 m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the computer system remembers the current date, the arrival time and the randomly generated number.</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new">If the car park is full a sign is lit to indicate the situation and no vehicle is allowed to enter the car park.</p>  \r<p class="indent1new">For a vehicle arriving at the barrier-controlled <i>exit</i>:</p>  \r<p class="indent1">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the ticket is presented to a machine which reads the number on the ticket</p>  \r<p class="indent1 m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the computer system determines the length of time the vehicle has been parked in the car park and calculates the amount to pay</p>  \r<p class="indent1 m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the amount to pay is displayed on the machine</p>  \r<p class="indent1 m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the driver inserts the correct money into the machine</p>  \r<p class="indent1 m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the computer system records the length of time in minutes and the amount to pay in pence</p>  \r<p class="indent1 m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; after a short interval the barrier is raised to enable the vehicle to exit.</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(a)&nbsp;&nbsp;&nbsp;&nbsp; Taking account of the technology that could be used for ticket production at the entrance barrier, describe <b>two </b>different ways for the number assigned to the ticket to be submitted to the computer system at the exit barrier. Your answer should include a reference to the relevant input/output hardware used.</p>  \r<p class="indent2new answer-toggle">1. _________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">2. _________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="mark">(4)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&nbsp;&nbsp;&nbsp;&nbsp; Using the table below, construct an appropriate record structure for the computer system to use to record the relevant car parking details for one vehicle. Data types should be given that would be available in a third generation programming language.</p>  \r<p class="bottom">&nbsp;</p>  \r<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=5  style=\'margin-left:48pt;border-collapse:collapse\'>  \r\t<tr>      \r\t\t<td width=295 valign=top style=\'width:177.2pt;border:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box><b>Field Name</b></p></td>   \r\t\t<td width=354 valign=top style=\'width:212.65pt;border:solid windowtext 1.0pt;border-left:none;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box><b>Data Type</b></p></td>  \r\t</tr>  \r\t<tr>      \r\t\t<td width=295 valign=top style=\'width:177.2pt;border:solid windowtext 1.0pt;border-top:none;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box>&nbsp;</p></td>   \r\t\t<td width=354 valign=top style=\'width:212.65pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box>&nbsp;</p></td>  \r\t</tr>  \r\t<tr>      \r\t\t<td width=295 valign=top style=\'width:177.2pt;border:solid windowtext 1.0pt;border-top:none;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box>&nbsp;</p></td>   \r\t\t<td width=354 valign=top style=\'width:212.65pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box>&nbsp;</p></td>  \r\t</tr>  \r\t<tr>      \r\t\t<td width=295 valign=top style=\'width:177.2pt;border:solid windowtext 1.0pt;border-top:none;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box>&nbsp;</p></td>   \r\t\t<td width=354 valign=top style=\'width:212.65pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box>&nbsp;</p></td>  \r\t</tr>  \r\t<tr>      \r\t\t<td width=295 valign=top style=\'width:177.2pt;border:solid windowtext 1.0pt;border-top:none;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box>&nbsp;</p></td>   \r\t\t<td width=354 valign=top style=\'width:212.65pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box>&nbsp;</p></td>  \r\t</tr>  \r\t<tr>      \r\t\t<td width=295 valign=top style=\'width:177.2pt;border:solid windowtext 1.0pt;border-top:none;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box>&nbsp;</p></td>   \r\t\t<td width=354 valign=top style=\'width:212.65pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt\'><p class=box>&nbsp;</p></td>  \r\t</tr> \r</table>  \r<p class="mark">(5)</p>  \r<p class="mark">(Total 9 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">&nbsp;</p>\r<p class="indent1 indentright m-t-0">(a)&nbsp;&nbsp;&nbsp;&nbsp; <i>Any two at two each; If entrance method doesn’t match exit method mark one wrong and the other correct</i></p>\r<p class="indent2new indentright m-t-0"><b>R</b> Voice <b>R</b> Written to ticket</p>  \r<p class="indent2new indentright m-t-0">Computer system/Printer prints number on ticket at entrance;</p>  \r<p class="indent2new indentright m-t-0">Driver types number into system using a keypad at exit barrier;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new indentright">Computer system encodes number on a magnetic stripe on ticket at entrance;</p>  \r<p class="indent2new indentright m-t-0"><b>R</b> Magnetic card</p>  \r<p class="indent2new indentright m-t-0">Ticket number read by a magnetic stripe reader at exit//inserted into a magnetic stripe reader at exit; <b>A </b>magnetic strip/stripe scanner</p>  \r<p class="indent2new indentright">Computer system/Printer prints number printed on ticket at entrance;</p>  \r<p class="indent2new indentright m-t-0">Number read by an optical character reader/OCR at exit//ticket inserted into an optical character reader at exit;</p>  \r<p class="indent2new indentright">Computer system/Printer prints number in barcode form on ticket at entrance;</p>  \r<p class="indent2new indentright m-t-0">Number read by barcode reader at exit//ticket inserted into barcode reader at exit;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new indentright">Computer system/Printer at entrance punches holes on ticket which are a coded form of number//Kimbal tag produced at entrance which encodes number;</p>  \r<p class="indent2new indentright m-t-0">Number read by sensor (mechanical or optical) at exit//ticket inserted into sensor at exit//Number read by Kimball tag reader at exit;</p>  \r<p class="indent2new indentright">Computer system/printer prints number using magnetic ink;</p>  \r<p class="indent2new indentright m-t-0">At exit MICR<b> </b>reader reads number;</p>  \r<p class="indent2new indentright">Computer system/printer prints marks (encoding number) on ticket;</p>  \r<p class="indent2new indentright m-t-0">At exit, OMR<b> </b>device is used;</p>  \r<p class="levelms">4</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(b)&nbsp;&nbsp;&nbsp;&nbsp; <b>R</b> any other data types. Mark is for field name + correct data type.</p>  \r<p class="indent2new indentright">NB synonyms for RandomNumber must include Number, e.g. IDNo, TicketNo, Number. <b>A</b> RandomInteger, <b>R </b>e.g. Vehicle ID <b>A</b> VehicleIDNo</p>  \r<p class="indent2new indentright"><b>A</b> DateTicketWasIssued</p>  \r<p class="indent2 indentright"><span class="comp">Record</span></p>  \r<p class="indent2 indentright"><span class="comp">&nbsp; RandomNo : Integer; </span><br><b>R</b> anything else</p>  \r<p class="levelms">1</p>  \r<p class="indent2 indentright"><span class="comp">CurrentDate :</span></p>  \r<p class="indent2 indentright"><span class="comp">&nbsp;&nbsp;&nbsp; String/Date/DateTime/TDateTime/TDate;</span></p>  \r<p class="levelms">1</p>  \r<p class="indent2 indentright"><span class="comp">&nbsp; ArrivalTime : </span></p>  \r<p class="indent2 indentright"><span class="comp">&nbsp;String/Integer/Time/DateTime/TDateTime/TTime;</span></p>  \r<p class="levelms">1</p>  \r<p class="indent2 indentright"><span class="comp">&nbsp; LengthOfTime/LengthOfStay/TimeStayed : Integer; </span></p>  \r<p class="indent2 indentright"><b>R</b> anything else</p>  \r<p class="levelms">1</p>  \r<p class="indent2 indentright"><span class="comp">&nbsp; Cost/AmountToPay : Integer/BCD;</span></p>  \r<p class="levelms">1</p>  \r<p class="indent2 indentright"><span class="comp">End;</span></p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new indentright"><b>A</b> Alphanumeric for String</p>  \r<p class="indent2new indentright m-t-0"><b>R</b> Text <b>R</b> LeavingTime <b>R</b> Binary,Byte,LongInteger</p>  \r<p class="indent2new indentright m-t-0"><b>R</b> Date for FieldName</p>  \r<p class="indent2new indentright m-t-0"><b>R</b> Date/Time but don’t penalise twice</p>  \r<p class="mark">[9]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Many candidates were able to suggest a suitable method at the exit barrier for submitting the number assigned to the ticket to the computer system. Fewer were careful enough to describe how the ticket was assigned to the ticket at the entrance barrier. The examiners were expecting a printer to be referenced or the action of printing in the case of a barcode, OMR, OCR, MICR and plain text solution for writing a number to the ticket; the action of encoding or writing to the ticket in the case of a magnetic stripe or smart card and the action of punching in the case of Kimball or Kimball-type tags. The better candidates offered such descriptions.</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new">A lack of experience of using a third generation programming language was exposed by part (b). Many candidates gave data types that were lifted straight from Microsoft ACCESS and therefore gained no credit. The question explicitly requested data types that would be available in a third generation programming language. Candidates must understand that their study of this subject must extend beyond products that have been intentionally designed to enable people with no background in Computing, and no desire to be educated in this subject, to achieve practical results in the minimum of time. For very simple practical tasks, this is desirable but as a foundation for more extensive tasks this is a recipe for disaster. Assembling flat-pack furniture is not considered adequate enough to qualify as a cabinetmaker.</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new">Some candidates had difficulty selecting relevant fields and in some cases when they did choose relevant ones lost a mark for poor choice of identifier. For example, several candidates chose <i>Date</i> instead of <i>CurrentDate</i>. The clue was in the question stem which stated that “the computer system remembers the <i>Current Date, Arrival Time </i>and <i>Randomly generated Number</i>.“ A principle of software engineering is that identifiers should be meaningful and reflect the real world entities which they represent.</p></h5>', 'notes': '', 'resources': ''}, 'Q20S1B09': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question m-b-1">This question refers to the subroutines <span class="comp">Graphics</span> and <span class="comp">LoadFile</span></p>\r\n<p class="indent1">(a)&emsp;&nbsp;State what values are passed in the parameter <span class="comp-top">Header</span> to the subroutine <span class="comp">LoadFile</span> when <span class="comp">LoadFile</span> is called for the <b>first</b> time in the subroutine <span class="comp">Graphics</span></p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(1)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&emsp;&nbsp;Explain how the content of <span class="comp">HeaderLine</span> is processed after it has been assigned a value.</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(3)</p>\r\n<p class="mark">(Total 4 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="questiona">(a)&emsp;&nbsp;<b>Mark is for AO2 (analyse)</b> </p>\r\n<p class="indent2new indentright">The default values of the file header;</p>\r\n<p class="indent2new indentright m-t-0">Empty string, <span class="comp">MAX_WIDTH, MAX_HEIGHT</span>, empty string;</p>\r\n<p class="indent2new indentright"><b>A.</b> \'\'\'\' / \'\' / <span class="comp">EMPTY_STRING</span> for empty string</p>\r\n<p class="indent2new indentright m-t-0"><b>A.</b> 100 for <span class="comp">MAX_WIDTH</span> and/or <span class="comp">MAX_HEIGHT</span></p>\r\n<p class="indent2new indentright"><b>Max 1</b></p>\r\n<p class="levelms">1</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(b)&emsp;&nbsp;<b>3 marks for AO2 (analyse)</b> </p>\r\n<p class="indent2new indentright">The string is split into separate parts;</p>\r\n<p class="indent2new indentright m-t-0">Delimited by a comma;</p>\r\n<p class="indent2new indentright m-t-0">Each part is assigned to a field of the header record;</p>\r\n<p class="indent2new indentright m-t-0"><b>A.</b> File type is used to determine which subroutine is called;</p>\r\n<p class="indent2new indentright"><b>Max 3</b></p>\r\n<p class="levelms">3</p>\r\n<p class="mark">[4]</p></h5>', 'examinerreport': '', 'notes': '', 'resources': ''}, 'Q20S1B05': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The <b>Skeleton</b> <b>Program</b> uses a number of data structures.</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(a)&emsp;&nbsp;State the identifier of the data structure that stores values of <b>more than one data type</b>.</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(1)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&emsp;&nbsp;State the identifier of a data structure that stores values of <b>only one data type</b>.</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="indent2new answer-toggle">___________________________________________________________________</p>\r\n<p class="mark">(1)</p>\r\n<p class="mark">(Total 2 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="questiona">(a)&emsp;&nbsp;<b>Mark is for AO1 (understand)</b> </p>\r\n<p class="indent2new indentright comp-top">Header / FileHeader;</p>\r\n<p class="indent2new indentright"><b>R.</b> if any additional code</p>\r\n<p class="indent2new indentright m-t-0"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent2new indentright m-t-0"><b>I.</b> case &amp; spacing</p>\r\n<p class="levelms">1</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(b)&emsp;&nbsp;<b>Mark is for AO1 (understand)</b></p>\r\n<p class="indent2new indentright comp-top">Grid / Fields;</p>\r\n<p class="indent2new indentright"><b>R.</b> if any additional code</p>\r\n<p class="indent2new indentright m-t-0"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent2new indentright m-t-0"><b>I.</b> case &amp; spacing</p>\r\n<p class="levelms">1</p>\r\n<p class="mark">[2]</p></h5>', 'examinerreport': '', 'notes': '', 'resources': ''}, 'QW06110': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The data shown below is a list of surnames of 20 motor car policyholders with the number of claims they have each made in the last five years.</p>  \r<p class="bottom">&nbsp;</p>  \r<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=5  style=\'margin-left:48pt;border-collapse:collapse\'>  \r\t<tr>      \r\t\t<td width=47 valign=top style=\'width:1.0cm;background:white;padding:0cm 2.0pt 0cm 2.0pt;   height:14.9pt\'><p class=box>&nbsp;</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border:none;border-bottom:   solid windowtext 1.0pt;background:white;padding:0cm 2.0pt 0cm 2.0pt;   height:14.9pt\'><p class=box>PolicyHolder</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;background:white;padding:0cm 2.0pt 0cm 2.0pt;   height:14.9pt\'><p class=box>&nbsp;</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border:none;border-bottom:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>NoOfClaims</p></td>  \r\t</tr>  \r\t<tr>      \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>1</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Wilcox</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>1</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>1</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>2</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Adams</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>2</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>0</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>3</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Pollard</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>3</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>0</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>4</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Williams</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>4</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>0</p></td>  \r\t</tr>  \r\t<tr>      \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>5</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Searle</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>5</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>3</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>6</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Kelly</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>6</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>0</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>7</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Lewis</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>7</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>1</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>8</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Franks</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>8</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>5</p></td>  \r\t</tr>  \r\t<tr>      \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>9</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Patel</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>9</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>1</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>10</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Li Che</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>10</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>0</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>...</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>&nbsp;</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>...</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>...</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>...</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>&nbsp;</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>...</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>...</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>19</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Wilkinson</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>19</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>3</p></td>  \r\t</tr>  \r\t<tr>       \r\t\t<td width=47 valign=top style=\'width:1.0cm;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>20</p></td>   \r\t\t<td width=177 valign=top style=\'width:106.35pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>Veale</p></td>   \r\t\t<td width=44 valign=top style=\'width:26.55pt;border:none;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>20</p></td>   \r\t\t<td width=185 valign=top style=\'width:110.9pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   background:white;padding:0cm 2.0pt 0cm 2.0pt\'><p class=box>0</p></td>  \r\t</tr> \r</table></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1a" style=\'margin-bottom:12.0pt\'>(a)&nbsp;&nbsp;&nbsp;&nbsp; (i)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The user inputs a policyholder. If the surname is found, the program outputs the number of claims for that policyholder.</p>  \r<p class="indent3 m-t-0"><span class="font10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="comp">Read(SearchName) <br> For P := 1 To 20 Do</span></p>  \r<p class="indent3 m-t-0"><span class="comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If PolicyHolder[P] = SearchName</span></p>  \r<p class="indent3 m-t-0"><span class="comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Then GoTo 200</span></p>  \r<p class="indent3 m-t-0"><span class="comp">&nbsp;&nbsp;&nbsp;&nbsp; GoTo 300</span></p>  \r<p class="indent3 m-t-0"><span class="comp">200 : Write(NoOfClaims[P])</span></p>  \r<p class="indent3 m-t-0"><span class="comp">300: End</span></p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent3new">Give<b> two </b>reasons why this is badly designed program code.</p>  \r<p class="indent3new answer-toggle">1. ____________________________________________________________</p>  \r<p class="indent3new answer-toggle">______________________________________________________________</p>  \r<p class="indent3new answer-toggle">2. ____________________________________________________________</p>  \r<p class="indent3new answer-toggle">______________________________________________________________</p>  \r<p class="mark">(2)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2">(ii)&nbsp;&nbsp;&nbsp;&nbsp; Write declaration statements (in a language with which you are familiar) for the PolicyHolder or NoOfClaims data structure above, and one other variable used in the code above.</p>  \r<p class="indent3new answer-toggle">The programming language I am using is _____________________________</p>  \r<p class="indent3new answer-toggle">1. ____________________________________________________________</p>  \r<p class="indent3new answer-toggle">2. ____________________________________________________________</p>  \r<p class="mark">(2)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&nbsp;&nbsp;&nbsp;&nbsp; A new task is to design and write code to establish if there are any policyholders who have made five or more claims. The program will output a ‘yes’ or ‘no’ message only.</p>  \r<p class="indent2new">Write the code for this new task in a programming language with which you are familiar.</p>  \r<p class="indent2new"><i>(Hint: Use a loop structure to initiate the loop, and then end the loop when some condition is met.)</i></p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="indent2new answer-toggle">___________________________________________________________________</p>  \r<p class="mark">(5)</p>  \r<p class="mark">(Total 9 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">&nbsp;</p>\r<p class="indent1a indentright m-t-0">(a)&nbsp;&nbsp;&nbsp;&nbsp; (i)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; •&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; poorly <u>structured</u> code;</p>  \r<p class="indent3 indentright m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uses GoTo statements;</p>  \r<p class="indent3 indentright m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the flow of control jumps out of a loop;</p>  \r<p class="indent3 indentright m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nothing reported to the user when no matching name found;</p>  \r<p class="indent3 indentright m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; abbreviated variable for ‘position’ variable;</p>  \r<p class="indent3 indentright m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReadLn is better than Read;</p>  \r<p class="indent3 indentright m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Program only iterates once / considers only the first array element;</p>  \r<p class="indent3 indentright m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (if duplicates) only the first matching surname is found;</p>  \r<p class="indent3 indentright m-t-0">•&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (loop terminates at 20) does not allow for additional array /name entries;</p>  \r<p class="indent3new indentright m-t-0"><b>A</b> poor layout - excessive indentation used;</p>  \r<p class="indent3new indentright m-t-0"><b>I.</b><b> </b>variable declaration // reference to the syntax</p>  \r<p class="levelms">Max 2</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2 indentright">(ii)&nbsp;&nbsp;&nbsp;&nbsp; All statements must have </i>correct identifier name correct data type (String / Text // Integer / Byte / Word / Int / Shortint / Short as appropriate)</p>  \r<p class="indent3new indentright">In addition, either array must have brackets to indicate an ‘array’ 19/20 to indicate a range;</p>  \r<p class="levelms">Max 2</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(b)&nbsp;&nbsp;&nbsp;&nbsp; Intialisation of counter or Boolean variable</p>  \r<p class="indent2new indentright m-t-0">P := 1 / P := 0 / For P := 1 to 20 // IsFound := False;</p>  \r<p class="indent2new indentright">Looping</p>  \r<p class="indent2new indentright m-t-0">LOOP UNTIL // DO WHILE // WHILE DO // REPEAT UNTIL and used at the beginning/end of a code block as appropriate;</p>  \r<p class="indent2new indentright">Some loop condition is met</p>  \r<p class="indent2new indentright m-t-0">(P = 20/21) OR IsFound = TRUE / P = 20/21 // IsFound = TRUE / IsFound;</p>  \r<p class="indent2new indentright">IF with use of the array</p>  \r<p class="indent2new indentright m-t-0">IF NoOfClaims [P];</p>  \r<p class="indent2new indentright">Selection condition </p>  \r<p class="indent2new indentright m-t-0">&gt;4 / &gt;=5;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new indentright">Loop counter incremented </p>  \r<p class="indent2new indentright m-t-0">P = P+1</p>  \r<p class="indent2new indentright">Final output</p>  \r<p class="indent2new indentright m-t-0">Correct logic followed with OUTPUT ‘Yes’</p>  \r<p class="indent2new indentright m-t-0"><b>A</b> multiple times </p>  \r<p class="indent2new indentright">Final output</p>  \r<p class="indent2new indentright m-t-0">Correct logic followed with OUTPUT ‘No’</p>  \r<p class="indent2new indentright m-t-0"><b>R </b>Multiple times</p>  \r<p class="indent2new indentright m-t-0"><b>R</b> ‘Prose’ scores 0</p>  \r<p class="levelms">5</p>  \r<p class="mark">[9]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">&nbsp;</p>\r<p class="indent1a m-t-0">(a)&nbsp;&nbsp;&nbsp;&nbsp; (i)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The use of GoTo statements has not previously been examined on this paper and most candidates struggled to suggest a single reason why this was poorly designed code, despite a large number of acceptable answers.&nbsp; The most common correct answers were that the use of GoTo statements gives rise to code which is difficult to follow and trace; there is no output produced when the SearchName value is not found; when there is more than one occurrence of SearchName in the PolicyHolder array, the program will output the number of claims value for the first occurrence of the name only.</p>  \r<p class="indent2">(ii)&nbsp;&nbsp;&nbsp;&nbsp; Few marks were obtained here with most candidates failing to give the bounds of the array for PolicyHolder or NoOfClaims, or omitting a data type for the identifier.</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&nbsp;&nbsp;&nbsp;&nbsp; Candidates should be able to write small amounts of program code in a unit that has the word ‘programming’ in its title. Knowledge of loops other than a For loop was rare. It was hoped that candidates would have constructed a Repeat – Until or While loop which terminated when a NoOfClaims value of 5 or more was found. Candidates who used a For loop were, however, still able to score the maximum 5 marks.</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new">Examiners were not looking for the correct use of exact syntax for the language as stated by the candidate. </p>  \r<p class="indent2new">The use of IF statements was better understood, but this often did not extend to using an array index for the NoOfClaims as part of the IF statement. Very many candidates used the maths operator incorrectly<span style=\'color:red\'>,</span> e.g. <span style=\'font-family:Symbol\'>³</span> or more usually =&gt;. Quite a few candidates reversed the logic testing for &lt;5 and gave appropriate output for which they gained marks. Most popular languages seen were Pascal and Visual Basic but the candidates that used C on the whole answered the question very well indeed.</p></h5>', 'notes': '', 'resources': ''}, 'QS19S1B05': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The Skeleton Program uses several data structures.</p>\r\n<p class="indent1new">State the identifier of the data structure that stores values of more than one data type.</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="indent1new answer-toggle">_______________________________________________________________________</p>\r\n<p class="mark">(Total 1 mark)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>Mark is for AO1 (understand)</b></p>\r\n<p class="indent1new comp-top">MoveRecord</p>\r\n<p class="indent1new comp">/ListOfMoves;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new"><b>R.</b> if any additional code</p>\r\n<p class="indent1new m-t-0"><b>R.</b> if spelt incorrectly</p>\r\n<p class="indent1new m-t-0"><b>R.</b> case & spacing</p>\r\n<p class="mark">[1]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The majority of students gained this mark.</p></h5>', 'notes': '', 'resources': ''}, 'Q22S1C13': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">This question adds further validation to the <b>Skeleton Program</b>. The subroutine <span class="comp">SolvePuzzle</span> asks the user to enter coordinates and a digit. The <b>Skeleton Program</b> is to be changed so that if the digit entered by the user already exists in the referenced row, column or sub-grid, the digit cannot be used.</p>\r\n<p class="indent1new">The figure below shows the numbers in the puzzle grid cells of <b>puzzle1</b> when first loaded.</p>\r\n<p class="graph"><img src="AA_COM/Q22S1C13_files_Q/img01.jpg"/>&nbsp;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new"><b>What you need to do:</b></p>\r\n<p class="indent1new"><b>Task 1</b></p>\r\n<p class="indent1new m-t-0">Write a new subroutine, <span class="comp">DuplicateDigit</span>, which takes <span class="comp">PuzzleGrid</span>, <span class="comp">Row</span>, <span class="comp">Column</span> and <span class="comp">Digit</span> as parameters. The subroutine should return <span class="comp">True</span> if the digit entered by the user is already present in the row, column or sub-grid of the cell the user has entered. Otherwise, the subroutine should return <span class="comp">False</span>.</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new"><b>Task 2</b></p>\r\n<p class="indent1new m-t-0">Amend the subroutine <span class="comp">SolvePuzzle</span> so that it uses <span class="comp">DuplicateDigit</span> to check the user input and only allows the digit to be placed into the puzzle grid if the digit is not already present in the row, column or sub-grid of the cell the user has entered. If the digit is already present, an appropriate message should be given to the user.</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new"><b>Task 3</b></p>\r\n<p class="indent1new m-t-0">Test that the changes you have made work by conducting the following test:</p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;run your amended <b>Skeleton Program</b></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;enter <span class="comp">L</span></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;load <b><span class="comp">puzzle1</span></b></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;enter <span class="comp">S</span></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;enter <span class="comp">178</span></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;enter <span class="comp">819</span></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;enter <span class="comp">124</span></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;enter <span class="comp">989</span></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;enter <span class="comp">555</span></p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new"><b>Evidence that you need to provide</b></p>\r\n<p class="indent1">(a)&emsp;&nbsp;Your PROGRAM SOURCE CODE for the entire subroutine <span class="comp">DuplicateDigit</span> and the entire subroutine <span class="comp">SolvePuzzle</span>.</p>\r\n<p class="mark">(8)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&emsp;&nbsp;SCREEN CAPTURE(S) showing the requested test described in <b>Task 3</b>.</p>\r\n<p class="indent2new">The SCREEN CAPTURE(S) need(s) to show the puzzle grid before and after the described test.</p>\r\n<p class="mark">(1)</p>\r\n<p class="mark">(Total 9 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="questiona">(a)&emsp;&nbsp;<b>2 marks for AO3 (design) and 6 marks for AO3 (programming)</b></p>\r\n<p class="indent2new indentright"><b>Marking guidance:</b></p>\r\n<p class="indent2new indentright"><b>Evidence of AO3 design &#x2013; 2 points:</b></p>\r\n<p class="indent2new indentright">Evidence of design to look for in response:</p>\r\n<p class="indent2 indentright">1.&emsp;&ensp;&nbsp;Identify the need for a loop containing a conditional statement;</p>\r\n<p class="indent2 indentright m-t-0">2.&emsp;&ensp;&nbsp;Recognise that subgrid boundaries need to be calculated;</p>\r\n<p class="indent2new indentright"><b>Note: AO3</b> (design) points are for selecting appropriate techniques to use to solve the problem, so should be credited whether the syntax of programming language statements is correct or not and regardless of whether the solution works.</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new indentright"><b>Evidence of AO3 programming &#x2013; 6 points:</b></p>\r\n<p class="indent2new indentright">Evidence of programming to look for in response:</p>\r\n<p class="indent2 indentright">3.&emsp;&ensp;&nbsp;Subroutine heading with correct parameters and return value;</p>\r\n<p class="indent2 indentright m-t-0">4.&emsp;&ensp;&nbsp;Check both row and column for duplicate <b>I.</b> failing to check location at which digit is to be placed;</p>\r\n<p class="indent2 indentright m-t-0">5.&emsp;&ensp;&nbsp;Correctly calculate subgrid boundaries;</p>\r\n<p class="indent2 indentright m-t-0">6.&emsp;&ensp;&nbsp;Check each digit in a subgrid for duplicate <i>(does not depend on MP5 above)</i>;</p>\r\n<p class="indent2 indentright m-t-0">7.&emsp;&ensp;&nbsp;Call in correct place in <span class="comp">SolvePuzzle</span> so that grid updated only under correct circumstances / if digit is valid / if subroutine returns true <b>R.</b> if returned value not used;</p>\r\n<p class="indent2 indentright m-t-0">8.&emsp;&ensp;&nbsp;Give appropriate error message (under at least some correct circumstances and is never displayed when it shouldn&#x2019;t be) <b>A.</b> error message in <span class="comp">DuplicateDigit</span>;</p>\r\n<p class="indent2new indentright"><b>Max 7</b> if any errors</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>VB.Net</b></p>\r\n<p class="indent2new comp-top m-b-0"><b>Function DuplicateDigit(PuzzleGrid(,) As Char, Row As Integer, Column As</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0"><b>Integer, Digit As Char) As Boolean \' MP3</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Dim duplicateFound As Boolean = False</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Dim i As Integer</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>For i = 1 To GRID_SIZE \' MP1</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>If PuzzleGrid(i, Column) = Digit Or PuzzleGrid(Row, i) = Digit Then</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>duplicateFound = True&emsp;&emsp;&emsp;\' MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>End If</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Next</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Dim endr As Integer = ((Row - 1) \\ 3 + 1) * 3 \' MP2</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Dim endc As Integer = ((Column - 1) \\ 3 + 1) * 3</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Dim r, c As Integer</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>For r = endr - 2 To endr</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>For c = endc - 2 To endc &#x2018;\' MP5</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>If PuzzleGrid(r, c) = Digit Then</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>duplicateFound = True \' MP6</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>End If</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>Next</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Next</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Return duplicateFound</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0"><b>End Function</b></p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new comp-top m-b-0">Sub SolvePuzzle(PuzzleGrid(,) As Char, Puzzle() As String, Answer() As String)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Dim CellInfo As String</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Dim InputError As Boolean</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Dim Digit As Char</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Dim Row, Column As Integer</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;DisplayGrid(PuzzleGrid)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;If PuzzleGrid(0, 0) &lt;&gt; &quot;X&quot; Then</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;No puzzle loaded&quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Enter row column digit: &quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;(Press Enter to stop)&quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;CellInfo = Console.ReadLine()</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;While CellInfo &lt;&gt; EMPTY_STRING</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = False</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If CellInfo.Length &lt;&gt; 3 Then</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Digit = CellInfo(2)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Try</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Row = Int32.Parse(CellInfo(0))</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catch</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Try</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Try</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Column = Int32.Parse(CellInfo(1))</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catch</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Try</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If (Digit &lt; &quot;1&quot;) Or (Digit &gt; &quot;9&quot;) Then</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If InputError Then</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Invalid input&quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>\' MP7: call subroutine in correct place</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>If DuplicateDigit(PuzzleGrid, Row, Column, Digit) Then</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Console.WriteLine(&quot;Duplicate digit entered.&quot;) \' MP8</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Else</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PuzzleGrid(Row, Column) = Digit</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Answer(2) = (Int32.Parse(Answer(2)) + 1).ToString()</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Answer(Int32.Parse(Answer(2)) + 2) = CellInfo</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayGrid(PuzzleGrid)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Enter row column digit: &quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;(Press Enter to stop)&quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CellInfo = Console.ReadLine()</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;End While</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;End If</p>\r\n<p class="indent2new comp m-t-0">End Sub</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>Alternative Solution DuplicateDigit subroutine:</b></p>\r\n<p class="indent2new comp-top m-b-0">Function DuplicateDigit(PuzzleGrid(,) As Char, Row As Integer, Column As Integer, Digit As Char) As Boolean&emsp;&emsp;\' MP3</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Dim duplicateFound As Boolean = False</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Dim i As Integer</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;For i = 1 To GRID_SIZE \' MP1</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;If PuzzleGrid(i, Column) = Digit Or PuzzleGrid(Row, i) = Digit Then</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;duplicateFound = True&emsp;&emsp;\' MP4</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;End If</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Next</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Dim startR As Integer = ((Row - 1) \\ 3) * 3 + 1&emsp;&emsp;\' MP2</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Dim startC As Integer = ((Column - 1) \\ 3) * 3 + 1</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Dim r, c As Integer</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;For r = startR To startR + 2</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;For c = startC To startC + 2 \'\' MP5</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If PuzzleGrid(r, c) = Digit Then</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;duplicateFound = True \' MP6</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;Next</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Next</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Return duplicateFound</p>\r\n<p class="indent2new comp m-b-0 m-t-0">End Function</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>Python 3</b></p>\r\n<p class="indent2new comp-top m-b-0"><b>def DuplicateDigit(PuzzleGrid, Row, Column, Digit): # MP3</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Duplicate = False</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for X in range(1, GRID_SIZE + 1): # MP1</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>if PuzzleGrid[X][Column] == Digit: # MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Duplicate = True</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for Y in range(1, GRID_SIZE + 1):</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>if PuzzleGrid[Row][Y] == Digit: # MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Duplicate = True</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>SubGridStartX = ((Row - 1) // 3) * 3 + 1 # MP2</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>SubGridStartY = ((Column - 1) // 3) * 3 + 1</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for X in range(SubGridStartX, SubGridStartX + 3):</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>for Y in range(SubGridStartY, SubGridStartY + 3): # MP5</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>if PuzzleGrid[X][Y] == Digit:</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Duplicate = True # MP6</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>return Duplicate</b></p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new comp-top m-b-0">def SolvePuzzle(PuzzleGrid, Puzzle, Answer):</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;DisplayGrid(PuzzleGrid)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;if PuzzleGrid[0][0] != \'X\':</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;No puzzle loaded&quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;else:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;Enter row column digit: &quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;(Press Enter to stop)&quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;CellInfo = input()</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;while CellInfo != EMPTY_STRING:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = False</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if len(CellInfo) != 3:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Digit = CellInfo[2]</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Row = int(CellInfo[0])</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Column = int(CellInfo[1])</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (Digit &lt; \'1\' or Digit &gt; \'9\'):</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if InputError:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;Invalid input&quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>if DuplicateDigit(PuzzleGrid, Row, Column, Digit): # MP7</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>print(&quot;Duplicate digit&quot;) # MP8</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>else:</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PuzzleGrid[Row][Column] = Digit</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Answer[2] = str(int(Answer[2]) + 1)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Answer[int(Answer[2]) + 2] = CellInfo</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayGrid(PuzzleGrid)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;Enter row column digit: &quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;(Press Enter to stop)&quot;)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CellInfo = input()</p>\r\n<p class="indent2new comp m-t-0">&nbsp;&nbsp;return PuzzleGrid, Answer</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>Python 2</b></p>\r\n<p class="indent2new comp-top m-b-0"><b>def DuplicateDigit(PuzzleGrid, Row, Column, Digit): # MP3</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Duplicate = False</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for X in range(1, GRID_SIZE + 1): # MP1</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>if PuzzleGrid[X][Column] == Digit: # MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Duplicate = True</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for Y in range(1, GRID_SIZE + 1):</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>if PuzzleGrid[Row][Y] == Digit: # MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Duplicate = True</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>SubGridStartX = ((Row - 1) // 3) * 3 + 1 # MP2</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>SubGridStartY = ((Column - 1) // 3) * 3 + 1</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for X in range(SubGridStartX, SubGridStartX + 3):</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>for Y in range(SubGridStartY, SubGridStartY + 3): # MP5</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>if PuzzleGrid[X][Y] == Digit:</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Duplicate = True # MP6</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>return Duplicate</b></p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new comp-top m-b-0">def SolvePuzzle(PuzzleGrid, Puzzle, Answer):</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;DisplayGrid(PuzzleGrid)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;if PuzzleGrid[0][0] != \'X\':</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;print &quot;No puzzle loaded&quot;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;else:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;print &quot;Enter row column digit: &quot;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;print &quot;(Press Enter to stop)&quot;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;CellInfo = raw_input()</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;while CellInfo != EMPTY_STRING:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = False</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if len(CellInfo) != 3:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Digit = CellInfo[2]</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Row = int(CellInfo[0])</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Column = int(CellInfo[1])</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (Digit &lt; \'1\' or Digit &gt; \'9\'):</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError = True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if InputError:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &quot;Invalid input&quot;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b># MP7: call subroutine in correct place</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>if DuplicateDigit(PuzzleGrid, Row, Column, Digit):</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>print(&quot;Duplicate digit&quot;) # MP8</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>else:</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PuzzleGrid[Row][Column] = Digit</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Answer[2] = str(int(Answer[2]) + 1)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Answer[int(Answer[2]) + 2] = CellInfo</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayGrid(PuzzleGrid)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &quot;Enter row column digit: &quot;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &quot;(Press Enter to stop)&quot;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CellInfo = raw_input()</p>\r\n<p class="indent2new comp m-t-0">&nbsp;&nbsp;return PuzzleGrid, Answer</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>Pascal</b></p>\r\n<p class="indent2new comp-top m-b-0"><b>function DuplicateDigit(PuzzleGrid: TPuzzleGrid; Row, Column: integer; Digit: string): boolean;&emsp;&emsp;// MP3</p>\r\n<p class="indent2new comp m-b-0 m-t-0">var</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Duplicate: boolean;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>X, Y, SubGridStartX, SubGridStartY: integer;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0"><b>begin</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>Duplicate := False;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for X := 1 to GRID_SIZE do&emsp;&emsp;// MP1</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>if PuzzleGrid[X, Column] = Digit then // MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Duplicate := True;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for Y := 1 to GRID_SIZE do</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>if PuzzleGrid[Row, Y] = Digit then // MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Duplicate := True;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>SubGridStartX := ((Row - 1) div 3) * 3 + 1; // MP2</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>SubGridStartY := ((Column - 1) div 3) * 3 + 1;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>for X := SubGridStartX to SubGridStartX + 2 do</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>for Y := SubGridStartY to (SubGridStartY + 2) do // MP5</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>if PuzzleGrid[X, Y] = Digit then</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Duplicate := True; // MP6</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>DuplicateDigit := Duplicate;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0"><b>end;</b></p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new comp-top m-b-0">procedure SolvePuzzle(var PuzzleGrid: TPuzzleGrid; Puzzle:</p>\r\n<p class="indent2new comp m-b-0 m-t-0">TPuzzle; var Answer: TAnswer);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">var</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;CellInfo: string;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;InputError: boolean;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Digit: char;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;Row, Column: integer;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">begin</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;DisplayGrid(PuzzleGrid);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;if PuzzleGrid[0, 0] &lt;&gt; \'X\' then</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;writeln(\'No puzzle loaded\')</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;begin</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;writeln(\'Enter row column digit: \');</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;writeln(\'(Press Enter to stop)\');</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;readln(CellInfo);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;while CellInfo &lt;&gt; EMPTY_STRING do</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;begin</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError := False;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if length(CellInfo) &lt;&gt; 3 then</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError := True</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Digit := CellInfo[3];</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Row := strToInt(CellInfo[1]);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError := True;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Column := strToInt(CellInfo[2]);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError := True;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (Digit &lt; \'1\') or (Digit &gt; \'9\') then</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputError := True;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if InputError then</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writeln(\'Invalid input\')</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else <b>// MP7: call subroutine in correct place</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>if DuplicateDigit(PuzzleGrid, Row, Column, Digit) then</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>writeln(\'Duplicate digit\') // MP8</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>else</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PuzzleGrid[Row, Column] := Digit;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Answer[2] := intToStr(strToInt(Answer[2]) + 1);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Answer[strToInt(Answer[2]) + 2] := CellInfo;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayGrid(PuzzleGrid);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writeln(\'Enter row column digit: \');</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writeln(\'(Press Enter to stop)\');</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;readln(CellInfo);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;end;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;end;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">end;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>C#</b></p>\r\n<p class="indent2new comp-top m-b-0"><b>private static bool DuplicateDigit(char[,] puzzleGrid, int row, int column, char digit) // MP3</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0"><b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>bool duplicate = false;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for (int x = 1; x &lt; GRID_SIZE + 1; x++) // MP1</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>if (puzzleGrid[x,column] == digit) // MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>duplicate = true;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for (int y = 1; y &lt; GRID_SIZE + 1; y++)</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>if (puzzleGrid[row,y] == digit) // MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>duplicate = true;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>int subGridStartX = ((row - 1) / 3) * 3 + 1; // MP2</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>int subGridStartY = ((column - 1) / 3) * 3 + 1;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for (int x = subGridStartX; x &lt; subGridStartX + 3; x++)</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>for (int y = subGridStartY; y &lt; subGridStartY + 3; y++)// MP5</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>if (puzzleGrid[x, y] == digit)</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>duplicate = true; // MP6</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>return duplicate;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0"><b>}</b></p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new comp-top m-b-0">private static void SolvePuzzle(char[,] puzzleGrid, string[] puzzle, string[] answer)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;int row = 0, column = 0;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;char digit = \' \';</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;DisplayGrid(puzzleGrid);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;if (puzzleGrid[0, 0] != \'X\')</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;No puzzle loaded&quot;);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Enter row column digit: &quot;);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;(Press Enter to stop)&quot;);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;string cellInfo = Console.ReadLine();</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;while (cellInfo != EMPTY_STRING)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bool inputError = false;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (cellInfo.Length != 3)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputError = true;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;digit = cellInfo[2];</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row = Convert.ToInt32(cellInfo[0].ToString());</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch (Exception)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputError = true;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;column = Convert.ToInt32(cellInfo[1].ToString());</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch (Exception)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputError = true;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (digit &lt; \'1\' || digit &gt; \'9\')</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputError = true;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (inputError)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Invalid input&quot;);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<b>// MP7: call subroutine in correct place</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>if (DuplicateDigit(puzzleGrid, row, column, digit))</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Console.WriteLine(&quot;Duplicate digit&quot;); // MP8</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>else</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puzzleGrid[row, column] = digit;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;answer[2] = (Convert.ToInt32(answer[2]) + 1).ToString();</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;answer[Convert.ToInt32(answer[2]) + 2] = cellInfo;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayGrid(puzzleGrid);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Enter row column digit: &quot;);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;(Press Enter to stop)&quot;);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cellInfo = Console.ReadLine();</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-t-0">}</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>Java</b></p>\r\n<p class="indent2new comp-top m-b-0"><b>boolean duplicateDigit(char [][] puzzleGrid, int row, int column, char digit) // MP3</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0"><b>{</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>boolean duplicate = false;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for (int x = 1; x &lt;= GRID_SIZE; x++) {// MP1</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>if (puzzleGrid[x][column] == digit) {// MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>duplicate = true;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for (int y = 1; y &lt;= GRID_SIZE; y++) {</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>if (puzzleGrid[row][y] == digit) {// MP4</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>duplicate = true;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>int subGridStartX = ((row - 1) / 3) * 3 + 1; // MP2</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>int subGridStartY = ((column - 1) / 3) * 3 + 1;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>for (int x = subGridStartX; x &lt; subGridStartX + 3; x++) {</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>for (int y = subGridStartY; y &lt; subGridStartY + 3; y++) {// MP5</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>if (puzzleGrid[x][y] == digit) {</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>duplicate = true; // MP6</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;<b>return duplicate;</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0"><b>}</b></p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new comp-top m-b-0">void solvePuzzle(char[][] puzzleGrid, String[] puzzle, String[] answer)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;String cellInfo;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;boolean inputError;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;char digit = \' \';</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;int row = 0, column = 0;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;displayGrid(puzzleGrid);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;if (puzzleGrid[0][0] != \'X\')</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;Console.writeLine(&quot;No puzzle loaded&quot;);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;Console.writeLine(&quot;Enter row column digit: &quot;);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;Console.writeLine(&quot;(Press Enter to stop)&quot;);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;cellInfo = Console.readLine();</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;while (!cellInfo.equals(EMPTY_STRING))</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputError = false;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (cellInfo.length() != 3)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputError = true;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;digit = cellInfo.charAt(2);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row = Integer.parseInt(cellInfo.charAt(0) + EMPTY_STRING);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch (Exception ex)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputError = true;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;column = Integer.parseInt(cellInfo.charAt(1) + EMPTY_STRING);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch (Exception ex)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputError = true;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((digit &lt; \'1\') || (digit &gt; \'9\'))</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputError = true;</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (inputError)</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.writeLine(&quot;Invalid input&quot;);</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else</p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<b>// MP7: call subroutine in correct place</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>if (duplicateDigit(puzzleGrid, row, column, digit)) {</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Console.writeLine(&quot;Duplicate digit&quot;);// MP8</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>}</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>else</b></p>\r\n<p class="indent2new comp m-b-0 m-t-0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>{</b></p>\r\n<p class="indent2new comp m-t-0"><b>&#x2026;</b></p>\r\n<p class="levelms">8</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(b)&emsp;&nbsp;<b>Mark is for AO3 (evaluate)</b></p>\r\n<p class="indent2new indentright"><b>**** SCREEN CAPTURE ****</b></p>\r\n<p class="indent2new indentright m-t-0">Must match code from <b>(a)</b>, including prompts on screen capture matching those in code.</p>\r\n<p class="indent2new indentright m-t-0">Code for <b>(a)</b> must be sensible.</p>\r\n<p class="indent2new indentright">Screen capture showing:</p>\r\n<p class="indent2new indentright comp m-t-1">Enter your choice: S</p>\r\n<p class="indent2"><img src="AA_COM/M22S1C13_files_M/img01.jpg"/>&nbsp;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new indentright comp m-t-1">Enter row column digit:</p>\r\n<p class="indent2new indentright comp">(Press Enter to stop)</p>\r\n<p class="indent2new indentright comp">178</p>\r\n<p class="indent2new indentright comp">Duplicate digit</p>\r\n<p class="indent2new indentright comp">Enter row column digit:</p>\r\n<p class="indent2new indentright comp">(Press Enter to stop)</p>\r\n<p class="indent2new indentright comp">819</p>\r\n<p class="indent2new indentright comp">Duplicate digit</p>\r\n<p class="indent2new indentright comp">Enter row column digit:</p>\r\n<p class="indent2new indentright comp">(Press Enter to stop)</p>\r\n<p class="indent2new indentright comp">124</p>\r\n<p class="indent2new indentright comp">Duplicate digit</p>\r\n<p class="indent2new indentright comp">Enter row column digit:</p>\r\n<p class="indent2new indentright comp">(Press Enter to stop)</p>\r\n<p class="indent2new indentright comp">989</p>\r\n<p class="indent2new indentright comp">Duplicate digit</p>\r\n<p class="indent2new indentright comp">Enter row column digit:</p>\r\n<p class="indent2new indentright comp">(Press Enter to stop)</p>\r\n<p class="indent2new indentright comp">555</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2"><img src="AA_COM/M22S1C13_files_M/img02.jpg"/>&nbsp;</p>\r\n<p class="levelms">1</p>\r\n<p class="mark">[9]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">This question required additional validation to be added to the skeleton code. A value should not be permitted in a cell if it already exists in the same row, column, or sub-grid. Most students secured some marks on this question, but only a minority picked up all six. The marks relating to the sub-grid were secured by fewer students than the marks relating to the row and column.</p>\r\n<p class="indent1new">Determining whether a value already existed within the same row or column was a relatively straightforward task. This could be accomplished using two simple loops. The most common way of checking a sub-grid required a combination of the modulo operator and nested loops. Other students opted for a nine-part selection structure, which was equally creditworthy.</p></h5>', 'notes': '', 'resources': ''}, 'Q23S1C12': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">This question extends the functionality of the <b>Skeleton Program</b>.</p>\r\n<p class="indent1new">The functionality of the <span class="comp">SKP</span> opcode is to be changed so that it increments the value stored in the accumulator by 1</p>\r\n<p class="indent1new">For example, if the accumulator contained 4, then executing the instruction</p>\r\n<p class="indent2new m-t-0"><span class="comp">SKP</span></p>\r\n<p class="indent1new m-t-s">would change the value in the accumulator to 5</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new"><b>What you need to do:</b></p>\r\n<p class="indent1new"><b>Task 1</b></p>\r\n<p class="indent1new m-t-0">Amend the subroutine <span class="comp">ExecuteSKP</span> so that it adds 1 to the accumulator and then updates the status register if required. The <span class="comp">Registers</span> data structure should be passed as a parameter.</p>\r\n<p class="indent1new"><b>Task 2</b></p>\r\n<p class="indent1new m-t-0">Amend the call to <span class="comp">ExecuteSKP</span> in the <span class="comp">Execute</span> subroutine as required.</p>\r\n<p class="indent1new"><b>Task 3</b></p>\r\n<p class="indent1new m-t-0">Test that the changes you have made work by conducting the following test:</p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;run your amended <b>Skeleton Program</b></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;enter <span class="comp">L</span></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;load <b>prog2</b></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;enter <span class="comp">A</span></p>\r\n<p class="indent1 m-t-0">&#8226;&emsp;&emsp;&nbsp;enter <span class="comp">R</span></p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new"><b>Evidence that you need to provide</b></p>\r\n<p class="indent1">(a)&emsp;&nbsp;Your PROGRAM SOURCE CODE for the entire subroutine <span class="comp">ExecuteSKP</span> and the entire subroutine <span class="comp">Execute</span>.</p>\r\n<p class="mark">(4)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1">(b)&emsp;&nbsp;SCREEN CAPTURE(S) showing the requested test described in <b>Task 3</b>.</p>\r\n<p class="indent2new">The SCREEN CAPTURE(S) only need to show all of Frame 0 and all of the final frame.</p>\r\n<p class="mark">(1)</p>\r\n<p class="mark">(Total 5 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="questiona">(a)&emsp;&nbsp;<b>4 marks for AO3 (programming)</b></p>\r\n<p class="indent2new indentright"><b>Mark as follows:</b></p>\r\n<p class="indent2 indentright">1)&emsp;&ensp;&nbsp;Add required parameter to subroutine call in <span class="comp">Execute</span>;</p>\r\n<p class="indent2 indentright m-t-0">2)&emsp;&ensp;&nbsp;Add required parameter to <span class="comp">ExecuteSKP</span> definition;</p>\r\n<p class="indent2 indentright m-t-0">3)&emsp;&ensp;&nbsp;Add <span class="comp">1</span> to <span class="comp">Registers[ACC];</span></p>\r\n<p class="indent2 indentright m-t-0">4)&emsp;&ensp;&nbsp;Update status register (by calling <span class="comp">SetFlags</span> with correct parameters);</p>\r\n<p class="indent2new indentright"><b>Max 3</b> if any errors</p>\r\n<p class="levelms">4</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1 indentright">(b)&emsp;&nbsp;<b>Mark is for AO3 (evaluate)</b></p>\r\n<p class="indent2new indentright"><b>&#42;&#42;&#42;&#42; SCREEN CAPTURE &#42;&#42;&#42;&#42;</b></p>\r\n<p class="indent2new indentright m-t-0">Must match code from <b>(a)</b>, including prompts on screen capture matching those in code.</p>\r\n<p class="indent2new indentright m-t-0">Code for <b>(a)</b> must be sensible.</p>\r\n<p class="indent2new indentright">Screen capture showing (values changing from Frame 0 to Frame 5 shown highlighted):</p>\r\n<p class="indent2new"><img src="AA_COM/M23S1C12_files_M/img01.jpg"/>&nbsp;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>VB.Net</b></p>\r\n<p class="indent2new comp-top">Sub ExecuteSKP(<b>Registers() As Integer</b>)&nbsp;&nbsp;\' MP2</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>Registers(ACC) += 1</b>&nbsp;&nbsp;\'MP3</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>SetFlags(Registers(ACC), Registers)</b>&nbsp;&nbsp;\'MP4</p>\r\n<p class="indent2new comp">End Sub</p>\r\n<p class="indent2new comp-top">Sub Execute(ByVal SourceCode() As String, ByVal Memory() As AssemblerInstruction)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Dim Registers() As Integer = {0, 0, 0, 0, 0}</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;SetFlags(Registers(ACC), Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers(PC) = 0</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers(TOS) = HI_MEM</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Dim FrameNumber As Integer = 0</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;DisplayFrameDelimiter(FrameNumber)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;DisplayCurrentState(SourceCode, Memory, Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Dim OpCode As String = Memory(Registers(PC)).OpCode</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;While OpCode &lt;&gt; &quot;HLT&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;FrameNumber += 1</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine()</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;DisplayFrameDelimiter(FrameNumber)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Dim Operand As Integer = Memory(Registers(PC)).OperandValue</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine($&quot;* Current Instruction Register: {OpCode} {Operand}&quot;)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Registers(PC) += 1</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Select Case OpCode</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;LDA&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteLDA(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;STA&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteSTA(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;LDA#&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteLDAimm(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;ADD&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteADD(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;JMP&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteJMP(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;JSR&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteJSR(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;CMP#&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteCMPimm(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;BEQ&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteBEQ(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;SUB&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteSUB(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;SKP&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteSKP(<b>Registers</b>)&nbsp;&nbsp;\'MP1</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case &quot;RTN&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteRTN(Memory, Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;End Select</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;If Registers(ERR) = 0 Then</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OpCode = Memory(Registers(PC)).OpCode</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayCurrentState(SourceCode, Memory, Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Else</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OpCode = &quot;HLT&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;End If</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;End While</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Console.WriteLine(&quot;Execution terminated&quot;)</p>\r\n<p class="indent2new comp">End Sub</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>Python 3</b></p>\r\n<p class="indent2new comp-top">def ExecuteSKP(<b>Registers</b>):&nbsp;&nbsp;<b># MP2</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>Registers[ACC] = Registers[ACC] + 1</b>&nbsp;&nbsp;<b># MP3</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>Registers = SetFlags(Registers[ACC], Registers)</b>&nbsp;&nbsp;<b># MP4</b></p>\r\n<p class="indent2new comp-top">def Execute(SourceCode, Memory):</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers = [0, 0, 0, 0, 0]</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers = SetFlags(Registers[ACC], Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers[PC] = 0</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers[TOS] = HI_MEM</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;FrameNumber = 0</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;DisplayFrameDelimiter(FrameNumber)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;DisplayCurrentState(SourceCode, Memory, Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;OpCode = Memory[Registers[PC]].OpCode</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;while OpCode != &quot;HLT&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;FrameNumber += 1</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;print()</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;DisplayFrameDelimiter(FrameNumber)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Operand = Memory[Registers[PC]].OperandValue</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;* Current Instruction Register: &quot;, OpCode, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Registers[PC] = Registers[PC] + 1</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;if OpCode == &quot;LDA&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteLDA(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;STA&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Memory = ExecuteSTA(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;LDA#&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteLDAimm(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;ADD&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteADD(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;JMP&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteJMP(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;JSR&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Memory, Registers = ExecuteJSR(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;CMP#&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteCMPimm(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;BEQ&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteBEQ(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;SUB&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteSUB(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;SKP&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteSKP(<b>Registers</b>)&nbsp;&nbsp;<b># MP1</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;RTN&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteRTN(Memory, Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;if Registers[ERR] == 0:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OpCode = Memory[Registers[PC]].OpCode</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayCurrentState(SourceCode, Memory, Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;else:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OpCode = &quot;HLT&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;print(&quot;Execution terminated&quot;)</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>Python 2</b></p>\r\n<p class="indent2new comp-top">def ExecuteSKP(<b>Registers</b>)<b>:</b>&nbsp;&nbsp;<b># MP2</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>Registers[ACC] = Registers[ACC] + 1</b>&nbsp;&nbsp;<b># MP3</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>Registers = SetFlags(Registers[ACC], Registers)</b>&nbsp;&nbsp;<b># MP4</b></p>\r\n<p class="indent2new comp-top">def Execute(SourceCode, Memory):</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers = [0, 0, 0, 0, 0]</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers = SetFlags(Registers[ACC], Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers[PC] = 0</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers[TOS] = HI_MEM</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;FrameNumber = 0</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;DisplayFrameDelimiter(FrameNumber)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;DisplayCurrentState(SourceCode, Memory, Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;OpCode = Memory[Registers[PC]].OpCode</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;while OpCode != &quot;HLT&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;FrameNumber += 1</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;print</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;DisplayFrameDelimiter(FrameNumber)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Operand = Memory[Registers[PC]].OperandValue</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;print &quot;* Current Instruction Register: &quot;, OpCode, Operand</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Registers[PC] = Registers[PC] + 1</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;if OpCode == &quot;LDA&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteLDA(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;STA&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Memory = ExecuteSTA(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;LDA#&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteLDAimm(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;ADD&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteADD(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;JMP&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteJMP(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;JSR&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Memory, Registers = ExecuteJSR(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;CMP#&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteCMPimm(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;BEQ&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteBEQ(Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;SUB&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteSUB(Memory, Registers, Operand)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;SKP&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteSKP(<b>Registers</b>)&nbsp;&nbsp;<b># MP1</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;elif OpCode == &quot;RTN&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers = ExecuteRTN(Memory, Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;if Registers[ERR] == 0:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OpCode = Memory[Registers[PC]].OpCode</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayCurrentState(SourceCode, Memory, Registers)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;else:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OpCode = &quot;HLT&quot;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;print &quot;Execution terminated&quot;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>Pascal</b></p>\r\n<p class="indent2new comp-top">procedure ExecuteSKP<b>(var Registers: TRegisters);</b>&nbsp;&nbsp;<b>// MP2</b></p>\r\n<p class="indent2new comp">begin</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>Registers[ACC] := Registers[ACC] + 1;</b>&nbsp;&nbsp;<b>// MP3</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>SetFlags(Registers[ACC], Registers);</b>&nbsp;&nbsp;<b>// MP4</b></p>\r\n<p class="indent2new comp">end;</p>\r\n<p class="indent2new comp-top">procedure Execute(var SourceCode: TSourceCode; var Memory: TMemory);</p>\r\n<p class="indent2new comp">var</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers: TRegisters;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;OpCode: string;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Operand, FrameNumber: integer;</p>\r\n<p class="indent2new comp">begin</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers := TRegisters.create(0, 0, 0, 0, 0);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;SetFlags(Registers[ACC], Registers);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers[PC] := 0;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Registers[TOS] := HI_MEM;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;FrameNumber := 0;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;DisplayFrameDelimiter(FrameNumber);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;DisplayCurrentState(SourceCode, Memory, Registers);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;OpCode := Memory[Registers[PC]].OpCode;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;while OpCode &lt;&gt; \'HLT\' do</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;begin</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FrameNumber := FrameNumber + 1;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writeln;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;DisplayFrameDelimiter(FrameNumber);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Operand := Memory[Registers[PC]].OperandValue;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writeln(\'* Current Instruction Register: \', OpCode, \' \', Operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Registers[PC] := Registers[PC] + 1;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'LDA\' then ExecuteLDA(Memory, Registers, Operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'STA\' then ExecuteSTA(Memory, Registers, Operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'LDA#\' then ExecuteLDAimm(Registers, Operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'ADD\' then ExecuteADD(Memory, Registers, Operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'JMP\' then ExecuteJMP(Registers, Operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'JSR\' then ExecuteJSR(Memory, Registers, Operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'CMP#\' then ExecuteCMPimm( Registers, Operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'BEQ\' then ExecuteBEQ(Registers, Operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'SUB\' then ExecuteSUB(Memory, Registers, Operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'SKP\' then ExecuteSKP(<b>Registers</b>);&nbsp;&nbsp;<b>// MP1</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if OpCode = \'RTN\' then ExecuteRTN(Memory, Registers);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if Registers[ERR] = 0</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;then</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OpCode := Memory[Registers[PC]].OpCode;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayCurrentState(SourceCode, Memory, Registers);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OpCode := \'HLT\';</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;end;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;writeln(\'Execution terminated\');</p>\r\n<p class="indent2new comp">end;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>C#</b></p>\r\n<p class="indent2new comp-top">private static void ExecuteSKP(<b>int[] registers</b>)&nbsp;&nbsp;<b>// MP2</b></p>\r\n<p class="indent2new comp">{</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>registers[ACC] = registers[ACC] + 1;</b>&nbsp;&nbsp;<b>// MP3</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>SetFlags(registers[ACC], registers);</b>&nbsp;&nbsp;<b>// MP4</b></p>\r\n<p class="indent2new comp">}</p>\r\n<p class="indent2new comp-top">private static void Execute(string[] sourceCode, AssemblerInstruction[] memory)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;int[] registers = new int[] { 0, 0, 0, 0, 0 };</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;int frameNumber = 0, operand = 0;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;SetFlags(registers[ACC], registers);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;registers[PC] = 0;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;registers[TOS] = HI_MEM;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;DisplayFrameDelimiter(frameNumber);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;DisplayCurrentState(sourceCode, memory, registers);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;string opCode = memory[registers[PC]].opCode;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;while (opCode != &quot;HLT&quot;)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frameNumber++;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine();</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayFrameDelimiter(frameNumber);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;operand = memory[registers[PC]].operandValue;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine($&quot;* Current Instruction Register: {opCode} {operand}&quot;);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;registers[PC] = registers[PC] + 1;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (opCode)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;LDA&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteLDA(memory, registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;STA&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteSTA(memory, registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;LDA#&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteLDAimm(registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;ADD&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteADD(memory, registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;JMP&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteJMP(registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;JSR&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteJSR(memory, registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;CMP#&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteCMPimm(registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;BEQ&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteBEQ(registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;SUB&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteSUB(memory, registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;SKP&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteSKP(<b>registers</b>); break;&nbsp;&nbsp;<b>// MP1</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;RTN&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecuteRTN(memory, registers); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (registers[ERR] == 0)</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opCode = memory[registers[PC]].opCode;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DisplayCurrentState(sourceCode, memory, registers);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opCode = &quot;HLT&quot;;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Execution terminated&quot;);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;}</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent2new"><b>Java</b></p>\r\n<p class="indent2new comp-top">void executeSKP(<b>int[] registers</b>) {&nbsp;&nbsp;<b>// MP4</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>registers[ACC] = registers[ACC] + 1;</b>&nbsp;&nbsp;<b>// MP2</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;<b>setFlags(registers[ACC], registers);</b>&nbsp;&nbsp;<b>// MP3</b></p>\r\n<p class="indent2new comp">}</p>\r\n<p class="indent2new comp-top">void execute(String[] sourceCode, AssemblerInstruction[] memory)</p>\r\n<p class="indent2new comp-top">{</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;int[] registers = {0, 0, 0, 0, 0} ;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;setFlags(registers[ACC], registers);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;registers[PC] = 0;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;registers[TOS] = HI_MEM;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;int frameNumber = 0;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;displayFrameDelimiter(frameNumber);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;displayCurrentState(sourceCode, memory, registers);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;String opCode = memory[registers[PC]].opCode;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;while (!opCode.equals(&quot;HLT&quot;)) {</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;frameNumber += 1;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Console.println();</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;displayFrameDelimiter(frameNumber);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;int operand = memory[registers[PC]].operandValue;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;Console.println(&quot;* Current instruction Register: &quot; + opCode + &quot; &quot; + operand);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;registers[PC] = registers[PC] + 1;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;switch (opCode) {</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;LDA&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeLDA(memory, registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;STA&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeSTA(memory, registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;LDA#&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeLDAimm(registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;ADD&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeADD(memory, registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;JMP&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeJMP(registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;JSR&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeJSR(memory, registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;CMP#&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeCMPimm(registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;BEQ&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeBEQ(registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;SUB&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeSUB(memory, registers, operand); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;SKP&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeSKP(<b>registers</b>); break;&nbsp;&nbsp;<b>// MP1</b></p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;RTN&quot;:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executeRTN(memory, registers); break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default:</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;if (registers[ERR] == 0) {</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opCode = memory[registers[PC]].opCode;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;displayCurrentState(sourceCode, memory, registers);</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;} else {</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opCode = &quot;HLT&quot;;</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;}</p>\r\n<p class="indent2new comp">&nbsp;&nbsp;Console.println(&quot;Execution terminated&quot;);</p>\r\n<p class="indent2new comp">}</p>\r\n<p class="levelms">1</p>\r\n<p class="mark">[5]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">This question was the first that required changes to be made to the skeleton program, and answers were of a good quality, with around seventy percent of students securing either full marks or three out of four on part (a).</p>\r\n<p class="indent1new">Where a mark was dropped in an otherwise correct response, it was that awarded for updating the status register, which was missed out rather than being attempted incorrectly.</p></h5>', 'notes': '', 'resources': ''}, 'Q23S1A02': {'question': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">The algorithm, represented using pseudo-code in the figure below, describes a method to rearrange four numbers in a data structure.</p>\r\n<p class="indent4new comp-top">Numbers[0] <span class="font18">&#8592;</span> 45</p>\r\n<p class="indent4new comp">Numbers[1] <span class="font18">&#8592;</span> 19</p>\r\n<p class="indent4new comp">Numbers[2] <span class="font18">&#8592;</span> 62</p>\r\n<p class="indent4new comp">Numbers[3] <span class="font18">&#8592;</span> 12</p>\r\n<p class="indent4new comp">FOR X <span class="font18">&#8592;</span> 1 TO 3</p>\r\n<p class="indent4new comp">&emsp;&emsp;Y <span class="font18">&#8592;</span> X &minus; 1</p>\r\n<p class="indent4new comp">&emsp;&emsp;N <span class="font18">&#8592;</span> Numbers[X]</p>\r\n<p class="indent4new comp">&emsp;&emsp;WHILE Y &gt; &minus;1 AND N &lt; Numbers[Y]</p>\r\n<p class="indent4new comp">&emsp;&emsp;&emsp;&emsp;Numbers[Y + 1] <span class="font18">&#8592;</span> Numbers[Y]</p>\r\n<p class="indent4new comp">&emsp;&emsp;&emsp;&emsp;Y <span class="font18">&#8592;</span> Y &minus; 1</p>\r\n<p class="indent4new comp">&emsp;&emsp;ENDWHILE</p>\r\n<p class="indent4new comp">&emsp;&emsp;Numbers[Y + 1] <span class="font18">&#8592;</span> N</p>\r\n<p class="indent4new comp">ENDFOR</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new">Complete the table below by hand-tracing the algorithm in the figure above.</p>\r\n<p class="indent1new">You may not need to use all the rows in the table below.</p>\r\n<p class="indent1new">The first row of the table below has already been completed for you.</p>\r\n<p class="bottom">&nbsp;</p>\r\n<table class="data-table left3">\r\n\t<tr>\r\n\t\t<td class="col-2 tablegrey" rowspan="2"><p class="padded"><span class="comp-top"><b>X</b></span></p></td>\r\n\t\t<td class="col-2 tablegrey" rowspan="2"><p class="padded"><span class="comp-top"><b>Y</b></span></p></td>\r\n\t\t<td class="col-2 tablegrey" rowspan="2"><p class="padded"><span class="comp-top"><b>N</b></span></p></td>\r\n\t\t<td class="col-2 tablegrey" colspan="4"><p class="padded"><span class="comp-top"><b>Numbers</b></span></p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2 tablegrey"><p class="padded"><span class="comp-top"><b>[0]</b></span></p></td>\r\n\t\t<td class="col-2 tablegrey"><p class="padded"><span class="comp-top"><b>[1]</b></span></p></td>\r\n\t\t<td class="col-2 tablegrey"><p class="padded"><span class="comp-top"><b>[2]</b></span></p></td>\r\n\t\t<td class="col-2 tablegrey"><p class="padded"><span class="comp-top"><b>[3]</b></span></p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2 tablegrey"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2 tablegrey"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2 tablegrey"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2 tablegrey"><p class="padded"><span class="comp-top">45</span></p></td>\r\n\t\t<td class="col-2 tablegrey"><p class="padded"><span class="comp-top">19</span></p></td>\r\n\t\t<td class="col-2 tablegrey"><p class="padded"><span class="comp-top">62</span></p></td>\r\n\t\t<td class="col-2 tablegrey"><p class="padded"><span class="comp-top">12</span></p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t\t<td class="col-2"><p class="padded">&nbsp;</p></td>\r\n\t</tr>\r\n</table>\r\n<p class="mark">(Total 5 marks)</p></h5>', 'markscheme': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question"><b>5 marks for AO2 (apply)</b></p>\r\n<p class="indent1new"><img src="AA_COM/M23S1A02_files_M/img01.jpg"/>&nbsp;</p></h5><h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="indent1new"><b>1 mark</b> for area A correct;</p>\r\n<p class="indent1new m-t-0"><b>1 mark</b> for area B correct;</p>\r\n<p class="indent1new m-t-0"><b>1 mark</b> for area C correct;</p>\r\n<p class="indent1new m-t-0"><b>1 mark</b> for area D correct;</p>\r\n<p class="indent1new m-t-0"><b>1 mark</b> for area E correct;</p>\r\n<p class="indent1new">Award a mark if the values in an area are correct regardless of which row they are on so long as they are in the correct overall sequence in a column.</p>\r\n<p class="indent1new"><b>I.</b> duplicated values instead of blanks</p>\r\n<p class="indent1new"><b>Max 4</b> if any errors</p>\r\n<p class="mark">[5]</p></h5>', 'examinerreport': '<h5 class=\'contentSeparator\' style=\'page-break-inside: avoid;\'><div class=\'qnumber-hidden\'></div><p class="question">Just under forty percent of students attained full marks in this question, which required completion of a trace table in accordance with a pseudo-code algorithm. The most common error here was entering the correct value in the wrong column, which might be due to errors of transposition rather than any misconceptions.</p></h5>', 'notes': '', 'resources': ''}}
User: Now, the user will ask questions after this message. Use everything I gave you and the knowledge you have acquired, and from the notes you made, to answer their question in a very concise way that WILL score ALL marks. Just like the notes. For this, your answer will not have the same structure as the revision notes. Think of it as answering an exam question: short, consice, useful, scores ALL marks. Just like the exam questions provided to you, you will not leave your response in a 'notes' manner. You are just answering an exam question: which means it has to be very short unless explicitly specified by the user that it must be long and detailed. So, keep it short, concise, and only a couple of sentences that score ALL marks. Remember, it is an A-Level exam question and you will style it as such: incredibly concise sentences (essentially like bullet points but without the bullet points) that score marks. Most sentences won't even have commas, this does not mean you can't use them. Also do not repeat the question in your answer, just do it. Score all marks, assume how many marks there are based on the question if it is not provided to you. Imagine that for every sentence you make, you score a mark (for simpler questions), for high (>5 mark) questions that may differ.
In summary, you must:
* Answer very concisely. Kind of like bullet points but as a short para. Most of the time, a sentence, or point, will be a mark.
* Do not repeat the question at the start.
* Don't over-do your answer. Please. 1 mark (e.g., usually, 'What' questions) is like one very short sentence usually. Remember the summary from the notes? Your answer will essentially be like that for most questions but a bit (a bit!) more developed. Remember, this is just A-Levels. Use some of the exam questions that I provided as an example of how you should model your answers.
* When you're listing examples, don't list every example in the universe.
* Score all marks. Be helpful.
User: Write the notes you made. Incldue ALL questions and the content of it and the simplest answer to it that scores ALL marks (from the markscheme). Incldue how many marks it is as well
Assistant: ### Data Structures and Abstract Data Types

#### **Data Structures** (Spec Points: 3.2.1.1)
- **Definition:** A data structure is any method used to store data in an organized and accessible format. It normally contains related data organized for manipulation by different programs.
- **Static and Dynamic Data Structures:**
  - **Static:** Fixed-size data structures allocated by the programmer.
  - **Dynamic:** Memory usage varies as needed; implemented with queues and stacks.
  
#### **Single- and Multi-Dimensional Arrays** (Spec Points: 3.2.1.2)
- **Definition:** An array is a data structure containing elements of the same data type using a single identifier.
- **One-Dimensional Array (List):** Represents a vector. Example: `DaysInMonth[]`
- **Two-Dimensional Array (Matrix):** Represents data in rows and columns. 

#### **Fields, Records, and Files** (Spec Points: 3.2.1.3)
- **File:** Collection of related data.
- **Record:** One line of a text file. 
- **Field:** An item of data within a record.
- **Text Files vs. Binary Files:**
  - **Text File:** Contains human-readable characters; data stored as records divided by fields.
  - **Binary File:** Stores data as sequences of 0s and 1s; contains a header to describe data representation.

#### **Reading and Writing Files**
- **Text Files:** 
  - **Write:** Use file I/O operations to write data from an array into a CSV.
  - **Read:** Load data from a CSV into a program.
- **Binary Files:** 
  - **Write:** Write data using binary representation.
  - **Read:** Read binary data into a byte array.

### Definitions
- **Data Structure:** A format for storing large volumes of related data.
- **Abstract Data Type:** A conceptual model of data organization and operations.
- **Array:** A set of related data items stored under a single identifier.
- **File:** A collection of related data.
- **Text File:** A file with human-readable characters.
- **Binary File:** Data stored as 0s and 1s.
- **Record:** One line of a text file.
- **Field:** An item of data within a record.
- **Static Data Structure:** Fixed-size memory for data.
- **Dynamic Data Structure:** Varying memory usage for data.
- **Queue:** First-in, first-out data structure.
- **Stack:** Last-in, first-out data structure.
- **Heap:** Pool of unused memory for dynamic structures.

### Try These Exam Questions
1. **Q20S1B07** (2 Marks): Possible errors in subroutine `LoadGreyScaleImage`.
   - Answer: `NextPixel` not an integer; file not available; empty file; invalid data size.
   
2. **QS0326A** (9 Marks): Ticket number submission methods and record structure.
   - (4 Marks) Answer: Number printed on ticket, read by a specific device (e.g., barcode reader, magnetic stripe reader).
   - (5 Marks) Record Structure:
     - RandomNo: Integer
     - CurrentDate: String/Date
     - ArrivalTime: String/Time
     - LengthOfStay: Integer
     - Cost: Integer
   
3. **Q20S1B09** (4 Marks): Purpose of a parameter and data processing.
   - (1 Mark) Answer: Default values in `Header`.
   - (3 Marks) Answer: HeaderLine is split by commas; assigned to fields.

4. **Q20S1B05** (2 Marks): Identify data structures by data type.
   - Answer: MoveRecord for multiple data types; Grid for single data type.

5. **QW06110** (9 Marks): Array processing in programming language.
   - (2 Marks) Bad design: GoTo statements; no output if not found.
   - (2 Marks) Declaration: Proper identifier and data type.
   - (5 Marks) Code: Loop to check claims; output “yes” or “no”.

6. **QS19S1B05** (1 Mark): Identifier for storing multiple data types.
   - Answer: MoveRecord or ListOfMoves.

7. **Q22S1C13** (9 Marks): Validation subroutine for duplicate digits.
   - (8 Marks) Code: Check rows, columns, sub-grid for duplicates; return boolean.
   - (1 Mark) Evidence: Screen capture of tests.

8. **Q23S1C12** (5 Marks): Amend subroutine with parameter and test.
   - (4 Marks) Amendments: Parameter addition and accumulator increment.
   - (1 Mark) Evidence: Screen capture of changes.

9. **Q23S1A02** (5 Marks): Pseudo-code trace for number reordering.
   - Answer: Accurate trace of algorithm steps with correct sequence.
User: Answer the questions and provide the ful question content
Assistant: