SlideShare a Scribd company logo
Algorithm
• An algorithm is a finite sequence or set of well-defined
instructions steps that can be used to solve a
computational problem.
• It provides a step-by-step procedure that convert an
input into a desired output.
• It is not the complete program or code; it is just a
solution (logic) of a problem, which can be represented
either as an informal description using a Flowchart or
Pseudo code.
History of Algorithm
• An algorithm (pronounced AL-go-rith-um) is a procedure
or formula for solving a problem.
• The word derives from the name of the mathematician ,
Mohammad Ibn-Musa-al-Khwarizmi, who was part of the
royal court in Baghdad and who lived from about 780 to
850.
• Al Khwarizmi’s work is the likely source for the word
algebra as well.
Algorithm  in  data  structure bca .pptx
How do Algorithms Work?
• Input: The algorithm receives input data.
• Processing: The algorithm performs a series of
operations on the input data.
• Output: The algorithm produces the desired output.
Characteristics of an Algorithm
• Clear and Unambiguous: The algorithm should be unambiguous.
Each of its steps should be clear in all aspects and must lead to
only one meaning.
• Well-Defined Inputs: If an algorithm says to take inputs, it should
be well-defined inputs. It may or may not take input.
• Well-Defined Outputs: The algorithm must clearly define what
output will be yielded and it should be well-defined as well. It
should produce at least 1 output.
• Finiteness: The algorithm must be finite, i.e. it should terminate
after a finite time.
• Feasible: The algorithm must be simple, generic, and practical,
such that it can be executed with the available resources. It must
not contain some future technology or anything.
Characteristics of an Algorithm
• Language Independent: The Algorithm designed must be
language-independent, i.e. it must be just plain instructions that
can be implemented in any language, and yet the output will be
the same, as expected.
• Input: An algorithm has zero or more inputs. Each that contains a
fundamental operator must accept zero or more inputs.
• Output: An algorithm produces at least one output. Every
instruction that contains a fundamental operator must accept zero
or more inputs.
• Definiteness: All instructions in an algorithm must be
unambiguous, precise, and easy to interpret. By referring to any of
the instructions in an algorithm one can clearly understand what is
to be done. Every fundamental operator in instruction must be
defined without any ambiguity.
Characteristics of an Algorithm
• Finiteness: An algorithm must terminate after a finite number of
steps in all test cases. Every instruction which contains a
fundamental operator must be terminated within a finite amount
of time. Infinite loops or recursive functions without base
conditions do not possess finiteness.
• Effectiveness: An algorithm must be developed by using very
basic, simple, and feasible operations so that one can trace it out
by using just paper and pencil.
Algorithm  in  data  structure bca .pptx
Use of the Algorithms
• Computer Science: Algorithms form the basis of computer programming
and are used to solve problems ranging from simple sorting and searching
to complex tasks such as artificial intelligence and machine learning.
• Mathematics: Algorithms are used to solve mathematical problems, such as
finding the optimal solution to a system of linear equations or finding the
shortest path in a graph.
• Operations Research: Algorithms are used to optimize and make decisions
in fields such as transportation, logistics, and resource allocation.
• Artificial Intelligence: Algorithms are the foundation of artificial intelligence
and machine learning, and are used to develop intelligent systems that can
perform tasks such as image recognition, natural language processing, and
decision-making.
• Data Science: Algorithms are used to analyze, process, and extract insights
from large amounts of data in fields such as marketing, finance, and
healthcare.
What is the Need for Algorithms?
Algorithms are essential for solving complex computational
problems efficiently and effectively. They provide a systematic
approach to:
• Solving problems: Algorithms break down problems into smaller,
manageable steps.
• Optimizing solutions: Algorithms find the best or near-optimal
solutions to problems.
• Automating tasks: Algorithms can automate repetitive or complex
tasks, saving time and effort.
Properties of Algorithms
• It should terminate after a finite time.
• It should produce at least one output.
• It should take zero or more input.
• It should be deterministic means giving the same output for the
same input case.
• Every step in the algorithm must be effective i.e. every step should
do some work.
Examples of Algorithms
Below are some example of algorithms:
• Sorting algorithms: Merge sort, Quick sort, Heap sort
• Searching algorithms: Linear search, Binary search, Hashing
• Graph algorithms: Dijkstra’s algorithm, Prim’s algorithm, Floyd-
Warshall algorithm
• String matching algorithms: Knuth-Morris-Pratt algorithm, Boyer-
Moore algorithm
Advantages of Algorithms
• It is easy to understand.
• An algorithm is a step-wise representation of a solution to a given
problem.
• In an Algorithm the problem is broken down into smaller pieces or
steps hence, it is easier for the programmer to convert it into an
actual program.
Disadvantages of Algorithms
• Writing an algorithm takes a long time so it is time-consuming.
• Understanding complex logic through algorithms can be very
difficult.
• Branching and Looping statements are difficult to show in
Algorithms.
How to Write an Algorithm?
To write an algorithm, follow these steps:
• Define the problem: Clearly state the problem to be solved.
• Design the algorithm: Choose an appropriate algorithm design
paradigm and develop a step-by-step procedure.
• Implement the algorithm: Translate the algorithm into a
programming language.
• Test and debug: Execute the algorithm with various inputs to
ensure its correctness and efficiency.
• Analyze the algorithm: Determine its time and space complexity
and compare it to alternative algorithms.
Example of Algorithm
• Algorithm to add 3 numbers and print their sum:
• START
• Declare 3 integer variables num1, num2, and num3.
• Take the three numbers, to be added, as inputs in variables num1,
num2, and num3 respectively.
• Declare an integer variable sum to store the resultant sum of the 3
numbers.
• Add the 3 numbers and store the result in the variable sum.
• Print the value of the variable sum
• END
Analysis of Algorithm
• Algorithm analysis is an important part of computational
complexity theory, which provides theoretical estimation
for the required resources of an algorithm to solve a
specific computational problem.
• Analysis of algorithms is the determination of the
amount of time and space resources required to execute
it.
Why Analysis of Algorithms is important?
• To predict the behavior of an algorithm without implementing it
on a specific computer.
• It is much more convenient to have simple measures for the
efficiency of an algorithm than to implement the algorithm and
test the efficiency every time a certain parameter in the
underlying computer system changes.
• It is impossible to predict the exact behavior of an algorithm.
There are too many influencing factors.
• The analysis is thus only an approximation; it is not perfect.
• More importantly, by analyzing different algorithms, we can
compare them to determine the best one for our purpose.
Types of Algorithm Analysis
• Best case: Define the input for which algorithm takes less time or
minimum time. In the best case calculate the lower bound of an
algorithm. Example: In the linear search when search data is
present at the first location of large data then the best case occurs.
• Worst Case: Define the input for which algorithm takes a long time
or maximum time. In the worst calculate the upper bound of an
algorithm. Example: In the linear search when search data is not
present at all then the worst case occurs.
• Average case: In the average case take all random inputs and
calculate the computation time for all inputs.
And then we divide it by the total number of inputs.
Average case = all random case time / total no of case
Asymptotic Notations
• Asymptotic Notations are mathematical tools used to analyze the performance
of algorithms by understanding how their efficiency changes as the input size
grows.
• These notations provide a concise way to express the behavior of an algorithm’s
time or space complexity as the input size approaches infinity.
• Rather than comparing algorithms directly, asymptotic analysis focuses on
understanding the relative growth rates of algorithms’ complexities.
• It enables comparisons of algorithms’ efficiency by abstracting away machine-
specific constants and implementation details, focusing instead on fundamental
trends.
• Asymptotic analysis allows for the comparison of algorithms’ space and time
complexities by examining their performance characteristics as the input size
varies.
• By using asymptotic notations, such as Big O, Big Omega, and Big Theta, we can
categorize algorithms based on their worst-case, best-case, or average-case
time or space complexities, providing valuable insights into their efficiency.
Asymptotic Notations
There are mainly three asymptotic notations:
• Big-O Notation (O-notation)
• Omega Notation (Ω-notation)
• Theta Notation (Θ-notation)
Theta Notation (Θ-Notation)
• Theta notation encloses the function from above and below.
• Since it represents the upper and the lower bound of the running
time of an algorithm, it is used for analyzing the average-
case complexity of an algorithm.
• Theta (Average Case) You add the running times for each possible
input combination and take the average in the average case.
• Let g and f be the function from the set of natural numbers to
itself. The function f is said to be Θ(g), if there are constants c1, c2
> 0 and a natural number n0 such that c1* g(n) ≤ f(n) ≤ c2 * g(n)
for all n ≥ n0
Θ (g(n)) = {f(n): there exist positive constants c1, c2 and n0 such
that 0 ≤ c1 * g(n) ≤ f(n) ≤ c2 * g(n) for all n ≥ n0}
Note: Θ(g) is a set
Big-O Notation (O-notation)
• Big-O notation represents the upper bound of the running time of an
algorithm. Therefore, it gives the worst-case complexity of an
algorithm.
• It is the most widely used notation for Asymptotic analysis.
• It specifies the upper bound of a function.
• The maximum time required by an algorithm or the worst-case time
complexity.
• It returns the highest possible output value(big-O) for a given input.
• Big-O(Worst Case) It is defined as the condition that allows an
algorithm to complete statement execution in the longest amount of
time possible.
• If f(n) describes the running time of an algorithm, f(n) is O(g(n)) if
there exist a positive constant C and n0 such that, 0 ≤ f(n) ≤ cg(n) for
all n ≥ n0
O(g(n)) = { f(n): there exist positive constants c and n0
such that 0 ≤ f(n) ≤ cg(n) for all n ≥ n0 }
Omega Notation (Ω-Notation)
• Omega notation represents the lower bound of the running time
of an algorithm.
• Thus, it provides the best case complexity of an algorithm.
• It is defined as the condition that allows an algorithm to complete
statement execution in the shortest amount of time.
• Let g and f be the function from the set of natural numbers to
itself. The function f is said to be Ω(g), if there is a constant c > 0
and a natural number n0 such that c*g(n) ≤ f(n) for all n ≥ n0
Ω(g(n)) = { f(n): there exist positive constants c and n0 such that 0
≤ cg(n) ≤ f(n) for all n ≥ n0 }
Complexities of an Algorithm
• The complexity of an algorithm computes the amount of time and
spaces required by an algorithm for an input of size (n). The
complexity of an algorithm can be divided into two types. The time
complexity and the space complexity.
• Time Complexity of an Algorithm: -The time complexity is defined as
the process of determining a formula for total time required towards
the execution of that algorithm. This calculation is totally
independent of implementation and programming language.
• Space Complexity of an Algorithm: - Space complexity is defining as
the process of defining a formula for prediction of how much
memory space is required for the successful execution of the
algorithm. The memory space is generally considered as the primary
memory.
Algorithm  in  data  structure bca .pptx
Algorithm  in  data  structure bca .pptx

More Related Content

Similar to Algorithm in data structure bca .pptx (20)

PDF
DAA INTRO.pdf of design analysis algorithms
VaishnaviDappu
 
PDF
Chapter-1-Introduction-to-Aglorithms.pdf
Shanmuganathan C
 
PDF
Introduction to Algorithms Complexity Analysis
Dr. Pankaj Agarwal
 
PPT
Introduction to design and analysis of algorithm
DevaKumari Vijay
 
PPTX
Algorithm.pptx
Koteswari Kasireddy
 
PPTX
Algorithm.pptx
Koteswari Kasireddy
 
PPT
Lec1.ppt
ssuser8bddb2
 
PDF
01 Revision Introduction SLides Od Design ANd Aalaysis Of aLgo
mtahanasir65
 
PPTX
design analysis of algorithmaa unit 1.pptx
rajesshs31r
 
PDF
Algorithm Analysis.pdf
NayanChandak1
 
PPTX
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
PDF
Lecture 2 role of algorithms in computing
jayavignesh86
 
PPT
Analysis of Algorithm data structure.ppt
22ad0301
 
PPTX
Algorithm and Complexity-Lesson 1.pptx
Apasra R
 
PPTX
Introduction to algorithms
Madishetty Prathibha
 
PPSX
Ds03 part i algorithms by jyoti lakhani
jyoti_lakhani
 
PDF
Python algorithm
Prof. Dr. K. Adisesha
 
PDF
Design Analysis and Algorithm Module1.pdf
Shana799280
 
PPTX
Design and Analysis of Algorithm ppt for unit one
ssuserb7c8b8
 
PPTX
FDFDRERSFDSGAGAFGGFGFGFGFGAFDGFDGFGFFAGFGGDF
AlthimeseAnderson
 
DAA INTRO.pdf of design analysis algorithms
VaishnaviDappu
 
Chapter-1-Introduction-to-Aglorithms.pdf
Shanmuganathan C
 
Introduction to Algorithms Complexity Analysis
Dr. Pankaj Agarwal
 
Introduction to design and analysis of algorithm
DevaKumari Vijay
 
Algorithm.pptx
Koteswari Kasireddy
 
Algorithm.pptx
Koteswari Kasireddy
 
Lec1.ppt
ssuser8bddb2
 
01 Revision Introduction SLides Od Design ANd Aalaysis Of aLgo
mtahanasir65
 
design analysis of algorithmaa unit 1.pptx
rajesshs31r
 
Algorithm Analysis.pdf
NayanChandak1
 
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Lecture 2 role of algorithms in computing
jayavignesh86
 
Analysis of Algorithm data structure.ppt
22ad0301
 
Algorithm and Complexity-Lesson 1.pptx
Apasra R
 
Introduction to algorithms
Madishetty Prathibha
 
Ds03 part i algorithms by jyoti lakhani
jyoti_lakhani
 
Python algorithm
Prof. Dr. K. Adisesha
 
Design Analysis and Algorithm Module1.pdf
Shana799280
 
Design and Analysis of Algorithm ppt for unit one
ssuserb7c8b8
 
FDFDRERSFDSGAGAFGGFGFGFGFGAFDGFDGFGFFAGFGGDF
AlthimeseAnderson
 

Recently uploaded (20)

PPTX
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
PPTX
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
PDF
AUDITABILITY & COMPLIANCE OF AI SYSTEMS IN HEALTHCARE
GAHI Youssef
 
PPTX
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
PDF
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
PPTX
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
PPT
AI Future trends and opportunities_oct7v1.ppt
SHIKHAKMEHTA
 
PDF
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
PDF
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna
 
PDF
Merits and Demerits of DBMS over File System & 3-Tier Architecture in DBMS
MD RIZWAN MOLLA
 
PDF
The European Business Wallet: Why It Matters and How It Powers the EUDI Ecosy...
Lal Chandran
 
PPT
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
PDF
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
PDF
Choosing the Right Database for Indexing.pdf
Tamanna
 
PDF
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
PDF
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
PPTX
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
PDF
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
PPTX
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
AUDITABILITY & COMPLIANCE OF AI SYSTEMS IN HEALTHCARE
GAHI Youssef
 
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
AI Future trends and opportunities_oct7v1.ppt
SHIKHAKMEHTA
 
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna
 
Merits and Demerits of DBMS over File System & 3-Tier Architecture in DBMS
MD RIZWAN MOLLA
 
The European Business Wallet: Why It Matters and How It Powers the EUDI Ecosy...
Lal Chandran
 
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
Choosing the Right Database for Indexing.pdf
Tamanna
 
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
Ad

Algorithm in data structure bca .pptx

  • 1. Algorithm • An algorithm is a finite sequence or set of well-defined instructions steps that can be used to solve a computational problem. • It provides a step-by-step procedure that convert an input into a desired output. • It is not the complete program or code; it is just a solution (logic) of a problem, which can be represented either as an informal description using a Flowchart or Pseudo code.
  • 2. History of Algorithm • An algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem. • The word derives from the name of the mathematician , Mohammad Ibn-Musa-al-Khwarizmi, who was part of the royal court in Baghdad and who lived from about 780 to 850. • Al Khwarizmi’s work is the likely source for the word algebra as well.
  • 4. How do Algorithms Work? • Input: The algorithm receives input data. • Processing: The algorithm performs a series of operations on the input data. • Output: The algorithm produces the desired output.
  • 5. Characteristics of an Algorithm • Clear and Unambiguous: The algorithm should be unambiguous. Each of its steps should be clear in all aspects and must lead to only one meaning. • Well-Defined Inputs: If an algorithm says to take inputs, it should be well-defined inputs. It may or may not take input. • Well-Defined Outputs: The algorithm must clearly define what output will be yielded and it should be well-defined as well. It should produce at least 1 output. • Finiteness: The algorithm must be finite, i.e. it should terminate after a finite time. • Feasible: The algorithm must be simple, generic, and practical, such that it can be executed with the available resources. It must not contain some future technology or anything.
  • 6. Characteristics of an Algorithm • Language Independent: The Algorithm designed must be language-independent, i.e. it must be just plain instructions that can be implemented in any language, and yet the output will be the same, as expected. • Input: An algorithm has zero or more inputs. Each that contains a fundamental operator must accept zero or more inputs. • Output: An algorithm produces at least one output. Every instruction that contains a fundamental operator must accept zero or more inputs. • Definiteness: All instructions in an algorithm must be unambiguous, precise, and easy to interpret. By referring to any of the instructions in an algorithm one can clearly understand what is to be done. Every fundamental operator in instruction must be defined without any ambiguity.
  • 7. Characteristics of an Algorithm • Finiteness: An algorithm must terminate after a finite number of steps in all test cases. Every instruction which contains a fundamental operator must be terminated within a finite amount of time. Infinite loops or recursive functions without base conditions do not possess finiteness. • Effectiveness: An algorithm must be developed by using very basic, simple, and feasible operations so that one can trace it out by using just paper and pencil.
  • 9. Use of the Algorithms • Computer Science: Algorithms form the basis of computer programming and are used to solve problems ranging from simple sorting and searching to complex tasks such as artificial intelligence and machine learning. • Mathematics: Algorithms are used to solve mathematical problems, such as finding the optimal solution to a system of linear equations or finding the shortest path in a graph. • Operations Research: Algorithms are used to optimize and make decisions in fields such as transportation, logistics, and resource allocation. • Artificial Intelligence: Algorithms are the foundation of artificial intelligence and machine learning, and are used to develop intelligent systems that can perform tasks such as image recognition, natural language processing, and decision-making. • Data Science: Algorithms are used to analyze, process, and extract insights from large amounts of data in fields such as marketing, finance, and healthcare.
  • 10. What is the Need for Algorithms? Algorithms are essential for solving complex computational problems efficiently and effectively. They provide a systematic approach to: • Solving problems: Algorithms break down problems into smaller, manageable steps. • Optimizing solutions: Algorithms find the best or near-optimal solutions to problems. • Automating tasks: Algorithms can automate repetitive or complex tasks, saving time and effort.
  • 11. Properties of Algorithms • It should terminate after a finite time. • It should produce at least one output. • It should take zero or more input. • It should be deterministic means giving the same output for the same input case. • Every step in the algorithm must be effective i.e. every step should do some work.
  • 12. Examples of Algorithms Below are some example of algorithms: • Sorting algorithms: Merge sort, Quick sort, Heap sort • Searching algorithms: Linear search, Binary search, Hashing • Graph algorithms: Dijkstra’s algorithm, Prim’s algorithm, Floyd- Warshall algorithm • String matching algorithms: Knuth-Morris-Pratt algorithm, Boyer- Moore algorithm
  • 13. Advantages of Algorithms • It is easy to understand. • An algorithm is a step-wise representation of a solution to a given problem. • In an Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the programmer to convert it into an actual program.
  • 14. Disadvantages of Algorithms • Writing an algorithm takes a long time so it is time-consuming. • Understanding complex logic through algorithms can be very difficult. • Branching and Looping statements are difficult to show in Algorithms.
  • 15. How to Write an Algorithm? To write an algorithm, follow these steps: • Define the problem: Clearly state the problem to be solved. • Design the algorithm: Choose an appropriate algorithm design paradigm and develop a step-by-step procedure. • Implement the algorithm: Translate the algorithm into a programming language. • Test and debug: Execute the algorithm with various inputs to ensure its correctness and efficiency. • Analyze the algorithm: Determine its time and space complexity and compare it to alternative algorithms.
  • 16. Example of Algorithm • Algorithm to add 3 numbers and print their sum: • START • Declare 3 integer variables num1, num2, and num3. • Take the three numbers, to be added, as inputs in variables num1, num2, and num3 respectively. • Declare an integer variable sum to store the resultant sum of the 3 numbers. • Add the 3 numbers and store the result in the variable sum. • Print the value of the variable sum • END
  • 17. Analysis of Algorithm • Algorithm analysis is an important part of computational complexity theory, which provides theoretical estimation for the required resources of an algorithm to solve a specific computational problem. • Analysis of algorithms is the determination of the amount of time and space resources required to execute it.
  • 18. Why Analysis of Algorithms is important? • To predict the behavior of an algorithm without implementing it on a specific computer. • It is much more convenient to have simple measures for the efficiency of an algorithm than to implement the algorithm and test the efficiency every time a certain parameter in the underlying computer system changes. • It is impossible to predict the exact behavior of an algorithm. There are too many influencing factors. • The analysis is thus only an approximation; it is not perfect. • More importantly, by analyzing different algorithms, we can compare them to determine the best one for our purpose.
  • 19. Types of Algorithm Analysis • Best case: Define the input for which algorithm takes less time or minimum time. In the best case calculate the lower bound of an algorithm. Example: In the linear search when search data is present at the first location of large data then the best case occurs. • Worst Case: Define the input for which algorithm takes a long time or maximum time. In the worst calculate the upper bound of an algorithm. Example: In the linear search when search data is not present at all then the worst case occurs. • Average case: In the average case take all random inputs and calculate the computation time for all inputs. And then we divide it by the total number of inputs. Average case = all random case time / total no of case
  • 20. Asymptotic Notations • Asymptotic Notations are mathematical tools used to analyze the performance of algorithms by understanding how their efficiency changes as the input size grows. • These notations provide a concise way to express the behavior of an algorithm’s time or space complexity as the input size approaches infinity. • Rather than comparing algorithms directly, asymptotic analysis focuses on understanding the relative growth rates of algorithms’ complexities. • It enables comparisons of algorithms’ efficiency by abstracting away machine- specific constants and implementation details, focusing instead on fundamental trends. • Asymptotic analysis allows for the comparison of algorithms’ space and time complexities by examining their performance characteristics as the input size varies. • By using asymptotic notations, such as Big O, Big Omega, and Big Theta, we can categorize algorithms based on their worst-case, best-case, or average-case time or space complexities, providing valuable insights into their efficiency.
  • 21. Asymptotic Notations There are mainly three asymptotic notations: • Big-O Notation (O-notation) • Omega Notation (Ω-notation) • Theta Notation (Θ-notation)
  • 22. Theta Notation (Θ-Notation) • Theta notation encloses the function from above and below. • Since it represents the upper and the lower bound of the running time of an algorithm, it is used for analyzing the average- case complexity of an algorithm. • Theta (Average Case) You add the running times for each possible input combination and take the average in the average case. • Let g and f be the function from the set of natural numbers to itself. The function f is said to be Θ(g), if there are constants c1, c2 > 0 and a natural number n0 such that c1* g(n) ≤ f(n) ≤ c2 * g(n) for all n ≥ n0
  • 23. Θ (g(n)) = {f(n): there exist positive constants c1, c2 and n0 such that 0 ≤ c1 * g(n) ≤ f(n) ≤ c2 * g(n) for all n ≥ n0} Note: Θ(g) is a set
  • 24. Big-O Notation (O-notation) • Big-O notation represents the upper bound of the running time of an algorithm. Therefore, it gives the worst-case complexity of an algorithm. • It is the most widely used notation for Asymptotic analysis. • It specifies the upper bound of a function. • The maximum time required by an algorithm or the worst-case time complexity. • It returns the highest possible output value(big-O) for a given input. • Big-O(Worst Case) It is defined as the condition that allows an algorithm to complete statement execution in the longest amount of time possible. • If f(n) describes the running time of an algorithm, f(n) is O(g(n)) if there exist a positive constant C and n0 such that, 0 ≤ f(n) ≤ cg(n) for all n ≥ n0
  • 25. O(g(n)) = { f(n): there exist positive constants c and n0 such that 0 ≤ f(n) ≤ cg(n) for all n ≥ n0 }
  • 26. Omega Notation (Ω-Notation) • Omega notation represents the lower bound of the running time of an algorithm. • Thus, it provides the best case complexity of an algorithm. • It is defined as the condition that allows an algorithm to complete statement execution in the shortest amount of time. • Let g and f be the function from the set of natural numbers to itself. The function f is said to be Ω(g), if there is a constant c > 0 and a natural number n0 such that c*g(n) ≤ f(n) for all n ≥ n0
  • 27. Ω(g(n)) = { f(n): there exist positive constants c and n0 such that 0 ≤ cg(n) ≤ f(n) for all n ≥ n0 }
  • 28. Complexities of an Algorithm • The complexity of an algorithm computes the amount of time and spaces required by an algorithm for an input of size (n). The complexity of an algorithm can be divided into two types. The time complexity and the space complexity. • Time Complexity of an Algorithm: -The time complexity is defined as the process of determining a formula for total time required towards the execution of that algorithm. This calculation is totally independent of implementation and programming language. • Space Complexity of an Algorithm: - Space complexity is defining as the process of defining a formula for prediction of how much memory space is required for the successful execution of the algorithm. The memory space is generally considered as the primary memory.