Viva Voice Daa
Viva Voice Daa
Q5. During linear search, when the record is present in first position then how many
comparisons are made ?
Ans. Only one comparison.
Q1. What is the worst case complexity of binary search using recursion?
Ans. O(logn)
Q2. What is the average case time complexity of binary search using recursion?
Ans. O(logn)
Ans. O(logn)
Experiment No.-3. Selection Sort
Q5. How many comparisons are performed in the second pass of the selection sort
algorithm?
Ans. n-2 comparisons are performed in the second pass of the selection sort algorithm.
Q1. What is the best case complexity for insertion sort algorithm
Ans. O(n)
Q2. What is the worst case complexity for insertion sort algorithm
Ans. O(n*n)
Q4. In which cases are the time complexities same in insertion sort?
Ans. Worst and Average
Q5. For insertion sort, the number of entries we must index through when there are n
elements in the array is
Ans. n-1 entries
Experiment No.-5 Bubble Sort
Q4. What are the basic criteria for selecting appropriate algorithm?
Ans. Execution Time, Storage Space, Programming Effort
Q5. What is the advantage of bubble sort over other sorting techniques
Ans. Detects whether the input is already sorted
Q1. Merge sort uses which of the following technique to implement sorting?
Ans. divide and conquer
Q2. Which of the following method is used for sorting in merge sort?
Ans. Merging
Q4. Merge sort is preferred for arrays over linked lists. Is it True or False ?
Ans. False
Q5. What will be the best case time complexity of merge sort?
Ans. O(n log n)
Experiment No.-7 Quick Sort
Q2. In which cases are the time complexities same in quick sort?
Ans. Best and Average
Q3. What pattern of splits gives the worst-case performance for quick sort?
Ans. Descending order.
Q5. What is the Best case, Average case and worst case complexity for quick sort algorithm
Ans. Best Case- O(nlogn) Average Case- O(nlogn) Worst Case- O(n*n)
Q3. Running time of Strassen’s algorithm is better than the naïve Theta(n3) method.
Ans. True
Q1. Which methods can be used to solve the matrix chain multiplication problem?
Ans. Dynamic programming, Brute force, Recursion
Q2. 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?
Ans. 10*20*30
Q3. Consider the matrices P, Q and R which are 10 x 20, 20 x 30 and 30 x 40 matrices
respectively. What is the minimum number of multiplications required to multiply the three
matrices?
Ans. 18000
Q4. Consider the brute force implementation in which we find all the possible ways of
multiplying the given set of n matrices. What is the time complexity of this implementation?
Ans. Exponential
Q5. What is the time complexity of the above dynamic programming implementation of the
matrix chain problem?
Ans. O(n3)
Q1. Consider the strings “PQRSTPQRS” and “PRATPBRQRPS”. What is the length of the
longest common subsequence?
Ans. 7
Q3. What is the time complexity of the above dynamic programming implementation of the
longest common subsequence problem where length of one string is “m” and the length of the
other string is “n”?
Ans. O(mn)
Q4. Which of the following is the longest common subsequence between the strings
“hbcfgmnapq” and “cbhgrsfnmq” ?
Ans. hgmq, cfnq, bfmq
Q5. What is the time complexity of the brute force algorithm used to find the longest common
subsequence?
Ans. O(2n)
Experiment No.-11 0-1 Knapsack Problem
Q3. 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?
Ans. 160
Q4. What is the time complexity of the brute force algorithm used to solve the Knapsack
problem?
Ans. O(2n)
Q5. The 0-1 Knapsack problem can be solved using Greedy algorithm.
Ans. False