Personal Learning record:one of Abstract Date Type(ADT)---Disjoint Set(by python)

  1. record all brunch of boxes and lines X complicated(graph)

I.A Better Approach: Connected Compnents

1 track the sets which membership in

just need to record which set each item belongs to
in other words, when we first start, each item is in its own set
(and then when we connnect 1 and 2, we put them in the same set or merge these sets)

2.What data structure can be use to track the set?

a list of set of integers?

x complicated and sloooow

a list of integers?

√like this
在这里插入图片描述

In id list, the ith entry tells us the set number of i.

it named QuickFind

class QuickFindDS(object):
	def __init__(self, N):
		self.__id = list(range(0,N))
		print(self.__id)

	def isConnected(self, p, q):#very fast
		return self.__id[p] == self.__id[q]
		
	def connect(self, p, q):#slow
		"""We want to change every id equal to p's id to be equal q's id"""
		pid = self.__id[p]
		qid = self.__id[q]
		# if x == pid: this item = qid, otherwise we just keep x 
		self.__id = [qid if x == pid else x for x in self,__id]

ds = QuickFindDS(7)
# ds.connect(0,1)
print(ds.isConnected(1,2))

But, the Big-Theta of its Connect is N, it is relatively slow.

II.Improving the Connect Operation

1.QuickUnion

we can give them parent~
using parent to only chage one value when we try to combine two sets.(before we needed to change potentially several values)
So when connecting, we just need connect the root of the two values.

how to connect?

  1. find the item’s root (5)
  2. find another item’s root (2)
  3. set the root of 5’s value to root 2;

like this
在这里插入图片描述

Considering the worst case:
new question appear: if the tree is very tall potentially this(connect and IsConnect) could be slow(Big O = N)
在这里插入图片描述
(we can keep the tree balance, reduce its height)

2. WeightedQuickUnion

In order to reduce the runtime of connect/IsConnect , we can balance the tree(min the height of the tree)
SO,we are always going to link the root of smaller tree(the number of elements) to the larger tree.
在这里插入图片描述

(but this operation using the weight instead of height, why?)
在这里插入图片描述

The worst situation of this is: always connect two equal-weight trees, the heigt is log(a tree which is logarithmic in height), pretty good
在这里插入图片描述

For why did we pick weight instead of height? The worst case performance for heighted QuickUniono is going t be the same. The worst case runtime is also Theta(logN). In other words, heighted QuickUnion has the exact same asymptotic performance as weightedQuickUnion. Chosing weight is a simpler solution.
two lists parents, size

Path Compression

With path compression, what we do is to tie every item that we saw along that path to the root.
在这里插入图片描述

The Big O decline dramatically.

class WeightQuinkUnionWithPathCompression(object):
	"""docstring for WeightQuinkUnion"""
	def __init__(self, N):
		self.__id = list[range(0,N)]
		self.__size = [1 for _ in range(N)]
		
	def getroot(self, p):
		if self.__size[p] == p:
			return p
		pid = getroot(self.__id[p])
		self.__id[p] = pid
		return pid

	def IsConnect(self, a, b):
		return self.getroot(a) == self.getroo(b)

	def connect(self, a, b):
		rta = self.getroot(a)
		rtb = self.getroot(b)
		if self.__size[rta] > self.__size[rtb]:
			self.__id[rtb] = self.__id[rta]
			self.__size[rta] += self.__size[rtb]
		else:
			self.__id[rta] = self.__id[rtb]
			self.__size[rtb] += self.__size[rta]
	#Written my myself, there may be some errors here. welcome correct and criticism

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: synaptics.exe 是 Synaptics 触摸板驱动程序的执行文件。当您的电脑上的 synaptics.exe 文件损坏时,可能会导致一些问题。 损坏的映像 x g:d\adt-bundle-windows-x86_ 64-20140702\eclipse\ 是指在该路径下的映像文件有损坏。这可能会导致无法正常启动该程序或功能异常。 要解决这个问题,您可以尝试以下几个步骤: 1. 重新安装 Synaptics 触摸板驱动程序:您可以从 Synaptics 官方网站或您电脑制造商的支持网站下载最新的驱动程序,并按照指示安装。 2. 修复损坏的映像文件:您可以尝试重新下载该文件,并确保下载完整和正确。如果您已经有备份,请还原替换损坏的文件。 3. 执行系统文件检查:您可以运行命令提示符或 PowerShell 作为管理员,然后输入" sfc /scannow",以检查并修复系统文件的损坏。 4. 更新操作系统:确保您的操作系统和所有驱动程序都是最新版本。有时旧版本的操作系统或驱动程序可能与新版本的软件不兼容。 如果以上步骤都无法解决问题,您可以联系 Synaptics 支持或找到专业的计算机技术人员寻求帮助。他们可能需要进一步检查您的系统并提供适当的解决方案。 ### 回答2: synaptics.exe是一个Synaptics触摸板的驱动程序文件。这个文件通常位于计算机的系统文件夹中,并用于控制和管理电脑上的触摸板功能。当出现"损坏的映像"错误时,意味着synaptics.exe文件已经受损或缺失,无法正常工作。 x g:d\adt-bundle-windows-x86_ 64-20140702\eclipse\表示的是synaptics.exe损坏的映像所在的路径。这个路径可能是指synaptics.exe文件的位置,其中g是一个驱动器,d是目录名,adt-bundle-windows-x86_64-20140702是文件夹中的子文件夹,eclipse是另一个子文件夹。 要解决synaptics.exe损坏的映像错误,可以尝试以下步骤: 1. 重新启动计算机:有时,重启计算机可以解决临时的系统错误问题。 2. 更新或重新安装驱动程序:去Synaptics官方网站下载最新的驱动程序,并按照说明进行安装。如果已经安装了最新驱动程序,可以尝试重新安装以修复任何损坏的文件。 3. 运行系统文件检查器:在命令提示符下,输入sfc /scannow命令,系统文件检查器将扫描并修复任何损坏的系统文件。 4. 手动替换文件:如果有备份的synaptics.exe文件,可以手动将其复制到正确的位置。 如果以上步骤都无法解决问题,可能需要联系计算机制造商或专业技术支持以获取进一步的帮助和解决方案。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值