Algorithm Suggestion question for segment – 4,5,6,7,8 Segment -4 1. Write down the differences between dynamic programming and greedy algorithm? 2. Define: An activity-selection problem. 3. Find all possible optimal set for the following data set using activity selection problem: i 1 2 3 4 5 6 7 Si 1 3 5 7 6 13 18 fi 4 5 6 11 12 18 22 Answer: a) {1,3,4,6,7} b){1,3,5,6,7} c) {2,3,4,6,7} d) {2,3,5,6,7} 4. What are the differences between 0/1 knapsack problem and fractional knapsack problem? Give example. 5. Why 0/1 knapsack problem can’t return optimal solution in greedy method? 6. Define: variable-length code and fixed-length code with example. 7. Generate a Huffman tree and determine an optimal Huffman code for the following text: “to be or not to be it is true” 8. Generate a Huffman tree and determine an optimal Huffman code for the following set of frequencies: a:45, b:13, c:12, d:16, e:9,f:5 9. What is a prefix code? Explain with example why variable length code must be prefix code. 10. Consider the following graph and apply the traveling salesperson problem to find the optimal tour: 10 A 15 B 11 13 25 D 14 18 15 13 20 14 C 17 Answer: 1,2,4,3,1 Segment -5 1. Give example of: complete graph, null graph, adjacent matrix, adjacent list, degree, sub-graph, loop, cycle, directed graph, undirected graph, Strongly connected graph, Weakly connected graph, Disjoint graph 2. What are the differences between graph and tree? 3. Show how Breadth First Search works on the following graph and consider E as the source: B A E F G D C 4. Show how Depth First Search works on the following graph and consider E as the source: B A E F D G C 5. Construct minimum spanning tree from the following graph using Prim’s algorithm and consider E as the source: A 50 90 85 F 75 E G 45 5 25 D 35 3 70 3 B 10 C 6. Construct minimum spanning tree from the following graph using Kruskal algorithm. A 50 90 85 F D 35 3 75 E 70 3 B 10 45 5 25 G C 7. Define: Spanning tree and minimum spanning tree. 8. Write down the differences between BFS and DFS. 9. Write algorithm for Breadth First Search (BFS). 10. Write an algorithm to find the minimum spanning tree of a connected weighted graph. Segment -6 1. 2. 3. 4. Define negative weight cycle and relaxation technique with example. Prove that the subpath of a shortest path is also a shortest path. What do you mean by relaxation of a vertex? Briefly discuss with necessary figure. Write down the differences between Dijkstra’s Algorithm and Bellman-Ford algorithm? 5. Consider the following weighted, directed graph. Run the Dijkstra’s algorithm to find single source shortest path on the graph using A as source. B 5 A 9 1 E 7 3 6 C 4 D 6. Consider the following weighted, directed graph. Run the Bellman-Ford algorithm to find single source shortest path on the graph using A as source. B 5 A 9 1 E 7 3 6 C 4 D 7. Find the Floyd-Warshall algorithm on the following weighted directed graph. Also show the matrix D(K) and ∏(K) that results for each iteration. 1 3 5 4 2 8 2 -4 1 -5 7 4 6 3 Segment -7 1. Define recurrence tree with example. 2. Briefly describe NP-complete and NP-Hard problem? 3. Briefly describe all NP-complete problems are NP-hard, but all NP-hard problems are not NP-complete. 4. Define: Backtracking. 5. Write an algorithm to solve n-queen problem. 6. Discuss n-queen problem with backtracking. 7. What are the applications of Branch and Bound? 8. Define halting problem. Give some simple argument why halting problem is undecidable. 9. Use recurrence tree to solve the following recurrence T(n) = 2T(n/4) + cn2. 10. Define the classes P and NP. What type of problem is called NP-Complete? Segment -8 1. What is Computational Geometry? What are the application areas of computational geometry? 2. How we can determine if two lines are collinear? 3. How we can determine if two line segments intersect? 4. Define: convex hull? 5. Write down Graham’s scan algorithm of convex hull construction? 6. Consider the following points and find convex hull using Graham’s scan algorithm: P1(0.7, 2.7), P2(1.8,3.2),P3(2.6,0.8),P4(0.9,2.5),P5(0.6,0.7),P6(1.5,0.6), P7(1.5,2.5),P8(2,1.5), P9(1.0,2.0),P10(0.8,1.5). Answer: P1,P2,P3,P5,P6 7. Write down Euclid’s algorithm of Greatest Common Divisor (GCD). 8. Write down the algorithm to calculate xn mod m.