普林斯顿大学算法公开课笔记

第一章 Union-Find

01 Dynamic connectivity (动态连接性问题即 the model of union find 并查集模型)

问题:

a set of N objects (use the numbers zero through N-1 to model our objects). and we then have the idea of a connection between two objects. And, we'll, postulate that there's going to be a command that says, connect two objects. Given two objects, provide a connection between them. And then key part of the problem is find query or the connected query, which just asks, is there a path connecting the two objects. so for example

有N个对象(用数字0到N-1去标记这N个对象) 两个对象是可以连通的。我们假设有一个命令可以连接两个对象,将两个对象传入该命令将创造两者之间的连接,现在问题的关键是连通性的查询,即查询两个对象之间是否有联通的路径存在。举例:

in this set of ten objects, a bunch of union commands, connecting 4 and 3, 3 and 8, 6 and 5, 9 and 4, 2 and 1. And now we might have a connected query that says, is zero connected to seven? in this case, there is no connection, so we say no. But if we ask is eight connected to nine? We are going to say yes, even no we don't have a direct connection between eight and nine. There is a path from eight to three to four to nine. So, that's our problem, to be able to officially support these two commands for given set of objects.


So that's our problem, intermix union, commands and connected queries and we need to be able to officially support
those commands for a large number of objects.

更大一点的问题举例


Applications involve manipulating objects of all types.

 

we'll just name the objects with a number, integers from zero to N-1. That's a very convenient initial starting point for our programs because we can use integers as an index into an array then, and then quickly access information relevant to each object. And it also just supresses a lot of details that are not relevant to union find. In fact, to make this mapping from an object name to the integer zero through N - one is to find application of a symbol table or a searching algorithm. (用0到N-1标记这N个对象的好处)

关于连接的性质假定

自连接性:p is connected to p

对称性:if p is connected to q, then q is connected to p.

传递性: if p is connected to q and q is connected to r, then p is connected to r.

When we have an equivalence relation a set of objects and connections divide into subsets called connected components. A connected component is a maximal set of objects that's mutually connected. For example 


未完待续...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值