(A) Maintain sizes (number of nodes) of all trees, and during union
(B) Make smaller tree, the subtree of the larger one
(C) Make the larger tree, the subtree of the smaller one
(D) Implementation: for each root node i, instead of setting parent[i] to -1, set it to -k if tree rooted at i has k nodes
»Important Links:
English Mcqs | General Knowledge Mcqs | Pak Studies Mcqs |
Current Affairs Mcqs | Current Affairs Mcqs PDF | Current Affairs of Pakistan |
Books PDF | Notes PDF | Islamic Studies Mcqs |