GATE 2024 (Session 1)
65 questions
MCQ 29 · MSQ 20 · NAT 161-mark 30 · 2-mark 35
Questions 41–45 of 65
An array is heapified. Which one of the following options represents the first three elements in the heapified array?
Answer: (D)
Make a max-heap from the bottom up (heapify from index down to index 1):
[82, 101, 90, 11, 111, 75, 33, 131, 44, 93]
- i=5 (111): its child is 93 no change.
- i=4 (11): its children are 131 and 44 swap with 131.
- i=3 (90): its children are 75 and 33 no change.
- i=2 (101): its children are 131 and 111 swap with 131 (101 is then fine above 11 and 44).
- i=1 (82): swap with 131, then with 111, then with 93.
Final heap: [131, 111, 90, 101, 93, 75, 33, 11, 44, 82]
Answer: 131, 111, 90
[82, 101, 90, 11, 111, 75, 33, 131, 44, 93]
- i=5 (111): its child is 93 no change.
- i=4 (11): its children are 131 and 44 swap with 131.
- i=3 (90): its children are 75 and 33 no change.
- i=2 (101): its children are 131 and 111 swap with 131 (101 is then fine above 11 and 44).
- i=1 (82): swap with 131, then with 111, then with 93.
Final heap: [131, 111, 90, 101, 93, 75, 33, 11, 44, 82]
Answer: 131, 111, 90
Consider the following recurrence relation:
Which one of the following options is CORRECT?
Which one of the following options is CORRECT?
Answer: (A)
The paper writes "for " for the recursive case as well. Since is the base case, read the recursive case as .
Start by dividing both sides by . This gives .
Now put . The relation becomes .
Keep taking the square root: . The value becomes a constant after steps, and each step adds 1. So .
Now we get
Answer:
Start by dividing both sides by . This gives .
Now put . The relation becomes .
Keep taking the square root: . The value becomes a constant after steps, and each step adds 1. So .
Now we get
Answer:
Consider a binary min-heap containing 105 distinct elements. Let be the index (in the underlying array) of the maximum element stored in the heap. The number of possible values of is
Answer: (A)
In a min-heap, every parent is smaller than its children. So the maximum element cannot have a child and it must be a leaf. Any leaf can hold it.
In an array heap with elements, the leaves sit at indices up to .
For : the leaves are 53 to 105 positions.
Answer: 53
In an array heap with elements, the leaves sit at indices up to .
For : the leaves are 53 to 105 positions.
Answer: 53
The symbol indicates functional dependency in the context of a relational database. Which of the following options is/are TRUE?
One or more options are correct.
Answer: (B), (C), (D)
- (A) does not give . Y may be needed so this is FALSE.
- (B) Decomposition rule: This is TRUE.
- (C) Pseudo-transitivity: (augment by X). We also have , so This is TRUE.
- (D) Transitivity: This is TRUE.
Answer: (B), (C), (D)
- (B) Decomposition rule: This is TRUE.
- (C) Pseudo-transitivity: (augment by X). We also have , so This is TRUE.
- (D) Transitivity: This is TRUE.
Answer: (B), (C), (D)
Let be a directed graph and a depth first search (DFS) spanning tree in that is rooted at a vertex . Suppose is also a breadth first search (BFS) tree in , rooted at . Which of the following statements is/are TRUE for every such graph and tree ?
One or more options are correct.
Answer: (C)
In a BFS tree, each edge of G obeys .
A forward edge starts at and ends at , a descendant that is not a child. So and this goes against BFS. So G has no forward edges TRUE.
The other statements can fail:
- Back edge: take G = {va, av}. The tree {va} is both a DFS tree and a BFS tree. The edge av is a back edge.
- Cross edge: take G = {va, vb, ba}. DFS visits a first and then b. The edge ba is a cross edge, and the tree is also the BFS tree.
- So G can also have edges that are not in T.
Answer: There are no forward-edges in G with respect to T
A forward edge starts at and ends at , a descendant that is not a child. So and this goes against BFS. So G has no forward edges TRUE.
The other statements can fail:
- Back edge: take G = {va, av}. The tree {va} is both a DFS tree and a BFS tree. The edge av is a back edge.
- Cross edge: take G = {va, vb, ba}. DFS visits a first and then b. The edge ba is a cross edge, and the tree is also the BFS tree.
- So G can also have edges that are not in T.
Answer: There are no forward-edges in G with respect to T