Professional Documents
Culture Documents
You are given infinite coins of denominations v1, v2, v3,…..,vn and a sum S. The coin change
problem is to find the minimum number of coins required to get the sum S. This problem can be
solved using ____________ dynamic programming
You are given infinite coins of denominations 1, 3, 4. What is the total number of ways in which a
sum of 7 can be achieved using these coins if the order of the coins is not important? 5
You are given infinite coins of denominations 1, 3, 4. What is the minimum number of coins
required to achieve a sum of 7? 2
Which of the following methods can be used to solve the Knapsack problem? Brute force,
Recursion and Dynamic Programming
You are given a knapsack that can carry a maximum weight of 60. There are 4 items with weights
{20, 30, 40, 70} and values {70, 80, 90, 200}. What is the maximum value of the items you can
carry using the knapsack? 160
Consider the two matrices P and Q which are 10 x 20 and 20 x 30 matrices respectively. What is
the number of multiplications required to multiply the two matrices? 10*20*30
Longest common subsequence is an example of ____________ 2D dynamic programming
Fractional knapsack problem is also known as __________ Continuous knapsack problem
Fractional knapsack problem is solved most efficiently by which of the following
algorithm? Greedy algorithm
What is the objective of the knapsack problem? To get maximum total value in the
knapsack
Which of the following statement about 0/1 knapsack and fractional knapsack problem is correct?
In 0/1 knapsack problem items are indivisible and in fractional knapsack items are
divisible
The main time taking step in fractional knapsack problem is ___________ Sorting
Which of the following algorithms is the best approach for solving Huffman codes? greedy
algorithm
In Huffman coding, data in a tree always occur? leaves
Which of the following is false in the case of a spanning tree of a graph G? It can be either
cyclic or acyclic
Consider a complete graph G with 4 vertices. The graph G has ____ spanning trees. 16
The travelling salesman problem can be solved using _________ A minimum spanning tree
Which of the following is false?
Which of the following is true?
Prim’s algorithm is a ______ greedy algorithm
Prim’s algorithm can be efficiently implemented using _____ for graphs with greater density. d-
ary heap
Which of the following is false about Prim’s algorithm? It constructs MST by selecting
edges in increasing order of their weights
Kruskal’s algorithm is used to ______ find minimum spanning tree
Kruskal’s algorithm is a ______ greedy algorithm
Which of the following is true?
Which of the following is false about the Kruskal’s algorithm? It can accept cycles in the MST
Consider the following statements. S1. Kruskal’s algorithm might produce a non-minimal spanning
tree. S2. Kruskal’s algorithm can efficiently implemented using the disjoint-set data structure. S2
is true but S1 is false
Dijkstra’s Algorithm is used to solve _____________ problems. Single source shortest path
ANALYSIS AND DESIGN OF ALGORITHM
Which of the following is the most commonly used data structure for implementing Dijkstra’s
Algorithm? Min priority queue
Dijkstra’s Algorithm cannot be applied on : graphs having negative weight function
How many priority queue operations are involved in Dijkstra’s Algorithm? The number of
priority queue operations involved is 3. They are insert, extract-min and decrease key.
The maximum number of times the decrease key operation performed in Dijkstra’s algorithm will
be equal to: If the total number of edges in all adjacency list is E, then there will be a total
of E number of iterations, hence there will be a total of at most E decrease key
operations. 9.
What is running time of Dijkstra’s algorithm using Binary min- heap method?: O(ElogV).
Dijkstra’s Algorithm is the prime example for : greedy algorithms
Depth First Search is equivalent to which of the traversal in the Binary Trees? : Pre order traversal
Time Complexity of DFS is? (V – number of vertices, E – number of edges): O ( V + E ) O(V + E)
O(V+E)
The Data structure used in standard implementation of Breadth First Search is?: stack can be
used as data structure to implement depth first search.
The Depth First Search traversal of a graph will result into?: The Depth First Search will
make a graph which don't have back edges (a tree) which is known as Depth
First Tree.
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 of the following is not an application of Depth First Search?: Peer to Peer network
When the Depth First Search of a graph is unique? When the graph is a linked list
Regarding implementation of Depth First Search using stacks, what is the maximum distance
between two nodes present in the stack? (considering each edge length 1): it can be the
maximum distance between two nodes in the graph.
In Depth First Search, how many times a node is visited?: The Depth First Search
explores every node once and every edge once (in worst case), so it's time complexity is
O(V + E).
Choose the incorrect statement about DFS and BFS from the following?
Breadth First Search is equivalent to which of the traversal in the Binary Trees?: Level order
traversal
Time Complexity of Breadth First Search is? (V – number of vertices, E – number of edges): O(V +
E)
The Data structure used in standard implementation of Breadth First Search is? Stack
The Breadth First Search traversal of a graph will result into?: a graph which don't have back
edges (a tree) which is known as Breadth First Tree.
A person wants to visit some places. He starts from a vertex and then wants to visit every place
connected to this vertex and so on. What algorithm he should use? : Breadth first search
Which of the following is not an application of Breadth First Search?: find the shortest path
between two nodes, in GPS Navigation. In Path finding, Depth First Search is used.
When the Breadth First Search of a graph is unique?: When Every node will have one
successor
Regarding implementation of Breadth First Search using queues, what is the maximum distance
between two nodes present in the queue? (considering each edge length 1): In the queue, at a
time, only those nodes will be there whose difference among levels is 1. Same as level
order traversal of the tree.
In BFS, how many times a node is visited?: every node once
Topological sort can be applied to which of the following graphs?: Directed Acyclic graph
ANALYSIS AND DESIGN OF ALGORITHM
Most Efficient Time Complexity of Topological Sorting is? (V – number of vertices, E – number of
edges): O(V+E)
In most of the cases, topological sort starts from a node which has: Zero degree
Which of the following is not an application of topological sorting?: Ordered Statistics
Topological sort of a Directed Acyclic graph is?: Sometimes unique and sometimes not
unique
Topological sort can be implemented by?: We can implement topological sort by both BFS
and DFS.
Topological sort is equivalent to which of the traversals in trees?: Pre order traversal
A man wants to go different places in the world. He has listed them down all. But there are some
places where he wants to visit before some other places. What application of graph can he use to
determine that?
When the topological sort of a graph is unique?: If a Hamiltonian path exists
Which of the problems cannot be solved by backtracking method?: N-queen problem, subset
sum problem
Backtracking algorithm is implemented by constructing a tree of choices called as?: state-space
tree.
What happens when the backtracking algorithm reaches a complete solution?: It continues
searching for other possible solutions
A node is said to be ____________ if it has a possibility of reaching a complete solution.: a
promising node
In what manner is a state-space tree for a backtracking algorithm constructed?: Depth first search
In general, backtracking can be used to solve?: complex combinatorial problems
Which one of the following is an application of the backtracking algorithm?: Crossword
puzzles
___________ enumerates a list of promising nodes that could be computed to give the possible
solutions of a given problem.: Backtracking
The problem of finding a subset of positive integers whose sum is equal to a given positive integer
is called as?: Subset sum problem
The problem of placing n queens in a chessboard such that no two queens attack each other is
called as?: The eight queens puzzle
Branch and bound is a __________ algorithm design paradigm
Which of the following is not a branch and bound strategy to generate branches?: Lowest cost
branch and bound
Which data structure is used for implementing a LIFO branch and bound strategy?: Stack
Which data structure is used for implementing a FIFO branch and bound strategy?: Queue
Which data structure is most suitable for implementing best first branch and bound strategy?:
Priority Queue
Which of the following branch and bound strategy leads to breadth first search?: FIFO branch
Which of the following branch and bound strategy leads to depth first search?: LIFO branch
and bound
Choose the correct statement from the following:
Which of the following can traverse the state space tree only in DFS manner?: backtracking
In how many directions do queens attack each other?: 3 directions
Placing n-queens so that no two queens attack each other is called?: n-queens problem.
Where is the n-queens problem implemented?: in chess
In n-queen problem, how many values of n does not provide an optimal solution?: n=2,3.
Which of the following methods can be used to solve n-queen’s problem?: Backtracking
Of the following given options, which one of the following is a correct option that provides an
optimal solution for 4-queens problem?: (3,1,4,2)
ANALYSIS AND DESIGN OF ALGORITHM