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

Similar documents
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)

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

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

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

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

( ) 1 B. 1. Suppose f x

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

( ) ( ) 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

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

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

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

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

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

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

Test points UTA Student ID #

CSci 231 Final Review

Data Structures Question Bank Multiple Choice

Course Review for Finals. Cpt S 223 Fall 2008

CS521 \ Notes for the Final Exam

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)

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

COMP 251 Winter 2017 Online quizzes with answers

Introduction to Algorithms Third Edition

ECE250: Algorithms and Data Structures Final Review Course

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

END-TERM EXAMINATION

Review of course COMP-251B winter 2010

Solutions to Exam Data structures (X and NV)

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

1. Attempt any three of the following: 15

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

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

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

Course Review. Cpt S 223 Fall 2009

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

Data Structures Brett Bernstein

DATA STRUCTURES AND ALGORITHMS

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

Lecture Summary CSC 263H. August 5, 2016

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

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

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

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

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?

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

CS301 - Data Structures Glossary By

INSTITUTE OF AERONAUTICAL ENGINEERING

CSE 5311 Notes 10: Medians/Selection

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

Department of Computer Science and Technology

Computer Science Spring 2005 Final Examination, May 12, 2005

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

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

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.

Computer Science E-22 Practice Final Exam

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

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

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

DESIGN AND ANALYSIS OF ALGORITHMS GREEDY METHOD

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

Course Review. Cpt S 223 Fall 2010

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

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

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

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?

Virtual University of Pakistan

( ) n 5. Test 1 - Closed Book

Chapter 9 Graph Algorithms

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

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

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

Graphs. CSE 2320 Algorithms and Data Structures Alexandra Stefan and Vassilis Athitsos University of Texas at Arlington

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

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.

ROOT: A node which doesn't have a parent. In the above tree. The Root is A.

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

Syllabus for Bachelor of Technology. Computer Engineering. Subject Code: 01CE0301. Subject Name: Data Structure. B.Tech. Year - II

Cs502 Solved MCQS MidTerm

DESIGN AND ANALYSIS OF ALGORITHMS

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

Minimum Spanning Trees My T. UF

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))

AP Computer Science 4325

Chapter 9 Graph Algorithms

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

MLR Institute of Technology

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

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

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

CS 161 Fall 2015 Final Exam

CS302 Data Structures using C++

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Computer Science 302 Spring 2007 Practice Final Examination: Part I

DATA STRUCTURES AND ALGORITHMS

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

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

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

Transcription:

CSE 220 Name Test Fall 20 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 4 points each. The time to compute the sum of the n elements of an integer array is in: A. Θ( n) B. Θ nlogn C. Θ D. Θ n 2. Suppose there is a large table with n integers, possibly with repeated values, in ascending order. How much time is needed to determine the number of occurences of a particular value? A. Θ B. Θ( logn) C. Θ( n) D. Θ( n logn) Ω f ( n). Suppose you have correctly determined some c and n o to prove g n necessarily true? A. c may be increased B. c may be decreased C. n o may be increased D. f n 4. Suppose you are using the substitution method to establish a Θ bound on a recurrence T n T( n) Ω( log n) and T( n) Ο n. Which of the following is not Ο g( n) and you already know that. Which of the following cannot be shown as an improvement? A. T( n) Ο B. T( n) Ο( log n) C. T( n) Ω. The function n logn + log n is in which set? A. Ω 6. Which of the following is not true? D. T n B. Θ( logn) C. Θ( n) D. Θ( n logn) A. Ο n B. n logn Ο C. g n Ο f ( n) f n Ω g( n) D. logn Ο loglogn Ω n. Suppose a binary search is to be performed on a table with 28 elements. The maximum number of elements that could be examined (probes) is: A. 4 B. C. 6 D. 8. Which of the following functions is not in Ω n logn? A. n B. nlgn C. D. n 9. 4 lg evaluates to which of the following? (Recall that lg x = log 2 x.) A. B. C. 0 D. 49 0. What is required when calling union(i,j) for maintaining disjoint subsets? A. i and j are in the same subset B. i and j are leaders for different subsets C. i and j are leaders for the same subset D. i is the ancestor of j in one of the trees Short Answer. points each. Explain what it means for a sort to be stable. 2. Suppose f ( n) Ο( g( n) ), g( n) Ο( h( n) ), and h( n) Ο( f ( n) ). What conclusion may be drawn about the three functions in terms of Θ sets?. Perform an asymptotic analysis for the following code segment to determine an appropriate Θ set for the time used. sum=0; for (i=0; i<n; i=i+2) for (j=; j<n; j=j+j) sum=sum + a[i]/a[j];. Two int arrays, A and B, contain m and n ints each, respectively with m<=n. The elements within both of these arrays appear in ascending order without duplicates (i.e. each table represents a set).

Give C code for a Θ( m + n) algorithm to test set containment (A B) by checking that every value in A appears as a value in B. If set containment holds, your code should return. If an element of A does not appear in B, your code should return 0. (Details of input/output, allocation, declarations, error checking, comments and style are unnecessary.) points 2. Use the recursion-tree method to show that T( n) = 2T n 4. Use the substitution method to show that T n = 2T n 4 + n2 is in Θ + n2 is in Θ. points. points CSE 220 Name Test 2 Fall 20 Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. 4 points each. The purpose of the binary searches used when solving the longest (monotone) increasing subsequence (LIS) problem is: A. to assure that the final solution is free of duplicate values B. to determine the longest possible increasing subsequence terminated by a particular input value C. to search a table that will contain only the LIS elements at termination D. to sort the original input 2. The cost function for the optimal matrix multiplication problem is: A. C(i, j) = min { C(i,k) + C(k, j) + Pi PkPj } B. C(i, j) = min { C(i,k) + C(k +, j) + P i P k P j } i k< j i k< j C. C(i, j) = min { C(i,k) + C(k +, j) + Pi PkPj } D. C( i, j) = max { C( i, j ),C ( i, j )} if x i y j i k< j. The time to optimally convert an array, with priorities stored at subscripts through n, to a minheap is in: A. Θ( logn) B. Θ( n) C. Θ( n logn) D. Θ 4. Which of the following is not a property of HEAPSORT for sorting keys into ascending order? A. It uses many fixups. B. The heap loses one element after each round. C. It is not stable. D. A maxheap is used.. Which statement is correct regarding the unweighted and weighted activity scheduling problems? A. Both require dynamic programming B. Both are easily solved using a greedy technique C. Unweighted is solved using a greedy technique, weighted is solved by dynamic programming D. Weighted is solved using a greedy technique, unweighted is solved by dynamic programming 6. Memoization is associated with which technique? A. top-down dynamic programming B. fixdown C. greedy methods D. bottom-up dynamic programming. Suppose the input to HEAPSORT is always a table of n zeroes and ones. The worst-case time will be: A. Θ( logn) B. Θ( n) C. Θ n logn D. Θ 8. Which of the following is solved heuristically by a greedy method? A. Fractional knapsack B. Huffman code C. Unweighted interval scheduling D. 0/ knapsack 9. When solving the activity scheduling problem (unweighted interval scheduling), the intervals are processed in the following order. A. Ascending order of finish time B. Ascending order of start time C. Descending order of interval length D. Descending order of finish time 0. What is minimized in the dynamic programming solution to the subset sum problem? 2

A. S j B. m C. The number of input values used to sum to each C i D. The index stored for each C i. 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.2 B 0.28 C 0.2 D 0.2 E 0. F 0.0 G 0.0 2. Complete the following example of the efficient dynamic programming technique for finding a Longest Increasing Subsequence (monotone). Circle the inputs that are in the final LIS. ( points) 2 4 6 8 9 0 2 0 20 0 40 2 4 2 4 C 2 4 j 0 2 0/ 2 20/2 0/ 4 40/4 6 8. Use the efficient construction to convert into a maxheap. points 2 2 8 4 6 6 0 8 9 0 9 4 2 4 6 8 9 0 4. Complete the following example of the efficient dynamic programming technique for finding a longest common subsequence. Be sure to provide the backtrace for your LCS using arrows in the matrix. points 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 0

4 0 0 0 0 0 CSE 220 Name Test Fall 20 Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. 4 points each. If POP is implemented as return stack[--sp], then PUSH of element X is implemented as: A. stack[sp++] = X B. stack[sp--] = X C. stack[++sp] = X D. return stack[sp++] 2. 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. What is the worst-case time to perform MINIMUM(L) for an ordered, doubly-linked list with n nodes? A. Θ B. Θ( logn) C. Θ( n) D. Θ( nlogn) 4. 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). Recently, we considered an abstraction supporting the operations allocate, allocateany, and freeup which was implemented 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 6. 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. Ο( logh) C. Ο( h) D. Ο( logn). Which of the following would not be used in implementing rat-in-a-maze in a depth-first fashion? A. Circular queue B. Recursion C. Stack D. 2-d array 8. In a binary search tree, which element does not have a successor? A. any one of the leaves B. the maximum C. the minimum D. the root 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. Θ. Twenty 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. ( points) 2. Show the result after PARTITION manipulates the following subarray. Be sure to circle which version of PARTITION you applied. ( points) 8 2 4 9 0 6 Version: 2/Sedgewick. Problems similar to the one below have appeared frequently on past CSE 220 exams. (A is the answer.) 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. 0, 200, 00, 00, 00 B. 00, 000, 200, 900, 00, 800, 400, 00, 00 C. 200, 00, 400, 00, 600, 00

D. 600, 00, 0, 40, 00 Write a short C code segment to check such sequences in linear time. The sequence is already stored in an int array seq with n entries. If the key sequence is valid for a downward path from the root, then print valid. Otherwise, print illegal. Note that an input sequence will not have duplicate values. Declarations, includes, mallocs, etc. need not be provided! ( points) 4. Explain how singly-linked lists may be used to implement the stack and queue abstractions. Diagrams, examples, code, or pseudo-code may be used in your answer. ( points) CSE 220 Name Test 4 Fall 20 Last 4 Digits of Student ID # Multiple Choice. Write the letter of your answer to the LEFT of each problem. 2 points each. Suppose a depth-first search on a directed graph yields a path of tree edges from vertex X to vertex Y and a path of tree edges from vertex X to Z. If there is also an edge from Y to Z, then its type will be: A. Back B. Cross C. Forward D. Tree 2. The worst-case time for depth-first search is: A. θ(v lg E) B. θ(e lg V) C. θ(v lg V) D. θ(v + E). 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 Y to X, then its type will be: A. Back B. Cross C. Forward D. Tree 4. During a breadth-first search, the status of a white vertex is: A. It has been completely processed. B. It is in the FIFO queue. C. It is in the priority queue. D. It is undiscovered.. 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. 6. The capacity of any cut is: A. An upper bound on the maximum flow. B. The same as the capacity of all other cuts. C. A lower bound on the maximum flow. D. The same as the maximum attainable flow.. The capacity of the following cut is. (S vertices are bold.) 0 4 S A B C D T A. B. 0 C. D. 2 8. Prim s algorithm, when implemented with a heap, is most suitable for: A. Finding the minimum spanning tree of a dense graph. B. Finding the minimum spanning tree of a sparse graph. C. Finding the shortest paths from a designated source vertex in a dense graph. D. Finding the shortest paths from a designated source vertex in a sparse graph. 9. Before searching for a minimum cut in a network, it is useful to do the following: A. Find one augmenting path. B. Determine the type of each edge using depth-first search. C. Find and record augmenting paths until none remains. D. Perform a breadth-first search on the input network. 0. Suppose the compressed adjacency list representation is used for a directed graph with n vertices and m edges. The number of entries in the two tables are: A. n for both B. m for both C. n and m D. n + and m. When using two breadth-first searches to find the diameter of a tree, the purpose of the first search is to find: A. all vertices that could be an end of a diameter.

B. both ends of a diameter. C. one end of a diameter. D. the number of edges in the diameter. 2. The expected number of probes for an unsuccessful search in hashing by chaining with α as the load factor is: A. α 2 B. 2 α C. α D. 2α. What is the number of strongly connected components in this graph? 6 2 0 4 A. B. 2 C. D. 4 4. Dijkstra s algorithm may be viewed as being a generalization of which technique? A. BFS B. DFS C. Minimum spanning trees D. Maximum flow. The number of potential probe sequences when using double hashing with a table with m entries (m is prime) is: B. m C. m( m ) D. m! A. Ο logm 6. Suppose a maximum bipartite matching with k edges is found using maximum flow. Which of the following does not hold? A. There will be k + breadth-first searches. B. All residual network capacities are zero or one. C. Every augmenting path uses three edges. D. The capacity of the minimum cut is k. Problems and 8 refer to the following hash table whose keys are stored by double hashing using h (key) = key % and h 2 (key) = + (key % 2). 0 2 4 6 8 9 0 2 20 86 8 62 22 0 94. 0 would be inserted into which slot of the given table? A. 0 B. 2 C. D. 8. 26 would be inserted into which slot of the given table? A. 0 B. 2 C. D. Problems 9 and 20 refer to the following hash table whose keys are stored by linear probing using h(key) = key %. 0 2 4 6 8 9 0 2 94 22 0 20 86 8 62 9. 6 would be inserted into which slot of the given table? A. 0 B. 4 C. 6 D. 20. 4 would be inserted into which slot of the given table? A. 0 B. C. 2 D.. 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 8 0 4 2 6

2. 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 8 0 4 2 6 Vertex Start Finish Edge Type Edge Type 0 0 8 0 4 2 0 8 4 2 4 8 4 6 2 6 2 6 2 8 6. 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. points. 0 2 4 0 999 999 999 4 999 999 2 4 2 8 6 999 999 999 20 999 999 4 999 999 999 999 4. Give augmenting paths for determining a maximum flow, along with a minimum cut for the following network. 0 is the source and is the sink. points. 2/ 0 2/ / 2 / / 4 6/ S vertices: 0 T vertices: Augmenting Paths and Contribution to Flow:. Insert 9 into the given red-black tree. 0 points 0/ / 0 60 0 40 0 0 2 20 0 80 4 6 8