sort

package
v0.0.0-...-619039e Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KahnAlgorithm

func KahnAlgorithm(g *Graph) ([]int, error)

KahnAlgorithm 实现Kahn算法进行拓扑排序

Types

type Graph

type Graph struct {
	Nodes []int
	Edges [][]int
}

Graph 表示有向无环图

type Trie

type Trie struct {
	Root *TrieNode
}

Trie 定义了Trie树的结构

func NewTrie

func NewTrie() *Trie

NewTrie 创建一个新的Trie树实例

func (*Trie) Insert

func (t *Trie) Insert(word string)

Insert 向Trie树中插入一个单词

func (*Trie) Search

func (t *Trie) Search(word string) bool

Search 在Trie树中搜索一个单词

func (*Trie) StartsWith

func (t *Trie) StartsWith(prefix string) bool

StartsWith 检查Trie树中是否有以给定前缀开头的单词

type TrieNode

type TrieNode struct {
	Children [26]*TrieNode // 假设只存储小写字母,使用26个字母
	IsEnd    bool          // 标记该节点是否为单词的结尾
}

TrieNode 定义了Trie树的节点结构

Jump to

Keyboard shortcuts

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