# hwk4 - Fall 2011 CMSC 351 Homework 4 Clyde Kruskal Due at...

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

Fall 2011 CMSC 351: Homework 4 Clyde Kruskal Due at the start of class Wednesday, October 5, 2011. Problem 1. Consider an array of size eight with the numbers in the following order 40 , 20 , 80 , 60 , 30 , 10 , 70 , 50. (a) Form the heap using the standard (Williams) algorithm. Show the heap as a tree. Show the heap as an array. Exactly how many comparisons did heap creation use? (b) Start with the heap created in Part (a). Show the array after each element sifts down after heap creation . How many comparisons does each sift use? What is the total number of comparisons after heap creation ? Problem 2. We are going to repeat Problem (1) using Floyd’s version for sifting. Consider an array of size eight with the numbers in the following order 40 , 20 , 80 , 60 , 30 , 10 , 70 , 50. (a) Form the heap using the Floyd’s sifting algorithm. Show the heap as an array. Exactly how many comparisons did heap creation use? (b) Start with the heap created in Part (a). Show the
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online