Consider a doubly linked list implemented as following:

typedef struct Node

{

int data;

struct Node *f, *b;

};

Where *f, and *b are forward and backward links to the adjacent nodes in the linked list.

Consider a pointer ‘middle’ pointing to a node in the list, which is neither the first nor the last node of the doubly linked list. Which among the following code segments deletes the node pointed by ‘middle’ pointer?

middle -> b -> f = middle -> f ; middle -> f -> b = middle -> b;

middle -> b -> b = middle -> f ; middle -> f -> f = middle -> b;

middle -> f -> b = middle -> f ; middle -> b -> f = middle -> b;

middle -> b -> f = middle -> b ; middle -> f -> b = middle -> f;

Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Choose the correct option, from the following:

I) We can find a cycle in the graph using BFS.

II) We can find a cycle in the graph using DFS.

Only I is correct
Only II is correct
Both I and II are correct
None is correct
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
The number of different Unlabeled Binary Trees can be there with 4 nodes are ___
14
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
A program attempts to generate as many permutations as possible of the string, ‘abcd’ by pushing the characters m, n, q, r in the same order onto a stack, but it may pop off the top character at any time. Which one of the following strings CANNOT be generated using this program?
n r q m
m n r q
q r n m
None of the above
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Height of complete 10-ary tree with 10000 nodes is : ___
4
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Given a tree T. Choose a proper option which describes the tree. [MSQ]

T is BST but not AVL
T is AVL & BST
Inserting ‘g’ into T will violate AVL property
Inserting ‘6’ into T will violate AVL property.
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.00
Consider the following Binary Search Tree

If we randomly search one of the keys present in the above BST, what would be the expected number of comparisons?

2.75
2.25
2.57
3.25
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
What is the output of the given code segment

a = {'x': 1, 'y': 2}

b = {'z': 3, **a}

print(b)

{'z': 3, 'x': 1, 'y': 2}
{'x': 1, 'y': 2, 'z': 3}
Error
{'z': 1, 'x': 3, 'y': 2}
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
What is the output of the given code segment

class GATE:

x = []

t1 = GATE()

t2 = GATE()

t1.x.append(1)

print(t2.x)

[]
[1]
AttributeError
Error
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
What is the output of the given code segment?

a, b = 5, 10

a, b = (lambda x: (x + 1, x + 2))(a)

print(a, b)

6, 7
5, 10
Error
TypeError
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
What is the output of the given code segment?

def func(val, lst=[]):

lst.append(val)

return lst

print(func(10))

print(func(20, []))

print(func(30))

[10], [20], [10, 30]
[10], [20], [30]
[10], [10, 20], [30]
[10, 20], [20], [10, 30]
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
What is the output of the given code segment?

def func(val, lst=None, counter=0):

if lst is None:

lst = []

def inner(value, cnt):

lst.append(value)

cnt += 1

return lst, cnt

return inner(val, counter)

print(func(10))

print(func(20, [5]))

print(func(30))

print(func(40, counter=3))

([10], 1), ([5, 20], 1), ([30], 1), ([40], 4)
([10], 1), ([5, 20], 1), ([10, 30], 1), ([40], 4)
([10], 1), ([5, 20], 1), ([30], 1), ([40], 6)
([10], 1), ([5, 20], 2), ([10, 30], 1), ([40], 4)
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Which one of the following values is returned by the function GATE(X) for X = [7, 4, 6, 8, 5]?

GATE(X)

T[1] ← 1

for i ← 2 to length(X)

T[i] ← T[i-1] * 2

if X[i-1] < X[i]

T[i] ← T[i] + 1

end if

end for

return T

[1, 2, 4, 9, 16]
[1, 3, 5, 11, 22]
[1, 2, 4, 8, 16]
[1, 2, 5, 9, 16]
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
For the input X = [3, 8, 7, 10], what is the value returned by GATE(X, length(X))?

GATE(X, i)

if i = 1

return 1

else

if X[i] > X[i-1]

return GATE(X, i-1) * 2

else

return GATE(X, i-1) + 1

end if

end if

4
5
6
7
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
What is the output of this code?

def GATE(child_dict, i):

if i not in child_dict.keys():

return 2

answer = 2

for j in child_dict[i]:

answer *= GATE(child_dict, j)

return answer

child_dict = dict()

child_dict[0] = [1, 2]

child_dict[1] = [3, 4]

child_dict[2] = [5]

child_dict[3] = []

child_dict[4] = [6]

print(GATE(child_dict, 0))

64
16
128
32
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
What is the output of this code?

def GATE(child_dict, i):

if i not in child_dict.keys():

return 1

answer = 1

for j in child_dict[i]:

answer += GATE(child_dict, j)

return answer

child_dict = dict()

child_dict[0] = [1, 2]

child_dict[1] = [3, 4]

child_dict[2] = []

child_dict[3] = [5, 6]

print(GATE(child_dict, 0))

6
7
8
5
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
A stable sort preserves the order of values that are equal with respect to the comparison function. We have a list of three dimensional points [(1, 2, 8),(2, 1, 7),(6, 5, 1),(5, 6, 2),(0, 2, 2),(9, 1, 9),(4,4,4)]. We sort these in ascending order by the second coordinate. Which of the following corresponds to a stable sort of this input?
[(9, 1, 9),(2, 1, 7),(1, 2, 8),(0, 2, 2),(4,4,4),(6, 5, 1),(5, 6, 2)]
[(2, 1, 7), (9, 1, 9),(0, 2, 2),(1, 2, 8),(4,4,4),(6, 5, 1),(5, 6, 2)]
[(2, 1, 7), (9, 1, 9),(1, 2, 8),(0, 2, 2),(4,4,4),(6, 5, 1),(5, 6, 2)]
[(9, 1, 9),(2, 1, 7),(0, 2, 2),(1, 2, 8),(4,4,4),(6, 5, 1),(5, 6, 2)]
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Given elements, Find the height of the optimal merge pattern?

17, 28, 13, 7, 8, 12, 10, 4

[ Hint: Height starts with 0 ]

4
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.00
Which of the following represents a binary max-heap?
25, 12, 16, 13, 10, 12, 4
25, 12, 13, 16, 4, 10, 12
25, 10, 13, 16, 4, 10, 12
25, 14, 16, 13, 10, 4, 12
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
While forming the Minimum Spanning Tree(MST) of the following graph using Prim's Algorithm, in what order will the edges be added?(Start from Vertex A)

A-C, C-E, E-F, C-G, G-B, B-D, E-H
A-B, A-E, E-F, C-G, G-B, B-D, E-H
A-E, A-B, E-F, C-G, G-B, B-D, E-H
A-C, A-B, B-D, C-G, G-B, A-E, E-F
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Given the frequencies and corresponding full binary tree using huffman code algorithm.

Character

A

B

C

D

E

F

Frequency

50

35

15

12

2

3

Find the difference between Y and X is _____?

3
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
Which of the following statement(s) is/are FALSE? [MSQ]
Given a connected graph G = (V,E), if a vertex v ∈ V is visited during level k of a breadth-first search from source vertex s ∈ V, then every path from s to v has length at most k.
Any Dynamic Programming algorithm with n subproblems will run in O(n) time.
Depth-first search will take Θ(V2) time on a graph G = (V,E) represented as an adjacency matrix.
Given an adjacency-list representation of a directed graph G = (V,E), it takes O(V ) time to compute the in-degree of every vertex.
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
Which of the following statement(s) is/are FALSE? [MSQ]
Radix Sort does not work correctly (Means, It does not produce the correct output) if we sort each individual digit using insertion sort instead of counting sort.
Suppose we use a hash function ‘h’ to hash ‘n’ distinct keys into an array ‘’T’ of length ‘m’. Assuming simple uniform hashing, the expected number of colliding pairs of elements is θ(n^2/m)
Let T be a complete binary tree with n nodes. Finding a path from the root of T(T is not necessarily sorted) to a given vertex v ∈ T using breadth-first search takes O(logn) time.
Selection sort and heap sort satisfying stable property.
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
A min heap contains 512 distinct elements with keys ranging from 0 to 511. These keys are stored in an array of 512 indices. To place an element 25 in a min heap, find the maximum difference between maximum level and minimum level is____? [ Hint: Assume root as level 0 ]

8
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
In a search problem, consider an agent tasked with finding a path in a maze. The agent uses a uninformed search algorithm, which of the following best describes an attribute of this algorithm?
It uses heuristics to guide the search toward the goal efficiently.
It explores all paths blindly without additional knowledge about the environment.
It guarantees the shortest path to the goal if one exists.
It can adapt its strategy based on the response from the environment.
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
When modeling the conditional independence in a Bayesian network, which of the following statements is true?
If A is independent of B given C, then knowing B provides no additional information about A once C is known.
Conditional independence implies that A and B cannot influence each other regardless of C.
The structure of a Bayesian network cannot represent conditional independence.
If A is dependent on B, it must also be dependent on every variable related to B.
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Which of the following statements about inference in Bayesian networks is true?
Any inference algorithm can calculate marginals without knowledge of the network structure.
Exact inference can always be performed in linear time irrespective of network complexity.
Graphical structures can lead to computational efficiency in performing inferences.
Inference is only possible when all node states are known a priori.
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
In approximate inference, which of the following statements is true concerning the importance sampling technique?
It guarantees convergence to the true distribution with a finite number of samples.
It assigns weights to samples based on their likelihood, improving estimates.
It assumes that all samples are equally relevant to the inference.
It is primarily used for exact inference rather than approximate inference.
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Which of the following best describes the main advantage of using probabilistic reasoning in AI over deterministic reasoning?
It provides absolute certainty in outcomes.
It allows for reasoning in domains with incomplete or uncertain information.
It simplifies the representation of knowledge.
It requires extensive computation for trivial problems.
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
∃x p(x) is read as -?
There exists one value in the universe of variable x such that p(x) is true
There exists at least one value in the universe of variable x such that p(x) is false
There exists at least one value in the universe of variable p(x) such that x is true
There exists at least one value in the universe of variable x such that p(x) is true
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
“If my computations are correct and I pay the electric bill, then I will run out of money. If I don’t pay the electric bill, the power will be turned off. Therefore, if I don’t run out of money and the power is still on, then my computations are incorrect.” Convert this argument into logical notations using the variables c, b, r, p for propositions of computations, electric bills, out of money and the power respectively. (Where ¬ means NOT)
if (c Λ b)→r and ¬b→p, then (¬r Λ p)→¬c
if (c ∨ b)→r and ¬b→¬p, then (r Λ p)→c
if (c Λ b)→r and ¬p→b, then (¬r ∨ p)→¬c
if (c ∨ b)→r and ¬b→¬p, then (¬r Λ p)→¬c
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Find the correct topological sequence using indegree elimination method for given graph G=(V,E)

1,6,5,0,3,2,4,7
0,1,3,7,2,4,5,6
1,7,6,5,0,3,2,4
0,5,7,2,3,1,4,6
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33