SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Review
Overview
Fundamentals of Analysis of Algorithm Efficiency
Algorithmic Techniques
  Divide-and-Conquer, Decrease-and-Conquer
  Dynamic Programming
  Greedy Technique
Data Structures
  Heaps
  Graphs– adjacency matrices & adjacency linked lists
  Trees




                                                        2
Fundamentals of Analysis of
      Algorithm Efficiency
Basic operations
Worst-, Best-, and Average-case time
efficiencies
Orders of growth
Efficiency of non-recursive algorithms
Efficiency of recursive algorithms


                                         3
Worst-Case, Best-Case, and
       Average-Case Efficiency
Worst case efficiency
  Efficiency (# of times the basic operation will be executed) for the
  worst case input of size n, for which
  The algorithm runs the longest among all possible inputs of size n.
Best case
  Efficiency (# of times the basic operation will be executed) for the
  best case input of size n, for which
  The algorithm runs the fastest among all possible inputs of size n.
Average case:
  Efficiency (#of times the basic operation will be executed) for a
  typical/random input
  NOT the average of worst and best case
  How to find the average case efficiency?                            4
Orders of Growth
Three notations used to compare orders of
growth of algorithms
  O(g(n)): class of functions f(n) that grow no
  faster than g(n)
  Θ (g(n)): class of functions f(n) that grow at
  same rate as g(n)
  Ω(g(n)): class of functions f(n) that grow at least
  as fast as g(n)

                                                  5
Theorem
 If t1(n) ∈ O(g1(n)) and t2(n) ∈ O(g2(n)), then
 t1(n) + t2(n) ∈ O(max{g1(n), g2(n)}).
 The analogous assertions are true for the Ω-
 notation and Θ-notation.
 The algorithm’s overall efficiency will be
 determined by the part with a larger order of
 growth.
   5n2 + 3n + 4


                                             6
Using Limits for Comparing Orders of
                   Growth

                      0       order of growth of T(n)    <       order of growth of g(n)


                      c>0       order of growth of T(n)      =    order of growth of g(n)
limn→∞ T(n)/g(n) =
                          ∞    order of growth of T(n)       >   order of growth of g(n)


   Examples:
   • 10n        vs.               2n2

   • n(n+1)/2   vs.               n2

   • logb n     vs.              logc n
                                                                                      7
Summary of How to Establish Orders of
      Growth of an Algorithm

Method 1: Using limits.
Method 2: Using the theorem.
Method 3: Using the definitions of O-,
Ω-, and Θ-notation.




                                         8
Basic Efficiency classes
fast
             1         constant    High time efficiency

           log n     logarithmic
             n           linear
           n log n      n log n
              n2      quadratic
              n3         cubic
             2n      exponential
slow
             n!        factorial   low time efficiency
                                                  9
Time Efficiency Analysis of Nonrecursive
Algorithms

Steps in mathematical analysis of nonrecursive algorithms:
  Decide on parameter n indicating input size

  Identify algorithm’s basic operation

  Determine worst, average, and best case for input of size n

  Set up summation for C(n) reflecting the number of times the
  algorithm’s basic operation is executed.

  Simplify summation using standard formulas (see Appendix A)



                                                                 10
Time Efficiency Analysis of Recursive
                 Algorithms
Decide on parameter n indicating input size

Identify algorithm’s basic operation

Determine worst, average, and best case for input of size n

Set up a recurrence relation and initial condition(s) for C(n)-the
number of times the basic operation will be executed for an
input of size n (alternatively count recursive calls).

Solve the recurrence or estimate the order of magnitude of the
solution (see Appendix B)

                                                                11
Master’s Theorem

T(n) = aT(n/b) + f (n)    where f (n) ∈ Θ(nk)
1. a < bk         T(n) ∈ Θ(nk)
2. a = bk         T(n) ∈ Θ(nk lg n )
3. a > bk         T(n) ∈ Θ(nlog b a)
Note: the same results hold with O instead of Θ.




                                               12
Divide-and-Conquer
Three Steps of The Divide and
Conquer Approach
The most well known algorithm design strategy:
1. Divide the problem into two or more smaller
   subproblems.

2.   Conquer the subproblems by solving them
     recursively(or recursively).

3.   Combine the solutions to the subproblems
     into the solutions for the original problem.

                                                    14
Divide-and-Conquer Technique
                  a problem of size n



 subproblem 1                            subproblem 2
   of size n/2                             of size n/2



  a solution to                           a solution to
 subproblem 1                            subproblem 2




                      a solution to
                  the original problem                    15
Divide and Conquer Examples
Sorting algorithms
   Mergesort
       In-place?
       Worst-case efficiency?
   Quicksort
       In-place?
       Worst-case , best-case and average-case efficiency?
Binary Tree algorithms
    Definitions
       What is a binary tree?
       A node’s/tree’s height?
       A node’s level?
   Pre-order, post-order, and in-order traversal
   Find the height
   Find the total number of leaves.
   …


                                                             16
Decrease-and-Conquer
Decrease and Conquer
 Exploring the relationship between a solution
 to a given instance of a problem and a
 solution to a smaller instance of the same
 problem.
 Use top down(recursive) or bottom up
 (iterative) to solve the problem.
 Example, an
   A top down (recursive) solution
   A bottom up (iterative) solution


                                            18
Examples of Decrease and Conquer
Decrease by one: the size of the problem is reduced by the same
constant on each iteration/recursion of the algorithm.
   Insertion sort
       In-place?
       Worst-case , best-case and average-case efficiency?
   Graph search algorithms:
      DFS
      BFS

Decrease by a constant factor: the size of the problem is reduced by
the same constant factor on each iteration/recursion of the algorithm.




                                                                  19
A Typical Decrease by One Technique

                     a problem of size n



  subproblem
    of size n-1



 a solution to the
  subproblem




                         a solution to
                     the original problem   20
A Typical Decrease by a Constant Factor
            (half) Technique

                    a problem of size n



 subproblem
   of size n/2



a solution to the
  subproblem




                        a solution to
                    the original problem   21
What’s the Difference?
Consider the problem of exponentiation:
  Compute an
  Divide and conquer:
   an= an/2 * an/2
  Decrease by one:
   an= an-1* a (top down)   an= a*a*a*a*...*a (bottom up)
  Decrease by a constant factor:
   an= (an/2)2


                                                     22
Depth-First Search
The idea
   traverse “deeper” whenever possible.
   When reaching a dead end, the algorithm backs up one edge to the
   parent and tries to continue visiting unvisited vertices from there.
   Break the tie by the alphabetic order of the vertices
   It’s convenient to use a stack to track the operation of depth-first
   search.
DFS forest/tree and the two orderings of DFS
DFS can be implemented with graphs represented as:
   Adjacency matrices: Θ(V2)
   Adjacency linked lists: Θ(V+E)
Applications:
   Topological sorting
   checking connectivity, finding connected components

                                                                   23
Breadth-First Search
The idea
   Traverse “wider” whenever possible.
   Discover all vertices at distance k from s (on level k) before
   discovering any vertices at distance k +1 (at level k+1)
   Similar to level-by-level tree traversals
   It’s convenient to use a queue to track the operation of
   depth-first search.
BFS forest/tree and the one ordering of BFS
BFS has same efficiency as DFS and can be
implemented with graphs represented as:
   Adjacency matrices: Θ(V2)
   Adjacency linked lists: Θ(V+E)
Applications:
   checking connectivity, finding connected components          24
Heapsort
Heaps
 Definition
 Representation
 Properties
 Heap algorithms
   Heap construction
     Top-down
     Bottom-up
   Root deletion
   Heapsort
     In-place?
     Time efficiency?
                        26
Examples of Dynamic Programming
             Algorithms

Main idea:
    solve several smaller (overlapping) subproblems
    record solutions in a table so that each subproblem is only
  solved once
    final state of the table will be (or contain) solution

VS. Divide and Conquer

Computing binomial coefficients

Warshall’s algorithm for transitive closure

Floyd’s algorithms for all-pairs shortest paths
                                                                  27
Greedy Algorithms
Greedy algorithms
Constructs a solution through a sequence of steps, each expanding
  a partially constructed solution obtained so far, until a complete
  solution to the problem is reached. The choice made at each step
  must be:
   Feasible
      Satisfy the problem’s constraints
   locally optimal
      Be the best local choice among all feasible choices
   Irrevocable
      Once made, the choice can’t be changed on subsequent
      steps.
Greedy algorithms do not always yield optimal solutions.

                                                                29
Examples of the Greedy Strategy
Minimum Spanning Tree (MST)
  Definition of spanning tree and MST
  Prim’s algorithm
  Kruskal’s algorithm
Single-source shortest paths
  Dijkstra’s algorithm




                                        30
P, NP, and NP-Complete Problems
 Tractable and intractable problems
 The class P
 The class NP
 The relationship between P and NP
 NP-complete problems



                                      31
Backtracking and Branch-and-Bound
 They guarantees solving the problem exactly
 but doesn’t guarantee to find a solution in
 polynomial time.

 Similarity and difference between
 backtracking and branch-and-bound




                                          32

Weitere ähnliche Inhalte

Was ist angesagt?

Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103Sure Interview
 
Graph Traversal Algorithms - Breadth First Search
Graph Traversal Algorithms - Breadth First SearchGraph Traversal Algorithms - Breadth First Search
Graph Traversal Algorithms - Breadth First SearchAmrinder Arora
 
R exam (B) given in Paris-Dauphine, Licence Mido, Jan. 11, 2013
R exam (B) given in Paris-Dauphine, Licence Mido, Jan. 11, 2013R exam (B) given in Paris-Dauphine, Licence Mido, Jan. 11, 2013
R exam (B) given in Paris-Dauphine, Licence Mido, Jan. 11, 2013Christian Robert
 
Algorithm chapter 11
Algorithm chapter 11Algorithm chapter 11
Algorithm chapter 11chidabdu
 
Branch and bound technique
Branch and bound techniqueBranch and bound technique
Branch and bound techniqueishmecse13
 
design and analysis of algorithm
design and analysis of algorithmdesign and analysis of algorithm
design and analysis of algorithmMuhammad Arish
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1Dynamic Programming - Part 1
Dynamic Programming - Part 1Amrinder Arora
 

Was ist angesagt? (20)

Np cooks theorem
Np cooks theoremNp cooks theorem
Np cooks theorem
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103
 
Graph Traversal Algorithms - Breadth First Search
Graph Traversal Algorithms - Breadth First SearchGraph Traversal Algorithms - Breadth First Search
Graph Traversal Algorithms - Breadth First Search
 
R exam (B) given in Paris-Dauphine, Licence Mido, Jan. 11, 2013
R exam (B) given in Paris-Dauphine, Licence Mido, Jan. 11, 2013R exam (B) given in Paris-Dauphine, Licence Mido, Jan. 11, 2013
R exam (B) given in Paris-Dauphine, Licence Mido, Jan. 11, 2013
 
algorithm Unit 2
algorithm Unit 2 algorithm Unit 2
algorithm Unit 2
 
Bq25399403
Bq25399403Bq25399403
Bq25399403
 
Algorithm chapter 11
Algorithm chapter 11Algorithm chapter 11
Algorithm chapter 11
 
Joco pavone
Joco pavoneJoco pavone
Joco pavone
 
Daa chapter6
Daa chapter6Daa chapter6
Daa chapter6
 
Ch10 Recursion
Ch10 RecursionCh10 Recursion
Ch10 Recursion
 
Unit 7 dynamic programming
Unit 7   dynamic programmingUnit 7   dynamic programming
Unit 7 dynamic programming
 
Data Structure and Algorithm - Divide and Conquer
Data Structure and Algorithm - Divide and ConquerData Structure and Algorithm - Divide and Conquer
Data Structure and Algorithm - Divide and Conquer
 
Branch and bound technique
Branch and bound techniqueBranch and bound technique
Branch and bound technique
 
design and analysis of algorithm
design and analysis of algorithmdesign and analysis of algorithm
design and analysis of algorithm
 
Recursion
RecursionRecursion
Recursion
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1Dynamic Programming - Part 1
Dynamic Programming - Part 1
 
NP Complete Problems in Graph Theory
NP Complete Problems in Graph TheoryNP Complete Problems in Graph Theory
NP Complete Problems in Graph Theory
 
Chapter 2 ds
Chapter 2 dsChapter 2 ds
Chapter 2 ds
 
NP Complete Problems -- Internship
NP Complete Problems -- InternshipNP Complete Problems -- Internship
NP Complete Problems -- Internship
 
Approx
ApproxApprox
Approx
 

Ähnlich wie Algorithm review

Sienna 13 limitations
Sienna 13 limitationsSienna 13 limitations
Sienna 13 limitationschidabdu
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2chidabdu
 
Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notesProf. Dr. K. Adisesha
 
lecture 1
lecture 1lecture 1
lecture 1sajinsc
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting classgiridaroori
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyappasami
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Deepak John
 
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfCS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfOpenWorld6
 
Jörg Stelzer
Jörg StelzerJörg Stelzer
Jörg Stelzerbutest
 
Lecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesLecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesjayavignesh86
 
Algorithm chapter 5
Algorithm chapter 5Algorithm chapter 5
Algorithm chapter 5chidabdu
 
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationGeoffrey Fox
 
4optmizationtechniques-150308051251-conversion-gate01.pdf
4optmizationtechniques-150308051251-conversion-gate01.pdf4optmizationtechniques-150308051251-conversion-gate01.pdf
4optmizationtechniques-150308051251-conversion-gate01.pdfBechanYadav4
 

Ähnlich wie Algorithm review (20)

Sienna 13 limitations
Sienna 13 limitationsSienna 13 limitations
Sienna 13 limitations
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
 
Unit7
Unit7Unit7
Unit7
 
Unit 5
Unit 5Unit 5
Unit 5
 
Unit 5
Unit 5Unit 5
Unit 5
 
Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notes
 
lecture 1
lecture 1lecture 1
lecture 1
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
Slide2
Slide2Slide2
Slide2
 
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfCS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
 
Jörg Stelzer
Jörg StelzerJörg Stelzer
Jörg Stelzer
 
algo_vc_lecture8.ppt
algo_vc_lecture8.pptalgo_vc_lecture8.ppt
algo_vc_lecture8.ppt
 
Lecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesLecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrences
 
Algorithm chapter 5
Algorithm chapter 5Algorithm chapter 5
Algorithm chapter 5
 
Unit 1
Unit 1Unit 1
Unit 1
 
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel application
 
analysis.ppt
analysis.pptanalysis.ppt
analysis.ppt
 
4optmizationtechniques-150308051251-conversion-gate01.pdf
4optmizationtechniques-150308051251-conversion-gate01.pdf4optmizationtechniques-150308051251-conversion-gate01.pdf
4optmizationtechniques-150308051251-conversion-gate01.pdf
 

Mehr von chidabdu

Sienna 12 huffman
Sienna 12 huffmanSienna 12 huffman
Sienna 12 huffmanchidabdu
 
Sienna 11 graphs
Sienna 11 graphsSienna 11 graphs
Sienna 11 graphschidabdu
 
Sienna 10 dynamic
Sienna 10 dynamicSienna 10 dynamic
Sienna 10 dynamicchidabdu
 
Sienna 9 hashing
Sienna 9 hashingSienna 9 hashing
Sienna 9 hashingchidabdu
 
Sienna 8 countingsorts
Sienna 8 countingsortsSienna 8 countingsorts
Sienna 8 countingsortschidabdu
 
Sienna 7 heaps
Sienna 7 heapsSienna 7 heaps
Sienna 7 heapschidabdu
 
Sienna 6 bst
Sienna 6 bstSienna 6 bst
Sienna 6 bstchidabdu
 
Sienna 5 decreaseandconquer
Sienna 5 decreaseandconquerSienna 5 decreaseandconquer
Sienna 5 decreaseandconquerchidabdu
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquerchidabdu
 
Sienna 3 bruteforce
Sienna 3 bruteforceSienna 3 bruteforce
Sienna 3 bruteforcechidabdu
 
Sienna 2 analysis
Sienna 2 analysisSienna 2 analysis
Sienna 2 analysischidabdu
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 introchidabdu
 
Unit 3 basic processing unit
Unit 3   basic processing unitUnit 3   basic processing unit
Unit 3 basic processing unitchidabdu
 
Unit 5 I/O organization
Unit 5   I/O organizationUnit 5   I/O organization
Unit 5 I/O organizationchidabdu
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10chidabdu
 
Algorithm chapter 9
Algorithm chapter 9Algorithm chapter 9
Algorithm chapter 9chidabdu
 
Algorithm chapter 8
Algorithm chapter 8Algorithm chapter 8
Algorithm chapter 8chidabdu
 
Algorithm chapter 7
Algorithm chapter 7Algorithm chapter 7
Algorithm chapter 7chidabdu
 
Algorithm chapter 6
Algorithm chapter 6Algorithm chapter 6
Algorithm chapter 6chidabdu
 
Unit 2 arithmetics
Unit 2   arithmeticsUnit 2   arithmetics
Unit 2 arithmeticschidabdu
 

Mehr von chidabdu (20)

Sienna 12 huffman
Sienna 12 huffmanSienna 12 huffman
Sienna 12 huffman
 
Sienna 11 graphs
Sienna 11 graphsSienna 11 graphs
Sienna 11 graphs
 
Sienna 10 dynamic
Sienna 10 dynamicSienna 10 dynamic
Sienna 10 dynamic
 
Sienna 9 hashing
Sienna 9 hashingSienna 9 hashing
Sienna 9 hashing
 
Sienna 8 countingsorts
Sienna 8 countingsortsSienna 8 countingsorts
Sienna 8 countingsorts
 
Sienna 7 heaps
Sienna 7 heapsSienna 7 heaps
Sienna 7 heaps
 
Sienna 6 bst
Sienna 6 bstSienna 6 bst
Sienna 6 bst
 
Sienna 5 decreaseandconquer
Sienna 5 decreaseandconquerSienna 5 decreaseandconquer
Sienna 5 decreaseandconquer
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquer
 
Sienna 3 bruteforce
Sienna 3 bruteforceSienna 3 bruteforce
Sienna 3 bruteforce
 
Sienna 2 analysis
Sienna 2 analysisSienna 2 analysis
Sienna 2 analysis
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 intro
 
Unit 3 basic processing unit
Unit 3   basic processing unitUnit 3   basic processing unit
Unit 3 basic processing unit
 
Unit 5 I/O organization
Unit 5   I/O organizationUnit 5   I/O organization
Unit 5 I/O organization
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10
 
Algorithm chapter 9
Algorithm chapter 9Algorithm chapter 9
Algorithm chapter 9
 
Algorithm chapter 8
Algorithm chapter 8Algorithm chapter 8
Algorithm chapter 8
 
Algorithm chapter 7
Algorithm chapter 7Algorithm chapter 7
Algorithm chapter 7
 
Algorithm chapter 6
Algorithm chapter 6Algorithm chapter 6
Algorithm chapter 6
 
Unit 2 arithmetics
Unit 2   arithmeticsUnit 2   arithmetics
Unit 2 arithmetics
 

Kürzlich hochgeladen

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Kürzlich hochgeladen (20)

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

Algorithm review

  • 2. Overview Fundamentals of Analysis of Algorithm Efficiency Algorithmic Techniques Divide-and-Conquer, Decrease-and-Conquer Dynamic Programming Greedy Technique Data Structures Heaps Graphs– adjacency matrices & adjacency linked lists Trees 2
  • 3. Fundamentals of Analysis of Algorithm Efficiency Basic operations Worst-, Best-, and Average-case time efficiencies Orders of growth Efficiency of non-recursive algorithms Efficiency of recursive algorithms 3
  • 4. Worst-Case, Best-Case, and Average-Case Efficiency Worst case efficiency Efficiency (# of times the basic operation will be executed) for the worst case input of size n, for which The algorithm runs the longest among all possible inputs of size n. Best case Efficiency (# of times the basic operation will be executed) for the best case input of size n, for which The algorithm runs the fastest among all possible inputs of size n. Average case: Efficiency (#of times the basic operation will be executed) for a typical/random input NOT the average of worst and best case How to find the average case efficiency? 4
  • 5. Orders of Growth Three notations used to compare orders of growth of algorithms O(g(n)): class of functions f(n) that grow no faster than g(n) Θ (g(n)): class of functions f(n) that grow at same rate as g(n) Ω(g(n)): class of functions f(n) that grow at least as fast as g(n) 5
  • 6. Theorem If t1(n) ∈ O(g1(n)) and t2(n) ∈ O(g2(n)), then t1(n) + t2(n) ∈ O(max{g1(n), g2(n)}). The analogous assertions are true for the Ω- notation and Θ-notation. The algorithm’s overall efficiency will be determined by the part with a larger order of growth. 5n2 + 3n + 4 6
  • 7. Using Limits for Comparing Orders of Growth 0 order of growth of T(n) < order of growth of g(n) c>0 order of growth of T(n) = order of growth of g(n) limn→∞ T(n)/g(n) = ∞ order of growth of T(n) > order of growth of g(n) Examples: • 10n vs. 2n2 • n(n+1)/2 vs. n2 • logb n vs. logc n 7
  • 8. Summary of How to Establish Orders of Growth of an Algorithm Method 1: Using limits. Method 2: Using the theorem. Method 3: Using the definitions of O-, Ω-, and Θ-notation. 8
  • 9. Basic Efficiency classes fast 1 constant High time efficiency log n logarithmic n linear n log n n log n n2 quadratic n3 cubic 2n exponential slow n! factorial low time efficiency 9
  • 10. Time Efficiency Analysis of Nonrecursive Algorithms Steps in mathematical analysis of nonrecursive algorithms: Decide on parameter n indicating input size Identify algorithm’s basic operation Determine worst, average, and best case for input of size n Set up summation for C(n) reflecting the number of times the algorithm’s basic operation is executed. Simplify summation using standard formulas (see Appendix A) 10
  • 11. Time Efficiency Analysis of Recursive Algorithms Decide on parameter n indicating input size Identify algorithm’s basic operation Determine worst, average, and best case for input of size n Set up a recurrence relation and initial condition(s) for C(n)-the number of times the basic operation will be executed for an input of size n (alternatively count recursive calls). Solve the recurrence or estimate the order of magnitude of the solution (see Appendix B) 11
  • 12. Master’s Theorem T(n) = aT(n/b) + f (n) where f (n) ∈ Θ(nk) 1. a < bk T(n) ∈ Θ(nk) 2. a = bk T(n) ∈ Θ(nk lg n ) 3. a > bk T(n) ∈ Θ(nlog b a) Note: the same results hold with O instead of Θ. 12
  • 14. Three Steps of The Divide and Conquer Approach The most well known algorithm design strategy: 1. Divide the problem into two or more smaller subproblems. 2. Conquer the subproblems by solving them recursively(or recursively). 3. Combine the solutions to the subproblems into the solutions for the original problem. 14
  • 15. Divide-and-Conquer Technique a problem of size n subproblem 1 subproblem 2 of size n/2 of size n/2 a solution to a solution to subproblem 1 subproblem 2 a solution to the original problem 15
  • 16. Divide and Conquer Examples Sorting algorithms Mergesort In-place? Worst-case efficiency? Quicksort In-place? Worst-case , best-case and average-case efficiency? Binary Tree algorithms Definitions What is a binary tree? A node’s/tree’s height? A node’s level? Pre-order, post-order, and in-order traversal Find the height Find the total number of leaves. … 16
  • 18. Decrease and Conquer Exploring the relationship between a solution to a given instance of a problem and a solution to a smaller instance of the same problem. Use top down(recursive) or bottom up (iterative) to solve the problem. Example, an A top down (recursive) solution A bottom up (iterative) solution 18
  • 19. Examples of Decrease and Conquer Decrease by one: the size of the problem is reduced by the same constant on each iteration/recursion of the algorithm. Insertion sort In-place? Worst-case , best-case and average-case efficiency? Graph search algorithms: DFS BFS Decrease by a constant factor: the size of the problem is reduced by the same constant factor on each iteration/recursion of the algorithm. 19
  • 20. A Typical Decrease by One Technique a problem of size n subproblem of size n-1 a solution to the subproblem a solution to the original problem 20
  • 21. A Typical Decrease by a Constant Factor (half) Technique a problem of size n subproblem of size n/2 a solution to the subproblem a solution to the original problem 21
  • 22. What’s the Difference? Consider the problem of exponentiation: Compute an Divide and conquer: an= an/2 * an/2 Decrease by one: an= an-1* a (top down) an= a*a*a*a*...*a (bottom up) Decrease by a constant factor: an= (an/2)2 22
  • 23. Depth-First Search The idea traverse “deeper” whenever possible. When reaching a dead end, the algorithm backs up one edge to the parent and tries to continue visiting unvisited vertices from there. Break the tie by the alphabetic order of the vertices It’s convenient to use a stack to track the operation of depth-first search. DFS forest/tree and the two orderings of DFS DFS can be implemented with graphs represented as: Adjacency matrices: Θ(V2) Adjacency linked lists: Θ(V+E) Applications: Topological sorting checking connectivity, finding connected components 23
  • 24. Breadth-First Search The idea Traverse “wider” whenever possible. Discover all vertices at distance k from s (on level k) before discovering any vertices at distance k +1 (at level k+1) Similar to level-by-level tree traversals It’s convenient to use a queue to track the operation of depth-first search. BFS forest/tree and the one ordering of BFS BFS has same efficiency as DFS and can be implemented with graphs represented as: Adjacency matrices: Θ(V2) Adjacency linked lists: Θ(V+E) Applications: checking connectivity, finding connected components 24
  • 26. Heaps Definition Representation Properties Heap algorithms Heap construction Top-down Bottom-up Root deletion Heapsort In-place? Time efficiency? 26
  • 27. Examples of Dynamic Programming Algorithms Main idea: solve several smaller (overlapping) subproblems record solutions in a table so that each subproblem is only solved once final state of the table will be (or contain) solution VS. Divide and Conquer Computing binomial coefficients Warshall’s algorithm for transitive closure Floyd’s algorithms for all-pairs shortest paths 27
  • 29. Greedy algorithms Constructs a solution through a sequence of steps, each expanding a partially constructed solution obtained so far, until a complete solution to the problem is reached. The choice made at each step must be: Feasible Satisfy the problem’s constraints locally optimal Be the best local choice among all feasible choices Irrevocable Once made, the choice can’t be changed on subsequent steps. Greedy algorithms do not always yield optimal solutions. 29
  • 30. Examples of the Greedy Strategy Minimum Spanning Tree (MST) Definition of spanning tree and MST Prim’s algorithm Kruskal’s algorithm Single-source shortest paths Dijkstra’s algorithm 30
  • 31. P, NP, and NP-Complete Problems Tractable and intractable problems The class P The class NP The relationship between P and NP NP-complete problems 31
  • 32. Backtracking and Branch-and-Bound They guarantees solving the problem exactly but doesn’t guarantee to find a solution in polynomial time. Similarity and difference between backtracking and branch-and-bound 32