Learn R Programming

TSTr (version 1.2)

completeWord: Autocompletion of strings

Description

Returns a character vector with the completed words

Usage

completeWord(tree, string)

Arguments

tree
an existing ternary search tree to search words in.
string
a string of characters to be completed.

Value

A vector of class `character`.

Details

Searches recursively through the tree until all words starting with the specified string have been found, and stores them in a character vector.

Examples

Run this code
fruitTree <- newTree(c("apple", "orange","apricot","cherry"))
fruits.ap <- completeWord(fruitTree, "ap")
fruits.ap

Run the code above in your browser using DataLab