MUNENE MARKDENIS
T020/301029/2023
1. a) A program is a set of instruc ons that a computer follows to perform a specific task or
solve a problem. The instruc ons are wri en in a programming language which is a
structured way of expressing algorithms and data manipula on.
b) Algorithm is a step-by-step procedure for solving a problem or specific task and are
fundamental to the way so ware programs operate.
c) A compiler is a so ware tool that translates source code wri en in a high-level
programming language into machine code that can be executed by a computer’s processor.
d) Syntax refers to the rules and structure governing the arrangement of symbols,
keywords and expressions in a programming language.
e) Seman cs refers to the meaning of the code, rather than its syntax or structure and
focuses on the intended behavior and func onality of the code.
2. Compila on diagram
source code
|
preprocessor
|
lexical analysis
|
syntax analysis
|
seman c analysis
|
intermediate code
|
code genera on
|
object code
|
linker
|
executable file
3. CHARACTERISTICS
I) Efficiency-an algorithm should be op mized in terms of me and space complexity.
ii) Modularity-an algorithm should be broken down into smaller, reusable modules for
easier maintenance and understanding.
iii) Correctness-An algorithm should produce the correct output for all possible inputs.
SIGNIFICANCE
I) Efficiency ensures that algorithm performs well even with large inputs.
ii) Modularity promotes code reusability and maintainability.
iii) Correctness ensures the algorithm behaves as expected.
4. I) start -> input n
ii) input n -> check if n < 0
iii) check if n < 0 -> "error; factorial of nega ve number is undefined" -> stop
iv) check if n < 0 -> no -> ini alize fact = 1, I = 1
v) ini alize fact = 1, I = 1 -> check if I <= n
vi) check if I <= n -> yes -> fact = fact * I, I = I + 1 -> repeat
vii) check if I <= n -> no -> output fact -> stop
5. I) Logical errors- errors in the logic that lead to incorrect output.
ii) Run me errors- errors that occur during program execu on.
iii) Syntax errors- errors in the structure of the code.
6. Tes ng involves systema cally checking the so ware for errors and bugs, while
valida on ensures that the so ware meets the specified requirements and fulfils the
intended purpose.
7. I) Clarity- pseudocode helps in breaking down complex algorithms into simpler steps for
be er comprehension.
ii) Readability- pseudocode is easy to read and understand for both technical and non-
technical people.
iii) Flexibility- pseudocode allows for quick and easy modifica ons before implemen ng
the actual code.