Explore topic-wise MCQs in Data Structures and Algorithms.

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

1.

What is the space complexity of the following dynamic programming implementation of the boolean parenthesization problem?

A. O(1)
B. O(n)
C. O(n2)
D. O(n3)View Answer
Answer» D. O(n3)View Answer
2.

What is the time complexity of the following dynamic programming implementation of the boolean parenthesization problem?

A. O(1)
B. O(n)
C. O(n2)
D. O(n3)View Answer
Answer» E.
3.

Which of the following lines should be added to complete the “if(op[k] == ‘&’)” part of the following code?

A. True[row][col] += False[row][pos] * False[pos+1][col]; False[row][col] += t_row_pos * t_pos_col – True[row][pos] * True[pos+1][col];
B. True[row][col] += True[row][pos] * True[pos+1][col]; False[row][col] += t_row_pos * t_pos_col – True[row][pos] * True[pos+1][col];
C. True[row][col] += True[row][pos] * False[pos+1][col]; False[row][col] += t_row_pos * t_pos_col – False[row][pos] * True[pos+1][col];
D. True[row][col] += False[row][pos] * True[pos+1][col]; False[row][col] += t_row_pos * t_pos_col – False[row][pos] * True[pos+1][col];View Answer
Answer» C. True[row][col] += True[row][pos] * False[pos+1][col]; False[row][col] += t_row_pos * t_pos_col – False[row][pos] * True[pos+1][col];
4.

Consider the following dynamic programming implementation of the boolean parenthesization problem: Which of the following lines should be added to complete the “if(op[pos] == ‘|’)” part of the code?

A. False[row][col] += True[row][pos] * False[pos+1][col]; True[row][col] += t_row_pos * t_pos_col + False[row][pos] * False[pos+1][col];
B. False[row][col] += False[row][pos] * True[pos+1][col]; True[row][col] += t_row_pos * t_pos_col – True[row][pos] * True[pos+1][col];
C. False[row][col] += True[row][pos] * True[pos+1][col]; True[row][col] += t_row_pos * t_pos_col + True[row][pos] * True[pos+1][col];
D. False[row][col] += False[row][pos] * False[pos+1][col]; True[row][col] += t_row_pos * t_pos_col – False[row][pos] * False[pos+1][col];View Answer
Answer» E.
5.

Consider the expression T | F ∧ T. In how many ways can the expression be parenthesized so that the output is F (false)?

A. 0
B. 1
C. 2
D. 3
E. ?a) 0b) 1c) 2d) 3
Answer» C. 2
6.

Consider the expression T & F ∧ T. What is the number of ways in which the expression can be parenthesized so that the output is T (true)?

A. 0
B. 1
C. 2
D. 3
E. ?a) 0b) 1c) 2d) 3
Answer» D. 3
7.

You are given a boolean expression which consists of operators &, | and ∧ (AND, OR and XOR) and symbols T or F (true or false). You have to find the number of ways in which the symbols can be parenthesized so that the expression evaluates to true. This is the boolean parenthesization problem. Which of the following methods can be used to solve the problem?

A. Dynamic programming
B. Recursion
C. Brute force
D. Dynamic programming, Recursion and Brute force
E. . You have to find the number of ways in which the symbols can be parenthesized so that the expression evaluates to true. This is the boolean parenthesization problem. Which of the following methods can be used to solve the problem?a) Dynamic programmingb) Recursionc) Brute forced) Dynamic programming, Recursion and Brute force
Answer» E. . You have to find the number of ways in which the symbols can be parenthesized so that the expression evaluates to true. This is the boolean parenthesization problem. Which of the following methods can be used to solve the problem?a) Dynamic programmingb) Recursionc) Brute forced) Dynamic programming, Recursion and Brute force
8.

What is the space complexity of the above dynamic programming implementation of the boolean parenthesization problem?$

A. O(1)
B. O(n)
C. O(n<sup>2</sup>)
D. O(n<sup>3</sup>)
Answer» E.
9.

What_is_the_time_complexity_of_the_above_dynamic_programming_implementation_of_the_boolean_parenthesization_problem?$

A. O(1)
B. O(n)
C. O(n<sup>2</sup>)
D. O(n<sup>3</sup>)
Answer» D. O(n<sup>3</sup>)
10.

” part of the code?#

A. False[row][col] += True[row][pos] * False[pos+1][col];
B.
Answer» C.
11.

What is the maximum number of ways in which a boolean expression with n + 1 terms can be parenthesized, such that the output is true?

A. nth catalan number
B. n factorial
C. n cube
D. n square
Answer» B. n factorial
12.

Which of the following gives the total number of ways of parenthesizing an expression with n + 1 terms?

A. n factorial
B. n square
C. n cube
D. nth catalan number
Answer» E.
13.

Consider the expression T | F ‚àß T. In how many ways can the expression be parenthesized so that the output is F (false)?$

A. 0
B. 1
C. 2
D. 3
Answer» C. 2
14.

Consider the expression T & F ‚àß T. What is the number of ways in which the expression can be parenthesized so that the output is T (true)?$

A. 0
B. 1
C. 2
D. 3
Answer» D. 3
15.

Consider the expression T & F | T. What is the number of ways in which the expression can be parenthesized so that the output is T (true)?

A. 0
B. 1
C. 2
D. 3
Answer» C. 2
16.

You are given a boolean expression which consists of operators &, | and ‚àß (AND, OR and XOR) and symbols T or F (true or false). You have to find the number of ways in which the symbols can be parenthesized so that the expression evaluates to true. This is the boolean parenthesization problem. Which of the following methods can be used to solve the problem?

A. Dynamic programming
B. Recursion
C. Brute force
D. All of the mentioned
Answer» E.