2
ANALYSIS OF ALGORITHMS PROBLEMS Author: Kasun Ranga Wijeweera Email: [email protected] (TOTAL MARKS = 40) a) What do you mean by the term “Algorithm” in computer science? (5 marks) A well defined (2 marks) finite set (2 marks) of steps a computer follows to solve a problem (1 marks) b) State five properties of algorithms (10 marks) i. It must be correct (2 marks) ii. It must be composed of a series of concrete steps (2 marks) iii. There can be no ambiguity as to which step will be performed next (2 marks) iv. It must be composed of a finite number of steps (2 marks) v. It must terminate (2 marks) c) State five factors affecting the running time of algorithms (10 marks) i. Speed of the machine running the program (2 marks) ii. Language in which the program was written (2 marks) iii. Efficiency of the compiler that created the program (2 marks) iv. The size of the input (2 marks) v. Organization of the input (2 marks) d) Briefly explain the two conflicting goals in computer program design (5 marks) i. To design an algorithm that is easy to understand, code, debug (2.5 marks) ii. To design an algorithm that makes efficient use of the computer’s resources (2.5 marks) e) Define the terms “Average case” and “Worst case” (5 marks) Average Case: The amount of time a program might be expected to take on “typical” input data (2.5 marks)

Analysis of Algorithms Problems

Embed Size (px)

Citation preview

ANALYSIS OF ALGORITHMS PROBLEMS

Author: Kasun Ranga Wijeweera

Email: [email protected]

(TOTAL MARKS = 40)

a) What do you mean by the term “Algorithm” in computer science? (5 marks)

A well defined (2 marks) finite set (2 marks) of steps a computer follows to solve a problem

(1 marks)

b) State five properties of algorithms (10 marks)

i. It must be correct (2 marks)

ii. It must be composed of a series of concrete steps (2 marks)

iii. There can be no ambiguity as to which step will be performed next (2 marks)

iv. It must be composed of a finite number of steps (2 marks)

v. It must terminate (2 marks)

c) State five factors affecting the running time of algorithms (10 marks)

i. Speed of the machine running the program (2 marks)

ii. Language in which the program was written (2 marks)

iii. Efficiency of the compiler that created the program (2 marks)

iv. The size of the input (2 marks)

v. Organization of the input (2 marks)

d) Briefly explain the two conflicting goals in computer program design (5 marks)

i. To design an algorithm that is easy to understand, code, debug (2.5 marks)

ii. To design an algorithm that makes efficient use of the computer’s resources (2.5

marks)

e) Define the terms “Average case” and “Worst case” (5 marks)

Average Case: The amount of time a program might be expected to take on “typical”

input data (2.5 marks)

Worst Case: The amount of time a program would take on the worst possible input

configuration (2.5 marks)

f) Write the definition of Big-O notation and illustrate using a graph (5 marks)

A function g (N) is said to O (f (N)) if there exists constants c0 and N0 such that g (N) is less

than c0 * f (N) for all N > N0 (2 marks)

(3 marks)

N

C0* f (N)

g (N)

Does not

matter