SlideShare a Scribd company logo
1 of 2
Download to read offline
ANALYSIS OF ALGORITHMS PROBLEMS
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
(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

More Related Content

Viewers also liked

Digital Differential Analyzer Line Drawing Algorithm in C
Digital Differential Analyzer Line Drawing Algorithm in CDigital Differential Analyzer Line Drawing Algorithm in C
Digital Differential Analyzer Line Drawing Algorithm in CKasun Ranga Wijeweera
 
Implementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in CImplementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in CKasun Ranga Wijeweera
 
Principles of Object Oriented Programming
Principles of Object Oriented ProgrammingPrinciples of Object Oriented Programming
Principles of Object Oriented ProgrammingKasun Ranga Wijeweera
 
Linked List Implementation of Deque in C
Linked List Implementation of Deque in CLinked List Implementation of Deque in C
Linked List Implementation of Deque in CKasun Ranga Wijeweera
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmKasun Ranga Wijeweera
 
Linked List Implementation of Queue in C
Linked List Implementation of Queue in CLinked List Implementation of Queue in C
Linked List Implementation of Queue in CKasun Ranga Wijeweera
 

Viewers also liked (9)

Exercises for Convexity of Polygons
Exercises for Convexity of PolygonsExercises for Convexity of Polygons
Exercises for Convexity of Polygons
 
Digital Differential Analyzer Line Drawing Algorithm in C
Digital Differential Analyzer Line Drawing Algorithm in CDigital Differential Analyzer Line Drawing Algorithm in C
Digital Differential Analyzer Line Drawing Algorithm in C
 
Implementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in CImplementation of k-means clustering algorithm in C
Implementation of k-means clustering algorithm in C
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
Principles of Object Oriented Programming
Principles of Object Oriented ProgrammingPrinciples of Object Oriented Programming
Principles of Object Oriented Programming
 
Linked List Implementation of Deque in C
Linked List Implementation of Deque in CLinked List Implementation of Deque in C
Linked List Implementation of Deque in C
 
Boundary Fill Algorithm in C
Boundary Fill Algorithm in CBoundary Fill Algorithm in C
Boundary Fill Algorithm in C
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
 
Linked List Implementation of Queue in C
Linked List Implementation of Queue in CLinked List Implementation of Queue in C
Linked List Implementation of Queue in C
 

More from Kasun Ranga Wijeweera

Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonKasun Ranga Wijeweera
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmKasun Ranga Wijeweera
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingKasun Ranga Wijeweera
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic ProgrammingKasun Ranga Wijeweera
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingKasun Ranga Wijeweera
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Kasun Ranga Wijeweera
 

More from Kasun Ranga Wijeweera (20)

Decorator Design Pattern in C#
Decorator Design Pattern in C#Decorator Design Pattern in C#
Decorator Design Pattern in C#
 
Singleton Design Pattern in C#
Singleton Design Pattern in C#Singleton Design Pattern in C#
Singleton Design Pattern in C#
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a Polygon
 
Geometric Transformations II
Geometric Transformations IIGeometric Transformations II
Geometric Transformations II
 
Geometric Transformations I
Geometric Transformations IGeometric Transformations I
Geometric Transformations I
 
Introduction to Polygons
Introduction to PolygonsIntroduction to Polygons
Introduction to Polygons
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
 
Loops in Visual Basic: Exercises
Loops in Visual Basic: ExercisesLoops in Visual Basic: Exercises
Loops in Visual Basic: Exercises
 
Conditional Logic: Exercises
Conditional Logic: ExercisesConditional Logic: Exercises
Conditional Logic: Exercises
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic Programming
 
CheckBoxes and RadioButtons
CheckBoxes and RadioButtonsCheckBoxes and RadioButtons
CheckBoxes and RadioButtons
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic Programming
 
Loops in Visual Basic Programming
Loops in Visual Basic ProgrammingLoops in Visual Basic Programming
Loops in Visual Basic Programming
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic Programming
 
Assignment for Variables
Assignment for VariablesAssignment for Variables
Assignment for Variables
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]
 
Assignment for Events
Assignment for EventsAssignment for Events
Assignment for Events
 
Mastering Arrays Assignment
Mastering Arrays AssignmentMastering Arrays Assignment
Mastering Arrays Assignment
 

Analysis of Algorithms Problems

  • 1. ANALYSIS OF ALGORITHMS PROBLEMS Author: Kasun Ranga Wijeweera Email: krw19870829@gmail.com (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)
  • 2.  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