GATE 2026 (Session 2)
65 questions
MCQ 35 · MSQ 11 · NAT 191-mark 30 · 2-mark 35
Questions 61–65 of 65
Consider the following ANSI-C function.
Note: Ignore syntax errors (if any) in the function.
int func(int start, int end){
int length=end+1-start;
if((length<1)||(start<0)||(end<0)){ return(0); }
if(length%3==0){
return(func(start+1, end));
}else if(length%3==1){
return(1+func(start, end-1));
}else {
return(func(start+2, end));
}
} The maximum possible value that can be returned from this function is ________. (answer in integer) Note: Ignore syntax errors (if any) in the function.
Answer: 1
Follow how changes in each recursive call. Only the branch adds to the result. The other two branches just call the function again and add nothing:
- If the current length is : call again with the length smaller by (nothing is added). The new length is .
- If the current length is : add and call again with the length smaller by . The new length is .
- If the current length is : call again with the length smaller by (nothing is added). The new length is .
Once the length enters the cycle , it can never come back to residue . The only moves from and both stay inside this same two-value cycle. So the "" branch can run only once in any chain of calls. This happens only if the length of the very first call is . After that one possible addition, the calls stay in the cycle, which adds nothing, until the base case ends them.
So the maximum value that can be returned for any valid input is .
Answer: 1
- If the current length is : call again with the length smaller by (nothing is added). The new length is .
- If the current length is : add and call again with the length smaller by . The new length is .
- If the current length is : call again with the length smaller by (nothing is added). The new length is .
Once the length enters the cycle , it can never come back to residue . The only moves from and both stay inside this same two-value cycle. So the "" branch can run only once in any chain of calls. This happens only if the length of the very first call is . After that one possible addition, the calls stay in the cycle, which adds nothing, until the base case ends them.
So the maximum value that can be returned for any valid input is .
Answer: 1
The determinant of a matrix is . The value of the determinant of is ________. (answer in integer)
Answer: 48
Take an matrix and a scalar . If every entry is multiplied by , the determinant gets multiplied by . This is because the determinant is a multilinear function of degree in the rows/columns: .
In this question we have , and :
.
Answer: 48
In this question we have , and :
.
Answer: 48
Suppose an unbiased coin is tossed times. Each coin toss is independent of all previous coin tosses. Let be the event that among the second, fourth, and sixth coin tosses, there are at least two heads. Let be the event that among the first, second, third, and fifth coin tosses, there are equal number of heads and tails.
The conditional probability is equal to ________ (rounded off to one decimal place)
The conditional probability is equal to ________ (rounded off to one decimal place)
Answer: 0.5
Toss and toss are not in the set of , which is . So they stay independent fair coins, whatever happens with .
Toss is in both the set of , which is , and the set of , which is . Given (exactly heads among tosses ), look at these fair coins. They are symmetric, so the chance that any one of them (in particular, toss ) is heads is . This is the same as its normal probability. So conditioning on does not change the chance of heads for toss .
So, given , tosses act like independent fair coins. We need :
.
Answer: 0.5
Toss is in both the set of , which is , and the set of , which is . Given (exactly heads among tosses ), look at these fair coins. They are symmetric, so the chance that any one of them (in particular, toss ) is heads is . This is the same as its normal probability. So conditioning on does not change the chance of heads for toss .
So, given , tosses act like independent fair coins. We need :
.
Answer: 0.5
Consider a function defined as follows.
For a real number , if the second digit after the decimal point in is one of the four digits and . Otherwise, is equal to .
The number of points in at which is discontinuous is ______. (Answer in integer)
For a real number , if the second digit after the decimal point in is one of the four digits and . Otherwise, is equal to .
The number of points in at which is discontinuous is ______. (Answer in integer)
Answer: 40
The value of depends only on the second digit after the decimal point of . So splits into equal sub-intervals of length (one for every pair of first two decimal digits). Inside each sub-interval is constant, so it can jump only at the inner boundary points . A boundary is a discontinuity only if the value of really changes across it, that is, if the second digit moves between the "special" set and the other digits.
Fix the first digit. The second digit runs through , and the pattern of special (S) and non-special (N) is N,N,S,S,N,N,S,S,N,N.
- Inside this block there are transitions (). The value changes at and , which is four changes. At the other five it stays the same.
- The boundary between two blocks is the step from second digit to the of the next first digit. This is a separate case: both are non-special, so stays and there is no jump.
So each of the first-digit blocks gives exactly discontinuities, and the block boundaries add none. Total .
Answer: 40
Fix the first digit. The second digit runs through , and the pattern of special (S) and non-special (N) is N,N,S,S,N,N,S,S,N,N.
- Inside this block there are transitions (). The value changes at and , which is four changes. At the other five it stays the same.
- The boundary between two blocks is the step from second digit to the of the next first digit. This is a separate case: both are non-special, so stays and there is no jump.
So each of the first-digit blocks gives exactly discontinuities, and the block boundaries add none. Total .
Answer: 40
It is necessary to design a link-layer protocol between two hosts that are directly connected over a lossless link of length kilometers. Assume that the link bandwidth is bits per second and that the propagation delay in the link is nanoseconds per meter. Every transmitted data byte is assigned a unique sequence number.
Let be the minimum number of bits needed for the sequence number field in the protocol header such that:
(i) the sequence numbers do not wrap around before seconds, and
(ii) the maximum utilization of the link is achieved.
The value of is ______. (answer in integer)
Let be the minimum number of bits needed for the sequence number field in the protocol header such that:
(i) the sequence numbers do not wrap around before seconds, and
(ii) the maximum utilization of the link is achieved.
The value of is ______. (answer in integer)
Answer: 30
One-way propagation delay: ms. So the round-trip time is ms, which s.
Condition (ii), maximum utilization: the window in bits must be at least the bandwidth-delay product. That gives bits, which bytes. This needs at least sequence-number bits.
Condition (i), no wraparound within 60 s: the bytes sent in s at full bandwidth bytes. We need , so (because ).
Here has to meet both conditions together. The stricter one is condition (i), which needs bits, so it sets the answer.
Answer: 30
Condition (ii), maximum utilization: the window in bits must be at least the bandwidth-delay product. That gives bits, which bytes. This needs at least sequence-number bits.
Condition (i), no wraparound within 60 s: the bytes sent in s at full bandwidth bytes. We need , so (because ).
Here has to meet both conditions together. The stricter one is condition (i), which needs bits, so it sets the answer.
Answer: 30