COMP9024: Data Structures and Algorithms Final Exam Hui Wu Session 2, 2015 http://www.cse.unsw.edu.au/~cs9024
Final Exam Time: 8:45 am – 12:00 Fri 13/11/2015 Venue: The Scientia - Gallery Duration: 3 hours Closed book Two parts Part 1: Basic data structures and algorithms 8 problems (40 marks) Part 2: Design and analysis of algorithms 5 problems (60 marks) Descriptions of algorithms Use pseudo code
Topics Not Examinable Java Programming Language Red-Black Trees Amortized time complexity analysis Design and Analysis of randomized algorithms All the topics not in the textbook
Sample Problems in Part 1 (1/3) Summarize the time complexity of finding a path between two vertices u and v in an undirected graph.
Sample Problems in Part 1 (2/3) Draw the frequency array and Huffman tree for the following string: "dogs do not spot hot pots or cats"
Sample Problems in Part 1 (3/3) Given a (2,4) tree shown below, draw the resultant (2,4) trees after deleting key 12 and inserting key 30, and the intermediate tree after each step (splitting, or fusion or transfer). 10 15 24 v 2 8 12 18 27 32 35
Sample Problems in Part 2 (1/4) Design an algorithm with the time complexity O(n)for testing if a binary search tree with n entries is an AVL tree, and explain why your algorithm has O(n) time complexity.
Sample Problems in Part 2 (2/4) An edge-weighted DAG (directed acyclic graph)is the DAG where each edge has a weight. The path length of a path from a vertex u to a vertex v is the sum of all the edge weights of the path. A shortest path from a vertex u to a vertex v is the path with the minimum path length. Describe an efficient algorithm for finding a shorted path from a vertex u to a vertex v in a weighted DAG G, and analyze its time complexity in Big-O notation.
Sample Problems in Part 2 (3/4) Show how to modify the KPM pattern matching algorithm so as to find every occurrence of a pattern string P that appears as a substring in T, while still running in O(n+m) time. (Be sure to catch even those matches that overlap.)
Sample Problems in Part 2 (4/4) Show how to modify the KPM pattern matching algorithm so as to find every occurrence of a pattern string P that appears as a substring in T, while still running in O(n+m) time. (Be sure to catch even those matches that overlap.)