The inorder traversal of a BST is 11, 12, 13, 16, 24, 26 and the preorder traversal of the same tree is: 16, 12, 11, 13, 26, 24.
If the root node is deleted then what will be the next root of the resultant tree?
(i) 13 (ii) 24 (iii) 11 (iv) 26
Note: Full ternary tree is a tree whose all nodes have 0 or 3 children
The X data structure is:
Consider the above graph. Which among the following is correct BFS traversal ? [MSQ]
If we convert the above diagram into the relational model, then which of the following is/are valid the attributes set for the relations? [MSQ]
R(H,I,J,K,L,M,N,O)
H,I->J,K,L
J->M
K->N
L->O
A → BC
CD → E
B → D
E → A.
Which of the following is a canonical cover for R?
2, 6, 8, 1, 4, 3
What are the common edges between minimum cost and maximum cost spanning tree?
def calculate_depth(t, n):
if n not in t:
return 1
depth = 1
for c in t[n]:
depth += calculate_depth(t, c)
return depth
tree = {}
tree['X'] = ['Y', 'Z']
tree['Y'] = ['P', 'Q']
tree['Z'] = ['R']
tree['P'] = []
tree['Q'] = []
tree['R'] = []
print(calculate_depth(tree, 'X'))
What is the output of the given code ______?
def r_s(d):
total = 0
for key, value in d.items():
if isinstance(value, dict):
total += r_s(value)
elif isinstance(value, int):
total += value
return total
data = {
'w': 3,
'x': {'y': 7, 'z': {'p': 2}},
'm': {'n': 1},
'o': 4
}
print(r_s(data))
What is the output of the `r_s(data)` function ______
def computeD(X):
D = [0] * len(X)
for i in range(1, len(X)):
if X[i] < X[i - 1]:
D[i] = X[i - 1] - X[i]
else:
D[i] = 0
return D
X = [12, 10, 15, 9, 16]
result = computeD(X)
print(result)
Which ONE of the following values is returned by the function `computeD(X)` for `X = [12, 10, 15, 9, 16]`?
def fun(arr):
x = [0] * len(arr)
x[0] = arr[0]
for i in range(1, len(arr)):
x[i] = x[i-1] + arr[i]
return x
What does the function fun(arr) return if arr = [2, 4, 6, 8]?
def fun(n, r):
return (1 - r**n) / (1 - r)
result = fun(8, 3)
def fun(s):
x = []
for start in range(len(s)):
for end in range(start + 1, len(s) + 1):
x.append(s[start:end])
return max(x, key=len)
result = fun("xyz")
def fun(s):
parts = s.split('-')
return sum(int(part) for part in parts)
result = fun("5-15-25")
def fun(s, n):
return s * n
result = fun("X", 4) + "Y" + fun("X", 2)