midterm_702_08 - CAS 702 Data Structures and Algorithms...

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

View Full Document Right Arrow Icon
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)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/26/2009 for the course CAS 702 taught by Professor Zera during the Fall '09 term at McMaster University.

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 Right Arrow Icon
Ask a homework question - tutors are online