计算机问题求解一论题3-5 -用于动态等价关系的数据结构 2018年10月09日
计算机问题求解 – 论题3-5 -用于动态等价关系的数据结构 2018年10月09日
问题1: 什么是等价关系? 它有什么应用意义?
创建“迷宫” 入口 间题2 你能否基于动态 等价关系的概念 出口 来解释这个生成 过程?
创建“迷宫” 入口 出口 i j
间题3: 我们用什么数据结构实现 动态等价关系? 这个数据结构的基本操作 是什么?
MAKE-SET(x)creates a new set whose only member (and thus representative) is x.Since the sets are disjoint,we require that x not already be in some other set. UNION(x,y)unites the dynamic sets that contain x and y,say Sx and S,into a new set that is the union of these two sets.We assume that the two sets are dis- joint prior to the operation.The representative of the resulting set is any member of SxUSy,although many implementations of UNION specifically choose the representative of either Sx or S as the new representative.Since we require the sets in the collection to be disjoint,conceptually we destroy sets Sx and Sy, removing them from the collection 8.In practice,we often absorb the elements of one of the sets into the other set. FIND-SET(x)returns a pointer to the representative of the (unique)set contain- ing x
问题4: 什么是representative? 讨论数学与讨论数据结构 时它有什么差别?
问题5: 我们讨论的不是一个算法 而是一个数据结构,那所谓 时间复杂性分析”究竞 是什么意思呢?
CONNECTED-COMPONENTS(G) 1 for each vertex v∈G.V b 2 MAKE-SET(V) 3 for each edge (u,v)EG.E 4 if FIND-SET()FIND-SET(v) 5 UNION(u,V) SAME-COMPONENT(,V) 1 if FIND-SET()==FIND-SET(v) 2 return TRUE 3 else return FALSE Edge processed Collection of disjoint sets initial sets {a} {b} {c} d) {e} 份 {g} (h) (i } (b.d0 La) (b.d} {c} Le) 仍 {8} (h) i (e,g) {a} {b,d) {c} {e,g} (h; Ad } (a,c) {a,c} {b.dy {e,g} 份 {h) 》 (h,i0 {a,c} {b,d0 {e,g} {h,} } (a,b) a.b.c,dy {e,g} 份 (h.i } (e,f) a.bc.dy {e,f8} h,i 仍 (b,c) a.bc.dy {e,f8} (h.i }
问题6: 假如我们想知道原来未直接相 连的两个顶点一旦连起来就会 形成回路。应该如何解决?
(a) c e head head S1 S tail tail 操作union(g,e)执行后 入 head S1 tail
操作union(g,e)执行后