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

Similar documents
9. Which situation is true regarding a cascading cut that produces c trees for a Fibonacci heap?

( ) n 5. Test 1 - Closed Book

1. To reduce the probability of having any collisions to < 0.5 when hashing n keys, the table should have at least this number of elements.

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

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

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1

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

n 2 ( ) ( ) + n is in Θ n logn

( ) 1 B. 1. Suppose f x

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

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

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

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

) $ f ( n) " %( g( n)

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

Data Structures and Algorithm Analysis in C++

Analysis of Algorithms

Balanced Binary Search Trees. Victor Gao

Introduction to Algorithms Third Edition

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

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

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

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

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

Final Examination CSE 100 UCSD (Practice)

( D. Θ n. ( ) f n ( ) D. Ο%

Lecture Summary CSC 263H. August 5, 2016

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

Course Review for Finals. Cpt S 223 Fall 2008

CS521 \ Notes for the Final Exam

COMP 251 Winter 2017 Online quizzes with answers

END-TERM EXAMINATION

Analysis of Algorithms

Quiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g)

Chapter 1 Introduction

CSE : ADVANCED ALGORITHMS

Direct Addressing Hash table: Collision resolution how handle collisions Hash Functions:

CSE 548: Analysis of Algorithms. Lectures 14 & 15 ( Dijkstra s SSSP & Fibonacci Heaps )

Course Review. Cpt S 223 Fall 2009

Course Review. Cpt S 223 Fall 2010

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

Final Exam. EECS 2011 Prof. J. Elder - 1 -

Lecture 6: Analysis of Algorithms (CS )

CSci 231 Final Review

CSE 5311 Notes 4a: Priority Queues

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

Lecture: Analysis of Algorithms (CS )

Thus, it is reasonable to compare binary search trees and binary heaps as is shown in Table 1.

4.1.2 Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting...

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

2. (a) Explain the concept of virtual functions in C++ with suitable examples. (b) Explain the concept of operator overloading in C++.

Solutions to Exam Data structures (X and NV)

9/24/ Hash functions

Question Bank Subject: Advanced Data Structures Class: SE Computer

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

Balanced Search Trees. CS 3110 Fall 2010

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

l Heaps very popular abstract data structure, where each object has a key value (the priority), and the operations are:

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

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

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

R16 SET - 1 '' ''' '' ''' Code No: R

Algorithms. AVL Tree

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

INSTITUTE OF AERONAUTICAL ENGINEERING

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

CS261: Problem Set #1

Test points UTA Student ID #

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

Table of Contents. Chapter 1: Introduction to Data Structures... 1

CISC 621 Algorithms, Midterm exam March 24, 2016

University of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 2017

CSE 100 Advanced Data Structures

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

l So unlike the search trees, there are neither arbitrary find operations nor arbitrary delete operations possible.

Treaps. 1 Binary Search Trees (BSTs) CSE341T/CSE549T 11/05/2014. Lecture 19

Introduction. for large input, even access time may be prohibitive we need data structures that exhibit times closer to O(log N) binary search tree

9/29/2016. Chapter 4 Trees. Introduction. Terminology. Terminology. Terminology. Terminology

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

Student number: Datenstrukturen & Algorithmen page 1

Sorted Arrays. Operation Access Search Selection Predecessor Successor Output (print) Insert Delete Extract-Min

Some Search Structures. Balanced Search Trees. Binary Search Trees. A Binary Search Tree. Review Binary Search Trees

CS 373: Combinatorial Algorithms, Spring 1999

CSE 5311 Notes 13: Computational Geometry

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING ECE 250 ALGORITHMS AND DATA STRUCTURES

COMP Analysis of Algorithms & Data Structures

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

Analysis of Algorithms

AP Computer Science 4325

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING E&CE 250 ALGORITHMS AND DATA STRUCTURES

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

COMP Analysis of Algorithms & Data Structures

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

Midterm solutions. n f 3 (n) = 3

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

ADVANCED DATA STRUCTURES STUDY NOTES. The left subtree of each node contains values that are smaller than the value in the given node.

MA/CSSE 473 Day 20. Recap: Josephus Problem

Transcription:

CSE 5311 Test 1 - Closed Book Summer 2009 Name Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. 3 points each 1. Which of the following statements is true? A. A binary search tree may be assigned legal AVL balance factors if and only if it may be legally colored as a red-black tree. B. If a binary search tree may be assigned legal AVL balance factors, then it may be legally colored as a red-black tree. C. If a binary search tree may be legally colored as a red-black tree, then it may be assigned legal AVL balance factors. D. No binary search tree may be assigned both legal AVL balance factors and be legally colored as a red-black tree. 2. During which operation on a leftist heap may subtree swaps be needed? A. DECREASE-KEY B. EXTRACT-MIN C. UNION D. All of A., B., and C. 3. What is the worst-case number of rotations when performing deletion on an AVL tree? A. Θ( 1) B. Θ( logn) C. Θ( n) D. No rotations are ever used 4. Suppose you already have 15 different coupons when there are 20 coupon types. What is the expected number of boxes for obtaining a coupon different from the 15 you already have? A. 3 B. 4 C. 5 D. 15 5. Path compression is used in which algorithm? A. DECREASE-KEY (e.g. CASCADING-CUT) for Fibonacci heaps B. FIND for disjoint sets C. UNION for disjoint sets D. UNION for Fibonacci heaps 6. The balance factors in an AVL tree are computed as: A. height right - height left B. same as the null path length in a leftist heap C. the difference of the number of nodes in the left and right subtrees D. the distance from a node to the root 7. Which situation is true regarding a cascade cut that produces c trees for a Fibonacci heap? A. Both the actual and amortized costs are O(1). B. The actual cost is O(c). The amortized cost is O(1).

C. The actual cost is O(1). The amortized cost is O(c). D. The potential can become negative. 2 8. Which change to a binary search tree preserves the inorder traversal property? A. rotation B. zig-zag C. zig-zig D. all of the above 9. Which property does not hold for binomial heaps? ( ) time. A. DECREASE-KEY takes Ο 1 B. MINIMUM takes Ο( logn) time. C. Performing n INSERT operations into an empty heap will take O(n) time. D. The number of trees is based on the binary representation of the number of stored items. 10. Which problem may be addressed using the assignment problem? A. Optimal binary search tree B. Optimal hashing C. Perfect hashing D. Primary clustering 11. Which of the following data structures offers similar capabilities and performance characteristics to skip lists? A. AVL trees B. Splay trees C. Treap D. Union-find with path compression 12. Slow convergence toward the optimal fixed ordering is a property of which technique? A. Count B. Move-ahead-k C. Move-to-front D. Transpose 13. How many inversions are there for the lists 1, 2, 5, 4, 3 and 2, 5, 4, 1, 3? A. 2 B. 3 C. 4 D. 5 14. The number of potential probe sequences when using double hashing with a table with m entries (m is prime) is: A. Ο( logm) B. m C. m( m 1) D. m! 15. When using Brent s rehash during insertion, the number of previously inserted keys that may move is:

3 A. 1 B. 2 C. 1 α D. Hm, where m is the number of stored keys 16. Suppose there are 20 coupon types for the coupon collecting problem and you have already obtained 17 of the coupon types. How many boxes of cereal do you expect (mathematically) to open to get the remaining three coupon types? (5 points) CSE 5311 Test 1 - Open Book Summer 2009 Name Last 4 Digits of Student ID # 1. Give the range of possible heights for an AVL tree with 200 keys. (10 points) 2. Evaluate the following recurrences using the master method. Indicate the case that is used for each. (10 points) a. T( n) = T( 0.7n) + n b. T( n) = T( 0.7n) +1 c. T( n) =16T( n 2) + n3 3. Construct the final optimal binary search tree (using Knuth s root trick) and give its cost. SHOW YOUR WORK. (10 points) n=6; q[0]=0.12; key[1]=10; p[1]=0.12; q[1]=0.09; key[2]=20; p[2]=0.2; q[2]=0.03; key[3]=30; p[3]=0.1; q[3]=0.04; key[4]=40; p[4]=0.2; q[4]=0.0; key[5]=50; p[5]=0.01; q[5]=0.04;

key[6]=60; p[6]=0.03; q[6]=0.02; w[0][0]=0.120000 w[0][1]=0.330000 w[0][2]=0.560000 w[0][3]=0.700000 w[0][4]=0.900000 w[0][5]=0.950000 w[0][6]=1.000000 w[1][1]=0.090000 w[1][2]=0.320000 w[1][3]=0.460000 w[1][4]=0.660000 w[1][5]=0.710000 w[1][6]=0.760000 w[2][2]=0.030000 w[2][3]=0.170000 w[2][4]=0.370000 w[2][5]=0.420000 w[2][6]=0.470000 w[3][3]=0.040000 w[3][4]=0.240000 w[3][5]=0.290000 w[3][6]=0.340000 w[4][4]=0.000000 w[4][5]=0.050000 w[4][6]=0.100000 w[5][5]=0.040000 w[5][6]=0.090000 w[6][6]=0.020000 Building c(0,2) using roots 1 thru 2 Building c(1,3) using roots 2 thru 3 Building c(2,4) using roots 3 thru 4 Building c(3,5) using roots 4 thru 5 Building c(4,6) using roots 5 thru 6 Building c(0,3) using roots 1 thru 2 Building c(1,4) using roots 2 thru 4 Building c(2,5) using roots 4 thru 4 Building c(3,6) using roots 4 thru 6 Building c(0,4) using roots 2 thru 2 Building c(1,5) using roots 2 thru 4 Building c(2,6) using roots 4 thru 4 Building c(0,5) using roots 2 thru 2 Building c(1,6) using roots 2 thru 4 Building c(0,6) using roots? thru? Counts - root trick 31 without root trick 50 Average probe length is??? trees in parenthesized prefix 4 c(0,0) cost 0.000000 c(1,1) cost 0.000000 c(2,2) cost 0.000000

c(3,3) cost 0.000000 c(4,4) cost 0.000000 c(5,5) cost 0.000000 c(6,6) cost 0.000000 c(0,1) cost 0.330000 10 c(1,2) cost 0.320000 20 c(2,3) cost 0.170000 30 c(3,4) cost 0.240000 40 c(4,5) cost 0.050000 50 c(5,6) cost 0.090000 60 c(0,2) cost 0.880000 10(,20) c(1,3) cost 0.630000 20(,30) c(2,4) cost 0.540000 40(30,) c(3,5) cost 0.340000 40(,50) c(4,6) cost 0.150000 60(50,) c(0,3) cost 1.200000 20(10,30) c(1,4) cost 1.200000 20(,40(30,)) c(2,5) cost 0.640000 40(30,50) c(3,6) cost 0.490000 40(,60(50,)) c(0,4) cost 1.770000 20(10,40(30,)) c(1,5) cost 1.350000 20(,40(30,50)) c(2,6) cost 0.790000 40(30,60(50,)) c(0,5) cost 1.920000 20(10,40(30,50)) c(1,6) cost 1.540000 40(20(,30),60(50,)) c(0,6) cost????????????????????? 5 4. The hash table below was created using double hashing with Brent s rehash. The initial slot ( h1( key)) and rehashing increment ( h2( key)) are given for each key. Show the result from inserting 9000 using Brent s rehash when h 1 (9000) = 5 and h 2 (9000) = 4. (10 points) key h1( key) h2( key) 0 1 2 5000 2 1 3 4000 3 4 4 3000 4 1 5 2000 5 5 6 1000 6 2 key 0 1

6 2 3 4 5 6 5. Suppose all 2 k - 1 nodes, along with the sentinel, in a red-black tree are colored black. Explain what will happen if any key is deleted. (10 points) CSE 5311 Name Test 2 - Closed Book Summer 2009 Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. 3 points each 1. When performing selection in worst-cast linear time for n numbers, roughly how many column medians are computed in the first round? A. W ( n 5) B. n 5 C. m, the median-of-medians D. 0.7n 2. What data structure is used for the sweep-line status when detecting intersections among rectilinear rectangles? A. BST of points with x-coordinates as the key B. BST of points with y-coordinates as the key C. Interval tree D. Sorted array by ascending x-coordinates 3. While constructing a suffix array for a sequence with n symbols by using radix sorts, sequence symbols are used in which of the radix sorts? A. All of them B. None of them C. The last one D. The first one 4. Constructing a suffix array for a sequence with n symbols by using the original Manber-Myers radix sort construction has this worst-case time: A. Θ( n) B. Θ( nlogn) C. Θ n 2 D. Θ n 2 logn 5. In a maximum flow problem, the number of augmenting paths in a flow decomposition is bounded by: A. V B. Ο( VE) C. f D. E

6. Which of the following is not true regarding Strassen s algorithm? 7 A. It is not possible to have an asymptotically faster algorithm. B. It requires more space than the everyday method. C. It uses Θ n lg7 scalar additions when multiplying two n x n matrices. D. It uses Θ n lg7 scalar multiplications when multiplying two n x n matrices. 7. What is the maximum number of times that an edge can become critical in the Edmonds-Karp method? A. Once B. Twice C. (V-2)/2 D. VE 8. The worst-case time to determine a longest (monotone) increasing subsequence for a sequence of n numbers is: A. Θ( m + n) B. Θ( n) C. Θ( nlogn) D. Θ n 2 9. Which of the following is NOT required when showing that problem B is NP-complete by a reduction from problem A? A. The reduction has an inverse that takes each instance of problem B to an instance of problem A. B. The reduction takes polynomial time. C. The reduction must be consistent for the decision results for each instance of problem A and and the corresponding instance of problem B. D. Problem A is NP-complete. 10. On an augmenting path, a critical edge is: A. an edge with the minimum residual capacity B. an edge from the source C. an edge into the sink D. an edge that used to be saturated 11. Which algorithm is defined using the notions of left-turn and right-turn? A. Closest points in 2-d space B. Graham scan C. Jarvis march D. Suffix array construction 12. The reduction from 3-sat to 3-colorability will give a graph requiring four colors when: A. The 3-sat instance is satisfiable. B. Removing one clause from the 3-sat instance will leave a satisifiable set of clauses. C. The 3-sat instance is unsatisfiable. D. The 3-sat instance is a tautology. 13. Which of the following is not required before relabeling ( lifting ) a vertex to a new height?

A. Both breadth-first searches have been done. B. The vertex is overflowing. C. Any eligible edges for the present height have been saturated. D. The vertex is not the source or sink. 8 14. When coloring the edges of a graph, a dc-path gets inverted because: A. d is a free color for all fan vertices. B. We are trying to minimize the number of colors used by the path. C. All edges in the fan will be colored with d or c. D. d is the free color for two fan vertices. 15. The least general approximation result that can be achieved for an NP-hard problem is: A. Approximation Scheme B. Approximation Algorithm C. Fully Polynomial-time Approximation Scheme D. Polynomial-time Approximation Scheme 16. Give the style 2 KMP failure links for this sequence. (5 points) 0 a 1 c 2 a 3 b 4 a 5 c 6 a 7 c 8 a 9 b 10 a 11 c 12 a 13 b 14 a 15 c 16 a 17 c 18 a 19 b

20 a 21 c 22 a 23 c 24 a 25 b CSE 5311 Test 2 - Open Book Summer 2009 Name Last 4 Digits of Student ID # 9 1. Explain how to use the Z algorithm to determine the maximum overlap for a suffix of string X and a prefix of string Y. For example, if X= dogcatcat and Y= catcatdog, then the maximum overlap would be catcat. Do not explain details of the Z algorithm. 10 points 2. Solve the following instance of Longest Common Subsequence using the method based on the Longest Strictly Increasing Subsequence problem. (10 points) 0 1 2 3 4 5 6 7 a b d c d e b a b c d c e d b a 3. List the lift and push operations to solve for the maximum flow. In addition, give a minimum cut. (15 points) a 1 4 b 3 2 s c t 5 2 d 2 1 e 4. Show that deciding whether an undirected graph is 5-colorable is NP-complete by a simple reduction from the 3-colorability problem. In addition to your proof, give an example of your reduction on a 3- colorable graph. (15 points)