SlideShare a Scribd company logo
1 of 26
APPLICATION OF GREEDY METHOD

KRUSKAL’S ALGORITHM TO FIND
MINIMUM
        COST SPANNING TREES
   An algorithm is a mathematical procedure often used to
    solve optimization problems in a finite number of steps.

   Most solution algorithms make choices based on a
    global overview of all current and future possibilities
    aiming at reaching the single global optimum solution.

   Greedy algorithms make choices that look best at that
    every moment.
   When compared to algorithms that guarantee to yield a
    global optimum solution, greedy algorithms have
    several advantages:

   They are easier to implement, they require much less
    computing resources, they are much faster to execute.

   Their only disadvantage being that they do not always
    reach the global optimum solution
    when the global optimum solution is not
    reached, most of the times the reached sub- optimal
    solution is a very good solution.

   Several classical optimization problems like minimum
    spanning tree and optimal prefix codes for data
    compression yield global optimum solutions using
    greedy algorithm.
   A tree T is said to be a spanning tree of a connected
    graph G if T is a subgraph of G and T contains all vertices
    of G.
   Since the vertices of G are barely hanging together in a
    spanning tree, it is a sort of skeleton of the original
    graph g. so, a spanning tree is called a skeleton or
    scaffolding of G.
   Among the spanning trees of G, one with the smallest
    weight is called minimal spanning tree or shortest
    spanning tree or shortest-distance spanning tree.
A second greedy algorithm was developed by Joseph Kruskal.

Steps in Kruskal’s algorithm:
 list all edges of G in order of increasing weight.
 Select a smallest edge of G.
 For each successive step, select (from all remaining
  edges of G) another smallest edge that makes no circuit
 with the previously selected edges.
 Continue until n-1 edges have been selected.
      At each stage, the algorithm chooses an edge
     to add to its current partial solution. To do so, it needs
    to test each candidate edge (u ,v ) to
    see whether the endpoints u and v lie in different
    components; otherwise the edge produces a
    cycle.
5
              A                               B
    4                         6           2

            2                     D               3
C

    3                         1           2
              E                               F
                                      4
        Kruskal's Algorithm
enqueue edges of G in a queue in increasing order of
cost.
T=;
while(queue is not empty)
{
       dequeue an edge e;
       if(e does not create a cycle with edges in T)
       add e to T;
}
return T;
5
              A                               B
    4                         6           2

            2                     D               3
C

    3                         1           2
              E                               F
                                      4
        Kruskal's Algorithm
5
              A                               B
    4                         6           2

            2                     D               3
C

    3                         1           2
              E                               F
                                      4
        Kruskal's Algorithm
5
              A                               B
    4                         6           2

            2                     D               3
C

    3                         1           2
              E                               F
                                      4
        Kruskal's Algorithm
5
              A                               B
    4                         6           2

            2                     D               3
C

    3                         1           2
              E                               F
                                      4
        Kruskal's Algorithm
5
              A                               B
    4                         6           2

            2                     D               3   cycle!!
C

    3                         1           2
              E                               F
                                      4
        Kruskal's Algorithm
5
              A                               B
    4                         6           2

            2                     D               3
C

    3                         1           2
              E                               F
                                      4
        Kruskal's Algorithm
5
              A                               B
    4                         6           2

            2                     D               3
C

    3                         1           2
              E                               F
                                      4
        Kruskal's Algorithm
minimum- spanning tree



                    A                           B
                                            2

                  2                     D
C

        3                           1       2
                    E                           F

              Kruskal's Algorithm
8                   7

             b                   c           d        9
    4

                             2
        11                                       14        e
a                    i               4
                 7           6
                                                      10
    8
             h                   g           f
                         1               2
8                   7
             b                   c               d         9
    4
                             2
a       11                                           14        e
                         i           4
                 7           6
                                                          10
    8
             h                   g               f
                         1                   2




                     8                   7
             b                   c               d        9
    4
                             2
a       11                                           14        e
                     i               4
                 7           6
                                                          10
    8
             h                   g               f
                     1                   2

                                                                   19
8               7
             b               c           d        9
    4
                         2
a       11                                   14        e
                     i           4
                 7       6
                                                  10
    8
             h               g           f
                     1               2



                     8               7
             b               c           d        9
    4
                         2
a       11                                   14        e
                     i           4
                 7       6
                                                  10
    8
             h               g           f
                     1               2

                                                           20
8               7
             b               c           d        9
    4
                         2
a       11                                   14        e
                     i           4
                 7       6
                                                  10
    8
             h               g           f
                     1               2


                     8               7
             b               c           d        9
    4
                         2
a       11                                   14        e
                     i           4
                 7       6
                                                  10
    8
             h               g           f
                     1               2


                                                           21
8               7
             b               c           d        9
    4
                         2
a       11                                   14        e
                     i           4
                 7       6
                                                  10
    8
             h               g           f
                     1               2



                     8               7
             b               c           d        9
    4
                         2
a       11                                   14        e
                     i           4
                 7       6
                                                  10
    8
             h               g           f
                     1               2


                                                           22
8               7
                     b               c           d        9
            4
                                 2
        a       11                                   14        e
                             i           4
                         7       6
                                                          10
            8
                     h               g           f
                             1               2

MINIMAL SPANNING TREEE
                             8               7
                     b               c           d        9
            4
                                 2
        a       11                                   14        e
                             i           4
                         7       6
                                                          10
            8
                     h               g           f
                             1               2


                                                                   23
   Initialization O(V) time
   Sorting the edges Q(E lg E) = Q(E lg V) (why?)
   O(E) calls to FindSet
   Union costs
     Let t(v) – the number of times v is moved to a new
      cluster
     Each time a vertex is moved to a new cluster the size
      of the cluster containing the vertex at least doubles:
      t(v) log V
     Total time spent doing Union vV
                                       t (v)  V log V
   Total time: O(E lg V)
                                                               24
   Where ever the minimum distance is needed to achieve
    there this algorithm gets place.
   For example.
     In telephone lining under the ground, they have to connect all
      the cities with the minimum amount of wire.
     If the new connection is in position to add between cities, there
      we have to consider the minimum cost distance.
     Assume, if the minimum distance is not calculated, the wastage
      of wires will be in peak.
   Railways track construction.
   National highway construction.
   Flyover bridge construction.
   Network between two intranets.
   The another non-technical example will be as,
     The by-pass rider or point to point buses will move on with the
      minimum distance path to reach the destination much faster.
      They will never circulate their bus through unwanted towns and
      villages.

More Related Content

What's hot

Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of AlgorithmsBulbul Agrawal
 
Artificial Intelligence -- Search Algorithms
Artificial Intelligence-- Search Algorithms Artificial Intelligence-- Search Algorithms
Artificial Intelligence -- Search Algorithms Syed Ahmed
 
K means clustering
K means clusteringK means clustering
K means clusteringkeshav goyal
 
K mean-clustering algorithm
K mean-clustering algorithmK mean-clustering algorithm
K mean-clustering algorithmparry prabhu
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithmsana younas
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 
Problem solving agents
Problem solving agentsProblem solving agents
Problem solving agentsMegha Sharma
 
Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligencesandeep54552
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithmsRajendran
 
Advance OOP concepts in Python
Advance OOP concepts in PythonAdvance OOP concepts in Python
Advance OOP concepts in PythonSujith Kumar
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search StrategiesAmey Kerkar
 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMvikas dhakane
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principlesdeonpmeyer
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's AlgorithmTanmay Baranwal
 

What's hot (20)

Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
 
Artificial Intelligence -- Search Algorithms
Artificial Intelligence-- Search Algorithms Artificial Intelligence-- Search Algorithms
Artificial Intelligence -- Search Algorithms
 
Dynamic method dispatch
Dynamic method dispatchDynamic method dispatch
Dynamic method dispatch
 
A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
 
K means clustering
K means clusteringK means clustering
K means clustering
 
K mean-clustering algorithm
K mean-clustering algorithmK mean-clustering algorithm
K mean-clustering algorithm
 
Backtracking
Backtracking  Backtracking
Backtracking
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithm
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Problem solving agents
Problem solving agentsProblem solving agents
Problem solving agents
 
Np hard
Np hardNp hard
Np hard
 
Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligence
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Advance OOP concepts in Python
Advance OOP concepts in PythonAdvance OOP concepts in Python
Advance OOP concepts in Python
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search Strategies
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
 
Knapsack problem using fixed tuple
Knapsack problem using fixed tupleKnapsack problem using fixed tuple
Knapsack problem using fixed tuple
 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHM
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
 

More from Tech_MX

Virtual base class
Virtual base classVirtual base class
Virtual base classTech_MX
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimationTech_MX
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
String & its application
String & its applicationString & its application
String & its applicationTech_MX
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structureTech_MX
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application Tech_MX
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applicationsTech_MX
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2Tech_MX
 
Set data structure
Set data structure Set data structure
Set data structure Tech_MX
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating SystemTech_MX
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Tech_MX
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pcTech_MX
 
More on Lex
More on LexMore on Lex
More on LexTech_MX
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbmsTech_MX
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)Tech_MX
 
Memory dbms
Memory dbmsMemory dbms
Memory dbmsTech_MX
 

More from Tech_MX (20)

Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Uid
UidUid
Uid
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
String & its application
String & its applicationString & its application
String & its application
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
 
Spss
SpssSpss
Spss
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
 
Set data structure
Set data structure Set data structure
Set data structure
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Parsing
ParsingParsing
Parsing
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
 
More on Lex
More on LexMore on Lex
More on Lex
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 

Application of greedy method

  • 1. APPLICATION OF GREEDY METHOD KRUSKAL’S ALGORITHM TO FIND MINIMUM COST SPANNING TREES
  • 2. An algorithm is a mathematical procedure often used to solve optimization problems in a finite number of steps.  Most solution algorithms make choices based on a global overview of all current and future possibilities aiming at reaching the single global optimum solution.  Greedy algorithms make choices that look best at that every moment.
  • 3. When compared to algorithms that guarantee to yield a global optimum solution, greedy algorithms have several advantages:  They are easier to implement, they require much less computing resources, they are much faster to execute.  Their only disadvantage being that they do not always reach the global optimum solution
  • 4. when the global optimum solution is not reached, most of the times the reached sub- optimal solution is a very good solution.  Several classical optimization problems like minimum spanning tree and optimal prefix codes for data compression yield global optimum solutions using greedy algorithm.
  • 5. A tree T is said to be a spanning tree of a connected graph G if T is a subgraph of G and T contains all vertices of G.  Since the vertices of G are barely hanging together in a spanning tree, it is a sort of skeleton of the original graph g. so, a spanning tree is called a skeleton or scaffolding of G.  Among the spanning trees of G, one with the smallest weight is called minimal spanning tree or shortest spanning tree or shortest-distance spanning tree.
  • 6. A second greedy algorithm was developed by Joseph Kruskal. Steps in Kruskal’s algorithm:  list all edges of G in order of increasing weight.  Select a smallest edge of G.  For each successive step, select (from all remaining edges of G) another smallest edge that makes no circuit  with the previously selected edges.  Continue until n-1 edges have been selected.
  • 7. At each stage, the algorithm chooses an edge to add to its current partial solution. To do so, it needs to test each candidate edge (u ,v ) to see whether the endpoints u and v lie in different components; otherwise the edge produces a cycle.
  • 8. 5 A B 4 6 2 2 D 3 C 3 1 2 E F 4 Kruskal's Algorithm
  • 9. enqueue edges of G in a queue in increasing order of cost. T=; while(queue is not empty) { dequeue an edge e; if(e does not create a cycle with edges in T) add e to T; } return T;
  • 10. 5 A B 4 6 2 2 D 3 C 3 1 2 E F 4 Kruskal's Algorithm
  • 11. 5 A B 4 6 2 2 D 3 C 3 1 2 E F 4 Kruskal's Algorithm
  • 12. 5 A B 4 6 2 2 D 3 C 3 1 2 E F 4 Kruskal's Algorithm
  • 13. 5 A B 4 6 2 2 D 3 C 3 1 2 E F 4 Kruskal's Algorithm
  • 14. 5 A B 4 6 2 2 D 3 cycle!! C 3 1 2 E F 4 Kruskal's Algorithm
  • 15. 5 A B 4 6 2 2 D 3 C 3 1 2 E F 4 Kruskal's Algorithm
  • 16. 5 A B 4 6 2 2 D 3 C 3 1 2 E F 4 Kruskal's Algorithm
  • 17. minimum- spanning tree A B 2 2 D C 3 1 2 E F Kruskal's Algorithm
  • 18. 8 7 b c d 9 4 2 11 14 e a i 4 7 6 10 8 h g f 1 2
  • 19. 8 7 b c d 9 4 2 a 11 14 e i 4 7 6 10 8 h g f 1 2 8 7 b c d 9 4 2 a 11 14 e i 4 7 6 10 8 h g f 1 2 19
  • 20. 8 7 b c d 9 4 2 a 11 14 e i 4 7 6 10 8 h g f 1 2 8 7 b c d 9 4 2 a 11 14 e i 4 7 6 10 8 h g f 1 2 20
  • 21. 8 7 b c d 9 4 2 a 11 14 e i 4 7 6 10 8 h g f 1 2 8 7 b c d 9 4 2 a 11 14 e i 4 7 6 10 8 h g f 1 2 21
  • 22. 8 7 b c d 9 4 2 a 11 14 e i 4 7 6 10 8 h g f 1 2 8 7 b c d 9 4 2 a 11 14 e i 4 7 6 10 8 h g f 1 2 22
  • 23. 8 7 b c d 9 4 2 a 11 14 e i 4 7 6 10 8 h g f 1 2 MINIMAL SPANNING TREEE 8 7 b c d 9 4 2 a 11 14 e i 4 7 6 10 8 h g f 1 2 23
  • 24. Initialization O(V) time  Sorting the edges Q(E lg E) = Q(E lg V) (why?)  O(E) calls to FindSet  Union costs  Let t(v) – the number of times v is moved to a new cluster  Each time a vertex is moved to a new cluster the size of the cluster containing the vertex at least doubles: t(v) log V  Total time spent doing Union vV  t (v)  V log V  Total time: O(E lg V) 24
  • 25. Where ever the minimum distance is needed to achieve there this algorithm gets place.  For example.  In telephone lining under the ground, they have to connect all the cities with the minimum amount of wire.  If the new connection is in position to add between cities, there we have to consider the minimum cost distance.  Assume, if the minimum distance is not calculated, the wastage of wires will be in peak.
  • 26. Railways track construction.  National highway construction.  Flyover bridge construction.  Network between two intranets.  The another non-technical example will be as,  The by-pass rider or point to point buses will move on with the minimum distance path to reach the destination much faster. They will never circulate their bus through unwanted towns and villages.