cisc 4080 computer algorithms spring 2019 final review
play

CISC 4080 Computer Algorithms Spring 2019 Final Review Quide The - PDF document

CISC 4080 Computer Algorithms Spring 2019 Final Review Quide The final exam is cumulative, with 70% of the questions from the second half of the semester. Please bear in mind that all topics are related. In the list below, items 1-7 were


  1. CISC 4080 —Computer Algorithms Spring 2019 Final Review Quide The final exam is cumulative, with 70% of the questions from the second half of the semester. Please bear in mind that all topics are related. In the list below, items 1-7 were covered before midterm exam. 1. Understand the basic concepts: algorithm, problem instance, input size, running time, space require- ment (memory required), best case, worst case and average case performance (running time or space requirement) 2. Running time analysis: given pseudocode, write T ( n ) (i.e., number of computer steps executed by the algorithm on an input of size n ). (a) non-recursive: analyze the loop (including nested loop) to count the total number of steps executed (b) recursive algorithm: write a recursive formula for T ( n ). 3. Master theorem: know how/when to apply it to solve recursive formula for closed one For example, it cannot be used to solve T ( n ) = 2 T ( n − 2) + n 2 , It can be used to solve T ( n ) = 3 T (3 n/ 4) + n 2 , with a = 3 , b = 4 / 3 , d = 2, because n/b = 3 n/ 4. 4. Understand the meaning of O , Ω, Θ notations, and can use the simple rules of thumbs (book DPV and slides) to decide for given pairs of functions of n , what is the relation between them. 5. Understand the algorithms studied for the problems listed below (a) Search problem: linear search (works for unsorted array or sorted one) and binary search (requires array to be sorted already) (b) Sorting: bubble sort, selection sort, insertion sort, mergesort, quick sort, counting sort, radix sort and so on (c) Selection (find the k -th largest element): adapted bubble sort, divide-and-conquer (practiced in hw3). Expectation: you should be able to answer questions about these algorithms, adapte the algorithms, and trace the codes. 6. Sorting algorithms concepts (a) comparison based vs non-comparison based (b) lower bound for comparison based sorting: n log n . (c) in-place vs out-of-place sorting (d) stable vs unstable sorting algorithms (depends on the implementation details) (e) n 2 vs n log n vs n running time sorting algorithms 7. Problem solving paradigm: how to come up an algorithm to solve a new problem • brute force: enumerate (try) all possibilities to find the best one

  2. • Divide and conquer: divide the problem into smaller problem instances, solve each of the smaller problem instances (recursively), and then do some processing to combine the solutions to the smaller problems to find the solution to the original problem. • Greedy algorithm: • Dynamic programming Expectation: Apply them to solve simple problems with some hints. (example, hw3, and problem set handed out in class). 8. Heap as a data structure • Understand the following concepts: Complete binary tree and its height (log 2 n ), maximum heap and minimum heap property • use heap: when maintaining a dynamic set, and need to find the minimum (or maximum) key quickly. For example, heap is used to implement priority queue, which is used in Prim algorithm, Dijkstra algorithm. • Implementation of heap operations and running times: (a) Basic common operations: check heap property, heapfiy up, heapify down (b) Retrieve root (which stores min or max value): constant time (c) Remove root: move last node to the root, heapify down: log n time operation (d) Insert: append to the end, heapfify up (to float up the new element to right place): log n time operation (e) Modify an item’s value: requires a heapify up or heapify down (depends on whether it’s min-heap or max-heap, and whether the new value is larger or smaller than original value). • use heap to implement heapsort (you should be able to illustrate how it works). Please refer to the exercise on heap and its solution. 9. Hashtable: data structure that supports a near constant time look-up using keys • Understand the following concepts: direct access table (using the key which is an integer as index to the array), hash function ( maps a key value to index of array), collision (when two different key values are hashed to the same index) • Understand why collision cannot be avoided if the universe (the set of all possible key values) is larger than the hash table size • collision resolution via chaining: the running time for search, insertion and deletion is Θ( α ), where α is the average length of all lists. In general, α equals to the load factor, i.e., N/m , with N denotes the number of elements, m denotes the array size. • collision resolution via open addressing (using a probing sequence). Please refer to homework 4 and its solution 10. Graph and graph algorithms • Understand the following concepts: undirected graph, directed graph, DAG (Directed Acyclic Graph), path, cycle; graph representation (adjacency lists and adjacency matrix); Spanning tree, minimum spanning tree • Understand that many problems can be modeled as graph: such as puzzles like water-pouring, and for a given problem, you can formulate a graph presentation for the problem. • Breadth-first traversal/search algorithm: explore graph from a source node, discover and explore nodes that is one hop away first, and then nodes that are two hops away, and so on. 2

  3. • Depth-first traversal/search algorithm and topological sorting (You should be able to show the result of DFS, use DFS to solve topological sorting, cycle detection). • Shortest-distance path algorithm: Dijkstra algorithm (Your should understand that this algorithm finds the shortest path from one source noe to all reachable nodes in a graph with positive weights on edge. You should be able to carry out the algorihtm on a given graph). • Minimal Spanning tree algorithm: Kruskal algorithm, Prim algorithm (You should be able to carry out these two algorithms on a given graph). • Know the running time of the above graph algorithms. Please refer to homework 5 and its solution. 11. Dynamic Programming • Understand characteristics of problems for which dynamic programming algorithm can be used: optimal substructure and overlapping of subproblems. (You should be able to explain the concepts with example.) • Able to identify the approaches used by a given DP algorithm to define subproblems (see ap- pendix). • Implementation of Dynamic Programming algorithm: using tables (1D, 2D or higher dimension) to store subproblem solutions (avoid recomputation). Top-down (recursion) with memoization, and bottom-up approaches (You should be able to write pseudocode from a given recursive formular – as practiced in homework 6). • Understand the pros and cons of the above two approaches: top-down memoization (pro: only solve subproblems as needed, con: overhead due to recrusive calls) and bottom-up (pro: no recusrive function call overhead, cons: need to solve all smaller subproblems – which sometimes is not necessary). • You should be able to trace, modify dynamic programming algorithms we learnt in class: rod cutting, knapsack (with or without repetition), maximum subarray, longest common subsequence. Please refer to homework 6 and its solution. 12. Appendix: Besides the approached listed below, we have seen another way to define subproblems: 0. The input is n (an integer), the subproblem is k (an integer that is smaller than n . The DP algorithms for rod cutting problem, and Knapsack with repetition uses this approach. 1. The input is an integer n and an array x 1 , x 2 , ..., x m , the subproblem is k ( k < n ), and an array x 1 , x 2 , ...x l ( l < m ). The DP algorithm for Knapsack without repetition uses this approach. 3

  4. 4

Recommend


More recommend