midterm_702_08

midterm_702_08 - CAS 702 Data Structures and Algorithms...

This preview shows pages 1–2. Sign up to view the full content.

CAS 702 – Data Structures and Algorithms Midterm Exam - 30 points, 4 problems, 2 pages October 8, 2008 ** justify your answers ** Name: Student number: Signature: Problem 1 a. Find a theta notation, i.e. Θ( ... ), for the number of times the statements i = i × i is executed. (Justify your answer.) 2p i = 2 k = 1 while ( k < n ) i := i × i k := i × i b. What is the largest possible number of internal nodes in a red-black tree with black-height k ? What is the smallest possible number? 3p c. Consider the problem of making change for n cents using the fewest number of coins. Assume each coins value is an integer. Give a set of coin denominations for which the greedy algorithm does not yield an optimal solution. Your set should include a penny so that there is a solution for every value of n . 3p Problem 2 Bubblesort is a popular sorting algorithm. It works by repeatedly swapping adjacent elements that are out of order. BUBBLESORT(A)

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

midterm_702_08 - CAS 702 Data Structures and Algorithms...

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

View Full Document
Ask a homework question - tutors are online