Trie

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: BSL-1.0 Imports: 1 Imported by: 0

Documentation

Overview

Package Trie implements a simple trie data structure for storing dictionary with strings. Source: https://youtu.be/H-6-8_p88r0 (JamieGo)

Index

Constants

View Source
const AlphabetSize = 26

AlphabetSize is the number of possible characters in the trie

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Children [AlphabetSize]*Node
	// contains filtered or unexported fields
}

Node represents a node in the trie

type Trie

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

Trie represents a trie and has a pointer to the root node

func InitTrie

func InitTrie() *Trie

InitTrie will create a new Trie

func (*Trie) Insert

func (t *Trie) Insert(w string)

Insert will take in a word and add it to the trie

func (*Trie) Search

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

Search will take in a word and RETURN true if that word is included in the trie same walking logic as Insert, but we don't need to create nodes

Jump to

Keyboard shortcuts

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