CSCE 310 Assignment 3 Summer 2018

Similar documents
Assignment 8 CSCE 156/156H/RAIK 184H Spring 2017

Problem Pts Score Grader Problem Pts Score Grader

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

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

Homework Assignment #3 Graph

LECTURE 26 PRIM S ALGORITHM

CIS 121 Data Structures and Algorithms Minimum Spanning Trees

Graph Algorithms (part 3 of CSC 282),

Week 12: Minimum Spanning trees and Shortest Paths

Info 2950, Lecture 16

Undirected Graphs. Hwansoo Han

Algorithms CMSC Homework set #2 due January 21, 2015

MST worksheet By Jim Xu

Graph Traversal CSCI Algorithms I. Andrew Rosenberg

Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret

PATH FINDING AND GRAPH TRAVERSAL

Question Paper Code : 97044

2018 Pummill Relay problem statement

Problem 1. Which of the following is true of functions =100 +log and = + log? Problem 2. Which of the following is true of functions = 2 and =3?

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

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

CMSC351 - Fall 2014, Homework #6

Dist(Vertex u, Vertex v, Graph preprocessed) return u.dist v.dist

Graph Algorithms (part 3 of CSC 282),

UNIVERSITY OF MANITOBA. SIGNATURE: (in ink) (I understand that cheating is a serious offense)

tree follows. Game Trees

CMSC th Lecture: Graph Theory: Trees.

Assignment 3 CSCE 155H/RAIK 183H Fall 2016

Definition: A graph G = (V, E) is called a tree if G is connected and acyclic. The following theorem captures many important facts about trees.

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

Week 11: Minimum Spanning trees

Questions Total Points Score

CSE 100 Minimum Spanning Trees Prim s and Kruskal

22 Elementary Graph Algorithms. There are two standard ways to represent a

Minimum spanning trees

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

CMSC351 - Fall 2014, Final Exam

CSE 21 Spring 2016 Homework 5. Instructions

Exam Datenstrukturen und Algorithmen D-INFK

CIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018

Mathematics Masters Examination

Lecture 6 Basic Graph Algorithms

Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 3.. NIL. 2. error new key is greater than current key 6. CASCADING-CUT(, )

All Shortest Paths. Questions from exercises and exams

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

CS 4349 Lecture October 18th, 2017

Depth-First Search Depth-first search (DFS) is another way to traverse the graph.

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

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

UCSD CSE 101 MIDTERM 1, Winter 2008

Exam 3 Practice Problems

This course is intended for 3rd and/or 4th year undergraduate majors in Computer Science.


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

CSE 431/531: Analysis of Algorithms. Greedy Algorithms. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo

Computer Science E-22 Practice Final Exam

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE

Minimum Spanning Trees

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

Final Examination CSE 100 UCSD (Practice)

Graph Search Methods. Graph Search Methods

RYERSON UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE CPS 616 FINAL EXAM WINTER 2018

CSE 21 Summer 2017 Homework 4

CSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms. Lecturer: Shi Li

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Algorithms For Inference Fall 2014

Graph traversal is a generalization of tree traversal except we have to keep track of the visited vertices.

CSC 8301 Design & Analysis of Algorithms: Warshall s, Floyd s, and Prim s algorithms

CSE 373: Practice Final

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Prelim 2 Solution. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader

COL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:

University of New Mexico Department of Computer Science. Final Examination. CS 362 Data Structures and Algorithms Spring, 2006

Data Structure and Algorithm I Homework #4 Due: 5pm, Sunday, December 12, 2010

Outline. Graphs. Divide and Conquer.

CSE373: Data Structures & Algorithms Lecture 17: Minimum Spanning Trees. Dan Grossman Fall 2013

( ) n 3. n 2 ( ) D. Ο

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

Solutions for the Exam 6 January 2014

Student number: Datenstrukturen & Algorithmen page 1

Homework 2. Sample Solution. Due Date: Thursday, May 31, 11:59 pm

Chapter 23. Minimum Spanning Trees

CS 373: Combinatorial Algorithms, Spring 1999

BT, BST, AVL. Web Resources page on textbook website:

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

Announcements. CSEP 521 Applied Algorithms. Announcements. Polynomial time efficiency. Definitions of efficiency 1/14/2013

Math 15 - Spring Homework 5.2 Solutions

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

22 Elementary Graph Algorithms. There are two standard ways to represent a

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

CS2223: Algorithms D-Term, Assignment 5

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

CS490 Quiz 1. This is the written part of Quiz 1. The quiz is closed book; in particular, no notes, calculators and cell phones are allowed.

Graphs - II. Announcements. Where did I leave that book? Where did I leave that book? Where did I leave that book? CS 2110, Fall 2016

Undirected Graphs. DSA - lecture 6 - T.U.Cluj-Napoca - M. Joldos 1

CS521 \ Notes for the Final Exam

CSE331 Introduction to Algorithms Lecture 15 Minimum Spanning Trees

Algorithms and Data Structures, Academic Year 2010/2011

ECE 250 Algorithms and Data Structures

CSE 373 MAY 10 TH SPANNING TREES AND UNION FIND

Prelim 2 Solution. CS 2110, November 19, 2015, 5:30 PM Total. Sorting Invariants Max Score Grader

Transcription:

Name(s) CSE Login Programming Language(s) Used Question Points Score 1 10 2 10 3 20 4 5 5 5 6 10 7 20 8 120 Total: 200 Graders Notes:

Instructions Follow instructions carefully, failure to do so may result in points being deducted. Clearly label each problem and submit the answers in order. Be sure to show sufficient work to justify your answer(s). If you are asked to prove something, you must give a formal, rigorous, and complete proof You must adhere to the CSE academic integrity policy: http://cse.unl.edu/academic-integrity-policy You are encouraged to typeset your homework using L A TEX; if your answers are not legible, you may be required to use L A TEX in future assignments. We recommend that you use the following packages: Algorithm2e package for pseudocode Minted for typesetting code Tikz/PGF for graphs and figures Hand in your written answers hardcopy, properly stapled, with a copy of the first page as a cover sheet. Hand in all programs softcopy using the CSE webhandin and be sure that they properly execute in the webgrader. Failure to do so will mean that your program is not graded. Partner Policy You may work in groups of at most two students. This is optional and you may work alone if you wish. If you opt to work in pairs, you must follow these guidelines: 1. You must work on all problems together. You may not simply partition the work between you. 2. You should not discuss problems with other groups or individuals beyond general questions. 3. Hand in only one hard copy (and possibly soft copy) under the first author s name/cse login. Programming Instructions: you are highly encouraged to solve the programming problems using a high level programming language that you are not already familiar with (C++, PHP, Python, C# etc.); however, you may not use Java. Your program will be required to compile and run on the CSE server from the command line. Because we are allowing a variety of languages, you are required to also provide a script file named run.sh that contains the commands to compile and execute your program passing any command line arguments on to your program. Several examples have been provided. Page 2 of 7

You are required to hand in all source file, test cases, and other artifacts necessary to compile and run your program through webhandin. Moreover, you are required to rigorously test your programs locally and ensure that they work. Your program is required to work through the course webgrader as well. If your program fails to run, you may receive a zero. Your programs will be evaluated based on the following: 10 pts You must provide at least 2 non-trivial test cases to show that you properly tested your program (test cases each include a plaintext input file and output file with the formatting and naming specified for each problem) The remainder of the points will be awarded based on the correctness of your program. We have provided numerous test cases (if you find an error with any, please notify us and you will be awarded bonus points). You should use these test cases to debug and test your programs. The correctness of your program, will be evaluated using these test cases as well as your classmates test cases. Points will be awarded based on the proportion of test cases you successfully pass. If your test case(s) are found to be in error, you will lose points for your test cases. Page 3 of 7

1. 10 points For each of the following sequences of keys, insert them into an initially empty AVL tree. Show the configuration of the tree after each insert. (a) 1, 2, 3, 4, 5, 6 (b) 6, 1, 2, 3, 4, 5 (c) 3, 6, 5, 1, 2, 4 2. 10 points For each of the following sequences of keys, insert them into an initially empty 2-3 tree. Show the configuration of the tree after each insert. (a) 1, 2, 3, 4, 5, 6 (b) 6, 1, 2, 3, 4, 5 (c) 3, 6, 5, 1, 2, 4 3. 20 points Suppose you have an AVL tree with tree nodes such that each tree node, u has the following pieces of data: u leftchild u rightchild u parent u key u balancef actor Now suppose that you are given, as input, a tree node u. (a) Write pseudocode to determine what kind of rotation (if any) should be performed on u to rebalance it (b) Write pseudocode to perform a left-rotation about u (c) Write pseudocode to perform a right-rotation about u (d) Write pseudocode to perform a left-right-rotation about u (e) Write pseudocode to perform a right-left-rotation about u 4. 5 points Each iteration of Kruskal s algorithm considers adding an edge e = (u, v) to the current minimum spanning tree T by checking whether or not its inclusion in T would induce a cycle. Gomer thinks he s found a better way: rather than checking for a cycle, just check if the end points of e are already in T : if they are, then do not include the edge as they would not add any vertex to the minimum spanning tree. If either end point (u or v) is outside the current tree then do add the edge as it would connect the tree further. Show that Gomer is wrong by providing an example of a tree where using this criteria instead would fail. Briefly explain why Gomer s criteria is wrong. Page 4 of 7

5. 5 points Suppose we run an MST algorithm on an undirected graph G = (V, E) and it produces a full spanning tree, T = (V, E ). Now consider the subgraph G = (V, E \ E ) (that is, the graph with all the edges in the spanning tree are removed). Prove or disprove: G must be acyclic. 6. 10 points A cycle graph, C n is a graph on n 3 vertices where the only edges present form a single simple cycle. Develop an algorithm to determine whether or not a given graph G = (V, E) is a cycle graph or not. 7. 20 points The girth of an undirected graph G = (V, E) is the length of the shortest cycle in G. In this exercise you will develop an algorithm to compute the girth of a graph. (a) Develop an algorithm that, given a graph G = (V, E) and an edge e = (u, v) E determines the length of the shortest cycle that includes e in it. (b) Use the algorithm from part (a) to solve the girth problem. 8. 120 points Program You will implement a suite of graph algorithms including DFS, BFS, MST (either Prim s or Kruskal s) and a minimum weighted-distance finding algorithm (either Floyd-Warshall or Dijsktra s). In particular, you will write a program to parse an input file (file name should be read from the command line) with data representing a weighted undirected graph as follows. The first line is an integer n, the number of vertices in the graph. By convention, vertices will be identified with the integers 0 thru n 1 inclusive. Each line after that contains two integers and a decimal number delimited by spaces. The first two are the vertices (since it is undirected, nothing should be inferred from their order) and the last is a weight. An example: 5 0 2 3.0 0 3 2.1 0 4 4.3 1 2 3.14 1 3 2.5 2 3 3.9 2 4 10.3 Once processed your program will run several graph algorithms on the input graph and output statistics associated with it. In particular, your output should display: A DFS traversal (visited order of vertices) starting at vertex 0 according to the following strategy: the next vertex should be the least numbered unvisited vertex A BFS traversal (visited order of vertices) starting at vertex 0 according to the following strategy: the next vertex should be an unvisited vertex with least edge weight. Page 5 of 7

The edges (pairs of vertices) that make up a minimum spanning tree of the graph along with the total weight of the MST A complete list of vertex pairs along with the weight of the shortest path between them An example output: Depth First Search Traversal: 0, 2, 1, 3, 4 Breadth First Search Traversal: 0, 3, 2, 4, 1 Minimum Spanning Tree: V = [0, 1, 2, 3, 4] E = (0, 3, 2.1), (1, 3, 2.5), (0, 2, 3.0), (0, 4, 4.3), Total Weight: 11.90 Shortest Paths: 0 -> 1 = (0, 3, 2.1) -> (1, 3, 2.5) Path Weight = 4.6 0 -> 2 = (0, 2, 3.0) Path Weight = 3.0 0 -> 3 = (0, 3, 2.1) Path Weight = 2.1 0 -> 4 = (0, 4, 4.3) Path Weight = 4.3 1 -> 2 = (1, 2, 3.14) Path Weight = 3.14 1 -> 3 = (1, 3, 2.5) Path Weight = 2.5 1 -> 4 = (1, 3, 2.5) -> (0, 3, 2.1) -> (0, 4, 4.3) Path Weight = 8.899999999999999 2 -> 3 = (2, 3, 3.9) Path Weight = 3.9 2 -> 4 = (0, 2, 3.0) -> (0, 4, 4.3) Path Weight = 7.3 3 -> 4 = (0, 3, 2.1) -> (0, 4, 4.3) Path Weight = 6.4 You may use a library to represent graphs in your language of choice if you wish. You may use basic methods on a graph (such as getting the vertex set or testing if two Page 6 of 7

vertices are connected, etc.). However, you may not use any graph algorithms within that library that would make the assignment trivial. Name your test case files input001.txt output001.txt input002.txt output002.txt respectively. Page 7 of 7