hw05 - available in the examples on the course web page...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
HW05 CSE 331 Section 1 Due Friday 21 Feb noon 14 Feb version Remember that this is individual work. 1) Problem 6.2 of the text, page 251. (a) Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a time, into an initially empty binary heap. (b) Show the result of using the linear-time algorithm to build a binary heap all at once using the same input. 2) Problem 6.3 of the text, page 252. Show the result of performing three deleteMin operations in the heap produced by problem 6.2 (a) above. 3) Problem 6.8 of text, page 253. Show the following regarding the maximum item in the min heap. (a) The max item must be at one of the leaves. (b) The number of leaves is exactly N/2, rounded up. (c) Every leaf must be examined to find the max. 4) This exercise requires implementing and timing code for min heap operations. Adapt the code from Sections 6.3 (heap) and 7.5 (heapsort) as you wish. (min heap code should be
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: available in the examples on the course web page /Examples/*. The text code is likely not to run as is on arctic. Also, reuse your previous timing and key generation code. ) Perform the following timing experiments: be sure to identify what computer is used. (a) Build a min heap by inserting elements 1. .N in order and compare the runtime to that of building the AVL trees in HW04. What is the computational effort in each case? (b) Build a min heap by inserting the elements 1. .N in random order and compare the runtime with building the AVL tree as above in (a). (c) For N = 10000, 20000, 40000, compare heapsort with quicksort on these two cases and discuss which is faster. (i) sort an array of data that is already in ascending order (ii) sort an array of data in random order (randomly shuffled)....
View Full Document

This note was uploaded on 07/25/2008 for the course CSE 331 taught by Professor M.mccullen during the Spring '08 term at Michigan State University.

Ask a homework question - tutors are online