Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Definition of Algorithm and notation

Uploaded by

atul
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Definition of Algorithm and notation

Uploaded by

atul
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Algorithm and concept of Notation

Definition of Algorithm

The word Algorithm means ” A set of finite rules or instructions to be followed in


calculations or other problem-solving operations ”
Or
” A procedure for solving a mathematical problem in a finite number of steps that
frequently involves recursive operations”.

Notation refers to how we represent and analyze algorithms in terms of time and
space requirements.

 Big O, Omega, and Theta Notations


These are used to measure an algorithm's performance, specifically how its running
time grows with input size.

Big O Notation (O)

Big O Notation gives the hardest or maximum complexity of an algorithm. It shows how
much work an algorithm might need to do in the worst-case scenario when the input size
increases.

 It tells us the maximum time an algorithm can take.


 Example:
o Searching for a number in an array of size n.
o In the worst case, it checks all n elements → Big O = O(n).

The letter 'O' in Big O stands for "Order", which means how an algorithm grows
as the input size increases. (Big means large data)

It shows the upper bound (worst-case performance) of an algorithm.

If the library has n books, the time taken is proportional to n → Big O is O(n)
Omega (Ω) Notation
It shows how easy or fast an algorithm can be in the best-case scenario, where the time
taken is the minimum possible.
it is useful to check How little time can the algorithm take
Example:

 If the first number in the array matches, the search stops → Best case = Ω(1)

It shows the best-case performance of an algorithm (minimum time it can take).

Example:
Searching for a book:

 If the book is the very first one you pick, you only need one step → Best case
= Ω(1).

Omega = Minimum Time

Worst Case (Big O):


If the number is the last element or not present, you might need to check all
elements → Hardest case.

Theta (Θ) Notation

Represents the average-case scenario.


It gives the exact time an algorithm takes on average.
Example:

 On average, the search might take half the size of the array → Θ(n/2)
simplifies to Θ(n).

Example:
Searching for a book:

 On average, you might find the book after checking half the books in the
library.
 If there are n books, the time is proportional to n/2 → Θ(n)

Symbo
Notation Meaning Example
l
Worst-case O(n) → Check all
Big O (O) O
performance books
Best-case Ω(1) → Find in 1
Omega (Ω) Ω
performance step
Average-case Θ(n) → Check
Theta (Θ) Θ
performance half books
Why Are These Notations Important?

1. They help us understand how efficient an algorithm is for large inputs.


2. They guide us in choosing the best algorithm for a given problem

You might also like