我正在一個項目,我必須聯合和相交兩組。我使用鏈接列表爲每個虛擬節點集。這是我如何初始化我的套LL類 public Set() {
top = new Node(Integer.MIN_VALUE, new Node(Integer.MAX_VALUE, null));
} //end Set
這就是我如何插入項目。 public void insert(int item) {
Node
I studied the union find algo and found it is very useful in following ways.
to find out if 2 node are connected or not
to compress the path. (save space)
if the problem is to find if
我試圖找到一種操作,可以採取正常語言,並與另一個「不連接」它。例如: a * L - a * = L |其中L是常規語言 我知道差異(減法)不是我想要的操作。但我相信我明白自己的觀點。 另一種看待它的方法是,如果有一個邏輯上等於(A∪B)的集合L,但我們沒有訪問A.所以如果我們只能使用L,B和派生這樣,我們可以以某種方式推導A.基本上: L - B = A | L =(A∪B) 我對這個問題進行了