Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Trie is also known as _________(a) Digital Tree(b) Treap(c) Binomial Tree(d) 2-3 TreeI want to ask this question from Trie topic in chapter Trie of Data Structures & Algorithms IThis question was addressed to me in a job interview.

Answer»

Correct choice is (a) Digital Tree

Best 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.

2.

What traversal over trie gives the lexicographical sorting of the set of the strings?(a) postorder(b) preorders(c) inorder(d) level orderI need to ask this question from Trie in chapter Trie of Data Structures & Algorithms IThis question was posed to me in homework.

Answer» CORRECT option is (c) inorder

Easy 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.
3.

Which of the following is the efficient data structure for searching words in dictionaries?(a) BST(b) Linked List(c) Balancded BST(d) TrieMy question comes from Trie in chapter Trie of Data Structures & Algorithms IThis question was addressed to me in semester exam.

Answer»

Correct CHOICE is (d) Trie

Easiest 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.

4.

Which of the following special type of trie is used for fast searching of the full texts?(a) Ctrie(b) Hash tree(c) Suffix tree(d) T treeOrigin of the question is Trie topic in chapter Trie of Data Structures & Algorithms II got this question in a job interview.

Answer»

Correct choice is (c) Suffix tree

The best 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.

5.

Which of the following is not true?(a) Trie requires less storage space than hashing(b) Trie allows listing of all the words with same prefix(c) Tries are collision free(d) Trie is also known as prefix treeQuestion is taken from Trie topic in division Trie of Data Structures & Algorithms II had been asked this question in an online quiz.

Answer» CORRECT answer is (a) Trie requires less storage space than hashing

Easiest explanation - Both the hashing and the trie provides searching in the LINEAR TIME. But trie requires EXTRA space for storage and it is collision free. And trie allows finding all the strings with same prefix, so it is also called prefix tree.
6.

A program to search a contact from phone directory can be implemented efficiently using ______(a) a BST(b) a trie(c) a balanced BST(d) a binary treeMy question is based upon Trie in division Trie of Data Structures & Algorithms II had been asked this question in class test.

Answer»

The CORRECT choice is (b) a trie

To explain: Dictionaries, phone DIRECTORIES can be implemented efficiently using the trie. Because it trie PROVIDES the EFFICIENT linear time searching over the entries.

7.

What can be the maximum depth of the trie with n strings and m as the maximum sting the length?(a) log2n(b) log2m(c) n(d) mMy doubt is from Trie in division Trie of Data Structures & Algorithms IThis question was addressed to me at a job interview.

Answer»

The correct choice is (d) m

Best EXPLANATION: In the TRIE, the strings are stored efficiently based on the common prefixes. And trie has maximum fan-out 26 if english alphabets are considered. OWING to this, the maximum depth is equal to the maximum STRING length.

8.

Which of the following is true about the trie?(a) root is letter a(b) path from root to the leat yields the string(c) children of nodes are randomly ordered(d) each node stores the associated keysThis intriguing question originated from Trie topic in section Trie of Data Structures & Algorithms II had been asked this question during an online exam.

Answer» RIGHT answer is (b) path from root to the leat YIELDS the string

Easiest explanation - A trie is an ordered tree where (i) the root represents an empty string(“”) (ii) each NODE other than root is labeled with a character (III) the children of a nodes are lexicographically ordered (iv) the paths from the leaves to the root yields the strings.
9.

Auto complete and spell checkers can be implemented efficiently using the trie.(a) True(b) FalseEnquiry is from Trie in portion Trie of Data Structures & Algorithms IThis question was posed to me during an interview for a job.

Answer» CORRECT answer is (a) True

Explanation: TRIE PROVIDES fast searching and storing of the words. And tries STORES words in lexicographical order so, trie is the efficient data structure for implementation of spell checkers and AUTO complete.
10.

What is the other name for Suffix Tree?(a) Array(b) Stack(c) Priority Queue(d) PAT TreeAsked question is from Suffix Tree topic in division Trie of Data Structures & Algorithms IThis question was posed to me in my homework.

Answer»

Correct CHOICE is (d) PAT Tree

The explanation is: In computer science, a SUFFIX tree is also known as PAT tree or position tree. It is a compressed SEARCH tree or prefix tree in which keys CONTAIN the suffix of TEXT values as the text position.

11.

Which tree allows fast implementation of string operation?(a) Rope Tree(b) Suffix Tree(c) Tango Tree(d) Top TreeQuestion is taken from Suffix Tree in section Trie of Data Structures & Algorithms IThe question was asked in quiz.

Answer»

Correct option is (B) Suffix Tree

Best explanation: In computer science, a suffix tree is also known as PAT tree or position tree. It is a COMPRESSED search tree or prefix tree in which KEYS contain the suffix of text values as the text position. It allows fast STRING operation to be CARRIED out by the user.

12.

How much time does construction of suffix tree take?(a) O (log M)(b) O (M!)(c) Exponential to Length of Tree(d) Linear to Length of TreeMy doubt stems from Suffix Tree topic in division Trie of Data Structures & Algorithms II have been asked this question in an online quiz.

Answer»

Right ANSWER is (d) Linear to Length of Tree

The best I can explain: SUFFIX tree is also known as PAT tree or position tree. It is a compressed search tree or prefix tree in which keys contain the suffix of text values as the text position. It ALLOWS fast STRING operation. Total time taken for CONSTRUCTION of suffix tree is linear to the length of the tree.

13.

How much space does construction of suffix tree takes?(a) O (log M)(b) Exponential to Length of Tree(c) O (M!)(d) Linear to Length of TreeOrigin of the question is Suffix Tree topic in section Trie of Data Structures & Algorithms IThis question was addressed to me at a job interview.

Answer»

Correct option is (d) Linear to Length of Tree

The explanation is: Suffix tree is also KNOWN as PAT tree or position tree. It is a compressed search tree or prefix tree in which keys contain the suffix of text VALUES as the text position. It allows fast string operation. TOTAL SPACE taken for construction of a suffix tree is linear to the length of the tree.

14.

Which tree provides a linear time solution for substring operation?(a) Rope Tree(b) Suffix Tree(c) Tango Tree(d) Top TreeMy question is based upon Suffix Tree topic in division Trie of Data Structures & Algorithms II had been asked this question by my college professor while I was bunking the class.

Answer»

Correct ANSWER is (b) SUFFIX Tree

Easiest explanation - It is a compressed SEARCH tree or prefix tree in which keys contain the suffix of text values as the text position. It ALLOWS fast STRING operation to be carried out by the user. The substring operation can be performed by suffix tree in linear time.

15.

Who proposed the concept of Suffix Tree?(a) Weiner(b) Samuel F. B. Morse(c) Friedrich Clemens Gerke(d) Alexander MorseThis interesting question is from Suffix Tree topic in division Trie of Data Structures & Algorithms IThe question was asked in examination.

Answer»

Right OPTION is (a) Weiner

The BEST explanation: In COMPUTER science, a suffix tree is also KNOWN as PAT tree or POSITION tree. It is a compressed search tree or prefix tree in which keys contain the suffix of text values as the text position. The concept of Suffix Tree was introduced by Weiner in 1973.

16.

Who among the following provided the first online contribution of Suffix Tree?(a) Weiner(b) Samuel F. B. Morse(c) Ukkonen(d) Alexander MorseMy question comes from Suffix Tree in division Trie of Data Structures & Algorithms IThis question was addressed to me in an internship interview.

Answer»

Right choice is (c) UKKONEN

Easy explanation - In computer science, a suffix tree is also known as PAT tree or position tree. The concept of Suffix Tree was introduced by WEINER in 1973. Ukkonen provided the first ONLINE CONTRIBUTION of Suffix tree which had the time complexity of the fastest algorithm of that period.

17.

What is the time complexity of Uttkonen’s algorithm?(a) O (log n!)(b) O (n!)(c) O (n^2)(d) O (n log n)I need to ask this question from Suffix Tree in division Trie of Data Structures & Algorithms IThis question was posed to me in my homework.

Answer» CORRECT option is (d) O (n log n)

To explain: The concept of SUFFIX Tree was INTRODUCED by Weiner in 1973. UKKONEN provided the FIRST online contribution of Suffix tree which had the time complexity of the fastest algorithm of that period. Ukkonen’s algorithm had a time complexity of n log n.
18.

Who among the following algorithm is used in external memory and compression of the suffix tree?(a) Weiner’s algorithm(b) Farach’s algorithm(c) Ukkonen’s algorithm(d) Alexander MorseOrigin of the question is Suffix Tree topic in section Trie of Data Structures & Algorithms IThis question was addressed to me by my college professor while I was bunking the class.

Answer»

Right choice is (b) Farach’s algorithm

To explain: The concept of Suffix Tree was INTRODUCED by Weiner in 1973. Ukkonen PROVIDED the FIRST online contribution of the Suffix tree. Farach gave the first suffix tree contribution for all ALPHABETS in 1997. Farach’s algorithm is used in external memory and compression.

19.

Who among the following provided the first suffix tree contribution for all alphabet?(a) Weiner(b) Farach(c) Ukkonen(d) Alexander MorseI would like to ask this question from Suffix Tree topic in portion Trie of Data Structures & Algorithms IThe question was asked in a national level competition.

Answer»

Correct CHOICE is (b) Farach

Best explanation: The concept of Suffix Tree was introduced by Weiner in 1973. UKKONEN provided the first online contribution of Suffix tree which had the time complexity of the fastest ALGORITHM of that period. Farach GAVE the first suffix tree contribution for all alphabets in 1997.

20.

Do all the nodes have at least two children in suffix tree.(a) True(b) FalseI want to ask this question from Suffix Tree topic in section Trie of Data Structures & Algorithms II have been asked this question during an interview.

Answer»

The correct choice is (b) False

To explain: It is a COMPRESSED search tree or prefix tree in which KEYS contain the suffix of text values as the text position. All the nodes (INTERNAL) except for the root nodes have at least two CHILDREN.

21.

Which statement is correct of suffix tree with a string of length n?(a) The tree has n leaves.(b) The tree has n roots(c) Height of Tree is n(d) Depth of tree is nThe origin of the question is Suffix Tree in division Trie of Data Structures & Algorithms II had been asked this question in my homework.

Answer»

The correct option is (a) The tree has n leaves.

To explain: In computer science, a suffix tree is also known as PAT tree or POSITION tree. It is a compressed SEARCH tree or PREFIX tree in which keys contain the suffix of text values as the text position. For a string of length n, the suffix tree has leaves equal to n.

22.

Can the two edges that are coming out of a node have labels of string beginning with the same character?(a) True(b) FalseThis key question is from Suffix Tree topic in portion Trie of Data Structures & Algorithms II have been asked this question in semester exam.

Answer»

The correct choice is (b) False

Explanation: It is a compressed SEARCH TREE or prefix tree in which keys contain the suffix of text values as the text POSITION. All the nodes (internal) except for the root nodes have at least two children. No two edges that are COMING out of a node have labels of STRING beginning with the same character.

23.

Which tree allows fast implementation of a set of string operation?(a) Rope Tree(b) Tango Tree(c) Generalized Suffix Tree(d) Top TreeThe above asked question is from Suffix Tree in chapter Trie of Data Structures & Algorithms II got this question in an interview for internship.

Answer»

Correct option is (c) Generalized Suffix Tree

The best explanation: In computer SCIENCE, the generalized suffix is a special suffix tree which contains a set of strings or set of WORDS instead of a single STRING like suffix tree.Hence DIFFERENT operation can be PERFORMED on a set of strings using a generalized suffix tree.

24.

What is a time complexity for checking a string of length n is substring or not?(a) O (log n!)(b) O (n!)(c) O (n^2)(d) O (n)My question is taken from Suffix Tree in chapter Trie of Data Structures & Algorithms II have been asked this question by my college professor while I was bunking the class.

Answer»

Correct OPTION is (d) O (N)

Explanation: Suffix tree is also known as PAT tree or position tree. It allows fast STRING operation. Total time taken for construction of suffix tree is linear to the length of the tree. To CHECK if a substring is present in a string of a length of n, the time complexity for such operation is FOUND to be O (n).

25.

What is a time complexity for x pattern occurrence of length n?(a) O (log n!)(b) Ɵ (n!)(c) O (n^2)(d) Ɵ (n + x)I want to ask this question from Suffix tree topic in portion Trie of Data Structures & Algorithms II have been asked this question in an online quiz.

Answer»

The correct option is (d) Ɵ (n + x)

The explanation is: Suffix tree is ALSO KNOWN as PAT tree or position tree. It allows fast string operation. To check if a substring is PRESENT in a string of a length of n, the time COMPLEXITY for such operation is found to be O (n). The time complexity for x pattern occurrence of length n is Ɵ (n + x).

26.

What is a time complexity for finding the longest substring that is common in string S1 and S2 (n1 and n2 are the string lengths of strings s1, s2 respectively)?(a) O (log n!)(b) Ɵ (n!)(c) O (n^2+ n1)(d) Ɵ (n1 + n2)Question is taken from Suffix tree in chapter Trie of Data Structures & Algorithms II had been asked this question at a job interview.

Answer»

The correct answer is (d) Ɵ (N1 + n2)

Easy explanation - Suffix Tree ALLOWS fast string operation. To check if a substring is PRESENT in a string of a LENGTH of n, the time complexity for such operation is found to be O (n). The time complexity for finding the longest substring that is COMMON in string S1 and S2 is Ɵ (n1 + n2).

27.

What is a time complexity for finding the longest substring that is repeated in a string?(a) O (log n!)(b) Ɵ (n!)(c) O (n^2+ n1)(d) Ɵ (n)This interesting question is from Suffix tree topic in chapter Trie of Data Structures & Algorithms IThis question was addressed to me during an internship interview.

Answer»

Right choice is (d) Ɵ (n)

EASIEST explanation - SUFFIX Tree ALLOWS fast string OPERATION. To check if a substring is present in a string of a length of n, the TIME complexity for such operation is found to be O (n). The time complexity for finding the longest substring that is repeated in a string is Ɵ (n).

28.

What is a time complexity for finding frequently occurring of a substring of minimum length in a string?(a) Ɵ (n)(b) Ɵ (n!)(c) O (n^2+ n1)(d) O (log n!)This interesting question is from Suffix tree in division Trie of Data Structures & Algorithms II got this question during an internship interview.

Answer» RIGHT choice is (a) Ɵ (n)

The best explanation: Suffix Tree allows FAST string operation. To check if a substring is present in a string of a length of n, the TIME complexity for such operation is found to be O (n). The time complexity for FINDING frequently occurring of a substring of minimum length in a string is Ɵ (n).
29.

What is a time complexity for finding the longest prefix that is common between suffix in a string?(a) Ɵ (n)(b) Ɵ (n!)(c) Ɵ (1)(d) O (log n!)This question is from Suffix tree in division Trie of Data Structures & Algorithms IThis question was posed to me in an interview.

Answer» RIGHT option is (c) Ɵ (1)

The best explanation: Suffix Tree allows fast string operation. To check if a substring is present in a string of a length of N, the time complexity for such operation is found to be O (n). The time complexity for finding the longest PREFIX that is COMMON between suffix in a string is Ɵ (1).
30.

What is a time complexity for finding all the maximal palindrome in a string?(a) Ɵ (n)(b) Ɵ (n!)(c) Ɵ (1)(d) O (log n!)Question is from Suffix tree in chapter Trie of Data Structures & Algorithms II have been asked this question in examination.

Answer» CORRECT choice is (a) Ɵ (n)

The explanation is: Palindrome is a string that is the same when READING forward as well as backward. To CHECK if a substring is present in a string of a LENGTH of n, the time complexity for such operation is found to be O (n). The time complexity for finding all the maximal palindrome in a string is Ɵ (n).
31.

What is a time complexity for finding all the tandem repeats?(a) Ɵ (n)(b) Ɵ (n!)(c) Ɵ (1)(d) O (n log n + z)Query is from Suffix tree topic in chapter Trie of Data Structures & Algorithms IThe question was posed to me at a job interview.

Answer»

The correct option is (a) Ɵ (n)

Best EXPLANATION: Tandem REPEATS are formed in DNA when the NUCLEOTIDES pattern repeats more than once. To check if a substring is present in a string of a length of n, the time complexity for such OPERATION is found to be O (n). The time complexity for finding all the tandem repeats in a string is O (n log n + z).

32.

What is a time complexity for finding the longest palindromic substring in a string by using the generalized suffix tree?(a) Linear Time(b) Exponential Time(c) Logarithmic Time(d) Cubic TimeThe above asked question is from Suffix tree in section Trie of Data Structures & Algorithms II got this question in an online interview.

Answer»

Right option is (a) Linear Time

The explanation is: Palindrome is a string that is same when READING forward as WELL as BACKWARD. The time complexity for finding the longest palindromic substring in a string by using GENERALIZED suffix tree is linear time.

33.

Which of the following algorithm of data compression uses a suffix tree?(a) Weiner’s algorithm(b) Farach’s algorithm(c) Lempel – Ziv – Welch’s algorithm(d) Alexander Morse’s algorithmThe question is from Suffix tree topic in chapter Trie of Data Structures & Algorithms IThe question was asked during an interview.

Answer»

The CORRECT option is (C) Lempel – Ziv – Welch’s algorithm

The best explanation: The concept of Suffix Tree was introduced by Weiner in 1973. Ukkonen provided the first online CONTRIBUTION of the Suffix tree. FARACH GAVE the first suffix tree contribution for all alphabets in 1997. Lempel – Ziv – Welch’s algorithm of data compression uses a suffix tree.

34.

Which of the following data clustering algorithm uses suffix tree in search engines?(a) Weiner’s algorithm(b) Farach’s algorithm(c) Lempel – Ziv – Welch’s algorithm(d) Suffix Tree ClusteringThis key question is from Suffix tree in chapter Trie of Data Structures & Algorithms II had been asked this question in an online quiz.

Answer»

Correct option is (d) Suffix Tree Clustering

For explanation: The concept of Suffix Tree was INTRODUCED by Weiner in 1973. Ukkonen provided the first online contribution of Suffix. Farach gave the first suffix tree contribution for all alphabets in 1997. Suffix Tree Clustering is a data clustering algorithm that USES suffix tree in search ENGINES.

35.

What is a time complexity for finding the total length of all string on all edges of a tree?(a) Ɵ (n)(b) Ɵ (n!)(c) Ɵ (1)(d) O (n^2)This is a very interesting question from Suffix tree topic in chapter Trie of Data Structures & Algorithms IThe question was posed to me by my college professor while I was bunking the class.

Answer»

Correct choice is (d) O (N^2)

The best I can EXPLAIN: To check if a substring is present in a string of a length of n, the time COMPLEXITY for such OPERATION is FOUND to be O (n). The time complexity for finding the total length of all string on all edges of a tree is O (n^2).

36.

Can suffix tree be used in string problems occurring in a text editor.(a) True(b) FalseThe doubt is from Suffix tree in section Trie of Data Structures & Algorithms II got this question in an online quiz.

Answer» RIGHT answer is (a) True

The best I can explain: It is a compressed search tree or prefix tree in which keys contain the suffix of text values as the text POSITION. So, the suffix tree can be used in string PROBLEMS occurring in a text editor. The time TAKEN to solve the PROBLEM is linear to the length of the string.
37.

Can suffix tree be used in bioinformatics problems and solutions.(a) True(b) FalseThis interesting question is from Suffix tree in division Trie of Data Structures & Algorithms IThe question was posed to me during an internship interview.

Answer»

Right option is (a) True

The best explanation: It is a compressed SEARCH tree or prefix tree in which keys contain the suffix of text VALUES as the text position. So, a suffix tree is used in bioinformatics PROBLEMS and solutions LIKE pattern SEARCHING in DNA and protein sequences.

38.

For what size of nodes, the worst case of usage of space in suffix tree seen?(a) n Nodes(b) 2^n Nodes(c) 2n nodes(d) n! nodesQuestion is taken from Suffix tree in division Trie of Data Structures & Algorithms IThe question was posed to me during an online exam.

Answer»

Right CHOICE is (c) 2n nodes

The BEST I can explain: In computer science, the WORST case of usage of space in a suffix TREE is found to be for a Fibonacci word for a full 2n nodes. The time complexity for usage of space is found to be O (n).

39.

What is a time complexity for inserting an alphabet in the tree using hash maps?(a) O (log n!)(b) O (n!)(c) O (n^2)(d) O (1)The origin of the question is Suffix tree topic in chapter Trie of Data Structures & Algorithms IThis question was addressed to me during an interview.

Answer»

The correct choice is (d) O (1)

Best explanation: SUFFIX tree is also known as PAT tree or position tree. It allows fast string operation. Total time taken for construction of suffix tree is linear to the length of the tree. The time complexity for inserting an alphabet in the tree using hash MAPS is CONSTANT, O (1).