GATE 2025
65 questions
MCQ 35 · MSQ 18 · NAT 121-mark 30 · 2-mark 35
Questions 61–65 of 65
A bag contains 5 white balls and 10 black balls. In a random experiment, balls are drawn from the bag one at a time with replacement. Let denote the total number of black balls drawn in the experiment. The expectation of denoted by _____ (Round off to one decimal place)
Answer: 66.6 to 66.7
The bag holds white balls and black balls, so the total is . Each draw is independent because the ball is replaced, and the chance of black is .
counts the black balls in independent draws. So it is a random variable.
Answer: 66.7
counts the black balls in independent draws. So it is a random variable.
Answer: 66.7
Consider the following tables, Loan and Borrower, of a bank.
Query:
where denotes natural join. The number of tuples returned by the above relational algebra query is ________ (Answer in integer)
Query:
where denotes natural join. The number of tuples returned by the above relational algebra query is ________ (Answer in integer)
Answer: 1
Step 1: Take . This is a natural join on . Then project on . Follow each loan to its branch and its borrower(s):
Karteek has loans in all four branches (Banjara Hills through L11, Kondapur through L14, SR Nagar through L22, Balanagar through L23). Each of the other customers (Anand, Ankita, Gopal, Sunil) is linked to only to branches, so none of them covers all four.
We have , which gives distinct branches. The division operation then returns only those customer names linked to each of these branches. Only Karteek qualifies.
Answer: 1
Karteek has loans in all four branches (Banjara Hills through L11, Kondapur through L14, SR Nagar through L22, Balanagar through L23). Each of the other customers (Anand, Ankita, Gopal, Sunil) is linked to only to branches, so none of them covers all four.
We have , which gives distinct branches. The division operation then returns only those customer names linked to each of these branches. Only Karteek qualifies.
Answer: 1
Consider the following Python code snippet.
def f(a,b):
if (a==0):
return b
if (a%2==1):
return 2*f((a-1)/2,b)
return b+f(a-1,b)
print(f(15,10))
The value printed by the code snippet is _________ (Answer in integer)Answer: 160
For : when , the function gives back . When is odd, it gives back . In every other case it gives back . The values are all odd, so the odd rule applies each time:
Answer: 160
Answer: 160
Consider the following pseudocode.
Create empty stack S
Set x=0, flag=0, sum=0
Push x onto S
while (S is not empty){
if (flag equals 0){
Set x = x+1
Push x onto S}
if (x equals 8):
Set flag=1
if (flag equals 1){
x = Pop(S)
if (x is odd):
Pop(S)
Set sum = sum + x}
}
Output sum
The value of sum output by a program executing the above pseudocode is ___________ (Answer in integer)Answer: 24
At the start, the values are:
Push 0 onto the stack.
Stack (Bottom - Top): 0
As flag = 0, the loop adds 1 to x and pushes it onto the stack. It does this again and again until x = 8.
The stack is now:
Bottom - 0, 1, 2, 3, 4, 5, 6, 7, 8 - Top
When x = 8, the second if statement sets:
The if statements are independent of each other. So the third if statement also runs in this same iteration.
The stack operations go as follows:
After the last iteration the stack is empty, so the while loop ends.
The final value of sum is 24.
Correct Answer: 24
Push 0 onto the stack.
Stack (Bottom - Top): 0
As flag = 0, the loop adds 1 to x and pushes it onto the stack. It does this again and again until x = 8.
The stack is now:
Bottom - 0, 1, 2, 3, 4, 5, 6, 7, 8 - Top
When x = 8, the second if statement sets:
The if statements are independent of each other. So the third if statement also runs in this same iteration.
The stack operations go as follows:
| Iteration | Value popped (x) | x is Odd? | Additional Pop() | sum |
|---|---|---|---|---|
| 1 | 8 | No | — | 8 |
| 2 | 7 | Yes | 6 | 15 |
| 3 | 5 | Yes | 4 | 20 |
| 4 | 3 | Yes | 2 | 23 |
| 5 | 1 | Yes | 0 | 24 |
After the last iteration the stack is empty, so the while loop ends.
The final value of sum is 24.
Correct Answer: 24
Consider a directed graph , where and . Suppose the adjacency list of each vertex is in decreasing order of vertex number, and depth-first search (DFS) is performed at vertex 0. The number of vertices that will be discovered after vertex 50 is ___________ (Answer in integer)
Answer: 75
The vertex set is . The edges obey . So from vertex , edges go to and if they exist. Each adjacency list is in decreasing order. So DFS from any vertex tries the "" jump first and the "" jump after that.
DFS starts at . It jumps by every time, because that edge is tried first. The path is . These are all even vertices, and they are discovered first in this order. At DFS is stuck, since no vertex exists. It backtracks and picks up the unvisited "" neighbors on the way back. This discovers the odd vertices in descending order:
So the discovery order is (positions to ), and then (positions to ).
Vertex is the th even vertex discovered. Its position is , since . The vertices discovered after it:
Answer: 75
DFS starts at . It jumps by every time, because that edge is tried first. The path is . These are all even vertices, and they are discovered first in this order. At DFS is stuck, since no vertex exists. It backtracks and picks up the unvisited "" neighbors on the way back. This discovers the odd vertices in descending order:
So the discovery order is (positions to ), and then (positions to ).
Vertex is the th even vertex discovered. Its position is , since . The vertices discovered after it:
Answer: 75