Fundamentals of Algorithm Analysis: Types and Techniques

sns college of engineering coimbatore n.w
1 / 12
Embed
Share

Explore different problem-solving techniques in algorithm analysis including Brute Force, Recursive, Divide and Conquer, Dynamic Programming, Greedy, and Backtracking algorithms. Understand how each type optimizes time and space efficiency for various problem types within the realm of computer science and technology.

  • Algorithm Analysis
  • Problem Solving
  • Types
  • Techniques
  • Computer Science

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. SNS COLLEGE OF ENGINEERING Coimbatore-107 An Autonomous Institution Accredited by AICTE and Accredited by NAAC UGC with A Grade Approved by AICTE, New Delhi & Affiliated to Anna University, Chennai COURSE NAME: ANALYSIS OF ALGORITHMS II YEAR/ IV SEMESTER Topic Notion of an Algorithm Fundamentals of Algorithmic Problem Solving Important Problem Types Fundamentals of the Analysis of Algorithm Efficiency Analysis Framework Asymptotic Notations and its properties Mathematical analysis for Recursive and Non-recursive algorithms. K.Priyanka Assistant Professor Department of Computer Science and Technology Analysis of Algorithm/Unit I/K.Priyanka/AP/CST/SNSCE 1

  2. TOPIC 3-IMPORTANT PROBLEM TYPE An algorithm should be optimized in terms of time and space. Different types of problems require different types of algorithmic techniques to be solved in the most optimized manner. There are many types of algorithms. 1. Brute Force Algorithm: It is an intuitive, direct, and straightforward technique of problem-solving in which all the possible ways or all the possible solutions to a given problem are enumerated. Example: Brute force strategy exploring all the paths to a nearby market to find the minimum shortest path. 2. Recursive Algorithm: Recursion is technique used in computer science to solve big problems by breaking them into smaller, similar problems. The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. Example: Factorial of a Number, Fibonacci Series, Tower of Hanoi, DFS for Graph, etc. Analysis of Algorithms/Unit I/K.Priyanka/AP/CST/SNSCE 2

  3. Divide and Conquer Algorithm: In Divide and Conquer algorithms, the idea is to solve the problem in two sections, the first section divides the problem into subproblems of the same type. The second section is to solve the smaller problems independently and then add the combined result to produce the final answer to the problem. Example: Search, Merge Sort, Quick Sort, Strassen s Matrix Multiplication, etc. Dynamic Programming Algorithms: It is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for the same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of subproblems so that we do not have to re-compute them when needed later. This simple optimization typically reduces time complexities from exponential to polynomial. Eg: Fibonacci Numbers, Bellman Ford Shortest Path and Matrix Chain Multiplication. UNIT 4 - ATCD code optimization 3

  4. Greedy Algorithm: Greedy algorithms are a class of algorithms that make locally optimal choices at each step. At every step, we can make a choice that looks best at the moment, and we get the optimal solution to the complete problem. Examples: Knapsack, Dijkstra's algorithm, Kruskal's algorithm, Huffman coding and Prim's Algorithm Backtracking Algorithm: Backtracking algorithms are like problem-solving strategies that help explore different options to find the best solution. They work by trying out different paths and if one doesn't work, they backtrack and try another until they find the right one. Example: the Hamiltonian Cycle, M-Coloring Problem, N Queen Problem, etc. 3. Randomized Algorithm: An algorithm that uses random numbers to decide what to do next anywhere in its logic is called a Randomized Algorithm UNIT 4 - ATCD code optimization 4

  5. Example: Quicksort: In Quicksort we use the random number for selecting the pivot Karger s algorithm:we randomly pick an edge. 4. Sorting Algorithm: The sorting algorithm is used to sort data in maybe ascending or descending order, according to a comparison operator on the elements. Example: Bubble sort, insertion sort, merge sort, selection sort, and quick sort 5. Searching Algorithm: The searching algorithm is the algorithm that is used for searching the specific key in particular sorted or unsorted data. various applications are done in databases, web search engines Example: Binary search or linear search UNIT 4 - ATCD code optimization 5

  6. 6. Hashing Algorithm: Hashing algorithms refers to the process of generating a fixed-size output from an input of variable size using the mathematical formulas known as hash functions. This technique determines an index or location for the storage of an item in a data structure. Example: Hashing Algorithm used in password verification. 7.Graph Algorithm: Graph is a collection of vertices and edges. The graph problem involves graph traversal algorithms, shortest path algorithms and topological sorting. Some graph problems are very hard to solve. Example: Travelling Salesman Problem, Graph Coloring Problems. UNIT 4 - ATCD code optimization 6

  7. TOPIC4- Asymptotic Notations and its properties The main idea of asymptotic analysis is to have a measure of the efficiency of algorithms Asymptotic notations are mathematical tools to represent the time complexity of algorithms for asymptotic analysis. There are mainly three asymptotic notations: Big-O Notation (O-notation) Omega Notation ( -notation) Theta Notation ( -notation) 1. Big-O Notation (O-notation): Big-O notation represents the upper bound of the running time of an algorithm. Thus, it provides the worst-case complexity of an algorithm Mathematical Representation of Big-O Notation: If f(n) describes the running time of an algorithm, then f(n) is O(g(n)).if there exist a positive constant C and n0 such that, f(n) c *g(n) for all n n0 Analysis of Algorithms/Unit I/K.Priyanka/AP/CST/SNSCE 7

  8. TOPIC4-Asymptotic Notations and its properties 2. 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. Mathematical Representation of Big-O Notation: Let g and f be the function from the set of natural numbers. The function f is said to be (g(n)), if there is a constant c > 0 and a natural number n0 such that, f(n) c*g(n) for all n n0 Analysis of Algorithms/Unit I/K.Priyanka/AP/CST/SNSCE 8

  9. TOPIC4-Asymptotic Notations and its properties 3. 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. Mathematical Representation of Big-O Notation: Let g and f be the function from the set of natural numbers. The function f is said to be (g(n)), 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 Analysis of Algorithms/Unit I/K.Priyanka/AP/CST/SNSCE 9

  10. TOPIC4-Asymptotic Notations and its properties 1. General Properties: If f(n) is O(g(n)) then a*f(n) is also O(g(n)), where a is a constant. 2. Transitive Properties: If f(n) is O(g(n)) and g(n) is O(h(n)) then f(n) = O(h(n)). 3. Reflexive Properties: If f(n) is given then, f(n) is O(f(n)). 4. Symmetric Properties: If f(n) is (g(n)) then, g(n) is (f(n)). 5. Transpose Symmetric Properties: If f(n) is O(g(n)) (Upper Bound), then g(n) is (f(n)) (Lower Bound) Analysis of Algorithms/Unit I/K.Priyanka/AP/CST/SNSCE 10

  11. TOPIC4-Asymptotic Notations and its properties 6. Some More Properties: 1. If f(n) = O(g(n)) (Upper Bound) and f(n) = (g(n)) (Lower Bound), then f(n) = (g(n)) note: g(n) f(n) g(n) [ since it swings between upper and lower bound and taken as avg bound] 2. If f(n) = O(g(n)) and d(n)=O(e(n)) then f(n) + d(n) = O(max( g(n), e(n) )) 3. If f(n)=O(g(n)) and d(n)=O(e(n)) then f(n) * d(n) = O(g(n) * e(n)) Analysis of Algorithms/Unit I/K.Priyanka/AP/CST/SNSCE 11

  12. 21-10-2024 UNIT IV- ATCD 12/22

Related


More Related Content