GATE 2024
64 questions
MCQ 36 · MSQ 12 · NAT 161-mark 29 · 2-mark 35
Questions 36–40 of 64
Let be a function. Note: denotes the set of real numbers.
Which ONE of the following choices gives the values of that make the function continuous and differentiable?
Which ONE of the following choices gives the values of that make the function continuous and differentiable?
Answer: (A)
We need f to be continuous and differentiable at and . This gives the following conditions:
1. Continuity at :
must be continuous at . So the value from the left side equals the value from the middle interval:
On simplifying:
2. Continuity at :
In the same way, the value from the middle interval equals the value from the right side:
On simplifying:
Now the differentiability equations
3. Differentiability at :
For differentiability at , the derivative from the left side equals the derivative from the middle interval. The derivative of is , and the derivative of is :
On simplifying:
4. Differentiability at :
For differentiability at , the derivative from the middle interval equals the derivative from the right side. The derivative of is :
On simplifying:
Solving the equations
We have four equations:
1.
2.
3.
4.
Subtract Equation 1 from Equation 2 to remove :
Put in the other equations:
1. From Equation 1:
2. From Equation 3:
3. Put in Equation 1 to get :
Final Answer
The values of , and that make continuous and differentiable are:
So the correct answer is:
Option A:
1. Continuity at :
must be continuous at . So the value from the left side equals the value from the middle interval:
On simplifying:
2. Continuity at :
In the same way, the value from the middle interval equals the value from the right side:
On simplifying:
Now the differentiability equations
3. Differentiability at :
For differentiability at , the derivative from the left side equals the derivative from the middle interval. The derivative of is , and the derivative of is :
On simplifying:
4. Differentiability at :
For differentiability at , the derivative from the middle interval equals the derivative from the right side. The derivative of is :
On simplifying:
Solving the equations
We have four equations:
1.
2.
3.
4.
Subtract Equation 1 from Equation 2 to remove :
Put in the other equations:
1. From Equation 1:
2. From Equation 3:
3. Put in Equation 1 to get :
Final Answer
The values of , and that make continuous and differentiable are:
So the correct answer is:
Option A:
Consider the following Python code:
def count(child_dict, i):
if i not in child_dict.keys():
return 1
ans = 1
for j in child_dict[i]:
ans += count(child_dict, j)
return ans
child_dict = dict()
child_dict[0] = [1,2]
child_dict[1] = [3,4,5]
child_dict[2] = [6,7,8]
print(count(child_dict,0))
Which ONE of the following is the output of this code?Answer: (D)
count(child_dict, i) counts the nodes in the tree below node i, including i itself.If
i is not a key in child_dict, it has no children, so the function returns . Otherwise it starts with ans = 1 for the node itself, then adds count(child_dict, j) for every child j, and returns ans.The dictionary is:
child_dict[0] = [1, 2]child_dict[1] = [3, 4, 5]child_dict[2] = [6, 7, 8]Trace
count(child_dict, 0):Nodes are not keys, so each returns .
count(child_dict, 1): .count(child_dict, 2): .count(child_dict, 0): .The output is .
Answer: (D)
Consider the function whose pseudocode is given below:
S[1] ← 1
for i ← 2 to length(X)
S[i] ← 1
if X[i-1] ≤ X[i]
S[i] ← S[i]+S[i-1]
end if
end for
return S
Which ONE of the following values is returned by the function for ?Answer: (C)
Use 1-based indices as in the pseudocode. . by default, and it becomes when . So is the length of the non-decreasing run that ends at position .
: is false, so .
: is true, so .
: is false, so .
: is true, so .
The result is . Options (A) and (B) wrongly carry the count over at , where 5 > 4. Option (D) gives 5 at the end, but so .
Answer: (C)
: is false, so .
: is true, so .
: is false, so .
: is true, so .
The result is . Options (A) and (B) wrongly carry the count over at , where 5 > 4. Option (D) gives 5 at the end, but so .
Answer: (C)
Let denote the maximum number of comparisons made while searching for an entry in a sorted array of size using binary search.
Which ONE of the following options is TRUE?
Which ONE of the following options is TRUE?
Answer: (A)
In each step, binary search compares the key with the middle element. That is 1 comparison. If the key is not the middle element, only one of the two parts is searched further.
After removing the middle element, the other elements are split into parts of size and . For the worst case we take the larger part, and . So
Why the other options are wrong:
- (B) would mean searching both halves. Binary search searches only one.
- (C) leaves out the comparison made at each step.
- (D) shrinks the array by only 1 element each time, which is linear search, not binary search.
Answer: (A)
After removing the middle element, the other elements are split into parts of size and . For the worst case we take the larger part, and . So
Why the other options are wrong:
- (B) would mean searching both halves. Binary search searches only one.
- (C) leaves out the comparison made at each step.
- (D) shrinks the array by only 1 element each time, which is linear search, not binary search.
Answer: (A)
Consider the following Python function:
def fun(D, s1, s2):
if s1 < s2:
D[s1], D[s2] = D[s2], D[s1]
fun(D, s1+1, s2-1) What does this Python function fun() do? Select the ONE appropriate option below.Answer: (C)
When , each call swaps and , then calls itself on . So the outermost pair is swapped first, then the next pair inward, and so on. The calls stop when the two indices meet (odd length, the middle element stays) or cross (even length).
Example: , . Swap indices 0 and 4, then 1 and 3, then stop at . The result is , so the elements from to are reversed.
If at the first call, the condition fails at once and nothing changes. The question is about the range to , so that case is not the intended one.
The other options are wrong. The function never compares values, so it does not find a minimum (A) or sort (B). It swaps many pairs, not just the one at and , when (D).
Answer: (C)
Example: , . Swap indices 0 and 4, then 1 and 3, then stop at . The result is , so the elements from to are reversed.
If at the first call, the condition fails at once and nothing changes. The question is about the range to , so that case is not the intended one.
The other options are wrong. The function never compares values, so it does not find a minimum (A) or sort (B). It swaps many pairs, not just the one at and , when (D).
Answer: (C)