A Level Computer Science 9618 · Topic practice

Data Types and Structures past paper questions

Use focused Data Types and Structures questions to practise the ideas in context, then return to a mixed set to check whether you can recognise the relevant approach without a topic prompt.

Appears inPaper 2 114

Paper
Sort questions

You’re practising 2021–2022 papers. The 2023–2026 papers, including 2026, need a plan.

Unlock from $6/mo
24 free questions

2022 JunePaper 2Question 1Component 21Variant 111 marks
Data Types and StructuresData Types and RecordsAlgorithmsProgramming Basics
Loading original question

1 (a) A programmer draws a program flowchart to show the sequence of steps required to solve a problem. Give the technical term for a sequence of steps that describe how to solve a problem. [1] (b) The table lists some of the variables used in a program. (i) Complete the table by writing the most appropriate data type for each variable. Variable | Use of variable | Data type Temp | Stores the average temperature | '' PetName | Stores the name of my pet | '' MyDOB | To calculate the number of days until my next birthday | '' LightOn | Stores state of light; light is only on or off | '' [4] (ii) One of the names used for a variable in the table in part 1(b)(i) is not an example of good practice. Identify the variable and give a reason why it is not good practice to use that name. Variable ... Reason ... [2] (c) Complete the table by evaluating each expression. Expression | Evaluation INT((31 / 3) + 1) | '' MID(TO_UPPER("Version"), 4, 2) | '' TRUE AND (NOT FALSE) | '' NUM_TO_STR(27 MOD 3) | '' [4]

2022 NovemberPaper 2Question 1Component 21Variant 112 marks
ProgrammingProgramming BasicsArrays
Loading original question

1 (a) An algorithm includes a number of complex calculations. A programmer is writing a program to implement the algorithm and decides to use library routines to provide part of the solution. State three possible benefits of using library routines in the development of the program. 1 … 2 … 3 … [3] (b) The following pseudocode is part of a program that stores names and test marks for use in other parts of the program. DECLARE Name1, Name2, Name3 : STRING DECLARE Mark1, Mark2, Mark3 : INTEGER INPUT Name1 INPUT Mark1 INPUT Name2 INPUT Mark2 INPUT Name3 INPUT Mark3 (i) The pseudocode needs to be changed to allow for data to be stored for up to 30 students. Explain why it would be good practice to use arrays to store the data. [3] (ii) The following pseudocode statement includes array references: OUTPUT "Student ", Name[Count], " scored ", Mark[Count] State the purpose of the variable Count and give its data type. Purpose … Data type … [2] (c) The pseudocode statements in the following table may contain errors. State the error in each case or write 'NO ERROR' if the statement contains no error. Assume that any variables used are of the correct type for the given function. Statement | Error IF EMPTY ← "" THEN | '' Status ← IS_NUM(-23.4) | '' X ← STR_TO_NUM("37") + 5 | '' Y ← STR_TO_NUM("37" + "5") | '' [4]

2022 NovemberPaper 2Question 1Component 23Variant 312 marks
Software DevelopmentProgram Development Life cycleData Types and RecordsProgram Testing and Maintenance
Loading original question

1 A program is required for a shopping website. (a) Part of the program requires four variables. The following table describes the use of each variable. Complete the table by adding the most appropriate data type for each variable. Variable use | Data type. Store the number of days in the current month | ''. Store the first letter of the customer's first name | ''. Store an indication of whether a year is a leap year | ''. Store the average amount spent per customer visit | ''. [4] (b) The designer considers the use of a development life cycle to split the development of the website into several stages. (i) State one benefit of a development life cycle when developing the website. [1] (ii) Analysis is one stage of a development life cycle. State one document that may be produced from the analysis stage of the website project. [1] (c) The program will be developed using the Rapid Application Development (RAD) life cycle. (i) State one principle of this life cycle. [1] (ii) Give two benefits and one drawback of its use compared to the waterfall life cycle. Benefit 1 Benefit 2 Drawback [3] (d) Adaptive maintenance needs to be carried out on the website program. Give two reasons why adaptive maintenance may be required. 1 2 [2]

2022 NovemberPaper 2Question 2Component 22Variant 211 marks
Data Types and StructuresFilesAlgorithmsProgram Design
Loading original question

2 (a) An algorithm will process data from a test taken by a group of students. The algorithm will prompt and input the name and test mark for each of the 35 students. The algorithm will add the names of all the students with a test mark of less than 20 to an existing text file Support_List.txt, which already contains data from other group tests. (i) Describe the steps that the algorithm should perform. Do not include pseudocode statements in your answer. [5] (ii) Explain why it may be better to store the names of the students in a file rather than in an array. [1] (iii) Explain why WRITE mode cannot be used in the answer to part 2(a)(i). [1] (b) Examine the following state-transition diagram. [State-transition diagram: START arrow to S1. S1 to S2 on Input-A | Output-X. S2 loops to itself on Input-A. S2 to S3 on Input-B | Output-W. S3 loops to itself on Input-B. S3 to S4 on Input-A | Output-W. S4 to S1 on Input-A. S1 to S4 on Input-B.] Complete the table to show the inputs, outputs and next states. Input | Output | Next state (shaded) | (shaded) | S1 Input-A | '' | '' '' | '' | S2 '' | Output-W | '' '' | Output-W | '' [4]

2022 NovemberPaper 2Question 3Component 21Variant 15 marks
Algorithm Design and Problem-solvingAlgorithmsArrays
Loading original question

3 A 1D array Data of type integer contains 200 elements. Each element has a unique value. An algorithm is required to search for the largest value and output it. Describe the steps that the algorithm should perform. Do not include pseudocode statements in your answer. [5]

2022 NovemberPaper 2Question 3Component 22Variant 213 marks
Data Types and StructuresIntroduction to Abstract Data Types (ADT)
Loading original question

3 A stack is used in a program to store string data which needs to be accessed in several modules. (a) A stack is an example of an Abstract Data Type (ADT). Identify one other example of an ADT and describe its main features. Example … Features … [3] (b) Explain how the stack can be implemented using an array. [5] (c) A second stack is used in the program. The diagram below shows the initial state of this stack. Value X is at the top of the stack and was the last item added. Upper-case letters are used to represent different data values. Stack operations are performed in three groups as follows: Group 1: PUSH D, PUSH E Group 2: POP, POP, POP Group 3: PUSH A, PUSH B, POP, PUSH C Complete the diagram to show the state of the stack after each group of operations has been performed. Include the current stack pointer (SP) after each group. Memory location | Initial state | After Group 1 | After Group 2 | After Group 3 957 | '' | '' | '' | '' 956 | '' | '' | '' | '' 955 | '' | '' | '' | '' 954 | '' | '' | '' | '' 953 | X (SP points here) | '' | '' | '' 952 | Y | '' | '' | '' 951 | Z | '' | '' | '' 950 | P | '' | '' | '' [5]

2022 JunePaper 2Question 4Component 21Variant 16 marks
Data Types and StructuresIntroduction to Abstract Data Types (ADT)
Loading original question

4 A stack is created using a high-level language. Memory locations 200 to 207 are to be used to store the stack. The following diagram represents the current state of the stack. TopOfStack points to the last value added to the stack. Memory location | Value 200 | '' 201 | '' 202 | '' 203 | 'F' <- TopOfStack 204 | 'C' 205 | 'D' 206 | 'E' 207 | 'H' (a) Complete the following table by writing the answers. The value that has been on the stack for the longest time. | '' The memory location pointed to by TopOfStack if three POP operations are performed. | '' [2] (b) The following diagram shows the current state of the stack: 200 | '' 201 | '' 202 | 'W' <- TopOfStack 203 | 'Y' 204 | 'X' 205 | 'Z' 206 | 'N' 207 | 'P' The following operations are performed: POP, POP, PUSH 'A', PUSH 'B', POP, PUSH 'C', PUSH 'D' Complete the diagram to show the state of the stack after the operations have been performed. (Blank table with Memory location 200 to 207, a Value column and a Pointer column.) [4]

2022 JunePaper 2Question 4Component 22Variant 29 marks
ProgrammingProgramming BasicsFilesStructured Programming
Loading original question

4 (a) A procedure LastLines() will: - take the name of a text file as a parameter - output the last three lines from that file, in the same order as they appear in the file. Note: Use local variables LineX, LineY and LineZ to store the three lines from the file. You may assume the file exists and contains at least three lines. Write pseudocode for the procedure LastLines(). [6] (b) The algorithm in part (a) is to be amended. The calling program will pass the number of lines to be output as well as the name of the text file. The number of lines could be any value from 1 to 30. It can be assumed that the file contains at least the number of lines passed. Outline three changes that would be needed. 1 ... 2 ... 3 ... [3]

2022 NovemberPaper 2Question 4Component 21Variant 112 marks
Data Types and StructuresIntroduction to Abstract Data Types (ADT)
Loading original question

4 (a) The following diagram shows an Abstract Data Type (ADT) representation of an ordered linked list. The data item stored in each node is a single character. The data will be accessed in alphabetical order. The symbol Ø represents a null pointer. [Diagram: Start pointer box with an arrow to node 'C'; node 'C' has a pointer box with an arrow to node 'J'; node 'J' has a pointer box with an arrow to node 'L'; node 'L' has a pointer box containing Ø.] (i) Nodes with data 'A' and 'K' are added to the linked list. Nodes with data 'J' and 'L' are deleted. After the changes, the data items still need to be accessed in alphabetical order. Complete the diagram to show the new state of the linked list. [Empty box containing a Start pointer box and nodes 'C', 'J', 'L' each with an empty pointer box, for the candidate to complete.] [4] (ii) The original data could have been stored in a 1D array in which each element stores a character. For example: [array of five cells: 'C' | 'J' | 'L' | '' | ''] Explain the advantages of making the changes described in part (a)(i) when the data is stored in the linked list instead of an array. [2] (iii) Explain the disadvantages of making the changes described in part (a)(i) when the data is stored in the linked list instead of an array. [2] (b) A program will store data using a linked list like the one shown in part (a). Explain how the linked list can be implemented. [4]

2022 NovemberPaper 2Question 4Component 23Variant 310 marks
Data Types and StructuresIntroduction to Abstract Data Types (ADT)Arrays
Loading original question

4 (a) A program contains a 1D array DataItem with 100 elements. State the one additional piece of information required before the array can be declared. [1] (b) A programmer decides to implement a queue Abstract Data Type (ADT) in order to store characters received from the keyboard. The queue will need to store at least 10 characters and will be implemented using an array. (i) Describe two operations that are typically required when implementing a queue. State the check that must be carried out before each operation can be completed. Operation 1 ... Check 1 ... Operation 2 ... Check 2 ... [4] (ii) Describe the declaration and initialisation of the variables and data structures used to implement the queue. [5]

2022 JunePaper 2Question 5Component 21Variant 16 marks
Data Types and StructuresFilesProgramming Basics
Loading original question

5 Each line of a text file contains data organised into fixed-length fields as shown: <Field 1><Field 2><Field 3> An algorithm is required to search for the first instance of a given value of Field 2 and, if found, to output the corresponding values for Field 1 and Field 3. Describe the algorithm needed. Do not include pseudocode statements in your answer. [6]

2022 JunePaper 2Question 5Component 23Variant 312 marks
Data Types and StructuresArraysData Types and RecordsConstructs
Loading original question

5 A program will store attendance data about each employee of a company. The data will be held in a record structure of type Employee. The fields that will be needed are as shown: Field | Typical value | Comment EmployeeNumber | 123 | A numeric value starting from 1 Name | "Smith,Eric" | Format: <last name>','<first name> Department | "1B" | May contain letters and numbers Born | 13/02/2006 | Must not be before 04/02/1957 Attendance | 97.40 | Represents a percentage (a) (i) Write pseudocode to declare the record structure for type Employee. [4] (ii) A 1D array Staff containing 500 elements will be used to store the employee records. Write pseudocode to declare the Staff array. [2] (b) There may be more records in the array than there are employees in the company. In this case, some records of the array will be unused. (i) State why it is good practice to have a standard way to indicate unused array elements. [1] (ii) Give one way of indicating an unused record in the Staff array. [1] (c) A procedure Absentees() will output the EmployeeNumber and the Name of all employees who have an Attendance value of 90.00 or less. Write pseudocode for the procedure Absentees(). Assume that the Staff array is global. [4]

2022 NovemberPaper 2Question 5Component 21Variant 15 marks
ProgrammingConstructsArrays
Loading original question

5 A program uses two 1D arrays of type integer. Array1 contains 600 elements and Array2 contains 200 elements. Array1 contains sample values read from a sensor. The sensor always takes three consecutive samples and all of these values are stored in Array1. A procedure Summarise() will calculate the average of three consecutive values from Array1 and write the result to Array2. This will be repeated for all values in Array1. The diagram below illustrates the process for the first six entries in Array1. Array1 | Array2 | Comment 10 | 15 | average of first three values 20 | 41 | average of next three values 15 | '' | 40 | '' | 41 | '' | 42 | '' | [Diagram: the first three entries of Array1 (10, 20, 15) are grouped by a brace with an arrow to the first entry of Array2 (15); the next three entries (40, 41, 42) are grouped by a brace with an arrow to the second entry of Array2 (41).] Write pseudocode for the procedure Summarise(). [5]

2022 NovemberPaper 2Question 7Component 22Variant 218 marks
Data Types and StructuresArraysData Types and Records
Loading original question

7 A teacher is designing a program to perform simple syntax checks on programs written by students. Two global 1D arrays are used to store the syntax error data. Both arrays contain 500 elements. • Array ErrCode contains integer values that represent an error number in the range 1 to 800. • Array ErrText contains string values that represent an error description. The following diagram shows an example of the arrays. Index | ErrCode | ErrText 1 | 10 | "Invalid identifier name" 2 | 20 | "Bracket mismatch" 3 | 50 | "Undeclared variable" 4 | 60 | "Type mismatch in assignment" ... | ... | ... 500 | 999 | <Undefined> Note: • There may be less than 500 error numbers so corresponding elements in both arrays may be unused. Unused elements in ErrCode have the value 999. The value of unused elements in ErrText is undefined. • Values in the ErrCode array are stored in ascending order but not all values may be present, for example, there may be no error code 31. The teacher has defined two program modules as follows: Module | Description OutputError() | • takes two parameters as integers: o a line number in the student's program o an error number • searches for the error number in the ErrCode array: o if found, outputs the corresponding error description and the line number, for example: "Bracket mismatch on line 34" o if not found, outputs the line number and a warning, for example: "Unknown error on line 34" SortArrays() | sorts the arrays into ascending order of ErrCode (a) Write efficient pseudocode for module OutputError(). [6] (b) Write an efficient bubble sort algorithm in pseudocode for module SortArrays(). [8] (c) Two 1D arrays were described at the beginning of the question. Both arrays contain 500 elements. • Array ErrCode contains integer values that represent an error number in the range 1 to 800. • Array ErrText contains string values that represent an error description. The two arrays will be replaced by a single array. A user-defined data type (record structure) has been declared as follows: TYPE ErrorRec DECLARE ErrCode : STRING DECLARE ErrText : STRING ENDTYPE (i) State the error in the record declaration. [1] (ii) State two benefits of using the single array of the user-defined data type. 1 … 2 … [2] (iii) Write the declaration for the single array in pseudocode. [1]

2022 NovemberPaper 2Question 7Component 23Variant 317 marks
Data Types and StructuresArraysProgramming BasicsConstructsStructured Programming
Loading original question

7 A teacher is designing a program to perform simple syntax checks on programs written by students. Two global 1D arrays are used to store the syntax error data. Both arrays contain 500 elements. Array ErrCode contains integer values that represent an error number in the range 1 to 800. Array ErrText contains string values that represent an error description. The following diagram shows an example of the arrays. [diagram: Index | ErrCode | ErrText. 1 | 10 | "Invalid identifier name". 2 | 20 | "Bracket mismatch". 3 | 50 | "". 4 | 60 | "Type mismatch in assignment". ... 500 | 999 | <Undefined>] Note: There are less than 500 error codes so corresponding elements in both arrays may be unused. Unused elements in ErrCode have the value 999. These will occur at the end of the array. The value of unused elements in ErrText is undefined. Values in the ErrCode array are stored in ascending order but not all values may be present. For example, there may be no error code 31. Some error numbers are undefined. In these instances, the ErrCode array will contain a valid error number but the corresponding ErrText element will contain an empty string. The teacher has defined one program module as follows: Module OutputRange(): Prompts for input of two error numbers; outputs a list of error numbers between the two numbers input (inclusive) together with the corresponding error description; outputs a warning message when the error description is missing as for error number 50 in the example; outputs a suitable header and a final count of error numbers found. Output based on the example array data above: List of error numbers from 1 to 60 / 10 : Invalid identifier name / 20 : Bracket mismatch / 50 : Error Text Missing / 60 : Type mismatch in assignment / 4 error numbers output (a) Write pseudocode for module OutputRange(). Assume that the two numbers input represent a valid error number range. [8] (b) (i) Two additional modules are defined: SortArrays(): sorts the arrays into ascending order of ErrCode. AddError(): takes two parameters, an error number as an integer and an error description as a string; writes the error number and error description to the first unused element of the two arrays; ensures the ErrCode array is still in ascending order; returns the number of unused elements after the new error number has been added; returns -1 if the new error number could not be added. Write pseudocode for the module AddError(). Assume that the error code is not already in the ErrCode array. [6] (ii) A new Module RemoveError() will remove a given error number from the array. Describe the algorithm that would be required. Do not include pseudocode statements in your answer. [3]

2022 JunePaper 2Question 8Component 21Variant 121 marks
ProgrammingConstructsArraysProgramming BasicsStructured Programming
Loading original question

8 A program allows a user to save passwords used to login to websites. A stored password is inserted automatically when the user logs into the corresponding website. A student is developing a program to generate a password. The password will be of a fixed format, consisting of three groups of four alphanumeric characters. The groups are separated by the hyphen character '-'. An example of a password is: "FxAf-3haV-Tq49" A global 2D array Secret of type STRING stores the passwords together with the website domain name where they are used. Secret contains 1000 elements organised as 500 rows by 2 columns. Unused elements contain the empty string (""). These may occur anywhere in the array. An example of a part of the array is: Array element | Value Secret[27, 1] | "www.thiswebsite.com" Secret[27, 2] | "***************" (encrypted form) Secret[28, 1] | "www.thatwebsite.com" Secret[28, 2] | "***************" (encrypted form) Note: For security, passwords are stored in an encrypted form. The passwords cannot be used without being decrypted. Assume that the encrypted form of a password will not be an empty string. The programmer has started to define program modules as follows: Module | Description RandomChar() | Generates a single random character from within one of the following ranges: 'a' to 'z'; 'A' to 'Z'; '0' to '9'. Returns the character Encrypt() | Takes a password as a parameter of type string. Returns the encrypted form of the password as a string Decrypt() | Takes an encrypted password as a parameter of type string. Returns the decrypted form of the password as a string For reference, relevant ASCII values are as follows: Character range | ASCII range 'a' to 'z' | 97 to 122 'A' to 'Z' | 65 to 90 '0' to '9' | 48 to 57 (a) Write pseudocode for module RandomChar(). You may wish to refer to the insert for a description of the CHR() function. Other functions may also be required. [6] (b) A new module is defined as follows: Module | Description FindPassword() | Takes a website domain name as a parameter of type string. Searches for the website domain name in the array Secret. If the website domain name is found, the decrypted password is returned. If the website domain name is not found, a warning message is output, and an empty string is returned Write pseudocode for module FindPassword(). Assume that modules Encrypt() and Decrypt() have already been written. [7] (c) The modules Encrypt() and Decrypt() are called from several places in the main program. Identify a method that could have been used to test the main program before these modules were completed. Describe how this would work. Method ... Description ... [3] (d) A validation function is written to check that the passwords generated are valid. To be valid, each password must: be 14 characters long; be organised as three groups of four case-sensitive alphanumeric characters, the groups separated by hyphen characters; not include any duplicated characters, except for the hyphen characters. Note: lower-case and upper-case characters are not the same. For example, 'a' is not the same as 'A'. Give two password strings that could be used to test different areas of the validation rules. Password 1 ... Password 2 ... [2] (e) The RandomChar() module is to be modified so that alphabetic characters are generated twice as often as numeric characters. Describe how this might be achieved. [3]

2022 JunePaper 2Question 8Component 22Variant 219 marks
ProgrammingConstructsAlgorithmsArraysStructured Programming
Loading original question

8 A program allows a user to save passwords used to log in to websites. A stored password is then inserted automatically when the user logs in to the corresponding website. A global 2D array Secret of type STRING stores the passwords together with the website domain name where they are used. Secret contains 1000 elements organised as 500 rows by 2 columns. Unused elements contain the empty string (""). These may occur anywhere in the array. An example of a part of the array is: Array element | Value Secret[27, 1] | "thiswebsite.com" Secret[27, 2] | "************" (encrypted form) Secret[28, 1] | "thatwebsite.com" Secret[28, 2] | "************" (encrypted form) Note: For security, the passwords are stored in an encrypted form. The passwords cannot be used without being decrypted. You may assume that the encrypted form of a password will NOT be an empty string. The programmer has started to define program modules as follows: Module | Description Exists() | Takes two parameters: a string, a character. Performs a case-sensitive search for the character in the string. Returns TRUE if the character occurs in the string, otherwise returns FALSE Encrypt() | Takes a password as a parameter of type string. Returns the encrypted form of the password as a string Decrypt() | Takes an encrypted password as a parameter of type string. Returns the decrypted form of the password as a string Note: in a case-sensitive comparison, 'a' is not the same as 'A'. (a) Write pseudocode for the module Exists(). [5] (b) A new module SearchDuplicates() will: search for the first password that occurs more than once in the array and output a message each time a duplicate is found. For example, if the same password was used for the three websites ThisWebsite.com, website27.net and websiteZ99.org, then the following messages will be output: "Password for ThisWebsite.com also used for website27.net" "Password for ThisWebsite.com also used for websiteZ99.org". It will end once all messages have been output. The module will output a message if no duplicates are found. For example: "No duplicate passwords found" Write efficient pseudocode for the module SearchDuplicates(). Encrypt() and Decrypt() functions have been written. Note: It is necessary to decrypt each password before checking its value. [8] (c) A password has a fixed format, consisting of three groups of four alphanumeric characters, separated by the hyphen character '-'. An example of a password is: "FxAf-3haV-Tq49". Each password must: be 14 characters long; be organised as three groups of four alphanumeric characters, the groups separated by hyphen characters; not include any duplicated characters, except for the hyphen characters. An algorithm is needed for a new function GeneratePassword(), which will generate and return a password in this format. Assume that the following modules have already been written: Module | Description Exists() | Takes two parameters: a string, a character. Performs a case-sensitive search for the character in the string. Returns TRUE if the character occurs in the string, otherwise returns FALSE RandomChar() | Generates a single random character from within one of the following ranges: 'a' to 'z'; 'A' to 'Z'; '0' to '9'. Returns the character Note: in a case-sensitive comparison, 'a' is not the same as 'A'. Describe the algorithm for GeneratePassword(). Do not use pseudocode statements in your answer. [6]

2022 NovemberPaper 2Question 8Component 21Variant 119 marks
ProgrammingStructured ProgrammingFilesProgramming BasicsConstructs
Loading original question

8 A teacher is designing a program to perform simple syntax checks on programs written by students. Student programs are submitted as text files, which are known as project files. A project file may contain blank lines. The teacher has defined the first program module as follows: Module | Description CheckFile() | • takes the name of an existing project file as a parameter of type string • returns TRUE if the file is valid (it contains at least 10 non-blank lines), otherwise returns FALSE (a) Write pseudocode for module CheckFile(). [7] Further modules are defined as follows: Module | Description CheckLine() | • takes a line from a project file as a parameter of type string • returns zero if the line is blank or contains no syntax error, otherwise returns an error number as an integer CountErrors() | • takes two parameters: o the name of a project file as a string o the maximum number of errors as an integer • uses CheckFile() to test the project file. Outputs an error message and ends if the project file is not valid • calls CheckLine() for each line in the project file • counts the number of errors • outputs the number of errors or a warning message if the maximum number of errors is exceeded (b) CountErrors() is called to check the project file Jim01Prog.txt and to stop if more than 20 errors are found. Write the pseudocode statement for this call. [2] (c) Write pseudocode for module CountErrors(). Assume CheckFile() and CheckLine() have been written and can be used in your solution. [8] (d) Module CheckLine() includes a check for syntax errors. Two examples of syntax error that cannot be detected from examining a single line are those involving selection and iteration. Give two other examples. 1 … 2 … [2]

2022 JunePaper 2Question 9Component 23Variant 316 marks
ProgrammingConstructsArraysFilesProgramming Basics
Loading original question

9 A program allows a user to save passwords used to log in to websites. A stored password is then inserted automatically when the user logs in to the corresponding website. A student is developing a program to generate a strong password. The password will be of a fixed format, consisting of three groups of four alphanumeric characters, separated by the hyphen character '-'. An example of a password is: "FxAf-3hzV-Aq49" A valid password: must be 14 characters long; must be organised as three groups of four alphanumeric characters. The groups are separated by hyphen characters; may include duplicated characters, provided these appear in different groups. The programmer has started to define program modules as follows: Module | Description RandomChar() | Generates a single random character from within one of the following ranges: 'a' to 'z'; 'A' to 'Z'; '0' to '9'. Returns the character Exists() | Takes two parameters: a string, a character. Performs a case-sensitive search for the character in the string. Returns TRUE if the character occurs in the string, otherwise returns FALSE Generate() | Generates a valid password. Uses RandomChar() and Exists(). Returns the password Note: in a case-sensitive comparison, 'a' is not the same as 'A'. (a) Write pseudocode for the module Generate(). [7] (b) A global 2D array Secret of type STRING stores the passwords together with the website domain name where they are used. Secret contains 1000 elements organised as 500 rows by 2 columns. Unused elements contain the empty string (""). These may occur anywhere in the array. An example of part of the array is: Array element | Value Secret[27, 1] | "www.thiswebsite.com" Secret[27, 2] | "●●●●●●●●●●●●" Secret[28, 1] | "www.thatwebsite.com" Secret[28, 2] | "●●●●●●●●●●●●" Note: For security, the passwords are stored in an encrypted form, shown as "●●●●●●●●●●●●" in the example. The passwords cannot be used without being decrypted. You may assume that the encrypted form of a password will not be an empty string. Additional modules are defined as follows: Module | Description Encrypt() | Takes a password as a string. Returns the encrypted form of the password as a string Decrypt() | Takes an encrypted password as a string. Returns the decrypted form of the password as a string FindPassword() | Takes a website domain name as a string. Searches for the website domain name in the array Secret. If the website domain name is found, the decrypted password is returned. If the website domain name is not found, an empty string is returned AddPassword() | Takes two parameters as strings: a website domain name and a password. Searches for the website domain name in the array Secret and if not found, adds the website domain name and the encrypted password to the array. Returns TRUE if the website domain name and encrypted password are added to the array, otherwise returns FALSE The first three modules have been written. Write pseudocode for the module AddPassword(). [6] (c) The content of the array Secret is to be stored in a text file for backup. It must be possible to read the data back from the file and extract the website domain name and the encrypted password. Both the website domain name and encrypted password are stored in the array as strings of characters. The encrypted password may contain any character from the character set used and the length of both the encrypted password and the website domain name is variable. Explain how a single line of the text file can be used to store the website domain name and the encrypted password. [3]

2021 JunePaper 2Question 1Component 21Variant 112 marks
ProgrammingProgramming BasicsAlgorithmsData Types and Records
Loading original question

1 (a) A program is being developed to help manage the membership of a football club. Complete the following identifier table. Example value | Explanation | Variable name | Data type "Wong" | The preferred name of the member joining the football club | '' | '' FALSE | A value to indicate whether an existing member of the club lives at the same address | '' | '' 19/02/1983 | When the member joined the football club | '' | '' 1345 | The number of points a member has earned. Members of the club earn points for different activities. | '' | '' [4] (b) Each pseudocode statement in the following table may contain an error due to the incorrect use of the function or operator. Describe the error in each case, or write 'NO ERROR' if the statement contains no error. You can assume that none of the variables referenced are of an incorrect type. Statement | Error Result ← 2 & 4 | '' SubString ← MID("pseudocode", 4, 1) | '' IF x = 3 OR 4 THEN | '' Result ← Status AND INT(x/2) | '' Message ← "Done" + LENGTH(MyString) | '' [5] (c) The following data items need to be stored for each student in a group: • student name (a string) • test score (an integer). State a suitable data structure and justify your answer. Structure … Justification … [3]

Data Types and Structures: quick facts

How often does Data Types and Structures come up in A Level Computer Science 9618?

Data Types and Structures is tagged on 114 of the 750 A Level Computer Science 9618 past-paper questions on PastPaperPrep (15%), from papers sat 2021-2026. Paper 2 has the most Data Types and Structures questions, with 114. These are archive counts, not a prediction, and a question can carry more than one topic.

Are the A Level Computer Science 9618 Data Types and Structures questions free?

38 of the 114 A Level Computer Science 9618 Data Types and Structures questions are free to practise. The other 76 need a plan for A Level Computer Science 9618, from $6 a month.

Do the A Level Computer Science 9618 Data Types and Structures questions have answers?

Yes. Each A Level Computer Science 9618 Data Types and Structures question shows the official mark scheme answer.