Problem Pts Score Grader Problem Pts Score Grader

Similar documents
Exam 3 Practice Problems

Problem Score Maximum MC 34 (25/17) = 50 Total 100

Total Score /1 /20 /41 /15 /23 Grader

CS 170 Spring 2000 Solutions and grading standards for exam 1 Clancy

Solutions to relevant spring 2000 exam problems

This is a set of practice questions for the final for CS16. The actual exam will consist of problems that are quite similar to those you have

CISC 320 Midterm Exam

( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1

Questions Total Points Score

Final Exam. 1. (8 pts) Consider the following directed graph. If you iterate through all of the vertices as

CSE332 Summer 2012 Final Exam, August 15, 2012

Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2012

CS 170 Second Midterm ANSWERS 7 April NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt):

Math 454 Final Exam, Fall 2005

CSCE 310 Assignment 3 Summer 2018

Final Exam. If you plan to solve a problem using a standard graph algorithm then you should clearly

CS 3343 (Spring 2013) Exam 2

Lecture Summary CSC 263H. August 5, 2016

Prelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

Instructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII.

Algorithm Design and Analysis

Exam Datastrukturer. DIT960 / DIT961, VT-18 Göteborgs Universitet, CSE

COMPSCI 311: Introduction to Algorithms First Midterm Exam, October 3, 2018

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination

CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: Instructions

Algorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee

Homework Assignment #3 Graph

CSE 100 Minimum Spanning Trees Prim s and Kruskal

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

CSE Winter 2015 Quiz 1 Solutions

CSE332, Spring 2012, Final Examination June 5, 2012

INDIAN STATISTICAL INSTITUTE

Prelim 2 Solutions. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer

Computer Science 385 Design and Analysis of Algorithms Siena College Spring Lab 8: Greedy Algorithms Due: Start of your next lab session

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

Outline for Today. Why could we construct them in time O(n)? Analyzing data structures over the long term.

MST worksheet By Jim Xu

Final Examination CSE 100 UCSD (Practice)

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

Name: Lirong TAN 1. (15 pts) (a) Define what is a shortest s-t path in a weighted, connected graph G.

Computer Science E-22 Practice Final Exam

Minimum Spanning Trees My T. UF

Analyze the obvious algorithm, 5 points Here is the most obvious algorithm for this problem: (LastLargerElement[A[1..n]:

Quiz 2. Problem Parts Points Grade Grader. Total 120. Name: Recitation: Jayant 12 PM. Christina 10 AM. Jayant 1 PM. Jason 2 PM.

CMSC Theory of Algorithms Second Midterm

Sorting and Searching

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2010

CS 373: Combinatorial Algorithms, Spring 1999

Course Review for Finals. Cpt S 223 Fall 2008

Math.3336: Discrete Mathematics. Chapter 10 Graph Theory

Sorting and Searching

CS 3343 (Spring 2018) Assignment 4 (105 points + 15 extra) Due: March 9 before class starts

Chapter 9 Graph Algorithms

Graph Algorithms (part 3 of CSC 282),

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE331 Introduction to Algorithms Lecture 15 Minimum Spanning Trees

CSE 373 Autumn 2012: Midterm #2 (closed book, closed notes, NO calculators allowed)

Graph Algorithms (part 3 of CSC 282),

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes )

Questions Total Points Score

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

FINAL EXAM SOLUTIONS

CSE 247 Data Structures and Algorithms Fall Exam I

EXAM ELEMENTARY MATH FOR GMT: ALGORITHM ANALYSIS NOVEMBER 7, 2013, 13:15-16:15, RUPPERT D

( ) ( ) C. " 1 n. ( ) $ f n. ( ) B. " log( n! ) ( ) and that you already know ( ) ( ) " % g( n) ( ) " #&

Introduction to Algorithms November 17, 2011 Massachusetts Institute of Technology Fall 2011 Professors Erik Demaine and Srini Devadas Quiz 2

MATH 2100 / 2105 / 2350 EXAM 1

Announcements Problem Set 5 is out (today)!

CSE100 Practice Final Exam Section C Fall 2015: Dec 10 th, Problem Topic Points Possible Points Earned Grader

Minimum Spanning Trees

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

COS 226 Midterm Exam, Spring 2009

Exam Datastrukturer. DIT960 / DIT961, VT-18 Göteborgs Universitet, CSE

CS 170, Spring 2000 Midterm #1 Professor M. Clancy

CSE 241 Class 17. Jeremy Buhler. October 28, Ordered collections supported both, plus total ordering operations (pred and succ)

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

Chapter 6 Heapsort 1

Practice Midterm Exam Solutions

CSE 21 Summer 2017 Homework 4

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

Total Score /15 /20 /30 /10 /5 /20 Grader

CSE373 Winter 2014, Final Examination March 18, 2014 Please do not turn the page until the bell rings.

CS711008Z Algorithm Design and Analysis

COS 226 Algorithms and Data Structures Fall Midterm

CSE 21 Spring 2016 Homework 5. Instructions

Chapter 9 Graph Algorithms

CSci 231 Final Review

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

managing an evolving set of connected components implementing a Union-Find data structure implementing Kruskal s algorithm

Chapter 9 Graph Algorithms

CS210 (161) with Dr. Basit Qureshi Final Exam Weight 40%

Priority Queues. Priority Queues Trees and Heaps Representations of Heaps Algorithms on Heaps Building a Heap Heapsort.

CS 6783 (Applied Algorithms) Lecture 5

Transcription:

CSE 502 Fundamentals of Computer Science Spring Semester 2015 Homework 5 Assigned: 4/10/2015 Due Date: 4/21/2015 You must read and sign the following statement to get credit for this assignment: I have read and understood the CSE 502 collaboration policy posted on the course web site. I understand that these rules govern homeworks, labs, and exams assigned in this class, and that violations are subject to severe penalties. I have neither violated the collaboration policy nor helped others to violate it in completing this assignment. Name: Signed: Date: In the box below, please describe any sources of help you received in completing this assignment,and for which problem(s) the help was received. You need not list the instructor & TAs, our book/notes/handouts, or the class Piazza forum. Problem Pts Score Grader Problem Pts Score Grader 1 25 4 25 2 25 5 25 3 25 Total

To receive full credit for the assignment, you must: print and include the required cover sheet; staple all pages together and write your name on each page; typeset or hand-write all solutions clearly, concisely, and legibly; show your work. The approximate weights of each problem (out of 100%) are given in parentheses, but things that come up in the course of grading may cause these weights to be adjusted. Note that you need only do any four problems out of five to get full credit for this homework, though you may do all five for extra credit. Unless otherwise noted, all occurrences of log refer to the base-2 logarithm. 1. (25%) Consider the following min-first binary heap stored as an array: {3, 6, 5, 8, 12, 9, 7, 10, 11, 14}. (a) Show the state of the heap after each of the following series of calls: insert(1); insert(4). Each call should modify the result of the previous call. To help us grade, please indicate which elements change during each insertion. (b) Starting from the original array before any insertions, show the state of the heap after each of the following series of calls: extractmin(); extractmin(); extractmin(). Again, each call should modify the result of the previous call. To help us grade, please indicate which elements change during each extraction. (c) A binary heap can be made to support deletion of an arbitrary element in worst-case time Θ(log n). (Note: this is not the deletion of a particular element of your choice; just an element with arbitrary index.) Write pseudocode for a procedure Delete(i) that removes the element in slot i of an array-based min-first heap Q containing exactly n elements and and fixes up the heap afterwards. Your code may call the insert() and extractmin() functions from the class notes, but should otherwise manipulate the heap s elements directly. (Hint: extractmin() will remove the root element... can you manipulate the element in slot i so that it ends up in the root position, all the while maintaining a valid heap?) Justify the running time of your procedure (informally if you like). 2. (25%) A heap can be used to sort an array in worst-case time Θ(n log n). More interestingly, this sort can be done in place without using temporary storage other the the input array. (a) Given an unsorted array A[1... n] of length n, show how to use n 1 heap insertions to turn A into a max-first heap. You should not use any arrays besides A itself to hold array elements. You do not need to provide pseudocode, but your description must be precise enough to be unambiguous. (Hint: start the heap from A[1] with size 1 and let it expand gradually into higher-numbered cells. In what order must you insert the elements?) 1

(b) Given your max-first heap A from (a), show how repeated extractmax operations can rearrange the elements of A into sorted order. (Hint: Which cells of the array become free to hold the extracted values?) Again, you should not use any arrays besides A itself to hold array elements, and you do not need to provide pseudocode, just a clear explanation. (c) Illustrate your in-place HeapSort algorithm on the following array: {4, 2, 9, 5, 1, 6}. Show the state of the array after each insert and each extractmax operation. 3. (25%) One way to describe an undirected graph is to list the degree of each of its vertices. A vertex s degree is the number of edges incident on it (i.e., the number of edges touching the vertex). If every vertex in a graph G has degree k, we say that G is k-regular. (a) Give an argument that in any undirected graph, the sum of degrees for all vertices is exactly twice the number of edges. (b) Does there exist an undirected graph whose vertices have degrees 5, 3, 3, 2, and 2 respectively? Show such a graph, or give an argument that it does not exist. (c) Two graphs G 1 and G 2 are said to be isomorphic if there is a mapping φ from the vertices of G 1 to the vertices of G 2 such that edge (u, v) exists in G 1 iff edge (φ(u), φ(v)) exists in G 2. (In non-math language, this just means that you can set up a direct correspondence between vertices in the two graphs such that for every edge in one graph, there s a corresponding edge in the other.) For example, the two graphs of Figure 1 are isomorphic under the mapping {A E, B F, C H, D G}. Are all 2-regular graphs on n vertices isomorphic? Give a proof or a counterexample. Figure 1: Two isomorphic graphs on four vertices. How does your answer change if we require that the graph be connected, i.e. that there is a path of edges between any two vertices? (An informal argument for the second part is fine.) (d) Give an example of two 3-regular graphs on six vertices that are both connected but are not isomorphic. (Hint: to show non-isomorphism, measure the lengths of the cycles in the two graphs and show that they are not the same.) 2

4. (25 %) It s final exam time, and you re in charge of scheduling rooms for the exams. Each exam has a designated start and end time, and no two exams whose time periods overlap may be scheduled in the same room. (a) Describe how to construct an (unweighted) graph that shows which pairs of exams can/cannot be scheduled in the same room. What are the vertices? What are the edges? (b) Unfortunately, campus construction projects have left you only two rooms to use for exams. Describe how to use breadth-first search to determine whether it is possible to schedule all exams using only the two rooms provided. If it is possible to do so, your procedure should assign a room to each exam. Your procedure should run in worst-case time proportional to the size of your graph (V + E). 5. (25%) Consider the directed graph G shown in Figure 2. (a) Suppose we run Dijkstra s shortest paths algorithm on G starting from the vertex A. Show the contents of the priority queue (a list of vertices in the queue, along with their key values) just before each extractmin() call made by the algorithm. If the priority queue must choose between vertices with equal keys, assume that it extracts the vertex whose label is alphabetically first. (b) Sketch the shortest path tree that results at the end of the algorithm. (c) Suppose now that we run Prim s minimum spanning tree algorithm in G starting from the vertex J (pretend for this problem that G is undirected; that is, ignore the arrowheads). Show the contents of the priority queue before each extractmin() call, as in part (a). (d) Sketch the minimum spanning tree produced by the algorithm. 3

Figure 2: Graph for running Dijkstra s and Prim s Algorithms. 4