阿摩線上測驗 登入

申論題資訊

試卷:109年 - 109國立臺灣大學_碩士班招生考試_資訊工程學研究所:資料結構與演算法(A)#106053
科目:台大◆資工◆資料結構與演算法(A)
年份:109年
排序:0

題組內容

13. (15 points) A disjoint-set data structure supports two operations. One is UNION(z,y), which merges the two roots of the trees containing a and y. The other is FIND(z), which returns the root of the tree containing 2. Union-by-beight is a union heuristic, which keeps track of the heights of the trees to attach the shorter tree to the root of the taller tree.

申論題內容

(a) (9 points) Given an undirected graph G = (V,E), where V = {u1,...um} (m > 0) and E = {e1,...,en) (n > 0), devise an algorithm to check if the graph G is a tree or not by using UNION(ui,uj) with union-by-height and FIND(uk) with no path com pression, where Ui,Us and Uk 620216d6eaf82.jpgV. Clearly describe your solution and analyze the tinre cumplexity of your algorithm in the worst case. No code is required (code will not be graded).