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

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

( ) 1 B. 1. Suppose f x

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

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

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

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) ( ) " #&

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

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

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

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

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

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

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

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

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

Test points UTA Student ID #

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

Course Review for Finals. Cpt S 223 Fall 2008

CSci 231 Final Review

CS521 \ Notes for the Final Exam

Data Structures Question Bank Multiple Choice

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

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

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

Introduction to Algorithms Third Edition

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

Solutions to Exam Data structures (X and NV)

COMP 251 Winter 2017 Online quizzes with answers

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

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

END-TERM EXAMINATION

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

( ) n 5. Test 1 - Closed Book

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

Course Review. Cpt S 223 Fall 2009

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

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

Review of course COMP-251B winter 2010

Fundamentals of Data Structure

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.

Data Structures Brett Bernstein

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

1. Attempt any three of the following: 15

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

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

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

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

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

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

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

Lecture Summary CSC 263H. August 5, 2016

Data Structure and Algorithm, Spring 2013 Midterm Examination 120 points Time: 2:20pm-5:20pm (180 minutes), Tuesday, April 16, 2013

DESIGN AND ANALYSIS OF ALGORITHMS

Department of Computer Science and Technology

ASSIGNMENTS. Progra m Outcom e. Chapter Q. No. Outcom e (CO) I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n))

ECE250: Algorithms and Data Structures Final Review Course

Virtual University of Pakistan

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?

Course Review. Cpt S 223 Fall 2010

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

Your favorite blog : (popularly known as VIJAY JOTANI S BLOG..now in facebook.join ON FB VIJAY

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

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

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

Lecture 6: Analysis of Algorithms (CS )

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

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

CSE 5311 Notes 10: Medians/Selection

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.

Lecture: Analysis of Algorithms (CS )

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

a) For the binary tree shown below, what are the preorder, inorder and post order traversals.

Final Examination CSE 100 UCSD (Practice)

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

DATA STRUCTURES AND ALGORITHMS

Design and Analysis of Algorithms - - Assessment

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

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

ECE 250 Algorithms and Data Structures

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

Reference Sheet for CO142.2 Discrete Mathematics II

Lecture 5: Sorting Part A

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance

Cs502 Solved MCQS MidTerm

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

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

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

(a) Write code to do this without using any floating-point arithmetic. Efficiency is not a concern here.

CSE2331/5331. Topic 6: Binary Search Tree. Data structure Operations CSE 2331/5331

CSE 373: Practice Final

Trees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology

Question And Answer.

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

Chapter 9 Graph Algorithms

INSTITUTE OF AERONAUTICAL ENGINEERING

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

looking ahead to see the optimum

CS301 - Data Structures Glossary By

Solutions to relevant spring 2000 exam problems

Transcription:

CSE Test Spring Name Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply an m n matrix and a n p matrix is in: A. Θ( n) B. Θ( max( m,n, p) ) C. Θ n. Which of the following is the best approximation for H mn? (m and n are positive integers) A. ( ln m) ( ln n) B. lnm + ln n C. lnn D. mn. Which sort has both its worst-case and expected times in Θ n? A. heap B. insertion C. merge D. selection. Suppose H n =. What is the value of n? A. B. C. D.. The function logn + n is in which set? A. Θ logn. Which of the following is not true? D. Θ( mnp) ( ) B. Θ( n) C. Ω( n logn) D. Θ( n logn) ( ) B. g( n) Ω f ( n) A. n Ω n logn C. n Ω n D. n Ο 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. D.. f n ( ) = n lg n is in all of the following sets, except A. Ο n ( ) C. Θ log( n! ) B. Ω logn ( ) D. Ο n 9. Suppose there is a large table with n integers in descending order, possibly with repeated values. How much time is needed to determine the minimum value? A. Θ ( ) B. Θ( logn) C. Θ( n) D. Θ( n logn). Which of the following is true regarding mergesort? A. It is difficult to code without recursion B. It is difficult to code to ensure stability C. It may be coded to operate in a bottom-up fashion D. The input must be preprocessed to exploit ordered subarrays or sublists in the input.. The worst-case time to initially construct a minheap for n keys is in which set? A. Θ( logn) B. Θ( n) C. Θ( n logn) D. Θ n. 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. The time for the following code is in which set? for (i=; i<; i++) for (j=; j<n; j++) { c[i][j] = ; for (k=; k<n; k++) c[i][j] += a[i][k]*b[k][j]; } ( ). Which of the following cannot be shown as an improvement? ( ) and you already know D. T( n) Ω( n lg n)

A. Θ( n) B. Θ( nlogn) C. Θ n D. Θ n. Which of the following is not true regarding a maxheap with elements? A. Subscript will store the maximum priority. B. The parent for the node with subscript is stored at subscript. C. The left child for the node with subscript is stored at subscript. D. The right child for the node with subscript is stored at subscript 9.. 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 Long Answer. Use the efficient construction to convert into a minheap. points 9 9 9. Show the maxheap after changing the priority at subscript to 9. points ( ) ( ). Use the recursion-tree method to show that T( n) = T n. Use the substitution method to show that T n ( ) = T n ( ). points ( ). points + n is in Θ n logn + n is in Θ n logn. Use dynamic programming to solve the following instance of weighted interval scheduling. Be sure to indicate the intervals in your solution and the sum achieved. points vi pi m(i) 9. Give the greedy solution for the unweighted interval scheduling problem using the set of intervals for problem. You may simply give the indices for the intervals in the solution. points. Complete the following instance of the optimal matrix multiplication ordering problem, including the tree showing the optimal ordering. points

p[]= p[]= p[]= p[]= p[]=???? ------- ------- ------- ------- ------- ------- CSE Name Test Spring Last Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose a (singly) linked list is used to implement a queue. Which of the following is true? A. Like a circular queue, the maximum number of items is determined at initialization. B. One node is always wasted. C. The head points to the first element and the tail points to the last element. D. The tail points to the first element and the head points to the last element.. The most accurate description of the time to perform a deletion in an unbalanced binary search tree with n keys and height h is: A. Ο ( ) B. Ο( logn) C. Ο( h) D. Ο( n). Which of the following will not be true regarding the decision tree for HEAP-SORT for sorting n input values? ( ) decisions. A. Every path from the root to a leaf will have Ο nlogn B. The height of the tree is Ω( nlogn). C. There will be a path from the root to a leaf with Ω n decisions. D. There will be n! leaves.. In the example of recycling the elements of a list in O() time, which situation holds? A. The list to be recycled is circular, the garbage list is not B. The garbage list is circular, the list to be recycled is not C. Both lists are circular D. Both lists are not circular. Given a pointer to a node, the worst-case time to delete the node from a singly-linked list with n nodes in ascending order is: A. Θ() B. Θ(log n) C. Θ(n log n) D. Θ(n). 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. Θ n ( ) B. A. Θ( ) C. Θ( logn) D. Θ( nlogn). The two mandatory pointers in a node for a rooted tree with linked siblings are: A. First child and right sibling B. Left sibling and right sibling C. Left child and right child D. Left child and parent. In which situation will a sentinel be inappropriate? A. Search for a key in an unordered linked list, to simplify and speed-up code B. Red-black tree, to simplify code C. Search for a key in an unordered table, to simplify and speed-up code D. Binary search for a key in an ordered table, to simplify and speed-up code 9. 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 above. Suppose a sequence of n keys will be inserted into an initially-empty instance of the following data structures. Which of the following will not take Θ n A. ordered table worst-case time for the entire sequence?

B. ordered linked list C. red-black tree D. unbalanced binary search tree. Which of the following binary trees has multiple legal colorings as a red-black tree? A. B. C. D.. Which of the following sorts is not based on key comparisons? A. COUNTING-SORT B. INSERTION-SORT C. MERGESORT D. QUICKSORT. An array with unique elements is subscripted starting with. You would like to iteratively use PARTITION to find the thirty largest values, but there is no requirement that the thirty largest values be ordered. Which of the following is not correct? A. If is returned from PARTITION, we must continue. B. If is returned from PARTITION, we must continue. C. If is returned from PARTITION, we must continue. D. If 9 is returned from PARTITION, we are done.. Which binary tree traversal corresponds to the following recursive code? void traverse(noderef x) { if (x==null) return; traverse(x.left); traverse(x.right); // process x here } A. inorder B. postorder C. preorder D. search for key x. The worst-case 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 Long Answer. Give the unbalanced binary search tree that results when the keys, 9,,,,,, are inserted, in the given order, into an initially empty tree. ( points). A billion integers in the range... - will be sorted by LSD radix sort. How much faster is this done using radix... - rather than... -? Show your work. ( points). Show the result after PARTITION manipulates the following subarray. Be sure to circle which version of PARTITION you applied. ( points) 9 Version: /Sedgewick. Use the dynamic programming solution for subset sums to determine a subset that sums to. ( points) i S i

. Insert 9 into the given red-black tree. Be sure to indicate the cases that you used. ( points) 9. Give the inorder, postorder, and preorder traversals of the given binary tree. Be sure to label your traversals appropriately. ( points) A B C D E F G H I J K O L N P M CSE Name Test Spring Last Digits of Student ID # Multiple Choice. Write the letter of your answer to the LEFT of each problem. points each. The number of edges in a maximum bipartite matching for the graph below is: A. B. C. D.. 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. Which edge is chosen in a phase of Kruskal s algorithm? A. An edge that is on a shortest path from the source B. An edge of maximum-weight in a cycle (to be excluded) C. A minimum-weight edge that keeps the result free of cycles D. A minimum-weight edge connecting T to S.. The fastest method for finding the diameter of a tree is to: A. Use the Floyd-Warshall algorithm. B. Use the Ford-Fulkerson algorithm. C. Use breadth-first search. D. Use Dijkstra s algorithm.. The capacity of any cut is: A. The same as the maximum attainable flow. B. A lower bound on the maximum flow. C. An upper bound on the maximum flow. D. The same as the capacity of all other cuts.. Suppose a directed graph has a path from vertex X to vertex Y, but no path from vertex Y to vertex X. The relationship between the finish times for depth-first search is: A. finish(x) = finish(y) B. could be either A. or B. C. finish(x) < finish(y) D. finish(x) > finish(y). The relationship of the net flow across a cut and the amount of flow from the source to the sink is: A. The amount of flow does not exceed the net flow. B. The net flow does not exceed the amount of flow.

C. They are equal. D. There is no relationship.. What is the number of strongly connected components in this graph? A. B. C. D. 9. The capacity of the following cut is. (S vertices are bold.) S A B C D A. B. C. D.. When a graph is dense, the best way to find a minimum spanning tree is: A. Prim s algorithm using T-table B. Floyd-Warshall algorithm C. Prim s algorithm using heap D. Warshall s algorithm. The Edmonds-Karp variant is important because: A. It solves the bipartite matching problem. B. It solves the network flow problem in polynomial time. C. It solves the network flow problem using critical edges. D. It solves the network flow problem without using augmenting paths.. Which of the following cannot occur when additional edges are included in a directed graph? A. The number of strong components may decrease. B. The number of strong components may increase. C. The graph acquires a cycle. D. The number of strong components may remain the same.. The number of potential probe sequences when using linear probing with a table with m entries is: ( ) B. m C. m( m ) D. m! A. Ο logm. What is the number of strongly connected components in this graph? T A. B. C. D.. The worst-case time for Prim s algorithm implemented with a minheap is: A. θ(v + E) B. θ(e lg V) C. θ(v lg V) D. θ(v lg E) Problems,, and refer to the following network. is the source. is the sink. Each edge is labeled with capacity/flow.

/ / / / / / / / / / / / / / /. The capacity of the indicated cut (S vertices are bold) is: A. B. C. D.. The net flow across the given cut is: A. B. C. D.. Suppose the flow is increased as much as possible using the augmenting path. Which is the critical edge? A. B. C. D. Insufficient information 9. 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,,..., V -.) A. Adjacency lists (ordered): Θ V C. Adjacency matrix: Θ ( ) B. Adjacency lists (unordered): Θ( V ) ( ) D. Compressed adjacency lists (ordered): Θ( V ). The expected number of probes for a successful search in hashing by chaining with α as the load factor is: A. α B. α C. α / D. α Long Answer. Consider the following hash table whose keys were stored by double hashing using h (key) = key % and h (key) = + (key % ). - - - - - 9 - - - - a. Suppose is to be inserted (using double hashing). Which slot will be used? ( points) b. Suppose is to be inserted (using double hashing) after has been stored. Which slot will be used? ( points). 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. points.. Perform a breadth-first search on the following graph listing the BFS number, shortest path distance (hops) from the source (), and the predecessor for each vertex. Assume that the adjacency lists are ordered. points

Vertex BFS Number Distance Predecessor. Demonstrate the Floyd-Warshall algorithm, with successors, for the following graph. The paths indicated in the final matrix must have at least one edge. You are not required to show the intermediate matrices. points. 9. 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. points Vertex Start Finish Edge Type Edge Type. Give augmenting paths for determining a maximum flow and give a minimum cut for the following network. is the source and is the sink. points.

9 S vertices: T vertices: Augmenting Paths and Contribution to Flow: Extra Credit: Fill in the KMP failure links. points pattern a b c d a b c a b 9 a