Lecturer - 3 Algorithm Analysis
Lecturer - 3 Algorithm Analysis
By: Samuel M.
Chapters Content
Introduction
Dynamic programing
Graph Theory
Queue
Data Structures
Classification data structure
Abstract Data Types
Simple and advanced searching and sorting algorism
Priority Queue
Demerging Queues and merging
LIFO, FIFO…
Application of Queues
Understand the properties of graph and graph algorisms and searching techniques
Definition
Data: Collection of raw facts
Data structure is systematic way of organizing and accessing data
Algorithm is a step by step procedure to solve a particular function task
Program is a series of instructions to carry out a particular task
What to Analyze ?
Correctness
Does the input/output relation match algorithm requirement?
What to Analyze…?
Amount of space used
Memory used
Simplicity, clarity
Verification and implementation
Optimality
Is it impossible to do better?
Time Complexity
Amount of computer time it needs to execute the program to get the intended result
Space Complexity
Memory requirements based on the problem size
It is measured by the amount of resources it uses, the time and the space
The time refers to the number of steps the algorithm executes
Space refers to the number of unit memory storage it requires.
Time complexity is a function dependent from the value of n for f(n) and computed
after all instruction performed
Time complexity of an algorithm is generally classified as three types.
i. Worst case [Big oh (O) notaion]:
It is the longest time that an algorithm will use over all instances of size n for a given
problem to produce a desired result
ii. Average Case [Theta (Ө notation)]:
It is the average time( or average space) that the algorithm will use over all instances of size
n for a given problem to produce a desired result
iii. Best Case [Omega (Ω notation)]: It is the shortest time ( or least space ) required to algorithm
for instances to produce a desired results
Time Comp..
g(x)= 5x
t(x)=x2
f(x)=x3
It is the amount of memory consumed by the algorithm (both i/o) until it completes its
execution
There are three different spaces considered for determining the amount of memory used
by the algorithm.
Instruction Space: the space in memory occupied by the compiled version of the
program
We consider this space as a constant space for any value of n.
The instruction space is independent of the size of the problem
Data Space: is the space in memory , which used to hold the variables , data
structures, allocated memory and other data elements.
Environment Space: is the space in memory used on the run time stack for each
function call
Space Complexity is not as big of an issue as time complexity because it can be reused, whereas time cannot
Algorism analysis does not give accurate value (time and space)
Conclusion it gives you the estimate values which can be used to study the behavior of
algorism
25
Select Business and Technology Collage
CSC 413:Theory of Algorisms
Data Structures and Algorithms Analysis
Lecturer :3
By: Samuel M.
Introduction: Data Structure (DS)
Definition:
Primitive DS Non-Primitive DS
array
queue
tree stack graph
Data Structures and Algorithms Analysis 32 June, 2021
Non-primitive Data Structure…
The number specified inside the square brackets is the number of elements an array
can store, also called sized /length of array
Following are some of the concepts to be remembered about arrays:
The individual element of an array can be accessed by specifying name of the
array, following by index or subscript inside square brackets
The first element of the array has index zero[0]
The first element & last element will be specified as arr[0] & arr[9] respectively
Due to this it is called as last in first out type of data structure (LIFO)
When an element is inserted into a stack or removed from the stack, its
base remains fixed where the top of stack changes
PUSH POP
[STACK]
Queue are first in first out type of data structure (i.e. FIFO)
In a queue new elements are added to the queue from one end called REAR
end & the element are always removed from other end called the FRONT
end
The people standing in a railway reservation row are an example of queue.
Each new person comes and stands at the end of the row and person
getting their reservation confirmed get out of the row from the front end
The bellow show figure how the operations take place on a stack:
10 20 30 40 50
front rear
A root
B C
D E F G
An edge connects a pair of vertices and many have weight such as length,
cost and another measuring instrument for according the graph.
Vertices on the graph are shown as point or circles and edges are drawn as
arcs or line segment.
Example of graph:
v2 6 v5 v1 v3
10
v1 8 11
15
9 v2 v4
v3 v4
59