Questions Answers
In the worst case, how many nodes need to be examined during the recovery of a BST? O(N)
In a max-heap, element with the greatest key is always in the which node? root node
Which of the following inbuilt- method is used to insert key-value pairs into a HashMap put()
Order of elements in a HashSet is Random Order
Depth First Search is equivalent to which of the traversal in the Binary Trees? Pre-order Traversal
What is the advantage of using a higher value of 'K' in a K-ary Heap? Improved time complexity for all operations.
A person wants to visit some places. He starts from a vertex and then wants to visit every vertex till it finishes from one vertex, backtracks and then explore other vertex from same vertex. What algorithm he should use? Depth First Search
Which sorting algorithm is often associated with the use of Winner Trees? TournamentSort
Which value of 'K' would make a K-ary Heap equivalent to a binary heap? 2
What is the key concept used in Dijkstra's Algorithm to ensure the optimality of the solution? -
When recovering a Binary Search Tree (BST) by swapping two nodes, what is the main idea behind using the Inorder Traversal? To visit nodes in ascending order
Which scenario makes a graph unsuitable for topological sorting? If the graph contains a cycle.
In Heap Sort, the process of converting an array into a heap is called: Heapify
Which condition indicates the absence of negative cycles in the graph when using Bellman-Ford Algorithm? A vertex's distance estimate decreases in the last iteration.
In a binary tree, if a node has a horizontal distance of 0, where is it located in relation to the root? At the same position as the root
Which data structure can be used to assist in the recovery of a BST by swapping two nodes? Stack
If a binary tree is traversed in postorder, which view is obtained? Bottom-up View
In Vertical Order Traversal, how are nodes at the same horizontal distance presented in the output? Left to right
In Boundary Traversal, what are the three main components of the traversal process? Left, Center, Right
In BFS, which vertices are visited before their adjacent vertices? Vertices with lower degree
In DFS, what is the primary purpose of backtracking? To avoid revisiting already explored vertices
Consider the DAG with Consider V = {1, 2, 3, 4, 5, 6}, shown below. Which of the following is NOT a topological ordering? 324165
Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only after first checking that the vertex has not been visited earlier. Then the maximum possible recursion depth (includin 19
Which of the following statement is correct?
P1: Every tree will always be a graph
P2: Every graph will always be trees.
P3: Every tree will be a graph, but every graph will not be a tree
P4: Every graph will be a tree, but every tree will not be a graph.
P1 and P3
A graph is said to have a negative weight cycle when? The total weight of the graph is negative
In Dijkstra's Algorithm, what is the purpose of the visited set? To prevent revisiting vertices.
What is Topological Sort primarily used for in directed acyclic graphs (DAGs)? Sorting the vertices in a linear order respecting the partial order.
In Heap Sort, the process of converting an array into a heap is called: Heapify
Which value of 'K' would make a K-ary Heap equivalent to a binary heap? 2
In Binomial Heap, what is the significance of the rank of a Binomial Tree? It indicates the degree of the tree.
When recovering a Binary Search Tree (BST) by swapping two nodes, what is the main idea behind using the Inorder Traversal? To visit nodes in ascending order
What is the correct order of nodes in the Inorder View of a binary tree? Left, Root, Right
What is the primary purpose of Vertical Order Traversal in a binary tree? To visit nodes in a vertical column-wise manner
In Boundary Traversal, what are the three main components of the traversal process? Left, Center, Right
In DFS, what is the primary purpose of backtracking? To avoid revisiting already explored vertices
Bellman-Ford Algorithm is used for: Finding the shortest path in a weighted, directed graph.
Heap Sort is based on which data structure? Tree
What is the primary purpose of a Winner Tree? Facilitating sorting in a tournament-based algorithm.
What is the main advantage of using a Winner Tree in a sorting algorithm? It facilitates efficient tournament-style comparisons.
In the process of recovering a BST, what is the purpose of identifying the two swapped nodes? Swap the nodes back
What data structure is typically used for implementing BFS? Queue
If a graph has a cycle, what is the result of attempting a topological sort? It fails to produce a valid topological ordering.
Binomial Heap is a data structure used for: Implementing priority queues.
Suppose you have a BST with values [8, 5, 10, 3, 7, 9, 12]. If nodes 3 and 10 are swapped, what will be the correct order after recovery? [3, 5, 7, 8, 9, 10, 12]
Vertical Order Traversal is particularly useful in applications where: Visualization of column-wise data is needed
In a Binary Search Tree (BST), what property ensures that the left subtree of a node contains only values less than the node, and the right subtree contains values greater than the node? BST Property
In the process of recovering a BST, what is the purpose of identifying the two swapped nodes? Swap the nodes back
In a binary tree, what is the maximum number of views that can be defined? Four
Which view of a tree provides a top-down representation, starting from the root and proceeding level by level? Level Order View
Which view of a binary tree provides the order in which nodes are visited in a depth-first manner? Postorder View
Which of the following algorithms can be used to detect cycles in a graph? DFS
Which traversal algorithm is often used to find the connected components of a graph? DFS
If there are negative weights in the graph, which algorithm is more suitable than Dijkstra's Algorithm? Bellman-Ford Algorithm.
If a graph contains a negative cycle, what does Bellman-Ford Algorithm detect? It will detect and report the negative cycle.
If a graph has a cycle, what is the result of attempting a topological sort? It fails to produce a valid topological ordering.
What does the presence of a back edge in a directed graph indicate during a DFS-based topological sort? A cycle is present in the graph.
What is the primary advantage of Heap Sort over other sorting algorithms? It is an in-place sorting algorithm.
Which phase of Heap Sort involves removing the maximum element from the heap and placing it at the end of the array? Sorting
K-ary Heap is a variant of the binary heap where each node has up to 'K' children. What is the value of 'K' in a binary heap? 2
During a tournament in Winner Tree, how are ties resolved? By comparing the indices of tied elements.