2.1.2 Thinking Ahead Flashcards

(7 cards)

1
Q

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.

A

Inputs:
1. Username.
2. Password.
Outputs:
1. Message to request input.
2. Message to state login successful.
[1 mark]
• Message to say login unsuccessful

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define what is meant by an algorithm’s preconditions and provide one example

A
  1. Conditions that must be met before an algorithm can execute successfully.
  2. E.g, with searching algorithm, the input list must not be empty otherwise, an “index out of bounds” error may occur.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give one reason why defining the inputs and outputs of an algorithm is important during its design phase

A

• 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]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define ‘caching’

A

Storing frequently used data or instructions for quick access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Suggest two reusable program components a developer could include in software library

A

• 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]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Give two benefits of developers including reusable components in software library

A

• Saves time and effort by avoiding redundant code [| mark]
• Promotes consistency and reliability [l mark]
• Enhances maintainability and debugging I| mark]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Give 2 benefits of caching in computational efficiency

A
  1. Reduce access time.
  2. Increase execution speed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly