11Fall - CSE 2320 Name _ Test 1 Fall 2011 Last 4 Digits of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 2320 Name ____________________________________ Test 1 Fall 2011 Last 4 Digits of Mav ID # _____________________ Multiple Choice. Write your answer to the LEFT of each problem. 4 points each 1. The time to compute the sum of the n elements of an integer array is in: A. Θ n ( ) B. Θ n log n ( ) C. Θ n 2 ae è ç ö ø ÷ D. Θ n 3 ae è ç ö ø ÷ 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. Θ 1 ( ) B. Θ log n ( ) C. Θ n ( ) D. Θ n log n ( ) 3. Suppose you have correctly determined some c and n o to prove g n ( ) Î W f n ( ) ( ) . Which of the following is not necessarily true? A. c may be increased B. c may be decreased C. n o may be increased D. f n ( ) Î O g n ( ) ( ) 4. Suppose you are using the substitution method to establish a Θ bound on a recurrence T n ( ) and you already know that T n ( ) Î Wlog n ( ) and T n ( ) Î O n 3 ae è ç ö ø ÷ . Which of the following cannot be shown as an improvement? A. T n ( ) Î O 1 ( ) B. T n ( ) Î O log n ( ) C. T n ( ) Î W n 2 ae è ç ö ø ÷ D. T n ( ) Î W n 3 ae è ç ö ø ÷ 5. The function n log n + log n is in which set? A. n 2 ae è ç ö ø ÷ B. Θ log n ( ) C. Θ n ( ) D. Θ n log n ( ) 6. Which of the following is not true? A. n 2 Î O n 3 ae è ç ö ø ÷ B. n log n Î O n 2 ae è ç ö ø ÷ C. g n ( ) Î O f n ( ) ( ) Û f n ( ) Î W g n ( ) ( ) D. log n Î O loglog n ( ) 7. 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. 5 C. 6 D. 7 8. Which of the following functions is not in n log n ( )? A. n B. n lg n C. n 2 D. n 3 9. 4 lg7 evaluates to which of the following? (Recall that lg x = log 2 x .) A. 7 B. 7 C. 30 D. 49 10. 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. 5 points each 1. Explain what it means for a sort to be stable. 2. Suppose f n ( ) Î O g n ( ) ( ) , g n ( ) Î O h n ( ) ( ) , and h n ( ) Î O f n ( ) ( ) . What conclusion may be drawn about the three functions in terms of Θ sets? 3. 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=1; j<n; j=j+j) sum=sum + a[i]/a[j]; Long Answer 1. Two int arrays, A and B , contain m and n int s 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).
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
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 1 . If an element of A does not appear in
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/25/2012 for the course CSE 2320 taught by Professor Bobweems during the Spring '12 term at UT Arlington.

Page1 / 8

11Fall - CSE 2320 Name _ Test 1 Fall 2011 Last 4 Digits of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online