A ternary search tree is a data structure for efficiently storing string data using prefixes.
Questions tagged [ternary-search-tree]
35 questions
1
vote
1 answer
Time complexity for inserting all suffixes of a string into a ternary search tree?
I have a ternary search tree that contain all the suffixes of a word. What is the time complexity for construction and searching a word in this structure?
Example:
a word banana$, have the suffix banana$,anana$,nana$,ana$,na$,a$,$
and in…

Yosvanys Aponte
- 51
- 3
1
vote
2 answers
Spell Checker : Ternary Search tree
i have made a spell checker code using Ternary search tree. Can anybody tell me how to find the next possible word in TST.
for example if i want to search if i search a word "Manly" in spell checker and the word is not present in TST, so the output…

Parul Setia
- 23
- 7
1
vote
2 answers
Ternary tree vs trie with map as transition table for Aho-Corasick FSA
What is the difference between FSA using ternary tree and a trie with transition tables implemented as search trees (e.g. std::map)? It seems like both have O(log k) complexity for reading one symbol and O(S) memory complexity, where k is alphabet…

lizarisk
- 7,562
- 10
- 46
- 70
1
vote
1 answer
Finding longest common prefix in a ternary search tree
I implement a ternary search tree for a 20000 words.I want to know an algorithm to find a longest common prefix(prefix that is shared by at least 2 words)?
Is there anyway to find a Longest Common Prefix in a tree?(without ternary search tree)

Proud
- 39
- 4
1
vote
1 answer
segmentation fault in insertion into ternary search tree
i am trying to insert the charachter in to ternary search tree, please help me out with this segmentation fault ??
here is what i am doing to inser in to trie,on running this i am getting segmentation fault(core dumped )
please help me out why this…

user1688392
- 21
- 1
- 3
0
votes
1 answer
Ternary search tree with all suggestions autocomplete in C#
I wonder is it possible to modify ternary search tree to check that word exists AND find all words that starts with that word ( or finish by that word ?) ?
For example do => dog dogs etc.
From this site is a sample code. First load all words to…

deadfish
- 11,996
- 12
- 87
- 136
0
votes
1 answer
Ternary Search Tree in C, Pointer to a Pointer to a struct problem
I'm trying to build a ternary search tree for a school project. As far as I can tell, my code looks okay.
But, the leaf nodes of the original root function are not being initialized when I use malloc.
So every string comparison beyond the first one…

Evan
- 5
- 2
0
votes
0 answers
Near-Neighbor Searching in Ternary Search Tree
How is the search for the nearest neighbors in the tree? Trying to find information, I get only some formulas without illustrative examples.
enter image description here
Example of a function:
void nearsearch(Tptr p, char *s, int d)
{ if (!p ||…

Willy Adams
- 1
- 1
0
votes
0 answers
Can ternary search trees be used for every word?
A node has three children, left, right, and middle, but what if those are occupied? Then what? And by a different character? If the root is 'b', and I try to insert cecil and dock, then what will I do?

FariyaAchhab
- 43
- 4
0
votes
1 answer
What is the name of this data structure search algorithm?
I have a tree search algorithm that uses multiple keys and each node has a sub tree which is searched with the next key in the list of keys until the keys run out and the data being searched is in that end node.
my code is working but I don't know…

Christ Kennedy
- 29
- 3
0
votes
1 answer
Properly deleting a node in a Ternary Search Tree
I want to delete a specific node using a key from a Ternary Search Tree. This works pretty well in most cases, but in some of my test sets, nodes that do not have a middle child also do not store values, which shouldn't happen.
I tried different…

deathkid535
- 3
- 4
0
votes
0 answers
How to implement autocomplete with top K suggestions algorithm?
This is a question for an interview: Write a program to implement autocomplete for a given set of N strings and positive weights. That is, given a prefix and an integer k, find the top k strings in the set among those that start with the prefix.
And…

LOCKLOCK
- 341
- 1
- 3
- 13
0
votes
0 answers
Ternary Search Tree Implementation in R
I'm trying to implement a ternary search tree in R.
Here's the logic I'm trying to implement:
A vector will be "tiered" by designating each level of the tree as the next 3^somepower of cells after the existing tier. So tier 1 will be the first cell,…

GFauxPas
- 299
- 1
- 14
0
votes
0 answers
Ordering for creating a balanced Ternary Tree
I'm trying to create a balanced ternary tree. To do that I want to insert keys in an order that ensures the tree is built so that each node partitions the range of characters below it evenly. So ideally the first node will be 'M' and on either side…

Ian Mercer
- 38,490
- 8
- 97
- 133
0
votes
2 answers
Spell Checker using Ternary Search tree
I made a spell checker using Ternary search tree (TST).
Can anybody tell me how to find the next possible word in the TST?
eg: If i want to search the word "Manly" in spell checker and if the word is not present in the TST, so that it outputs…

Parul Setia
- 23
- 7