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
    全站熱搜
    創作者介紹
    創作者 jmuko104 的頭像
    jmuko104

    new htc one開箱,htc手機評價,htc手機比較,htc手機遊戲,htc手機維修,htc手機價位,htc手機推薦,htc手機鈴聲,中華電信htc手機,htc手機截圖,亞太htc手機,

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