Author name: admin

What is a red-black tree?

What is a red-black tree? a) A self-balancing binary search tree where each node has an extra color attribute b) A binary heap with two colors c) A balanced AVL tree with different color properties d) A linked list where each node has a color Answer: a) A self-balancing binary search tree where each node

What is a red-black tree? Read More »

Which of the following algorithms is used to find the shortest path in a graph with negative weights?

Which of the following algorithms is used to find the shortest path in a graph with negative weights? a) Dijkstra’s Algorithm b) Bellman-Ford Algorithm c) Kruskal’s Algorithm d) Floyd-Warshall Algorithm Answer: b) Bellman-Ford Algorithm Explanation: The Bellman-Ford algorithm is used to find the shortest path in graphs with negative weights. Unlike Dijkstra’s algorithm, Bellman-Ford can

Which of the following algorithms is used to find the shortest path in a graph with negative weights? Read More »

Which of the following algorithms is used to detect a cycle in a graph?

Which of the following algorithms is used to detect a cycle in a graph? a) Depth-First Search (DFS) b) Breadth-First Search (BFS) c) Dijkstra’s Algorithm d) Kruskal’s Algorithm Answer: a) Depth-First Search (DFS) Explanation: Depth-First Search (DFS) is commonly used to detect cycles in a graph. By tracking visited nodes and using a recursive or

Which of the following algorithms is used to detect a cycle in a graph? Read More »

Which data structure is used to find the shortest path in an unweighted graph?

Which data structure is used to find the shortest path in an unweighted graph? a) Stack b) Queue c) Priority Queue d) Array Answer: b) Queue Explanation: Breadth-First Search (BFS), which uses a queue, is used to find the shortest path in an unweighted graph. BFS explores all vertices at the current level before moving

Which data structure is used to find the shortest path in an unweighted graph? Read More »

In a priority queue, which data structure is typically used to ensure efficient access to the highest (or lowest) priority element?

In a priority queue, which data structure is typically used to ensure efficient access to the highest (or lowest) priority element? a) Stack b) Queue c) Binary Heap d) Hash Table Answer: c) Binary Heap Explanation: A binary heap is commonly used to implement a priority queue. In a binary heap, the highest (or lowest)

In a priority queue, which data structure is typically used to ensure efficient access to the highest (or lowest) priority element? Read More »

Which of the following graph traversal algorithms uses recursion implicitly?

Which of the following graph traversal algorithms uses recursion implicitly? a) Breadth-First Search (BFS) b) Depth-First Search (DFS) c) Dijkstra’s Algorithm d) Kruskal’s Algorithm Answer: b) Depth-First Search (DFS) Explanation: Depth-First Search (DFS) uses recursion implicitly through the system’s call stack. The algorithm explores as far as possible along each branch before backtracking, which is

Which of the following graph traversal algorithms uses recursion implicitly? Read More »

In an AVL tree, what is the maximum difference in height between the left and right subtrees of a node?

In an AVL tree, what is the maximum difference in height between the left and right subtrees of a node? a) 1 b) 2 c) 3 d) No limit Answer: a) 1 Explanation: In an AVL tree, the maximum difference in height between the left and right subtrees of any node is 1. This condition

In an AVL tree, what is the maximum difference in height between the left and right subtrees of a node? Read More »

Which of the following data structures is best suited for implementing a circular queue?

Which of the following data structures is best suited for implementing a circular queue? a) Array b) Linked List c) Stack d) Heap Answer: a) Array Explanation: A circular queue is best implemented using an array. In a circular queue, the positions in the array are reused by wrapping around when the end of the

Which of the following data structures is best suited for implementing a circular queue? Read More »

Scroll to Top