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

Similar documents
( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. 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)

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

( ) 1 B. 1. Suppose f x

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

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

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

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

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

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

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

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 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.)

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

Test points UTA Student ID #

Data Structures Question Bank Multiple Choice

CS521 \ Notes for the Final Exam

CSci 231 Final Review

Course Review for Finals. Cpt S 223 Fall 2008

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

END-TERM EXAMINATION

Fundamentals of Data Structure

Solutions to Exam Data structures (X and NV)

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

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

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

Lecture Summary CSC 263H. August 5, 2016

COMP 251 Winter 2017 Online quizzes with answers

Final Examination CSE 100 UCSD (Practice)

CS301 - Data Structures Glossary By

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

1. Attempt any three of the following: 15

Introduction to Algorithms Third Edition

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

DATA STRUCTURES AND ALGORITHMS

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

Tutorial. Question There are no forward edges. 4. For each back edge u, v, we have 0 d[v] d[u].

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

DESIGN AND ANALYSIS OF ALGORITHMS

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

ECE250: Algorithms and Data Structures Final Review Course

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs

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

Module 2: Classical Algorithm Design Techniques

Course Review. Cpt S 223 Fall 2009

DESIGN AND ANALYSIS OF ALGORITHMS GREEDY METHOD

DATA STRUCTURES AND ALGORITHMS

Basic Data Structures (Version 7) Name:

Department of Computer Science and Technology

Lecture 5: Sorting Part A

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

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

( ) n 5. Test 1 - Closed Book

Review of course COMP-251B winter 2010

INSTITUTE OF AERONAUTICAL ENGINEERING

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

Algorithm Design (8) Graph Algorithms 1/2

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

Greedy Approach: Intro

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

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

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

Data Structure. IBPS SO (IT- Officer) Exam 2017

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

CS-301 Data Structure. Tariq Hanif

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

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

Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017

looking ahead to see the optimum

CSE 5311 Notes 10: Medians/Selection

III Data Structures. Dynamic sets

CSE 100: GRAPH ALGORITHMS

Minimum Spanning Trees

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

Data Structures and Algorithm Analysis in C++

Graphs and Network Flows ISE 411. Lecture 7. Dr. Ted Ralphs

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

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

Data Structures Brett Bernstein

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms. Final Examination T09:00

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?

Design and Analysis of Algorithms - - Assessment

UCS-406 (Data Structure) Lab Assignment-1 (2 weeks)

Module 5 Graph Algorithms

L.J. Institute of Engineering & Technology Semester: VIII (2016)

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned.

Minimum Spanning Trees My T. UF

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

Virtual University of Pakistan

Minimum Spanning Trees Ch 23 Traversing graphs

Course Review. Cpt S 223 Fall 2010

Representations of Weighted Graphs (as Matrices) Algorithms and Data Structures: Minimum Spanning Trees. Weighted Graphs

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

Operations on Heap Tree The major operations required to be performed on a heap tree are Insertion, Deletion, and Merging.

FINAL EXAM SOLUTIONS

Graph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1

CS2223: Algorithms Sorting Algorithms, Heap Sort, Linear-time sort, Median and Order Statistics

COS 226 Midterm Exam, Spring 2009

Transcription:

CSE 0 Name Test Spring 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to run the code below is in: for i=n; i>=; i--) for j=; j<n; j=*j+) sum+=i+j; A. Θ n logn) B. Θ% n C. Θ % n D. Θ n ). Which of the following is the best approximation for H mn? m and n are positive integers) A. mn B. lnm + ln n C. lnn D.. The expected time for insertion sort for n keys is in which set? All n! input permutations are equally likely.) ) B. Θ n) C. Θ n logn) D. Θ% n A. Θ logn 4. Which technique allows interfacing a priority queue with a dictionary? A. Binary search tree B. PQchange C. Array of handles D. Binary search. The time to run the code below is in: for i=n; i>=0; i--) for j=; j<n; j+=) sum+=i*j; ) B. Θ% n A. Θ n logn. Which of the following is not true? A. n Ω n % ) B. n Ο n ) % C. n Ω n logn ) D. g n) Ω f n) C. Θ % n D. Θ n ) f n ) ) ) Ο g n). What is n, the number of elements, for the largest table that can be processed by binary search using no more than probes? A. B. C. 4 D.. f n ) = n lg n is in all of the following sets, except ) B. Θ log n! ) A. Ω logn ) C. Ο n ) D. Ο% n 9. Suppose there is a large, unordered table with n integers, possibly with repeated values. How much time is needed to determine the minimum value? A. Θ ) B. Θ logn) C. Θ n) D. Θ n logn) 0. When solving the fractional knapsack problem, the items are processed in the following order. A. Ascending order of weight B. Ascending order of /lb C. Descending order of weight D. Descending order of /lb. Which of the following is not true regarding dynamic programming? A. It is a form of exhaustive search B. It is a form of divide-and-conquer C. A cost function must be defined D. The backtrace may be based on recomputing the cost function. Suppose you are using the substitution method to establish a Θ bound on a recurrence T n T n) Ω n) and T n) Ο n % A. T n) Ο lg n) B. T n) Ο n) C. T n) Ω n ) D. T n % ). Which of the following cannot be shown as an improvement?. What is required when calling unionfindi),findj)) for maintaining disjoint subsets? A. i and j are leaders for different subsets B. i and j are in the same subset C. i and j are in different subsets D. i is the ancestor of j in one of the trees ) and you already know ) Ω n lg n)

4. Which of the following is not true regarding a maxheap with 000 elements? A. Subscript will store the maximum priority. B. The parent for the node with subscript 00 is stored at subscript 0. C. The left child for the node with subscript 00 is stored at subscript 400. D. The right child for the node with subscript 40 is stored at subscript 9.. log n! ) is in all of the following sets, except A. Ω logn) B. Θ nlogn) C. Ο% n D. Ω % n Long Answer. Give a Huffman code tree for the following symbols and probabilities. Besides the tree, be sure to compute the expected bits per symbol. points A 0. B 0.0 C 0. D 0.0 E 0. F 0.0. Use the substitution method to show that T n) = T n Ω% n.) points. Use the recursion-tree method to show that T n ) = T n ) + n is in Ο% n 4. Use the efficient construction to convert into a maxheap. points ) + n is in Θ% n. You do not need to show that T n. points ) is in 4 4 9 0 0 9 4 9 0. Show the maxheap after changing the priority at subscript to. points 4 4 4 CSE 0 Name Test Spring 0 Multiple Choice:. Write the letter of your answer on the line ) to the LEFT of each problem.. CIRCLED ANSWERS DO NOT COUNT.. points each. Recently, we considered an abstraction supporting the operations allocate, allocateany, and freeup in constant time. Which of the following was not a feature of the implementation? A. a recycling list B. a circular, doubly-linked list C. a header D. arrays. What is the worst-case time to perform MINIMUML) for an unsorted, doubly-linked list with n nodes?

A. Θ ) B. Θ logn) C. Θ n) D. Θ nlogn). The time to extract the LCS for sequences of lengths m and n) after filling in the dynamic programming matrix is in: A. Θn) B. Θm + n) C. Θn log n) D. Θmn) 4. Circular linked lists are occasionally useful because A. some operations may be done in constant time. B. they are an alternative to red-black trees. C. they are useful for implementing circular queues. D. they avoid mallocs.. Which of the following binary trees has an illegal red-black tree coloring? A. B. C. D.. Which of the following will not be true regarding the decision tree for MERGESORT for sorting n input values? A. There will be n! leaves. B. Every path from the root to a leaf will have Ο% n C. There will be a path from the root to a leaf with Ω% n decisions. decisions. D. The height of the tree is Ω nlogn).. Which phase of counting sort actually counts? A. first B. second C. third D. fourth. What is the worst-case time to find the predecessor of a key in an unbalanced binary search tree storing n keys? Assume that parent pointers are available. A. Θ ) B. Θ logn) C. Θ n) D. Θ nlogn) 9. For which of the following sorts does the decision tree model not apply? A. Insertion B. LSD Radix Sort C. MERGE-SORT D. QUICKSORT 0. The expected number of comparisons for finding the kth largest of n keys using PARTITION is in which asymptotic set? A. Θ logn) B. Θ n) C. Θ nlogn ) D. Θ% n. The subset sum problem takes n input values and attempts to find a combination of those values whose sum is m. The worst-case time to extract the solution from the dynamic programming table is: A. Θ logm) B. Θ n) C. Θ m) D. Θ mn)g. If POP is implemented as return stack[--sp], then PUSH of element X is implemented as: A. return stack[sp++] B. stack[sp++] = X C. stack[--sp] = X D. stack[++sp] = X. In a red-black tree holding n keys, what is the total number of left and right pointers that will be set to nil the sentinel)? A. n - B. n C. n + D. None of the previous answers 4. The disadvantage of using LCS to solve an instance of LIS is: A. it only works for the monotone case B. it takes Θ% n time in the worst case C. the input must be free of duplicate values D. it requires sorting. Suppose that only numbers in... 000 appear as keys in a binary search tree. While searching for 00, which of the following sequences of keys could not be examined? A. 00, 400, 900, 00, 00 B. 00, 00, 00, 0, 00 C. 00, 00, 00, 00, 400, 00 D. 00, 000, 00, 00, 00, 900, 00 Long Answer. Give the unbalanced binary search tree that results when the keys 0, 90, 0, 00, 0, 0, 40, 0 are inserted, in the given order, into an initially empty tree. points)

. Complete the following instance of the optimal matrix multiplication ordering problem, including the tree showing the optimal ordering. 0 points p[0]= p[]=4 p[]= p[]= p[4]= p[]= 4 0 0 0???? ------- 0 0 4 ------- ------- 0 0 0 4 ------- ------- ------- 0 0 0 4 ------- ------- ------- ------- 0 0. Show the result after PARTITION manipulates the following subarray. Be sure to circle which version of PARTITION you applied. 0 points) 4 9 0 4 Version: /Sedgewick 4. Insert 9 into the given red-black tree showing the cases applied. 0 points 0 0 0 40 0 0 0 0 0 4. Use the dynamic programming solution for subset sums to determine a subset that sums to. Be sure to give the complete table that would be produced. 0 points) i 0 4 S i 0. Twenty million positive integers in the range 0... 999,999,999 are to be sorted by LSD radix sort. Compare the performance for using radix 0... 999 and radix 0... 9. Show your work. 0 points) CSE 0 Name Test Spring 0 Multiple Choice:. Write the letter of your answer on the line ) to the LEFT of each problem.. CIRCLED ANSWERS DO NOT COUNT.. points each. Which edge is chosen in a phase of Kruskal s algorithm? A. An edge that is on a shortest path from the source B. The unprocessed edge x, y) of smallest weight such that findx)!=findy) C. The unprocessed edge x, y) of smallest weight such that findx)==findy) D. An edge of maximum-weight in a cycle to be excluded). Suppose a depth-first search on a directed graph yields a path of tree edges from vertex X to vertex Y. If there is also an edge from X to Y, its type will be: A. Back B. Cross C. Forward D. Tree. Which statement is incorrect regarding depth-first search on a directed graph? A. Exploring an edge whose head is colored white will cause the edge to be a tree edge. B. The run time is Θ m + n), where m is the number of edges and n is the number of vertices. C. Exploring an edge whose head is colored black will cause the edge to be a back edge. D. Exploring an edge whose head is colored gray will cause the edge to be a back edge. 4. An adjacency matrix is the most useful representation for which problem? A. Breadth-first search B. Finding strongly-connected components C. Topological Ordering D. Warshall s algorithm

. Suppose an adjacency matrix represents a directed graph with V vertices numbered 0.. V-) and an adjacency list representation with unordered lists) represents a directed graph with the same vertices. How fast can you verify that the two representations are storing the same graph? You are allowed to use additional memory. A. Θ V ) B. Θ V logv ) C. Θ% V D. Θ % V. Using the values never-used -) and recycled -) are part of which data structure? A. hashing with chaining B. open addressing C. ordered linked list D. unbalanced binary search tree. The cycle property for minimum spanning trees may be used to find an MST by: A. Growing the MST by repeatedly including a maximum weight edge from some vertex in the tree to some vertex that has not yet been placed in the tree. B. Growing the MST by repeatedly including a minimum weight edge from some vertex in the tree to some vertex that has not yet been placed in the tree. C. Remove the maximum weight in any cycle until only a tree of edges remains. D. Remove the minimum weight in any cycle until only a tree of edges remains.. What is the number of strongly connected components in this graph? 0 4 A. B. C. D. 4 9. During a breadth-first search, the status of a gray vertex is: A. It has been completely processed. B. It is in the priority queue. C. It is in the FIFO queue. D. It is undiscovered. 0. When a graph is dense, the best way to find a minimum spanning tree is: A. Floyd-Warshall algorithm B. Prim s algorithm using heap C. Prim s algorithm using T-table D. Warshall s algorithm. Suppose Warshall s algorithm is used on a directed graph with vertices 0..., but is stopped after column 0 in the matrix is processed. Which paths will be represented in the matrix? A. All paths that start at some vertex in 0... 0 and stop at some vertex in 0... 0. B. All paths that start at some vertex in 0... 0, stop at some vertex in 0... 0, and have only vertices in 0... 0 in between. C. All paths that start at some vertex in 0..., stop at some vertex in 0..., and have only vertices in 0... 0 in between. D. All paths with no more than edges.. Which of the following cannot occur when additional edges are included in a directed graph? A. The graph acquires a cycle. B. The number of strong components may remain the same. C. The number of strong components may decrease. D. The number of strong components may increase.. What is the purpose of the first depth-first search when finding strongly connected components? A. To assure that two vertices, X and Y, with paths from X to Y but not from Y to X, are output in different components. B. To assure that two vertices that are in the same cycle will be output in the same component C. To assure that two vertices with no paths between them are not output in the same component D. To make sure that the input graph has no cycles. 4. The number of potential probe sequences when using double hashing with a table with m entries m is prime) is: ) B. m! C. Ο logm) D. m A. m m. Suppose that a directed graph is to be stored and then queries for the presence of various edges will be submitted. Which of the following worst-case time bounds for testing whether one edge is present is incorrect? Vertices are conveniently labeled by numbers 0,,..., V -.) A. Adjacency lists ordered): Θ V C. Adjacency matrix: Θ ) B. Adjacency lists unordered): Θ V ) ) D. Compressed adjacency lists ordered): Θ V )

. The following matrix was produced by Warshall s algorithm with successors. How many edges are on the represented path from to? - - 4-4 - - - - - - A. 0 B. C. D.. The fastest method for finding the diameter of a tree where distance is measured in hops ) is to: A. Use breadth-first search. B. Use Dijkstra s algorithm. C. Use the Floyd-Warshall algorithm. D. Use Prim s algorithm.. The main disadvantage of compressed adjacency lists is: A. Undirected graphs may not be represented B. Directed graphs may not be represented C. It is difficult to change the graph D. They waste space 9. The expected number of probes for a successful search in hashing by chaining with α as the load factor is: A. α B. α C. α D. α 0. Which of the following is not true about probe sequences for an implementation of double hashing? A. Two keys could have the same probe sequence B. The probe sequence for a key cannot change C. All slots in the hash table appear in each probe sequence D. The elements of a probe sequence are possible keys for the hash table. Suppose a double hash table has α = 0. without deletions), the upper bound on the expected number of probes for unsuccessful search is: A.. B. C. D. 0. What is the number of strongly connected components in this graph? 0 4 A. B. C. D. 4 Problems and 4 refer to the following hash table whose keys are stored by linear probing using hkey) = key %. 0 4 9 0 94 0 0. 4 would be inserted into which slot of the given table? A. 0 B. C. D. 4. would be inserted into which slot of the given table? without previously inserting 4) A. 0 B. 4 C. D.. Which algorithm maintains multiple subtrees? A. Dijkstra s. B. Kruskal s C. Prim s D. Warshall s Long Answer. What are the entries in the heap for Prim s algorithm) before and after moving the next vertex and edge into the minimum spanning tree? DO NOT COMPLETE THE ENTIRE MST!!! Edges already in the MST are the thick ones. Edges currently not in the MST are the narrow ones. You do not need to show the binary tree for the heap ordering. 0 points.

0 0 4 9 4. Perform depth-first search on the following graph, including start/finish times and edge types T=tree, B=back, C=cross, F=forward.) Assume that the adjacency lists are ordered. Write your answer in the tables below. 0 points 0 4 Vertex Start Finish Edge Type Edge Type 0 0 4 4 0 4 0 4. Demonstrate the Floyd-Warshall algorithm, with successors, for the following input adjacency matrix. 999 represents infinity) The paths indicated in the final matrix must have at least one edge. You are not required to show the intermediate matrices. 0 points. 0 4 0 999 999 999 4 999 999 4 999 999 999 0 999 999 4 999 999 999 999 4. Demonstrate, for the graph below, the algorithm that uses depth-first search to determine a topological ordering. Assume that the adjacency lists are ordered. Show your work. 0 points 0 4

. Consider the following hash table whose keys were stored by double hashing using h key) = key % and h key) = + key % 0). Show your work. 0 4 4 9 0 0 a. Suppose 4 is to be inserted using double hashing). Which slot will be used? points) b. Suppose 0 is to be inserted using double hashing) after 4 has been stored. Which slot will be used? points)