union_find

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2022 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UF

type UF interface {
	Size() int
	IsConnected(p int, q int) bool
	UnionElements(p int, q int)
}

type UnionFind

type UnionFind struct {
	// contains filtered or unexported fields
}

我们的第三版Union-Find

func NewUnionFind

func NewUnionFind(size int) *UnionFind

构造函数

func (*UnionFind) IsConnected

func (u *UnionFind) IsConnected(p int, q int) bool

查看元素p和元素q是否所属一个集合 O(h)复杂度, h为树的高度

func (*UnionFind) Size

func (u *UnionFind) Size() int

func (*UnionFind) UnionElements

func (u *UnionFind) UnionElements(p int, q int)

合并元素p和元素q所属的集合 O(h)复杂度, h为树的高度

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL