2.1.2 Thinking Ahead Flashcards
(7 cards)
A program is being designed that will allow a user to log into an account on a website using a username and password.
Identify two possible inputs and one output this program will need.
Inputs:
1. Username.
2. Password.
Outputs:
1. Message to request input.
2. Message to state login successful.
[1 mark]
• Message to say login unsuccessful
Define what is meant by an algorithm’s preconditions and provide one example
- Conditions that must be met before an algorithm can execute successfully.
- E.g, with searching algorithm, the input list must not be empty otherwise, an “index out of bounds” error may occur.
Give one reason why defining the inputs and outputs of an algorithm is important during its design phase
• Ensures clarity about what the algorithm needs and what it will produce [1 mark]
• Prevents errors or unexpected results during execution [1 mark]
• Facilitates testing and debugging by setting clear expectations [l mark]
Define ‘caching’
Storing frequently used data or instructions for quick access.
Suggest two reusable program components a developer could include in software library
• Sorting algorithms (e.g., quicksort, mergesort) [| mark]
• Data structure implementations (e.g., stacks, queues) [1 mark]
• Common mathematical functions (e.g., random number generation, factorials) [ mark]
Give two benefits of developers including reusable components in software library
• Saves time and effort by avoiding redundant code [| mark]
• Promotes consistency and reliability [l mark]
• Enhances maintainability and debugging I| mark]
Give 2 benefits of caching in computational efficiency
- Reduce access time.
- Increase execution speed.