An algorithm has been written in pseudocode to check that a password meets a set of rules. 01 OUTPUT "Please enter password " 02 INPUT Password 03 Accept ← TRUE 04 IF LENGTH(Password) < 8 OR LENGTH(Password) > 20 05 THEN 06 Accept ← FALSE 07 ENDIF 08 IF LCASE(Password) = Password OR UCASE(Password) = Password 09 THEN 10 Accept ← FALSE 11 ENDIF 12 Index ← 1 13 Found ← FALSE 14 WHILE NOT Found AND Accept AND Index < LENGTH(Password) 15 IF SUBSTRING(Password, Index, 1) = '!' 16 THEN 17 Found ← TRUE 18 ENDIF 19 Index ← Index + 1 20 ENDWHILE 21 IF NOT Found 22 THEN 23 Accept ← FALSE 24 ENDIF 25 IF Accept 26 THEN 27 OUTPUT "Accepted" 28 ELSE 29 OUTPUT "Rejected" 30 ENDIF
- (a)Complete the three trace tables using the data shown for each one. Data: MYWORD Password Accept Index Found OUTPUT Data: M!word Password Accept Index Found OUTPUT Data: My!Hidden Password Accept Index Found OUTPUT[6]
- (b)State the rules that the password must meet.[3]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.
- [6] (a) For each trace table, one mark Password and output, one mark Accept, Index and Found columns
- (a) MYWORD Trace Table: Password: MYWORD Accept: TRUE, FALSE, FALSE, FALSE Index: (blank), (blank), 1, (blank) Found: (blank), (blank), FALSE, (blank) OUTPUT: (Please enter password), (blank), (blank), Rejected
- (a) M!word Trace Table: Password: M!word Accept: TRUE, FALSE, FALSE, FALSE Index: (blank), (blank), 1, (blank) Found: (blank), (blank), FALSE, (blank) OUTPUT: (Please enter password), (blank), (blank), Rejected
- (a) My!Hidden Trace Table: Password: My!Hidden Accept: TRUE, TRUE, TRUE, TRUE, TRUE, TRUE Index: (blank), (blank), 1, 2, 3, 4 Found: (blank), (blank), FALSE, FALSE, TRUE, TRUE OUTPUT: (Please enter password), (blank), (blank), (blank), (blank), Accepted
- [3] (b) One mark for each correct point
- (b) maximum length 20 characters and minimum length 8 characters
- (b) cannot be all upper-case letters or all lower-case letters // must contain upper-case and lower-case letters
- (b) must contain an !
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →