You are on page 1of 6

ANALYSIS AND DESIGN OF ALGORITHM

In the analysis of algorithms, what plays an important role?growth rate


If x is a set and the set contains an integer which is neither positive nor negative then the set x is
____________.{0} non-empty and finite set
Which of the following is a subset of set {1, 2, 3, 4}? {1, 2}, {1, 2, 3}, and {1}. All of the
mention
Power set of empty or Null set has exactly _________ subset.One
What is the Cartesian product of set A and set B, if the set A = {1, 2} and set B = {a, b}?
{(1,a),(1,b),(2,a),(2,b)}
The difference of {1, 2, 3, 6, 8} and {1, 2, 5, 6} is the set ____________ {3,8}
If n(A) = 20 and n(B) = 30 and n(A U B) = 40 then n(A ∩ B) is? 10
Which option is correct for representing an algorithm?flowchart
Which case does not exist in complexity theory? Null case
Which of the following matrix having only one column and multiple rows? A column matrix
Which of the following matrix having only one row and multiple columns? A row matrix
Which of the following function is also referred to as an injective function? One to one
What is an external sorting algorithm? Algorithm that uses tape or disk during the sort
What is an internal sorting algorithm? Algorithm that uses main memory during the sort
Which of the following is not an advantage of optimised bubble sort over other sorting techniques
in case of sorted elements? Detects whether the input is already sorted
The given array is arr = {1, 2, 4, 3}. Bubble sort is used to sort the array elements. How many
iterations will be done to sort the array? 4
What is an in-place sorting algorithm? It needs O(1) or O(logn) memory to create auxiliary
locations
In the following scenarios, when will you use selection sort? Large values need to be sorted
with small keys
What is the advantage of selection sort over other sorting techniques? It requires no
additional storage space
What is the disadvantage of selection sort? It is not scalable
The given array is arr = {3,4,5,2,1}. The number of iterations in bubble sort and selection sort
respectively are __________ 5 and 4
Which of the following algorithm implementations is similar to that of an insertion sort? Binary
heap
Which of the following real time examples is based on insertion sort? arranging a pack of
playing cards
In C, what are the basic loops required to perform an insertion sort? for and while
Which of the following options contain the correct feature of an insertion sort algorithm? stable,
adaptive
Which of the following sorting algorithms is the fastest for sorting small arrays? Insertion sort
For the best case input, the running time of an insertion sort algorithm is? Linear
Which of the following examples represent the worst case input for an insertion sort? array
sorted in reverse order
Which of the following is not an exchange sort? Insertion sort
What is the other name for a shell sort algorithm? Diminishing increment sort
Shell sort algorithm is an example of? Internal sorting
Which of the following sorting algorithms is closely related to shell sort? Insertion sort
Why is Shell sort called as a generalization of Insertion sort? Shell sort allows an exchange
of far items whereas insertion sort moves elements by one position
ANALYSIS AND DESIGN OF ALGORITHM

On which algorithm is heap sort based on? priority queue


In what position does the array for heap sort contains data? 0
In heap sort, after deleting the last minimum element, the array will contain elements in?
decreasing sorting order
Heap sort is an implementation of ____________ using a descending priority queue. selection
sort
Which one of the following is false? Heap sort is stable sort
Which of the following method is used for sorting in merge sort? divide and conquer
Which of the following is not a variant of merge sort? linear merge sort
Choose the incorrect statement about merge sort from the following? it is an adaptive
algorithm
Which of the following is not in place sorting algorithm by default? merge sort
Which of the following is not a stable sorting algorithm? Quick sort
Which of the following stable sorting algorithm takes the least time when applied to an almost
sorted array? Merge sort
Which of the following sorting algorithms is the fastest? Quick sort
Which is the safest method to choose a pivot element? choosing a random element as pivot.
Which of the following sorting algorithms is used along with quick sort to sort the sub arrays?
Insertion sort
How many sub arrays does the quick sort algorithm divide the entire array into? two
QuickSort can be categorized into which of the following? Divide and conquer
What is a randomized QuickSort? quick sort with random choice of pivot
Which of the following is not true about QuickSort? pivot position can be changed
Strassen’s algorithm is a/an_____________ algorithm. Recursive
Strassen’s matrix multiplication algorithm follows ___________ technique. Divide and
Conquer
What is the formula to calculate the element present in second row, first column of the product
matrix? M2+M4
Which of the following is/are property/properties of a dynamic programming problem? Both
optimal substructure and overlapping subproblems
If an optimal solution can be created for a problem by constructing optimal solutions for its
subproblems, the problem possesses ____________ property. Optimal substructure
If a problem can be broken into subproblems which are reused several times, the problem
possesses ____________ property. Overlapping subproblems
If a problem can be solved by combining optimal solutions to non-overlapping problems, the
strategy is called _____________ Divide and Conquer
In dynamic programming, the technique of storing the previously calculated values is called
___________ Memoization
When a top-down approach of dynamic programming is applied to a problem, it usually
_____________ It increases the space complexity and decreases the time
complexity.
Which of the following problems is NOT solved using dynamic programming? Fractional
knapsack problem
Which of the following problems should be solved using dynamic programming? Longest
common subsequence
ANALYSIS AND DESIGN OF ALGORITHM

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

How many possible solutions exist for an 8-queen problem?: 92

You might also like