Engineering Questions with Answers - Multiple Choice Questions

# Suffix Array Multiple Choice MCQ

1 - Question

Which of the following is false?
a) Suffix array is always sorted
b) Suffix array is used in string matching problems
c) Suffix array is always unsorted
d) Suffix array contains all the suffixes of the given string

Explanation: Suffix array is always sorted as it contains all the suffixes of a string in sorted order. Suffix arrays are used to solve problems related to string, like string matching problems.

2 - Question

Suffix array of the string “statistics” is ____________
a) 2 8 7 4 9 0 5 1 6 3
b) 2 7 4 9 8 0 5 1 6 3
c) 2 4 9 0 5 7 8 1 6 3
d) 2 8 7 0 5 1 6 9 4 3

Explanation: The suffix array of the string statistics will be:
2 atistics
8 cs
7 ics
4 istics
9 s
0 statistics
5 stics
1 tatistics
6 tics
3 tistics
In Suffix array, we only store the indices of suffixes. So, correct option is 2 8 7 4 9 0 5 1 6 3.

3 - Question

Suffix array can be created by performing __________ traversal of a suffix tree.
b) level order
c) depth-first
d) either breadth-first or level order

Explanation: A suffix tree is a trie, which contains all the suffixes of the given string as their keys and positions in the string as their values. So, we can construct a suffix array by performing the depth-first traversal of a suffix tree.

4 - Question

Suffix array is space efficient and faster than the suffix tree.
a) True
b) Fasle

Explanation: Suffix arrays are more space efficient than the suffix trees as they just store the original string and an array of integer. But working with suffix tree is faster than that of the suffix array.

5 - Question

If comparison based sorting algorithm is used construct the suffix array, then what will be time required to construct the suffix array?
a) O(nlogn)
b) O(n2)
c) O(n2logn)
d) O(n2) + O(logn)

Explanation: On average comparison based sorting algorithms require O(nlogn) comparisons. But comparing a suffix takes O(n). So, overall time to construct the suffix array will be O(nlogn) * O(n) = O(n2logn).

6 - Question

What will be the suffix array of the string “engineering”?
a) 2 3 8 4 9 1 7 5 0 6 10
b) 5 0 6 1 4 9 1 7 0 2 3 8
c) 5 0 6 10 2 4 9 1 7 3 8
d) 5 0 6 10 2 3 8 4 9 1 7

Explanation: Correct choice is : 5 0 6 10 2 3 8 4 9 1 7.
Because the suffix array formed will be: 5 eering 0 engineering 6 ering 10 g 2 gineering 3 ineering 8 ing 4 neering 9 ng 1 ngineering 7 ring.

7 - Question

LCP array and ______ is used to construct suffix tree.
a) Hash tree
b) Hash trie
c) Suffix array
d) Balanced tree

Explanation: Suffix tree can be created using an LCP array and a suffix array. If we are given a string of length (n + 1) and its suffix array and LCP array, we can construct the suffix tree in linear time i.e in O(n) time.

8 - Question

What is the time required to locate the occurrences of a pattern P of length m in a string of length n using suffix array?
a) O(nm)
b) O(n2)
c) O(mnlogn)
d) O(mlogn)

Explanation: Suffix arrays are used to find the occurrences of a pattern in a string. Pattern of length m will require m characters to compare, so using suffix array we can find occurrences of a pattern in the string of length n in O(mlogn) time.

9 - Question

Suffix array can be created in O(nlogn) time.
a) True
b) False

Explanation: Suffix array can be constructed in O(n2logn) time using sorting algorithms but it is possible to build the suffix array in O(nlogn) time using prefix doubling.

10 - Question

Which of the following is/are advantages suffix array one suffix tree?
I. Lesser space requirement
II. Improved cache locality
III. Easy construction in linear time
a) Only I
b) All I, II and III
c) Only I and III
d) Only II and III