Skip to main content

[SSC II] Computer Science SLO 7.2.2

Computer Science SSC II Notes - AKUEB


7.2.2 Describe the following four essential parts of an algorithm;

  • Inputs:                                                                                                       Inputs are the data or information that is provided to an algorithm at the beginning of its execution. They are the values or variables on which the algorithm operates. Inputs can come in different forms, such as user input, data from files or databases, or generated within the program itself. The algorithm uses these inputs to perform computations and make decisions to produce the desired output.                            
Example: Let's consider an algorithm for calculating the average of a list of numbers. In this case, the inputs would be the list of numbers itself. For example, if the list is [5, 8, 12, 4, 6], the input to the algorithm would be this list of numbers.

 

  • Processing:                                                                                                     The processing component of an algorithm represents the series of operations or computations that are performed on the inputs. It defines the specific steps and actions that the algorithm carries out to transform the input data into the desired output. Processing may involve mathematical calculations, logical operations, data manipulation, iterative loops, conditionals, and other operations that manipulate or transform the input data.

Example: In our average calculation algorithm, the processing step would include summing up all the numbers in the list and dividing the sum by the total count of numbers. So, the processing step would involve adding 5 + 8 + 12 + 4 + 6 and then dividing the sum by 5 to calculate the average.

 

  • Decision:                                                                                                      Decision-making is a crucial aspect of many algorithms. It involves evaluating certain conditions or criteria to determine the path or action to take based on the current state of the algorithm's execution. Decision points typically involve logical comparisons, such as if-else statements or switch statements, where the algorithm selects different paths or actions based on the outcome of the evaluation. Decisions enable the algorithm to adapt its behavior and make different choices based on different conditions.                                                                                             
Example: While the average calculation algorithm doesn't involve decision-making, let's consider an example where decision-making is involved. Suppose we have an algorithm that determines whether a number is positive or negative. In this case, the decision component would evaluate whether the number is greater than zero or not. If the number is greater than zero, the algorithm would output "positive"; otherwise, it would output "negative".

 

  • Outputs:                                                                                                     Outputs represent the results or outcomes produced by the algorithm after processing the inputs and making decisions. These are the values, information, or final states that the algorithm generates or produces as a result of its execution. Outputs can take various forms depending on the nature of the problem and the algorithm itself, such as displaying information on the screen, storing data in memory or files, returning a value or data structure, or performing an action based on the desired outcome.                                                                                                         
Example: The output component represents the result or outcome of the algorithm. In our average calculation algorithm, the output would be the calculated average. For the list of numbers [5, 8, 12, 4, 6], the output would be the average value, which is 7.

The combination of inputs, processing, decision-making, and outputs forms the core components of an algorithm, allowing it to take in data, perform operations, make choices, and generate meaningful results or outcomes.

To summarize, in the average calculation algorithm example:

a. Inputs: [5, 8, 12, 4, 6]

b. Processing: Summing the numbers and dividing by the count (5)

c. Decision: Not applicable in this example

d. Output: Average value of 7


Cognitive Level: Understanding

 

Comments

© 2020 NEXUS NOTES

Designed by Open Themes & Nahuatl.mx.