## Buy/Download all MCQ Ebook
>>>**Click Here**<<<

## Trie Multiple choice Questions and Answers (MCQs)

## Click on any option to know the CORRECT ANSWERS

Question 1 |

Trie is also known as .....

Digital Tree | |

Treap | |

Binomial Tree | |

2-3 Tree |

Question 1 Explanation:

Trie is a very useful data structure which is based on the prefix of a string. Trie is used to represent the "Retrieval" of data and thus the name Trie. And it is also known as a digital tree.

Question 2 |

What traversal over trie gives the lexicographical sorting of the set of the strings?

postorder | |

preorders | |

inorder | |

level order |

Question 2 Explanation:

In trie, we store the strings in such a way that there is one node for every common prefix. Therefore the inorder traversal over trie gives the lexicographically sorted set of strings.

Question 3 |

Which of the following is the efficient data structure for searching words in dictionaries?

BST | |

Linked List | |

Balancded BST | |

Trie |

Question 3 Explanation:

In a BST, as well as in a balanced BST searching takes time in order of mlogn, where m is the maximum string length and n is the number of strings in tree. But searching in trie will take O(m) time to search the key.

Question 4 |

Which of the following special type of trie is used for fast searching of the full texts?

Ctrie | |

Hash tree | |

Suffix tree | |

T tree |

Question 4 Explanation:

Suffix tree, a special type of trie, contains all the suffixes of the given text at the key and their position in the text as their values. So, suffix trees are used for fast searching of the full texts.

Question 5 |

Following code snippet is the function to insert a string in a trie. Find the missing line.

private void insert(String str) { TrieNode node = root; for (int i = 0; i < length; i++) { int index = key.charAt(i) - 'a'; if (node.children[index] == null) node.children[index] = new TrieNode(); ..... } node.isEndOfWord = true; }

node = node.children[index]; | |

node = node.children[str.charAt(i + 1)]; | |

node = node.children[index++]; | |

node = node.children[index++]; |

Question 5 Explanation:

In the insert() method we search if the string is present or not. If the string is not present, then we insert the string into the trie. If it is present as the prefi, x we mark the leaf node. So, correct option is node = node.children[index];.

There are 5 questions to complete.