Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中 
Learn to Play Electric Guitar

Perfect for those new to guitar. Learn to play electric guitar with these easy step-by-step video lessons from JamPlay! Sign up for just $39.
From our sponsors
做disjoint set(分離式集合)
Dec 31st 2013, 00:58

問題如下:
1. The purpose here is to replace the original weighting rule of the union operation, which is based on the size (number of nodes) of the tree, with a different rule based on the height of the tree. Simply said, when doing union, the root of the tree with the smaller height is made a child of the root of the tree with the larger height.
2. Note: To make results consistent, when the two trees have the same height, use the root with the smaller index as the root of the combined tree.
3. Use the same array representation as in the textbook. However, parent[i], when i is a root node, should contain a negative number whose absolute value is the height of the tree.
4. This task will be arranged similar to the equivalence class problem. The first number in the input file (inputDS.txt) is the number of items. The items are indexed starting from 0. In the second line, each pair of integers indicate an equivalent pair; pairs are separated by semicolons. An example input file looks like this:
12
0 4; 3 1; 6 10; 8 9; 7 4; 6 8; 3 5; 2 11; 11 0
5. Read in the file in the main function and follow the steps in the slides, using height-based union. No need to do collapsing find though.
6. At the end, print to the screen the contents of the array parent. For the example input above, the output should look like
-3 -2 0 1 0 1 -3 0 6 8 6 2

我自己設計的程式

執行出來的結果沒有辦法和上面的example相符......

找不出原因

希望可以提供"完整的程式碼"

讓我可以對照檢視

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 jmuko100 的頭像
    jmuko100

    2015年假公告, 2015年假幾天, 2015年假公告人事行政局, 2015年假放幾天, 2015行事曆, 2015 國定假日, 2015年假日期, 2015年假9天, 明年假期2015, 2015 年假,

    jmuko100 發表在 痞客邦 留言(0) 人氣()