0% found this document useful (0 votes)
9 views4 pages

ALGOASS

The document discusses asymptotic notations used to analyze the time complexity of algorithms, including Big O, Omega, and Theta notations, each representing upper, lower, and tight bounds respectively. It also outlines the steps to calculate space complexity, emphasizing the importance of memory usage in algorithm efficiency, and provides examples of different space complexity classes. The document serves as an individual assignment for a student at Wollo University in the School of Public Health.

Uploaded by

Lamesa Edosa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

ALGOASS

The document discusses asymptotic notations used to analyze the time complexity of algorithms, including Big O, Omega, and Theta notations, each representing upper, lower, and tight bounds respectively. It also outlines the steps to calculate space complexity, emphasizing the importance of memory usage in algorithm efficiency, and provides examples of different space complexity classes. The document serves as an individual assignment for a student at Wollo University in the School of Public Health.

Uploaded by

Lamesa Edosa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

WOLLO UNIVERSITY

College of Medicine and Health Science


School of Public Health
Department of Health Informatics
INDIVIDUAL ASSAGNMENT OF DATA STRUCTURES AND ALGORITHMS

NAME ID
LAMESA EDOSA…………………………………………………….1555/13

Summission date 15/3/1017E.C


Summitted To Bedru Y.(MSc.)

NOV,2024 G.C
DESSIE, ETHIOPIA

1
1. Describe how the following Asymptotic Notations is used to calculate the running
time complexity of an algorithm.(provide necessary example )
Asymptotic notations are mathematical tools used to analyze and describe the time complexity of
algorithms. They provide a way to quantify the growth rate of an algorithm's running time as the
input size increases. The three main asymptotic notations used for this purpose are:
A) Big O Notation (O Notation)
The Big O notation represents the upper bound of an algorithm's time complexity. It describes
the worst-case scenario, where the algorithm's running time grows no faster than a given
function. The Big O notation is defined as:
O(f(n))=g(n)|thereexists c > 0 and no such that 0 ≤ g(n) ≤ c ∗ f(n) for all n ≥ no O (f(n)) =
g(n)| thereexists c> 0 and no such that 0 ≤ g(n) ≤ c ∗ f(n) for all n ≥ no
This means that the algorithm's running time is bounded above by a constant multiple of the
function f(n), where n is the input size.
Example: Consider an algorithm that has a running time of 2n + 3. The Big O notation for this
algorithm would be O(n), as the running time grows linearly with the input size.
The Big O notation is commonly used to describe the worst-case scenario, as it provides an
upper bound on the algorithm's running time. This is useful when we want to ensure that an
algorithm will not take an unacceptably long time to run, even in the worst case.
B) Omega Notation (Ω Notation)
The Omega notation represents the lower bound of an algorithm's time complexity. It describes
the best-case scenario, where the algorithm's running time is at least a given function. The
Omega notation is defined as:
Ω(f(n)) =g(n) | thereexists c > 0 and n0 such that 0 ≤ c ∗ f(n) ≤ g(n) forall n ≥ no Ω(f(n)) =
g(n) | thereexists c>0 and no such that 0 ≤ c ∗ f(n) ≤ g(n) for all n ≥ no
This means that the algorithm's running time is bounded below by a constant multiple of the
function f(n), where n is the input size.
Example: Consider an algorithm that has a running time of n^2. The Omega notation for this
algorithm would be Ω(n^2), as the running time grows quadratically with the input size.

2
The Omega notation is useful when we want to ensure that an algorithm will perform at least as
well as a given function, even in the best case. This can be important when we need to guarantee
a certain level of performance for our application.
C) Theta Notation (θ Notation)
The Theta notation represents the tight bound of an algorithm's time complexity. It describes the
exact growth rate of the algorithm's running time. The Theta notation is defined as:
θ(f(n)) = g(n) | thereexists positive constants c1 ,c2 and n0 suchthat 0 ≤ c1 ∗ f(n) ≤ g(n) ≤ c2
∗ f(n) forall n ≥ no θ(f(n)) = g(n) | thereexists positive constants c1, c2 and no suchthat 0 ≤
c1 ∗ f(n) ≤ g(n) ≤ c2 ∗ f(n) forall n ≥ no
This means that the algorithm's running time is bounded both above and below by constant
multiples of the function f(n), where n is the input size.
Example: Consider an algorithm that has a running time of 3n + 5. The Theta notation for this
algorithm would be θ(n), as the running time grows linearly with the input size.
The Theta notation is the most precise of the three asymptotic notations, as it provides both an
upper and lower bound on the algorithm's running time. This can be useful when we want to
know the exact growth rate of an algorithm, rather than just an upper or lower bound.

2) How can calculate space complexity of an algorithm ?

Space complexity is a measure of the amount of memory an algorithm uses to execute. It's
crucial to analyze space complexity to ensure that an algorithm will run efficiently within
memory constraints.

Steps to Calculate Space Complexity

1. Identify Data Structures: Determine the data structures used by the algorithm (arrays,
lists, trees, etc.).
2. Analyze Auxiliary Space: Estimate the memory used by variables, data structures, and
function call stacks.
3. Consider Input Size: Evaluate how auxiliary space changes with the size of the input
data.

3
4. Express in Big O Notation: Use Big O notation to represent the growth rate of space
complexity.

Examples

 Linear Search:
o Auxiliary space: Constant, independent of input size (O(1)).
o Total space: O(n) due to the input array.
 Bubble Sort:
o Auxiliary space: Constant (O(1)).
o Total space: O(n) due to the input array.
 Recursion:
o Auxiliary space: Depends on the recursion depth, which can be proportional to the
input size in some cases (O(n)).
o Total space: Depends on the input size and recursion depth.

Common Space Complexity Classes

 O(1) (Constant): Space usage remains fixed regardless of input size.


 O(log n) (Logarithmic): Space grows logarithmically with input size.
 O(n) (Linear): Space grows linearly with input size.
 O(n log n) (Linearithmic): Space grows linearly with input size and logarithmically
with another factor.
 O(n^2) (Quadratic): Space grows quadratically with input size.
 O(2^n) (Exponential): Space grows exponentially with input size.

You might also like