12.07.2015 Views

Heap sort and complexity, Disjoint Union & Find, Complexity ...

Heap sort and complexity, Disjoint Union & Find, Complexity ...

Heap sort and complexity, Disjoint Union & Find, Complexity ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 2: Elementary Data StructuresSince the time taken for union is constant, n-1 calls to U canbe processed in O(n) time. Time required to process F at leveli is O(i), n-2 calls of find takes O(n 2 ) time.Weighting rule: “if the number of nodes in tree i is less thanthe number of nodes in tree j, then make j the parent of i,else make i, the parent of j”.using the rule on the data set given before, <strong>and</strong> using the samesequence we have-

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!