GATE 2025 (Session 2)
65 questions
MCQ 32 · MSQ 18 · NAT 151-mark 30 · 2-mark 35
Questions 41–45 of 65
An array of length with distinct elements is said to be bitonic if there is an index such that is sorted in the non-decreasing order and is sorted in the non-increasing order.
Which ONE of the following represents the best possible asymptotic bound for the worst-case number of comparisons by an algorithm that searches for an element in a bitonic array ?
Which ONE of the following represents the best possible asymptotic bound for the worst-case number of comparisons by an algorithm that searches for an element in a bitonic array ?
Answer: (D)
A bitonic array first rises and then falls, so its largest element (the peak) splits it into a rising part and a falling part.
Upper bound. Step 1: find the peak with a binary-search-like method. Look at the middle element and its neighbour . If , the peak is to the right. Otherwise it is at or to the left. This takes comparisons. Step 2: the rising part is sorted in increasing order and the falling part in decreasing order, so plain binary search on each takes . Total: .
Lower bound. A completely sorted array is also bitonic (the case ). Searching a sorted array needs comparisons in the worst case. So no algorithm for bitonic arrays can do better.
So the best worst-case bound is . is below the lower bound, and and are larger than needed.
Answer: (D)
Upper bound. Step 1: find the peak with a binary-search-like method. Look at the middle element and its neighbour . If , the peak is to the right. Otherwise it is at or to the left. This takes comparisons. Step 2: the rising part is sorted in increasing order and the falling part in decreasing order, so plain binary search on each takes . Total: .
Lower bound. A completely sorted array is also bitonic (the case ). Searching a sorted array needs comparisons in the worst case. So no algorithm for bitonic arrays can do better.
So the best worst-case bound is . is below the lower bound, and and are larger than needed.
Answer: (D)
Let be the set of all functions from to . Define the binary relation on as follows:
Which of the following statement(s) is/are TRUE?
Which of the following statement(s) is/are TRUE?
One or more options are correct.
Answer: (B), (C)
holds exactly when is true for every . This is the usual pointwise "less than or equal to" order on binary functions.
- Reflexive: is always true. Antisymmetric: if and , then for all , so . Transitive: it carries through in the obvious way. So is a true partial order. It is not symmetric and not an equivalence relation, because for example does not give unless .
- Lattice: take any two functions . Their pointwise max (taking at every ) is the least upper bound. Their pointwise min is the greatest lower bound. Both always exist in . So is a lattice.
Answer: (F,⪯) is a partial order; and (F,⪯) is a lattice.
- Reflexive: is always true. Antisymmetric: if and , then for all , so . Transitive: it carries through in the obvious way. So is a true partial order. It is not symmetric and not an equivalence relation, because for example does not give unless .
- Lattice: take any two functions . Their pointwise max (taking at every ) is the least upper bound. Their pointwise min is the greatest lower bound. Both always exist in . So is a lattice.
Answer: (F,⪯) is a partial order; and (F,⪯) is a lattice.
Given the following Karnaugh Map for a Boolean function :
Which one or more of the following Boolean expression(s) represent(s) ?
Which one or more of the following Boolean expression(s) represent(s) ?
One or more options are correct.
Answer: (A), (D)
Read the K-map with rows and columns , both in the order 00, 01, 11, 10. The minterm number is read as a binary number. The 1s are at minterms .
When , only when . When , only when . This holds for every and . So F is the XNOR of and :
, which is option (D).
(A) The first four terms are minterms 0, 8, 2 and 10. Together they are with all values of and . So (A) is and matches F.
(B) The term is minterm 11, which is 0 in F, and minterms 8 and 10 are missing. Not equal to F.
(C) The term is minterm 9, which is 0 in F, and minterms 2 and 10 are missing. Not equal to F.
Answer: (A), (D)
When , only when . When , only when . This holds for every and . So F is the XNOR of and :
, which is option (D).
(A) The first four terms are minterms 0, 8, 2 and 10. Together they are with all values of and . So (A) is and matches F.
(B) The term is minterm 11, which is 0 in F, and minterms 8 and 10 are missing. Not equal to F.
(C) The term is minterm 9, which is 0 in F, and minterms 2 and 10 are missing. Not equal to F.
Answer: (A), (D)
Consider a system of linear equations where and . Suppose has an decomposition, , where
Which of the following statement(s) is/are TRUE?
Which of the following statement(s) is/are TRUE?
One or more options are correct.
Answer: (A), (B), (C)
(A) Put into to get . Set . First solve by forward substitution (L is lower triangular). Then solve by back substitution (U is upper triangular). This is the standard LU method. True.
(B) L is unit lower triangular, so and L is always invertible. Also . If P is invertible, , so and U is invertible. True.
(C) is the product of the diagonal entries of U, because U is triangular. If P is singular, , so at least one diagonal entry of U is 0. True.
(D) A triangular matrix is symmetric only if it is diagonal. If both L and U were symmetric, L would be diagonal with unit diagonal, so , and U would be diagonal, so would be diagonal. So a symmetric P that is not diagonal gives a counterexample. Take
.
P is symmetric, but neither L nor U is. False.
Answer: (A), (B), (C)
(B) L is unit lower triangular, so and L is always invertible. Also . If P is invertible, , so and U is invertible. True.
(C) is the product of the diagonal entries of U, because U is triangular. If P is singular, , so at least one diagonal entry of U is 0. True.
(D) A triangular matrix is symmetric only if it is diagonal. If both L and U were symmetric, L would be diagonal with unit diagonal, so , and U would be diagonal, so would be diagonal. So a symmetric P that is not diagonal gives a counterexample. Take
.
P is symmetric, but neither L nor U is. False.
Answer: (A), (B), (C)
Consider a stack data structure into which we can PUSH and POP records. Assume that each record pushed in the stack has a positive integer key and that all keys are distinct.
We wish to augment the stack data structure with an time MIN operation that returns a pointer to the record with the smallest key present in the stack
1) without deleting the corresponding record, and
2) without increasing the complexities of the standard stack operations.
Which one or more of the following approach(es) can achieve it?
We wish to augment the stack data structure with an time MIN operation that returns a pointer to the record with the smallest key present in the stack
1) without deleting the corresponding record, and
2) without increasing the complexities of the standard stack operations.
Which one or more of the following approach(es) can achieve it?
One or more options are correct.
Answer: (A)
We need an MIN operation, and PUSH and POP must not become slower.
Approach: store with every pushed record a pointer to the record that has the smallest key at or below it in the stack. This pointer is found once, at push time, by comparing the new key with the min pointer of the previous top. PUSH needs one comparison and one pointer copy (). POP only removes the top record. Its stored min pointer goes away with it, so the min is correct again for the new top (). MIN just reads the stored pointer of the top record (). So everything stays .
One global pointer to the minimum fails on POP. If the minimum record is popped, the next smallest cannot be found without scanning the rest of the stack. A sorted auxiliary array needs shifting on PUSH to stay sorted. A min-heap makes PUSH and POP cost instead of . This breaks the rule that the standard operations must not become slower.
Answer: Keep, with every record, a pointer to the record with the smallest key below it.
Approach: store with every pushed record a pointer to the record that has the smallest key at or below it in the stack. This pointer is found once, at push time, by comparing the new key with the min pointer of the previous top. PUSH needs one comparison and one pointer copy (). POP only removes the top record. Its stored min pointer goes away with it, so the min is correct again for the new top (). MIN just reads the stored pointer of the top record (). So everything stays .
One global pointer to the minimum fails on POP. If the minimum record is popped, the next smallest cannot be found without scanning the rest of the stack. A sorted auxiliary array needs shifting on PUSH to stay sorted. A min-heap makes PUSH and POP cost instead of . This breaks the rule that the standard operations must not become slower.
Answer: Keep, with every record, a pointer to the record with the smallest key below it.