SlideShare a Scribd company logo
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
 
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
sanjeevtandonsre
 
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
sanjeevtandonsre
 
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
sanjeevtandonsre
 
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
sanjeevtandonsre
 
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
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
 
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
sanjeevtandonsre
 
okkkSolutionokkk.pdf
okkkSolutionokkk.pdfokkkSolutionokkk.pdf
okkkSolutionokkk.pdf
sanjeevtandonsre
 
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
sanjeevtandonsre
 
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
sanjeevtandonsre
 
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
sanjeevtandonsre
 
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
sanjeevtandonsre
 
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
sanjeevtandonsre
 
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
sanjeevtandonsre
 
ExperimentRegionTissue expressedConclusion1ABCLIVER.pdf
ExperimentRegionTissue expressedConclusion1ABCLIVER.pdfExperimentRegionTissue expressedConclusion1ABCLIVER.pdf
ExperimentRegionTissue expressedConclusion1ABCLIVER.pdf
sanjeevtandonsre
 
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
sanjeevtandonsre
 
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
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

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 

Recently uploaded (20)

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 

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)