This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CS340 – Fall 2002 – FINAL EXAM Dr Malek Mouhoub December 11 2002 Duration: 3hours (Total: 40pts) Exercise 1 : Short Questions [5x1=5pts] Define the following concepts in your own words. 1. Decision tree versus spanning tree. 2. Greedy algorithm versus dynamic programming. 3. Randomized algorithm versus divide and conquer method. 4. Topological sort versus single source shortest path. 5. Feasible solution versus optimal solution. Exercise 2 : Data compression : Huffman coding [1+1+2+1=5pts] Suppose we have a file that contains 10 a , 15 e , 12 i , 3 s , 4 t , 13 blanks, one and one newline . 1. Compute the size of the file assuming each character is coded using 8 bits(ASCII code). 2. Using the naive method for compressing the file, compute the new size. 3. Using the Huffman algorithm with a binary tree representation: (a) Compute the optimal coding for each character. (b) What is the size of the compressed file in this case? 4. Assuming that N is the number of type of characters the file contains, what is the worst- case time complexity of the Huffman algorithm....
View Full Document
- Fall '10
- Insertion Sort, algorithm design techniques, Algorithm Quicksort Mergesort