SlideShare a Scribd company logo
4
Most read
5
Most read
9
Most read
Find  operation and smart union algorithm
 A union-find algorithm is an algorithm that
perform two useful operation they are..,
 Find:
 determine which subset a particular element is in
.this can be used for determining if two elements
are in the same subset
 Union:
 join two subset into a single subset.
 Union-find algorithm:
 Can be used to check whether an undirected graphs
contain cycle or not.
 Introduction
 Disjoint-set/union-find forest
 Disjoint set operation
 Disjoint set optimised
 Union by rank
 Two set of union
 Pseudo code
 A disjoint –set data structure is also called a
union-find data structure or merge-find set is a
data structure that stores a collection of disjoint
set
 It stores a *partition of a set into disjoint subset
 It provides operation for adding new set,
merging set and finding a representative
members of a set.
 The last operation allows to find out efficiently if
any two elements are in the same or different
set.
 Type : multiway tree
 invented : 1964
 Invented by : Michael j. Fischer
 Make set(x)
 Find(x)
 Union(x , y)
 Disjoint set is optimised by two main types
they are:
 Union by rank
 Path by compression
 User find to determine the roots of the trees x
and y belongs to
 If the roots are distinct the tree are combined
by attaching the root of one to the root of the
other
 If this is done naively such as by always
making x a child of y, the height of the tree
can grow as o(n).we can optimized it by using
union by rank
 Union by rank always attaches the shorter
tree to the root of the taller tree
 To implement union by rank , each element is
associated with a rank.
 Initially a set has one element and a rank of
zero.
 Union have a two set they are:
 Both trees have the same rank-the resulting set’s
rank is one longer.
 Both trees have the different rank-the resulting
set’s rank is larger of the two.
 Rank are used instead of height or depth
because path compression will change the
tress's height over time.
 Function union(x , y)
xroot:=find(x)
yroot:=find(y)
//x and y are not in same set , so
If xroot.rank< yroot.rank
xroot.parent:=yroot
Else if xroot.rank> yroot.rank
yroot. Parent:= xroot
Else
xroot.parent:=yroot
yroot.rank:=yroot.rank+1.
Thank you..☺️

More Related Content

What's hot (20)

DOC
Branch and bound
Nv Thejaswini
 
PPTX
Boyer moore algorithm
AYESHA JAVED
 
PPT
Stacks & Queues By Ms. Niti Arora
kulachihansraj
 
PDF
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
PPT
3.5 model based clustering
Krish_ver2
 
PPT
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
PPTX
Linked List
Ashim Lamichhane
 
PPTX
Looping Statements and Control Statements in Python
PriyankaC44
 
PPTX
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
PPTX
Data structure - Graph
Madhu Bala
 
PPT
pre processor directives in C
Sahithi Naraparaju
 
PPT
Multidimensional array in C
Smit Parikh
 
PPT
recursive transition_networks
Rajendran
 
PPT
Complexity of Algorithm
Muhammad Muzammal
 
PPTX
queue & its applications
somendra kumar
 
PPTX
Call by value or call by reference in C++
Sachin Yadav
 
PPT
String matching algorithms
Dr Shashikant Athawale
 
PPT
Structure c
thirumalaikumar3
 
PPTX
Asymptotic Notation and Data Structures
Amrinder Arora
 
PPTX
Types of Statements in Python Programming Language
Explore Skilled
 
Branch and bound
Nv Thejaswini
 
Boyer moore algorithm
AYESHA JAVED
 
Stacks & Queues By Ms. Niti Arora
kulachihansraj
 
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
3.5 model based clustering
Krish_ver2
 
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
Linked List
Ashim Lamichhane
 
Looping Statements and Control Statements in Python
PriyankaC44
 
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
Data structure - Graph
Madhu Bala
 
pre processor directives in C
Sahithi Naraparaju
 
Multidimensional array in C
Smit Parikh
 
recursive transition_networks
Rajendran
 
Complexity of Algorithm
Muhammad Muzammal
 
queue & its applications
somendra kumar
 
Call by value or call by reference in C++
Sachin Yadav
 
String matching algorithms
Dr Shashikant Athawale
 
Structure c
thirumalaikumar3
 
Asymptotic Notation and Data Structures
Amrinder Arora
 
Types of Statements in Python Programming Language
Explore Skilled
 

Similar to Find operation and smart union algorithm (20)

PPTX
Path compression
DEEPIKA T
 
PPTX
Disjoint set
DeepikaT13
 
PPTX
Lecture 6 disjoint set
Abirami A
 
PDF
learning about union find algorithm lectures
NamPhmPhng9
 
PPTX
data structure
SangeethaSasi1
 
PPTX
Implementation of union
rajshreemuthiah
 
PPT
Sets and disjoint sets union123
Ankita Goyal
 
PPT
DAA (Unit-2) (ii).ppt design analysis of algorithms
ssuser99ca78
 
PPTX
Disjoint set / Union Find Data Structure
Log(n) Academy
 
PPTX
DISJOINT SETS.pptx
JyoReddy9
 
PPTX
Disjoint sets union, find
subhashchandra197
 
PDF
Time complexity of union find
Wei (Terence) Li
 
PDF
Minimum Spanning Trees Artificial Intelligence
jiraf23341
 
PPT
ee220s02lec10.ppt.........................
AnilKumar914552
 
PDF
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Amrinder Arora
 
PDF
17 Disjoint Set Representation
Andres Mendez-Vazquez
 
PPTX
Union find
Vyakhya Shrivastava
 
PPT
computer notes - Data Structures - 30
ecomputernotes
 
PPT
Computer notes - Analysis of Union
ecomputernotes
 
PDF
Algorithms, Union Find
Nikita Shpilevoy
 
Path compression
DEEPIKA T
 
Disjoint set
DeepikaT13
 
Lecture 6 disjoint set
Abirami A
 
learning about union find algorithm lectures
NamPhmPhng9
 
data structure
SangeethaSasi1
 
Implementation of union
rajshreemuthiah
 
Sets and disjoint sets union123
Ankita Goyal
 
DAA (Unit-2) (ii).ppt design analysis of algorithms
ssuser99ca78
 
Disjoint set / Union Find Data Structure
Log(n) Academy
 
DISJOINT SETS.pptx
JyoReddy9
 
Disjoint sets union, find
subhashchandra197
 
Time complexity of union find
Wei (Terence) Li
 
Minimum Spanning Trees Artificial Intelligence
jiraf23341
 
ee220s02lec10.ppt.........................
AnilKumar914552
 
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Amrinder Arora
 
17 Disjoint Set Representation
Andres Mendez-Vazquez
 
computer notes - Data Structures - 30
ecomputernotes
 
Computer notes - Analysis of Union
ecomputernotes
 
Algorithms, Union Find
Nikita Shpilevoy
 
Ad

Recently uploaded (20)

PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
Top Managed Service Providers in Los Angeles
Captain IT
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Ad

Find operation and smart union algorithm

  • 2.  A union-find algorithm is an algorithm that perform two useful operation they are..,  Find:  determine which subset a particular element is in .this can be used for determining if two elements are in the same subset
  • 3.  Union:  join two subset into a single subset.  Union-find algorithm:  Can be used to check whether an undirected graphs contain cycle or not.
  • 4.  Introduction  Disjoint-set/union-find forest  Disjoint set operation  Disjoint set optimised  Union by rank  Two set of union  Pseudo code
  • 5.  A disjoint –set data structure is also called a union-find data structure or merge-find set is a data structure that stores a collection of disjoint set  It stores a *partition of a set into disjoint subset  It provides operation for adding new set, merging set and finding a representative members of a set.  The last operation allows to find out efficiently if any two elements are in the same or different set.
  • 6.  Type : multiway tree  invented : 1964  Invented by : Michael j. Fischer
  • 7.  Make set(x)  Find(x)  Union(x , y)
  • 8.  Disjoint set is optimised by two main types they are:  Union by rank  Path by compression
  • 9.  User find to determine the roots of the trees x and y belongs to  If the roots are distinct the tree are combined by attaching the root of one to the root of the other  If this is done naively such as by always making x a child of y, the height of the tree can grow as o(n).we can optimized it by using union by rank
  • 10.  Union by rank always attaches the shorter tree to the root of the taller tree  To implement union by rank , each element is associated with a rank.  Initially a set has one element and a rank of zero.
  • 11.  Union have a two set they are:  Both trees have the same rank-the resulting set’s rank is one longer.  Both trees have the different rank-the resulting set’s rank is larger of the two.  Rank are used instead of height or depth because path compression will change the tress's height over time.
  • 12.  Function union(x , y) xroot:=find(x) yroot:=find(y) //x and y are not in same set , so If xroot.rank< yroot.rank xroot.parent:=yroot Else if xroot.rank> yroot.rank yroot. Parent:= xroot Else xroot.parent:=yroot yroot.rank:=yroot.rank+1.