Preconditions for Devising Problem Solutions (OCR A-Level Computer Science): Flashcards
📚Flashcards
Practise the cards
14 cards from this deck
ShowHide
Practise the cards
14 cards from this deck
What are preconditions?
What are preconditions?
Conditions that must be met before a program or function executes correctly
Type of precondition: specific data types/formats/ranges
Type of precondition: specific data types/formats/ranges
Input Requirements
Type of precondition: hardware/software conditions
Type of precondition: hardware/software conditions
System Requirements
Type of precondition: environment/state conditions
Type of precondition: environment/state conditions
Contextual Assumptions
Why do preconditions ensure valid input?
Why do preconditions ensure valid input?
They avoid errors by checking inputs meet required conditions
How do preconditions define problem scope?
How do preconditions define problem scope?
Clarify what the program should and shouldn't handle
How do preconditions improve efficiency?
How do preconditions improve efficiency?
Allow design of solutions optimised for specific conditions
First step in determining preconditions
First step in determining preconditions
Analyse the problem description
Example: Password validation minimum length
Example: Password validation minimum length
At least 8 characters
Example: Password validation content requirements
Example: Password validation content requirements
One uppercase, one lowercase, one number
Example: Sorting algorithm input precondition
Example: Sorting algorithm input precondition
Must be a list of comparable elements
How preconditions affect algorithm choice
How preconditions affect algorithm choice
Influence which algorithms/data structures are appropriate
How preconditions affect efficiency
How preconditions affect efficiency
Known preconditions allow optimisations (e.g., sorted input)
Common mistake: assuming valid input without validation
Common mistake: assuming valid input without validation
Can cause runtime errors
