GATE 2024
64 questions
MCQ 36 · MSQ 12 · NAT 161-mark 29 · 2-mark 35
Questions 51–55 of 64
Let , and represent height, number of internal nodes, number of leaf nodes, and the total number of nodes respectively in a rooted binary tree.
Which of the following statements is/are always TRUE?
Which of the following statements is/are always TRUE?
One or more options are correct.
Answer: (A), (B), (C)
Here the height is the number of edges on the longest root-to-leaf path (a single node has ). Let = internal nodes, = leaves, = all nodes.
(A) Let be the number of nodes with two children and the number with one child. Then and . So . Always true.
(B) The fewest nodes is a single path, with nodes. The most nodes is a perfect tree, with nodes. Always true.
(C) The longest path has nodes and only the last is a leaf, so . Nodes at depth are leaves, so internal nodes lie at depths , and there are at most of them. Always true.
(D) False. A perfect tree with 7 nodes has and , but , and is false. Also a path tree with has .
Answer: (A), (B), (C)
(A) Let be the number of nodes with two children and the number with one child. Then and . So . Always true.
(B) The fewest nodes is a single path, with nodes. The most nodes is a perfect tree, with nodes. Always true.
(C) The longest path has nodes and only the last is a leaf, so . Nodes at depth are leaves, so internal nodes lie at depths , and there are at most of them. Always true.
(D) False. A perfect tree with 7 nodes has and , but , and is false. Also a path tree with has .
Answer: (A), (B), (C)
Consider the following figures representing datasets consisting of two-dimensional features with two classes denoted by circles and squares.
Which of the following is/are TRUE?
Which of the following is/are TRUE?
One or more options are correct.
Answer: (A), (D)
A data set is linearly separable if one straight line puts all circles on one side and all squares on the other. Reading the points from the figure:
(i) Circles at are all above the squares at . The line separates them. Separable.
(ii) The circle at has a square on each of its four sides, at . It sits inside the region the squares surround, so no line can put it on its own side. Not separable.
(iii) Squares at and circles at form an XOR pattern. The segment joining the two squares and the segment joining the two circles cross at , so no line separates the classes. Not separable.
(iv) Squares are at about and circles at about . The line has all three squares above it and all three circles below it. Separable.
Answer: (A), (D)
(i) Circles at are all above the squares at . The line separates them. Separable.
(ii) The circle at has a square on each of its four sides, at . It sits inside the region the squares surround, so no line can put it on its own side. Not separable.
(iii) Squares at and circles at form an XOR pattern. The segment joining the two squares and the segment joining the two circles cross at , so no line separates the classes. Not separable.
(iv) Squares are at about and circles at about . The line has all three squares above it and all three circles below it. Separable.
Answer: (A), (D)
Let game(ball, rugby) be true if the ball is used in rugby and false otherwise.
Let shape(ball, round) be true if the ball is round and false otherwise.
Consider the following logical sentences:
s1: ball game(ball, rugby) shape(ball, round)
s2: ball shape(ball, round) game(ball, rugby)
s3: ball game(ball, rugby) shape(ball, round)
s4: ball shape(ball, round) game(ball, rugby)
Which of the following choices is/are logical representations of the assertion, "All balls are round except balls used in rugby"?
Let shape(ball, round) be true if the ball is round and false otherwise.
Consider the following logical sentences:
s1: ball game(ball, rugby) shape(ball, round)
s2: ball shape(ball, round) game(ball, rugby)
s3: ball game(ball, rugby) shape(ball, round)
s4: ball shape(ball, round) game(ball, rugby)
Which of the following choices is/are logical representations of the assertion, "All balls are round except balls used in rugby"?
One or more options are correct.
Answer: (A), (C)
Let = game(ball, rugby) and = shape(ball, round). "All balls are round except balls used in rugby" says two things: a ball not used in rugby is round, , and a round ball is not used in rugby, .
Each implication equals its contrapositive:
and both say .
and both say .
The assertion is . So it needs one sentence from the first pair ( or ) and one from the second pair ( or ).
(A) : one from each pair. Correct.
(B) : both from the first pair, so it only says and does not stop a rugby ball from also being round. Wrong.
(C) : one from each pair. Correct.
(D) : both from the second pair, so it only says and allows a ball that is neither round nor used in rugby. Wrong.
Answer: (A), (C)
Each implication equals its contrapositive:
and both say .
and both say .
The assertion is . So it needs one sentence from the first pair ( or ) and one from the second pair ( or ).
(A) : one from each pair. Correct.
(B) : both from the first pair, so it only says and does not stop a rugby ball from also being round. Wrong.
(C) : one from each pair. Correct.
(D) : both from the second pair, so it only says and allows a ball that is neither round nor used in rugby. Wrong.
Answer: (A), (C)
An OTT company is maintaining a large disk-based relational database of differe nt movies with the following schema:
Consider the following SQL query on the relation database above:
Consider the following SQL query on the relation database above:
SELECT *
FROM Movie, Genre, Movie_Genre
WHERE
Movie.CustomerRating > 3.4 AND
Genre.Name = "Comedy" AND
Movie_Genre.MovieID = Movie.ID AND
Movie_Genre.GenreID = Genre.ID; This SQL query can be sped up using which of the following indexing options? One or more options are correct.
Answer: (A), (B)
The query has these conditions: a range condition, ; an equality condition, ; and two equality joins on the IDs.
A B+ tree supports both equality search and range search. A hash index supports only equality search. It cannot answer a range condition such as , because hashing does not keep the key values in order.
(A) B+ tree on all the attributes: it can serve the range condition and the equality conditions. This speeds up the query.
(B) Hash on Genre.Name serves the equality condition, and B+ trees on the other attributes serve the range condition and the joins. Every condition has an index of a suitable type. This speeds up the query.
(C) A hash index on CustomerRating cannot be used for , so the range condition gets no useful index.
(D) Hash indexes on all the attributes cannot serve the range condition at all.
Answer: (A), (B)
A B+ tree supports both equality search and range search. A hash index supports only equality search. It cannot answer a range condition such as , because hashing does not keep the key values in order.
(A) B+ tree on all the attributes: it can serve the range condition and the equality conditions. This speeds up the query.
(B) Hash on Genre.Name serves the equality condition, and B+ trees on the other attributes serve the range condition and the joins. Every condition has an index of a suitable type. This speeds up the query.
(C) A hash index on CustomerRating cannot be used for , so the range condition gets no useful index.
(D) Hash indexes on all the attributes cannot serve the range condition at all.
Answer: (A), (B)
Let be a random variable uniformly distributed in the interval [1,3] and be a random variable uniformly distributed in the interval [2,4]. If and are independent of each other, the probability is _________ (rounded off to three decimal places).
Answer: 0.125
is uniform on and is uniform on , and they are independent. So is uniform over the rectangle , with area and density .
is the part of the rectangle on or below the line . The line enters the rectangle at and leaves it at . This part is a right triangle with corners and area .
By integration: .
Answer: 0.125
is the part of the rectangle on or below the line . The line enters the rectangle at and leaves it at . This part is a right triangle with corners and area .
By integration: .
Answer: 0.125