GATE 2025 (Session 1)
65 questions
MCQ 30 · MSQ 13 · NAT 221-mark 30 · 2-mark 35
Questions 26–30 of 65
Which of the following statement(s) is/are TRUE for any binary search tree (BST) having distinct integers?
One or more options are correct.
Answer: (A), (B)
We check each statement for a BST with distinct integers.
- The longest path from the root to any node is : True. In the worst case the BST is fully skewed (degenerate), like a linked list. All nodes lie in one chain. The path from the root to the deepest node then has edges. It can never be longer, because the tree has only nodes.
- Inorder traversal always gives sorted order: True. This is the main property of a BST: left subtree node right subtree, applied at every level. It holds for any tree shape.
- Finding an element takes time in the worst case: False. This bound holds only for a balanced BST. A skewed (degenerate) BST, as seen above, can push the search time up to .
- Every BST is also a Min-Heap: False. A min-heap needs every parent to be smaller than both children. A BST only orders the nodes as left parent right. So a BST can break the heap order.
Answer: The maximum path length is n-1, and inorder traversal always gives sorted order.
- The longest path from the root to any node is : True. In the worst case the BST is fully skewed (degenerate), like a linked list. All nodes lie in one chain. The path from the root to the deepest node then has edges. It can never be longer, because the tree has only nodes.
- Inorder traversal always gives sorted order: True. This is the main property of a BST: left subtree node right subtree, applied at every level. It holds for any tree shape.
- Finding an element takes time in the worst case: False. This bound holds only for a balanced BST. A skewed (degenerate) BST, as seen above, can push the search time up to .
- Every BST is also a Min-Heap: False. A min-heap needs every parent to be smaller than both children. A BST only orders the nodes as left parent right. So a BST can break the heap order.
Answer: The maximum path length is n-1, and inorder traversal always gives sorted order.
A partial data path of a processor is given in the figure, where , , and are 32-bit registers. Which option(s) is/are CORRECT related to arithmetic operations using the data path as shown?
One or more options are correct.
Answer: (A), (B), (C)
The data path has these parts:
- Two 32-bit registers: RA and RB.
- Two multiplexers (Mux_A and Mux_B).
- Each multiplexer can pick one of two inputs: - the value of its own register, or - a 32-bit immediate value.
- The picked inputs go to the ALU, and the ALU output is stored in register RZ.
So the ALU can get these operand pairs:
Now check each statement.
Option A: The data path can implement arithmetic operations involving two registers.
Mux_A can pick RA and Mux_B can pick RB, so the ALU can do operations like
So Option A is Correct.
Option B: The data path can implement arithmetic operations involving one register and one immediate value.
Examples:
or
So Option B is Correct.
Option C: The data path can implement arithmetic operations involving two immediate values. Each multiplexer can pick its immediate input on its own, so the ALU can do operations like
So Option C is Correct.
Option D: The data path can only implement arithmetic operations involving one register and one immediate value. This is false because the data path also supports:
- Register + Register
- Immediate + Immediate
- Register + Immediate
So Option D is Incorrect.
Answer: (A), (B), (C)
- Two 32-bit registers: RA and RB.
- Two multiplexers (Mux_A and Mux_B).
- Each multiplexer can pick one of two inputs: - the value of its own register, or - a 32-bit immediate value.
- The picked inputs go to the ALU, and the ALU output is stored in register RZ.
So the ALU can get these operand pairs:
| Mux_A | Mux_B | Operands |
|---|---|---|
| RA | RB | Two registers |
| RA | Immediate | One register + one immediate |
| Immediate | RB | One immediate + one register |
| Immediate | Immediate | Two immediate values |
Now check each statement.
Option A: The data path can implement arithmetic operations involving two registers.
Mux_A can pick RA and Mux_B can pick RB, so the ALU can do operations like
So Option A is Correct.
Option B: The data path can implement arithmetic operations involving one register and one immediate value.
Examples:
or
So Option B is Correct.
Option C: The data path can implement arithmetic operations involving two immediate values. Each multiplexer can pick its immediate input on its own, so the ALU can do operations like
So Option C is Correct.
Option D: The data path can only implement arithmetic operations involving one register and one immediate value. This is false because the data path also supports:
- Register + Register
- Immediate + Immediate
- Register + Immediate
So Option D is Incorrect.
Answer: (A), (B), (C)
A regular language is accepted by a non-deterministic finite automaton (NFA) with states. Which of the following statement(s) is/are FALSE?
One or more options are correct.
Answer: (D)
Let the regular language be accepted by an NFA with states. Two standard facts help here: (1) the subset construction always gives an equivalent DFA with at most states, and (2) the number of states in an NFA or DFA for a language is not unique. A smaller equivalent automaton can exist.
- " may have an accepting NFA with states": this can be true, because the -state NFA may not be minimal. So it is not a false statement.
- " may have an accepting DFA with states": this is also possible, depending on the language. So it is also true, not false.
- "There exists a DFA with states accepting ": the subset construction guarantees this. So it is also true, not false.
- "Every DFA that accepts L has states": this contradicts the subset construction, since a DFA with at most states always exists. So this statement is FALSE.
Answer: "Every DFA that accepts L has more than states" is the FALSE statement.
- " may have an accepting NFA with states": this can be true, because the -state NFA may not be minimal. So it is not a false statement.
- " may have an accepting DFA with states": this is also possible, depending on the language. So it is also true, not false.
- "There exists a DFA with states accepting ": the subset construction guarantees this. So it is also true, not false.
- "Every DFA that accepts L has states": this contradicts the subset construction, since a DFA with at most states always exists. So this statement is FALSE.
Answer: "Every DFA that accepts L has more than states" is the FALSE statement.
Suppose in a multiprogramming environment, the following C program segment is executed. A process goes into I/O queue whenever an I/O related operation is performed. Assume that there will always be a context switch whenever a process requests for an I/O, and also whenever the process returns from an I/O. The number of times the process will enter the ready queue during its lifetime (not counting the time the process enters the ready queue when it is run initially) is _______. (Answer in integer)
int main()
{
int x=0,i=0;
scanf("%d",&x);
for(i=0; i<20; i++)
{
x = x + 20;
printf("%d\n",x);
}
return 0;
}
Answer: 21
Each time the process does an I/O operation, it leaves the CPU and goes to the I/O queue. When the I/O finishes, it must enter the ready queue again to wait for the CPU (context switch back).
Now count the I/O operations in this program. There is one at the start. There is also one in each of the loop iterations. So the total number of I/O operations is .
Each of these I/O completions sends the process into the ready queue once. The first entry into the ready queue, when the process starts, is not counted, and this count already leaves it out.
Answer: 21
Now count the I/O operations in this program. There is one at the start. There is also one in each of the loop iterations. So the total number of I/O operations is .
Each of these I/O completions sends the process into the ready queue once. The first entry into the ready queue, when the process starts, is not counted, and this count already leaves it out.
Answer: 21
Let be the set of all ternary strings defined over the alphabet . Consider all strings in that contain at least one occurrence of two consecutive symbols, that is, "aa", "bb" or "cc". The number of such strings of length 5 that are possible is _______. (Answer in integer)
Answer: 195
Count all ternary strings of length over : .
Counting the complement is easier. These are the strings with no two equal symbols side by side. The first symbol can be chosen in ways. Each next symbol only has to differ from the symbol just before it, so it has choices every time. This gives such "no-repeat" strings.
So the number of strings with at least one consecutive repeat .
Answer: 195
Counting the complement is easier. These are the strings with no two equal symbols side by side. The first symbol can be chosen in ways. Each next symbol only has to differ from the symbol just before it, so it has choices every time. This gives such "no-repeat" strings.
So the number of strings with at least one consecutive repeat .
Answer: 195