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

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

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

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

CSE 373 Sample Midterm #2 (closed book, closed notes, calculators o.k.)

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed)

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

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

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

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

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators)

CSE373 Fall 2013, Midterm Examination October 18, 2013

CSE332 Summer 2010: Midterm Exam Sample Solutions

CSE 332, Spring 2010, Midterm Examination 30 April 2010

CSE373 Fall 2013, Second Midterm Examination November 15, 2013

1. AVL Trees (10 Points)

CSE373 Winter 2014, Midterm Examination January 29, 2014

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

Section 1: True / False (1 point each, 15 pts total)

COS 226 Midterm Exam, Spring 2011

COS 226 Midterm Exam, Spring 2009

Final Examination CSE 100 UCSD (Practice)

CSE373 Fall 2013, Final Examination December 10, 2013 Please do not turn the page until the bell rings.

CSE373 Spring 2015: Final

CSE 373: Practice Final

CSE373: Data Structures & Algorithms Lecture 28: Final review and class wrap-up. Nicki Dell Spring 2014

CSE373 Fall 2013, Final Examination December 10, 2013 Please do not turn the page until the bell rings.

Course Review. Cpt S 223 Fall 2009

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 1

Cpt S 223 Fall Cpt S 223. School of EECS, WSU

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

ECE242 Data Structures and Algorithms Fall 2008

Course Review for Finals. Cpt S 223 Fall 2008

Data Structure Lecture#22: Searching 3 (Chapter 9) U Kang Seoul National University

Course Review. Cpt S 223 Fall 2010

Leftist Heaps and Skew Heaps. (Leftist Heaps and Skew Heaps) Data Structures and Programming Spring / 41

CS 61B Summer 2005 (Porter) Midterm 2 July 21, SOLUTIONS. Do not open until told to begin

Final Exam in Algorithms and Data Structures 1 (1DL210)

CPSC 331 Term Test #2 March 26, 2007

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

ECE 2035 Programming HW/SW Systems Fall problems, 5 pages Exam Three 28 November 2012

CS 315 Data Structures Spring 2012 Final examination Total Points: 80

Section 05: Midterm Review

EECS 311 Data Structures Midterm Exam Don t Panic!

University of Toronto Mississauga. Flip to the back cover and write down your name and student number.

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

Practice Midterm Exam Solutions

CSE 100: UNION-FIND HASH

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

Computer Science Foundation Exam

CSE 332 Autumn 2016 Final Exam (closed book, closed notes, no calculators)

Second Examination Solution

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

Second Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

CSE 373 NOVEMBER 8 TH COMPARISON SORTS

Spring 2002: Fundamental Structures of Computer Science

CS 251, LE 2 Fall MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY

Test 1 - Closed Book Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

Spring 2013 CS 122C & CS 222 Midterm Exam (and Comprehensive Exam, Part I) (Max. Points: 100)

CSE 332: Data Structures & Parallelism Lecture 10:Hashing. Ruth Anderson Autumn 2018

CPSC 311: Analysis of Algorithms (Honors) Exam 1 October 11, 2002

Hashed-Based Indexing

Analysis of Algorithms

Final Exam in Algorithms and Data Structures 1 (1DL210)

21# 33# 90# 91# 34# # 39# # # 31# 98# 0# 1# 2# 3# 4# 5# 6# 7# 8# 9# 10# #

York University AK/ITEC INTRODUCTION TO DATA STRUCTURES. Final Sample II. Examiner: S. Chen Duration: Three hours

CSE 214 Computer Science II Searching

CSE 100 Disjoint Set, Union Find

Computer Science E-22 Practice Final Exam

CS 3343 (Spring 2013) Exam 2

Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1

Homework 3. Theory (50 points) Data Structures and Algorithms in JAVA Shlomo Hershkop Department of Computer Science Columbia University Summer 2002

Chapter 1 Introduction

CSE 332 Winter 2018 Final Exam (closed book, closed notes, no calculators)

Recitation 9. Prelim Review

Introduction to Algorithms October 12, 2005 Massachusetts Institute of Technology Professors Erik D. Demaine and Charles E. Leiserson Quiz 1.

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

Cpt S 223 Course Overview. Cpt S 223, Fall 2007 Copyright: Washington State University

Technical University of Denmark

BINARY HEAP cs2420 Introduction to Algorithms and Data Structures Spring 2015

CS251-SE1. Midterm 2. Tuesday 11/1 8:00pm 9:00pm. There are 16 multiple-choice questions and 6 essay questions.

CSCI-1200 Data Structures Fall 2018 Lecture 23 Priority Queues II

Chapter 6 Heaps. Introduction. Heap Model. Heap Implementation

CSE wi: Practice Midterm

Open Addressing: Linear Probing (cont.)

CS 112 Final May 8, 2008 (Lightly edited for 2011 Practice) Name: BU ID: Instructions GOOD LUCK!

Questions Total Points Score

Data Structure and Algorithm, Spring 2017 Final Examination

CSE100. Advanced Data Structures. Lecture 21. (Based on Paul Kube course materials)

Data Structures and Algorithm Analysis in C++

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

(D) There is a constant value n 0 1 such that B is faster than A for every input of size. n n 0.

COS 226 Algorithms and Data Structures Fall Midterm

Fast Lookup: Hash tables

INSTITUTE OF AERONAUTICAL ENGINEERING

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

ECE 2035 A Programming HW/SW Systems Spring problems, 5 pages Exam Three 13 April Your Name (please print clearly)

6.7 b. Show that a heap of eight elements can be constructed in eight comparisons between heap elements. Tournament of pairwise comparisons

Selection, Bubble, Insertion, Merge, Heap, Quick Bucket, Radix

Outline Purpose Disjoint Sets Maze Generation. Disjoint Sets. Seth Long. March 24, 2010

Transcription:

Name: Email address: CSE 373 Spring 2010: Midterm #2 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial credit based on the work you write down, so if time permits, show your work! Use only the data structures and algorithms we have discussed in class or that were mentioned in the book so far. Note: For questions where you are drawing pictures, please circle your final answer for any credit. Good Luck! Total: 63 points. Time: 50 minutes. Question Max Points 1 8 2 12 3 13 4 6 5 8 6 16 Total 63 Score Page 1 of 10

1) [8 points total] Disjoint Sets The uptrees used to represent sets in the union-find algorithm can be stored in two n- element arrays: one giving the parent of each node (or -1 if the node has no parent), and the other giving the number of items in a set if the node is the root (representative node) of a set. For example, we can represent a collection of sets containing the numbers 1 through 14 as follows: up weight 1 2 3 4 5 6 7 8 9 10 11 12 13 14 6 5 4-1 6-1 11 6 10 11 5 11-1 13 - - - 2-10 - - - - - - 2 - a) Draw a picture of the uptrees represented by the data in the above arrays. Page 2 of 10 2

1) (cont) b) Now, draw a new set of uptrees and update the data arrays as needed to show the results of executing the following two set operations: union(find(7), find(14)); find(2); You should assume that the find operations use path compression and that the union operation uses union-by-size (aka union by weight). In case of ties, always make the higher numbered root point to the lower numbered one. c) Update the numbers in the arrays at the top of the previous page to reflect the picture after part b). Page 3 of 10

2) [12points total] Hashing Draw the contents of the two open addressing hash tables in the boxes below. The size of the hash table is 9. The hash function used is H(k) = k mod 9 What values will be in the hash table after the following sequence of insertions? Draw the values in the boxes below, and show your work for partial credit. 18, 16, 10, 7, 26 a) Linear Probing b) Quadratic Probing 0 1 2 3 4 0 1 2 3 4 5 6 7 8 5 6 7 8 Page 4 of 10 4

2) (cont) c) What is the load factor for the table a)? d) What is the load factor for the table b)? e) Table a) will (circle one): i. gradually degrade in performance as more values are inserted ii. may fail to find a location on the next insertion iii. none of the above e) Table b) will (circle one): i. gradually degrade in performance as more values are inserted ii. may fail to find a location on the next insertion iii. none of the above Page 5 of 10

3) [13 points total] Leftist Heaps: a) [8 pts] Draw the leftist heap that results from inserting: 60, 18, 9, 25, 12, 6, 14, 8, 17 in that order into an initially empty heap. You are only required to show the final heap, although if you draw intermediate heaps, please circle your final result for ANY credit. Page 6 of 10 6

3) (cont) b) [2 pts] What is the null path length of the root in your final heap from part a)? c) [3 pts] Draw the result of doing one deletemin on the heap you created in part a). Circle your final answer for any credit. Page 7 of 10

4) [6 points] Skew Heaps Draw the skew heap that results from doing a deletemin on the skew heap shown below. You are only required to show the final tree, although if you draw intermediate trees, please circle your final result for ANY credit. Page 8 of 10 8

5) [8 points] Memory Hierarchy & Locality: Examine the code example below: x = 7; y = 0; z = 400; for (i = 1; i < 1000; i++) { y = y + 5; a[i] = a[i] + a[i+1]; b[5] = b[5] + y; w += c[i] + 10; System.out.println( z = + z); } Considering only their use in the code segment above, for each of the following variables, indicate below what type of locality (if any) is demonstrated. Please circle all that apply (you may circle more than one item for each variable): a spatial locality temporal locality no locality b spatial locality temporal locality no locality c spatial locality temporal locality no locality i spatial locality temporal locality no locality w spatial locality temporal locality no locality x spatial locality temporal locality no locality y spatial locality temporal locality no locality z spatial locality temporal locality no locality Page 9 of 10

6) [16 points total] Running Time Analysis: Give the tightest possible upper bound for the worst case running time for each of the following in terms of N. You MUST choose your answer from the following (not given in any particular order), each of which could be re-used (could be the answer for more than one of a) f)): O(N 2 ), O(N ½ ), O(N log N), O(N), O(N 2 log N), O(N 5 ), O(2 N ), O(N 3 ), O(log N), O(1), O(N 4 ), O(N N ), O(N 6 ), O(N (log N) 2 ), O(N 2 (log N) 2 ) **For any credit, you must explain your answer. Assume that the most time-efficient implementation is used. Assume no duplicate values and that you can implement the operation as a member function of the class with access to the underlying data structure. If you remove elements from a structure you must re-assemble it when done. a) Merging two skew heaps containing N elements each. Explanation: a) b) Finding an element in a hash table containing N elements where separate chaining is used and each bucket points to an AVL tree. The table size = N. Explanation: b) c) Finding the median value in a leftist heap containing N elements. (You don t know what the median value is ahead of time.) You may assume N is odd. Explanation: c) d) Moving the values from two leftist heaps, each containing N elements, into one initially empty array of size 2N. The final contents of the array should be sorted from low to high. Explanation: d) Page 10 of 10 10