Q. How many usable IP addresses are available in a subnet with a /29 subnet mask?
Solution
A /29 subnet mask provides 8 total addresses, of which 6 are usable for hosts after excluding the network and broadcast addresses.
Correct Answer:
B
— 6
Learn More →
Q. If a binary search algorithm is implemented recursively, what is its space complexity due to recursion?
-
A.
O(1)
-
B.
O(log n)
-
C.
O(n)
-
D.
O(n log n)
Solution
The space complexity of a recursive binary search is O(log n) due to the call stack.
Correct Answer:
B
— O(log n)
Learn More →
Q. If a binary search algorithm is implemented recursively, what is the space complexity due to recursion?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(1)
-
D.
O(n log n)
Solution
The space complexity of a recursive binary search is O(log n) due to the call stack used for recursion.
Correct Answer:
B
— O(log n)
Learn More →
Q. If a binary search algorithm is implemented recursively, what is the space complexity?
-
A.
O(1)
-
B.
O(log n)
-
C.
O(n)
-
D.
O(n log n)
Solution
The space complexity is O(log n) due to the recursive call stack.
Correct Answer:
B
— O(log n)
Learn More →
Q. If a binary search algorithm returns -1, what does it indicate?
-
A.
The element is found
-
B.
The element is not in the array
-
C.
The array is empty
-
D.
The array is sorted
Solution
A return value of -1 typically indicates that the searched element is not present in the array.
Correct Answer:
B
— The element is not in the array
Learn More →
Q. If a binary search is performed on a sorted array of size n, what is the space complexity?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
The space complexity of binary search is O(1) when implemented iteratively, as it uses a constant amount of space.
Correct Answer:
A
— O(1)
Learn More →
Q. If a binary search is performed on an array of 32 elements, how many iterations will it take in the worst case?
Solution
The worst-case number of iterations is log2(32) = 5.
Correct Answer:
C
— 6
Learn More →
Q. If a binary search is performed on an array of size 16, how many comparisons are needed in the worst case?
Solution
The maximum number of comparisons needed is log2(16) = 4, but since we start counting from 0, it takes 5 comparisons.
Correct Answer:
D
— 7
Learn More →
Q. If a binary search is performed on an array of size 16, how many comparisons will be made in the worst case?
Solution
In the worst case, binary search will make log2(16) = 4 comparisons.
Correct Answer:
D
— 5
Learn More →
Q. If a binary search is performed on an array of size 16, how many comparisons will it take in the worst case?
Solution
In the worst case, binary search will take log2(16) = 4 comparisons, but since we start counting from 0, it will take 5 comparisons.
Correct Answer:
D
— 5
Learn More →
Q. If a binary tree has 'n' nodes, what is the maximum height of the tree?
-
A.
n
-
B.
log n
-
C.
n/2
-
D.
n-1
Solution
The maximum height of a binary tree occurs when the tree is skewed (like a linked list), resulting in a height of n.
Correct Answer:
A
— n
Learn More →
Q. If a binary tree has 15 nodes, what is the maximum height of the tree?
Solution
The maximum height of a binary tree with 15 nodes occurs when the tree is skewed, which can have a height of 15.
Correct Answer:
D
— 5
Learn More →
Q. If a binary tree has a height of 'h', what is the minimum number of nodes it can have?
-
A.
h
-
B.
h + 1
-
C.
2^h - 1
-
D.
2^h
Solution
The minimum number of nodes in a binary tree of height h is h + 1, which occurs in a skewed tree.
Correct Answer:
B
— h + 1
Learn More →
Q. If a binary tree has a height of h, what is the maximum number of nodes it can have?
-
A.
2^h - 1
-
B.
2^h
-
C.
h^2
-
D.
h!
Solution
The maximum number of nodes in a binary tree of height h is 2^h - 1, which occurs in a complete binary tree.
Correct Answer:
A
— 2^h - 1
Learn More →
Q. If a binary tree has n nodes, what is the maximum number of leaf nodes it can have?
-
A.
n
-
B.
n/2
-
C.
n/3
-
D.
n/2 + 1
Solution
In a binary tree, the maximum number of leaf nodes can be n, which occurs in a degenerate tree.
Correct Answer:
A
— n
Learn More →
Q. If a binary tree is balanced, what is the maximum height of the tree in terms of the number of nodes 'n'?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
In a balanced binary tree, the maximum height is O(log n), as the tree is structured to minimize height.
Correct Answer:
B
— O(log n)
Learn More →
Q. If a dataset has 200 points and you apply K-means clustering with K=4, how many points will be assigned to each cluster on average?
Solution
If K=4 and there are 200 points, on average, each cluster will have 200/4 = 50 points assigned to it.
Correct Answer:
A
— 50
Learn More →
Q. If a device has an IP address of 172.16.5.10 with a subnet mask of 255.255.255.0, what is its network address?
-
A.
172.16.5.0
-
B.
172.16.5.10
-
C.
172.16.0.0
-
D.
172.16.5.255
Solution
The network address is determined by the IP address and subnet mask; for 172.16.5.10/24, the network address is 172.16.5.0.
Correct Answer:
A
— 172.16.5.0
Learn More →
Q. If a graph has 5 vertices and 10 edges, what is the maximum number of edges it can have?
Solution
In a simple undirected graph, the maximum number of edges is given by the formula V(V-1)/2, which for 5 vertices is 5(5-1)/2 = 10.
Correct Answer:
C
— 20
Learn More →
Q. If a graph has 5 vertices and 10 edges, what is the maximum number of iterations Dijkstra's algorithm will perform?
Solution
Dijkstra's algorithm will perform at most V iterations, where V is the number of vertices. In this case, it will perform 5 iterations.
Correct Answer:
A
— 5
Learn More →
Q. If a graph has 5 vertices and 10 edges, what is the maximum time complexity of Dijkstra's algorithm using an adjacency matrix?
-
A.
O(10)
-
B.
O(5^2)
-
C.
O(5 log 5)
-
D.
O(10 + 5^2)
Solution
Using an adjacency matrix, the time complexity of Dijkstra's algorithm is O(V^2), which in this case is O(5^2) or O(25).
Correct Answer:
B
— O(5^2)
Learn More →
Q. If a graph has 5 vertices and 7 edges, what is the maximum number of edges in a complete graph with 5 vertices?
Solution
In a complete graph with V vertices, the maximum number of edges is given by V*(V-1)/2. For 5 vertices, it is 5*(5-1)/2 = 10.
Correct Answer:
A
— 10
Learn More →
Q. If a graph has 5 vertices and 7 edges, what is the maximum number of edges in a simple undirected graph?
Solution
In a simple undirected graph, the maximum number of edges is given by the formula V(V-1)/2. For 5 vertices, it is 5(5-1)/2 = 10.
Correct Answer:
A
— 10
Learn More →
Q. If a graph has 5 vertices and 7 edges, what is the maximum number of edges it can have?
Solution
In a simple undirected graph, the maximum number of edges is given by the formula V(V-1)/2, which for 5 vertices is 5(5-1)/2 = 10.
Correct Answer:
B
— 15
Learn More →
Q. If a graph has 5 vertices and 7 edges, what is the maximum number of iterations Dijkstra's algorithm will perform?
Solution
Dijkstra's algorithm will perform at most V iterations, where V is the number of vertices. In this case, it will perform 5 iterations.
Correct Answer:
A
— 5
Learn More →
Q. If a graph has a cycle, which traversal method can detect it?
-
A.
Only BFS
-
B.
Only DFS
-
C.
Both BFS and DFS
-
D.
Neither BFS nor DFS
Solution
DFS can detect cycles in a graph by keeping track of visited nodes and checking for back edges.
Correct Answer:
B
— Only DFS
Learn More →
Q. If a graph has negative edge weights, which algorithm can be used instead of Dijkstra's algorithm?
-
A.
Prim's Algorithm
-
B.
Kruskal's Algorithm
-
C.
Bellman-Ford Algorithm
-
D.
Floyd-Warshall Algorithm
Solution
The Bellman-Ford algorithm can be used instead of Dijkstra's algorithm when the graph has negative edge weights, as it can handle such cases.
Correct Answer:
C
— Bellman-Ford Algorithm
Learn More →
Q. If a graph has negative weight edges, which algorithm can be used instead of Dijkstra's?
-
A.
Prim's algorithm
-
B.
Kruskal's algorithm
-
C.
Bellman-Ford algorithm
-
D.
A* algorithm
Solution
The Bellman-Ford algorithm can handle graphs with negative weight edges, unlike Dijkstra's algorithm.
Correct Answer:
C
— Bellman-Ford algorithm
Learn More →
Q. If a graph has negative weight edges, which algorithm should be used instead of Dijkstra's algorithm?
-
A.
Prim's algorithm
-
B.
Kruskal's algorithm
-
C.
Bellman-Ford algorithm
-
D.
Floyd-Warshall algorithm
Solution
The Bellman-Ford algorithm should be used instead of Dijkstra's algorithm when the graph has negative weight edges, as it can handle such cases.
Correct Answer:
C
— Bellman-Ford algorithm
Learn More →
Q. If a graph has negative weight edges, which algorithm should be used instead of Dijkstra's?
-
A.
Prim's algorithm
-
B.
Kruskal's algorithm
-
C.
Bellman-Ford algorithm
-
D.
A* algorithm
Solution
The Bellman-Ford algorithm can handle graphs with negative weight edges, unlike Dijkstra's algorithm.
Correct Answer:
C
— Bellman-Ford algorithm
Learn More →
Showing 91 to 120 of 3237 (108 Pages)