MultiwayTrieSet Flashcards

1
Q

Multiway Trie is a motivated by:

A

ReTRIEVAL of words. Thus TREE is associated with TRIE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

As a result of Binary Search Tree being (1) ___ complexity , and HashTable providing a (2) ____ complexity, MULTI-WAY TRIE was developed (by Edward Fredkin)

A

(1) BST can search a library of of words with O(log n) worst case and
(2) HashTable can search a library wiht O(k) worst case time complexity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Trie is considered a “prefix tree”

A

Element being stored are not represented by the value of a singe node, but the concatenation of labels on the path from root to the corresponding element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Trie rely on

A

Edge Labels. These edge labels spell out the words to be stored

“word nodes” that are the “terminal” nodes or nodes with a boolean indicating that the current node produces a word in the lexicon, but additional nodes may still continue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Multiway Trie has more than ___child edges

A

“two”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

MWT always require starting from the root, traversing down its edges and ending on a node that has been labelled as a word node.

A

A word only exist if the final node that you have arrived on is labelled as a “word node”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

MWT relies on the FIND() algorithm.

A

The find() function will follow the algorthm. If it fails that means the word does not exist and if it does the label of the “word node” is removed from the label and return true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Inserting new words into a MWT involves:

A

If at any point the edge needed to continue building the word does not exist, we simply create the required edge and continue.

The letter labels EDGES of the trie, not the node.

An empty MWT is a single node tree with NO edges.

Inserting a single letter into the MWT (populating it with a single character) would entail creating a new node to join the originating root node, and connecting the root node to the new node. This is done to insert a new character/”word” into the MWT that is the size of one character.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Assume that, if you are given a node u and a character c, you can access the outgoing edge of u labeled by c (or determine that no such edge exists) in O(1) time. Given this assumption, what is the worst-case time complexity of the find, insert, and remove algorithms

A

O(k)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

To output all the “elements” in the trie in a sorted order a _____ is performed

A

PRE-Order Traversal

ascendingPreOrder(node): // Recursively iterate over the words in ascending order
if node is a word-node:
output the word labeled by path from root to node
for each child of node (in asc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

To output all the “elements” in the trie in a descending sorted order a _____ is performed

A

POST-Order Traversal

descendingPostOrder(node): // Recursively iterate over the words in descending order
for each child of node (in descending order):
descendingPreOrder(child)
if node is a word-node:
output the word labeled by path from root to node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can “auto-complete” be implemented?

A

Use recursive pre-order traversal technique to provide useful function to our Multiway Trie

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can “auto-complete” be implemented?

A

Use recursive pre-order traversal technique to provide useful function to our Multiway Trie. Just start at the node with the current set of characters and then perform pre-order traversal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly