SlideShare a Scribd company logo
1 of 1
Download to read offline
According to Union by size, each node x which has the size of the subtree rooted at x is stored.
In UNION, the tree of the smaller set is made the subtree of the other tree and the size field of
the root of the resulting tree is updated.
According to path compression heuristics, the parent pointer is reset from x such that it points to
the root for the find operation.
Let the number of nodes be n and the number of finds be m. The union operations are executed
before the find operations, so a tree is constructed before any operation.
There are at most O(n) union operations and each union operation takes O (1) time.
Thus, the total cost of union is O(n). The cost of a find operation is the increment of the number
of new children to the root by 1.
Each find operation will take O(m) time. So, the total cost of m find operation is O (m + n).
Here, n = 1 + max (number of children of the root)
Solution
According to Union by size, each node x which has the size of the subtree rooted at x is stored.
In UNION, the tree of the smaller set is made the subtree of the other tree and the size field of
the root of the resulting tree is updated.
According to path compression heuristics, the parent pointer is reset from x such that it points to
the root for the find operation.
Let the number of nodes be n and the number of finds be m. The union operations are executed
before the find operations, so a tree is constructed before any operation.
There are at most O(n) union operations and each union operation takes O (1) time.
Thus, the total cost of union is O(n). The cost of a find operation is the increment of the number
of new children to the root by 1.
Each find operation will take O(m) time. So, the total cost of m find operation is O (m + n).
Here, n = 1 + max (number of children of the root)

More Related Content

More from sanjeevtandonsre

Water qualities1. Physical qualitiesOdour and taste unobject.pdf
Water qualities1. Physical qualitiesOdour and taste  unobject.pdfWater qualities1. Physical qualitiesOdour and taste  unobject.pdf
Water qualities1. Physical qualitiesOdour and taste unobject.pdf
sanjeevtandonsre
 
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdfUses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
sanjeevtandonsre
 
The moving force behind IT decisions are variable as to what context.pdf
The moving force behind IT decisions are variable as to what context.pdfThe moving force behind IT decisions are variable as to what context.pdf
The moving force behind IT decisions are variable as to what context.pdf
sanjeevtandonsre
 
Physiological responce are those in which the functions of the body .pdf
Physiological responce are those in which the functions of the body .pdfPhysiological responce are those in which the functions of the body .pdf
Physiological responce are those in which the functions of the body .pdf
sanjeevtandonsre
 
ExperimentRegionTissue expressedConclusion1ABCLIVER.pdf
ExperimentRegionTissue expressedConclusion1ABCLIVER.pdfExperimentRegionTissue expressedConclusion1ABCLIVER.pdf
ExperimentRegionTissue expressedConclusion1ABCLIVER.pdf
sanjeevtandonsre
 

More from sanjeevtandonsre (20)

Water qualities1. Physical qualitiesOdour and taste unobject.pdf
Water qualities1. Physical qualitiesOdour and taste  unobject.pdfWater qualities1. Physical qualitiesOdour and taste  unobject.pdf
Water qualities1. Physical qualitiesOdour and taste unobject.pdf
 
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdfUses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
 
The moving force behind IT decisions are variable as to what context.pdf
The moving force behind IT decisions are variable as to what context.pdfThe moving force behind IT decisions are variable as to what context.pdf
The moving force behind IT decisions are variable as to what context.pdf
 
The Canadian city with a pre- 1800 historic heart is QuebecSolut.pdf
The Canadian city with a pre- 1800 historic heart is QuebecSolut.pdfThe Canadian city with a pre- 1800 historic heart is QuebecSolut.pdf
The Canadian city with a pre- 1800 historic heart is QuebecSolut.pdf
 
Solution Millennials referred to as narcissistic referred to as n.pdf
Solution Millennials referred to as narcissistic referred to as n.pdfSolution Millennials referred to as narcissistic referred to as n.pdf
Solution Millennials referred to as narcissistic referred to as n.pdf
 
SolutionThe SELECT DISTINCT stamen will returns distinct values. .pdf
SolutionThe SELECT DISTINCT stamen will returns distinct values. .pdfSolutionThe SELECT DISTINCT stamen will returns distinct values. .pdf
SolutionThe SELECT DISTINCT stamen will returns distinct values. .pdf
 
Starting from the topmost column,1. Cerebellum2. Spinocerebellar.pdf
Starting from the topmost column,1. Cerebellum2. Spinocerebellar.pdfStarting from the topmost column,1. Cerebellum2. Spinocerebellar.pdf
Starting from the topmost column,1. Cerebellum2. Spinocerebellar.pdf
 
Rheumatic fever shows various symptoms and signs, out of which sore .pdf
Rheumatic fever shows various symptoms and signs, out of which sore .pdfRheumatic fever shows various symptoms and signs, out of which sore .pdf
Rheumatic fever shows various symptoms and signs, out of which sore .pdf
 
Physiological responce are those in which the functions of the body .pdf
Physiological responce are those in which the functions of the body .pdfPhysiological responce are those in which the functions of the body .pdf
Physiological responce are those in which the functions of the body .pdf
 
NaF is the only oneSolutionNaF is the only one.pdf
NaF is the only oneSolutionNaF is the only one.pdfNaF is the only oneSolutionNaF is the only one.pdf
NaF is the only oneSolutionNaF is the only one.pdf
 
okkkSolutionokkk.pdf
okkkSolutionokkk.pdfokkkSolutionokkk.pdf
okkkSolutionokkk.pdf
 
Minimum IQ is 131SolutionMinimum IQ is 131.pdf
Minimum IQ is 131SolutionMinimum IQ is 131.pdfMinimum IQ is 131SolutionMinimum IQ is 131.pdf
Minimum IQ is 131SolutionMinimum IQ is 131.pdf
 
co2 because of the sqrt of their molar mases.. .pdf
                     co2 because of the sqrt of their molar mases..   .pdf                     co2 because of the sqrt of their molar mases..   .pdf
co2 because of the sqrt of their molar mases.. .pdf
 
L{e^{-t}} = int _0 to infinty [e^{st}e^{-t} dt = int _0 to infinty .pdf
L{e^{-t}} = int _0 to infinty [e^{st}e^{-t} dt = int _0 to infinty .pdfL{e^{-t}} = int _0 to infinty [e^{st}e^{-t} dt = int _0 to infinty .pdf
L{e^{-t}} = int _0 to infinty [e^{st}e^{-t} dt = int _0 to infinty .pdf
 
carbon forms 4 hydrogen forms 1 nitrogen forms 3 .pdf
                     carbon forms 4 hydrogen forms 1 nitrogen forms 3 .pdf                     carbon forms 4 hydrogen forms 1 nitrogen forms 3 .pdf
carbon forms 4 hydrogen forms 1 nitrogen forms 3 .pdf
 
H = H(lattice) + H(first ionisation) +H(second ionization) +2H(elec.pdf
H = H(lattice) + H(first ionisation) +H(second ionization) +2H(elec.pdfH = H(lattice) + H(first ionisation) +H(second ionization) +2H(elec.pdf
H = H(lattice) + H(first ionisation) +H(second ionization) +2H(elec.pdf
 
Heptatomic molecules contain 7 atomsNo. of H atoms = 2No. of S .pdf
Heptatomic molecules contain 7 atomsNo. of H atoms = 2No. of S .pdfHeptatomic molecules contain 7 atomsNo. of H atoms = 2No. of S .pdf
Heptatomic molecules contain 7 atomsNo. of H atoms = 2No. of S .pdf
 
ExperimentRegionTissue expressedConclusion1ABCLIVER.pdf
ExperimentRegionTissue expressedConclusion1ABCLIVER.pdfExperimentRegionTissue expressedConclusion1ABCLIVER.pdf
ExperimentRegionTissue expressedConclusion1ABCLIVER.pdf
 
D . All of the above could be reported within the fund financial sta.pdf
D . All of the above could be reported within the fund financial sta.pdfD . All of the above could be reported within the fund financial sta.pdf
D . All of the above could be reported within the fund financial sta.pdf
 
Codeclass Main { public static void main(String[] args) { dou.pdf
Codeclass Main { public static void main(String[] args) { dou.pdfCodeclass Main { public static void main(String[] args) { dou.pdf
Codeclass Main { public static void main(String[] args) { dou.pdf
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 

According to Union by size, each node x which has the size of the su.pdf

  • 1. According to Union by size, each node x which has the size of the subtree rooted at x is stored. In UNION, the tree of the smaller set is made the subtree of the other tree and the size field of the root of the resulting tree is updated. According to path compression heuristics, the parent pointer is reset from x such that it points to the root for the find operation. Let the number of nodes be n and the number of finds be m. The union operations are executed before the find operations, so a tree is constructed before any operation. There are at most O(n) union operations and each union operation takes O (1) time. Thus, the total cost of union is O(n). The cost of a find operation is the increment of the number of new children to the root by 1. Each find operation will take O(m) time. So, the total cost of m find operation is O (m + n). Here, n = 1 + max (number of children of the root) Solution According to Union by size, each node x which has the size of the subtree rooted at x is stored. In UNION, the tree of the smaller set is made the subtree of the other tree and the size field of the root of the resulting tree is updated. According to path compression heuristics, the parent pointer is reset from x such that it points to the root for the find operation. Let the number of nodes be n and the number of finds be m. The union operations are executed before the find operations, so a tree is constructed before any operation. There are at most O(n) union operations and each union operation takes O (1) time. Thus, the total cost of union is O(n). The cost of a find operation is the increment of the number of new children to the root by 1. Each find operation will take O(m) time. So, the total cost of m find operation is O (m + n). Here, n = 1 + max (number of children of the root)