0% found this document useful (0 votes)
69 views

cs502 Midterm Solved Mcqs by Me

1. The Huffman algorithm finds an optimal solution for encoding data in a way that is efficient and uses variable-length codes. 2. The worst case running time of the Floyd-Warshall algorithm for finding all shortest paths in a graph is O(n^3), where n is the number of vertices. It uses O(n^2) space. 3. Kruskal's algorithm finds a minimum spanning tree in overall O(E log E) time for a graph with E edges, or O(E log V) time for sparse graphs.

Uploaded by

Muhammad Raza
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

cs502 Midterm Solved Mcqs by Me

1. The Huffman algorithm finds an optimal solution for encoding data in a way that is efficient and uses variable-length codes. 2. The worst case running time of the Floyd-Warshall algorithm for finding all shortest paths in a graph is O(n^3), where n is the number of vertices. It uses O(n^2) space. 3. Kruskal's algorithm finds a minimum spanning tree in overall O(E log E) time for a graph with E edges, or O(E log V) time for sparse graphs.

Uploaded by

Muhammad Raza
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Non-Optical or greedy algorithm for money change takes O(k)


2. The Huffman algorithm finds a (an) optimal solution.
Tworst (n)  max T ( I )
I n
3. Which formula is used for calculating worst case running time?
4. The reason for introducing sieve technique algorithm is that it illustrates a very important special case of
Divide-and-conquer
5. Sieve technique applies to problem where we are interested in finding a single item from a larger se of n items
6. The number of nodes in a complete binary tree of height h is 2^(h+1)-1
 (n 2 )
If there are  ( n ) entries in edit distance matrix then the total running time is
2
7.
8. When a recursive algorithm revisits the same problem over and over again, we say that the optimization problem has
overlapping sub-problems.
9. A p x q matrix A can be multiplied with a q x r matrix B. The result will be a p x r matrix C. There are (p. r) total entries in C
and each takes O (q) to complete.
10. Maximum number of edges in a directed graph may be Approximately |V2|
11. An adjacency matrix for a graph it is not necessary for it to be square in shape
12. In fractional knapsack we sort the value per unit weight in decreasing order
13. The greedy part of the Huffman encoding algorithm is to first find nodes with smallest frequency.
14. The code word assigned to characters by the Huffman algorithm have the property
That no code word is the prefix of any other
15. In undirected graph there is convention of only back edges
16. In time stamp DFS for the edge (u , v) if f(u) > f(v) the edge is tree or cross or forward
17. Kruskal’s algorithm choose the best non-cycle edge
18. In Prim’s algorithm we use priority queue data structure
19. Adding any edge to a free tree create a unique cycle
20. Floyd-Warshall algorithm is based on dynamic programming approach and allow negative edges
21. Dijkstra’s algorithm is used for single source shortest path problems
22. Bellman Ford algorithm applies relaxation to every edge of the graph repeats exactly v-1 times
 ( n3 )
23. Running time of Floyd-Warshal algorithm is
24. If we can solve a single NP problem in P time. All NP problem can be solved
25. If a problem in NP-complete it must also be in NP
26. 3- color problem is known as NPC
27. Clique cover problem arises in applications of clustering
28. In the clique cover problem, for two vertices to be in the same group, they must be adjacent to each other.
29. In the 3-coloring problem, for two vertices to be in the same color group, they must not be adjacent.
30. What is the worst-case time for merge sort to sort an array of n elements? O (n log n)
31. Search technique of various algorithm look at many possible solutions
32. The Huffman encoding algorithm is a greedy algorithm
33. Breath first search is shortest path algorithm that works on un-weighted graphs
34. Consider the string “abacdaacac” if the string is coded with ASCII codes using Huffman encoding scheme, the message
length would be 80 bits
4n  15n 2  11n
6  (15 n 2 )
35. What is the asymptotic growth of ?
36. A heap is a left complete binary tree that confirm to the heap order
37. What is common between Bubble sort, Insertion sort, Quick sort, and Heap sort? All are in-place algorithms

Algorithm In-Place Stable


Bubble Sort Yes Yes
Insertion Sort Yes Yes
Selection Sort Yes No
Merge Sort No Yes
Heap Sort Yes No
Quick Sort Yes No

38. In In-place sorting algorithm is one that uses no additional array for storage.
39. The main shortcoming of counting sort is that it is useful for small integers
1 5
  1.618
The original recursive algorithm takes  ( ) time, where
n
40. 2
41. The Huffman codes provides a method of encoding data which is efficient and use fixed length codes i.e. ASCII
42. Using ASCII standard the string “adacdaacac” will be conceded with 8 bytes
43. In undirected graph there is convention of only back edges
44. In time stamp traversal we can calculate whether the graph has cycles
45. Precedence constraint graph is acyclic directed graph
46. In Prim’s algorithm, the additional information maintained by the algorithm is
The length of the shortest path from vertex v to the vertex u
47. In strongly connected components the component graph is necessarily cyclic
48. Floyd-Warshal algorithm is based on dynamic programming approach and allow negative edges
overall  ( E log E ) and for sparse graph  ( E log V )
49. Kruskal’s algorithm has time complexity
50. In NP-Problems “NP” represents Non-deterministic polynomials
51. Generalize coloring problem arises in various partitioning problems where there is a constraint
That two objects cannot be assigned to the same set of partitions and is belong to NP class
52. Sieve technique can be applied to solve selection problems
53. Usually which type of algorithm is harder to prove the correctness? Brute force
54. Flowchart is a graphical representation of an algorithm
it will take  ( I )
55. When we call heapify then at each level the comparison performed takes time?
56. Who invented quick sort procedure? Hoare
57. If we encode and compress text using ASCII standard each character is represented by, Fixed length code word of 8 bits
58. The Huffman coding used, Prefix property that no code word is prefix of any other code
59. In directed graph the cardinality of edges |E| =
Sum of out=degree of all the vertices
Sum of in-degree of all the vertices

60. A Hamiltonian cycle is a cycle, that visit every vertex in the graph exactly once
61. In generic graph traversal algorithm we, put edges in the bag data structure
62. The generic graph traversal algorithm stores a set of candidate edges in some data structures we well call a “bag”
63. Dijkstra’s algorithm:
The length of the shortest path to the start vertex is always zero.
It will work on any weighted graph with positive weights.
The running time of Bellman- Ford algorithm is greater than Dijkstra’s algorithm
64. Kruskal’s algorithm is used for calculating minimum spanning tree.
65. Dijkstra’s algorithm is used for single source shortest path problems
66. Floyd-Warshal algorithm dates back to the early 60’s
 (n 2 )
67. Space used by Floyd-Warshal algorithm is

The running is  ( n ) . The Space used by the algorithm is  ( n )


3 2
68.
69. What is the solution to the recurrence T(n) = T(n/2) + n ? O(n)
70. If a pseudo code is memory wise efficient then it may be memory wise efficient but not necessary
71. Merge sort makes two recursive calls. Which statement is true after recursive call finish, but before the merge step?
Elements in each half of the array are sorted amongst themselves
72. Random access machine or RAM is a/an Mathematical model
73. In order to say anything meaningful about our algorithms, it will be important for us to settle on a
Mathematical model of computation
74. Divide-and-conquer involves breaking the problems into a small number of sub problems
75. In Bucket sort, if there are duplicates then each bin can be replaced by a Linked list
76. A p × q matrix A can be multiplied with a q × r matrix B.
q
C [i, j ]   A[i, j ] B [k , j ]
k 1
The result will be a p × r matrix C. In particular, for 1 ≤ i ≤ p and 1 ≤ j ≤ r
2
77. Worst case running time of Quick sort algorithm for an array n elements is? n
78. The Huffman algorithm time complexity can be improved up to O (n log n)
79. Using ASCII standard the string “abacdaac”. If we use fixed code for ASCII it will be 64 bits
80. Using Huffman encoding technique the string”abc” will take 24 bits
81. Using Huffman encoding technique the string “a@$a” will be encoding with______ bits.
Huffman encoding fail at this string.
82. When the graph relatively few edges, Kruskal’s algorithm is better than prim’s
83. An un-weighted graph can be considered as a graph in which every edge has by default weight of one unit
84. All algorithm having the time complexity O (n 10) and O (n100) fall.
O (n10) in P class and O (n100) in NP class
85. If a problem “S” is NP-complete it must be NP and NP-hard
86. Which traversal technique is look like propagating wave-front outward, Breath First Traversal
87. An optimization problem is one in which you want to find. The best solution
88. Suppose that a graph G = (V,E) is implemented using adjacency lists. What is the complexity of a breath-first traversal of G?
O (|V| +|E|)
89. Non- optional or greedy algorithm for money change takes O(k)
90. The running time of Quick sort depends heavily on the selection of pivot
91. If a sorting algorithm solely based on comparisons of keys in the array then it is impossible to sort more efficiently than
 ( n log n)
92. Fibonacci sequence was posed by Leonardo Pisano
93. A free tree with “n” vertices has exactly n-1 edges
 (V  E )
94. GT for the digraph can be computed in
95. Which of the following is not true about Dijkstra’s algorithm?
It can find the shortest paths to all other vertices in the same worst case time that it needs to finds the shortest path a single vertices
 ( E log V )
96. The running time of the Dijkstra’s algorithm is
 (n 3 )
97. The running time of Floyd-Warshal algorithm is
98. The function having complexity O (nn) belongs to NP-Class
99. The function having complexity O (nk) belongs to NP-Class
100.Which type of instructions Random Access Machine (RAM) can execute? Arithmetic and logic

101.

You might also like