Page 65 - 2502_Pakistan-kifayat_C-8
P. 65
Example 8: Calculate the Factorial of a Number
Formula:
n!=1×2×3×…×n
Step 1: Start
Step 2: Input the number n.
Step 3: Initialise fact = 1.
Step 4: Set counter i = 1.
Step 5: Repeat Steps 6–7 while i ≤ n.
Step 6: Set fact = fact × i.
Step 7: Increment i by 1.
Step 8: Print fact.
Step 9: Stop
SCOPE AND LIMITATIONS OF ALGORITHMS
Algorithms are systematic procedures designed to solve problems or perform tasks by following clear,
step-by-step instructions. Their scope covers the following points:
Automation: Algorithms enable computers and machines to perform tasks automatically without
human intervention. For example, algorithms help search engines find relevant websites or allow
navigation apps to calculate routes.
Data processing: Tasks like sorting lists, searching for data, filtering information, and data analysis
rely heavily on algorithms.
Decision making: Algorithms can help make decisions based on input data, such as recommending
movies based on your preferences.
Reproducibility: Given the same input, an algorithm always produces the same output, making
results predictable and consistent.
Foundation of computing: Every software or application is built on one or more algorithms, from
simple calculators to complex AI systems.
Despite their strengths, algorithms have some limitations, which are as follows:
Clarity and precision needed: Algorithms require problems to be precisely defined. Ambiguous or
vague problems are difficult or impossible to solve algorithmically.
Dependence on input: Garbage in, garbage out — if inputs are incorrect or incomplete, the
algorithm’s output will be unreliable.
Lack of creativity and adaptation: Algorithms follow rules rigidly and do not think creatively or
adapt unless specifically programmed (e.g., machine learning models).
Scalability issues: Some algorithms work fine on small inputs but become impractical for large
datasets due to high time or memory requirements.
#Solving Complex Problems 63

