Learn R Programming

TSTr (version 1.2)

searchWord: Search a string

Description

Searches for a string within a ternary search tree

Usage

searchWord(tree, string)

Arguments

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

Value

logical. TRUE if the string is in the tree, FALSE if not.

Details

Searches through the tree for the specified string. Returns TRUE if the string have been added to the tree and FALSE if not.

Examples

Run this code
fruitTree <- newTree(c("apple", "orange","apricot","cherry"))
searchWord(fruitTree, "apricot")
searchWord(fruitTree, "banana")

Run the code above in your browser using DataLab