Docsity

Homework 2 - Data Structures and Algorithms | COSC 6320, Assignments of Computer Science

Toggle sidebar
bg1
COSC 6320
Spring 2009
Homework 2
On problems selected from the textbook, use the definitions and notations from the book.
Definitions from different books may be different.
[1] (10 points) Problem 10-2 on Page 217-218. Do this as a programming assignment.
Add a testing program that is implementation-independent, i.e., an application that uses a
mergeable heap without knowing the implementation (for the three implementations
stated in the problem).
[2] (10 points) Problem 11.2-4 on Page 229.
[3] (10 points) Problem 11-3 on page 250.
[4] (10 Points) Problem 12.3-4 and 12.3-5 on page 264.
[5] (10 points) Problem 12-2 on Page 269.
[6] (15 points) Problem 15.5-4 on Page 363. Let’s make this into a programming
assignment. I will provide a stand format for the input (through a file) so that the TA can
test your programs. (a) Implement the original version first. Then implement Knuth’s
theorem which provided a more efficient run time. Compare the result. Output the
optimal trees in a suitable form for efficient checking. (b) We can also construct a binary
search tree with the minimum height (with the same set of data). Compute the average
access cost of the tree with that of the optimal tree. Please note that the sample data is just
an example. Make sure your program works for all data of the specified format.
[7] (20 points) Assume that we change the definition of height balanced tree so as to
allow a maximal difference of 2 (instead of 1) between heights of the two subtrees of
each node. (a) What are the most skewed height balanced trees in this case? What is the
worst search time of the height balanced trees? (b) What is the average search time of the
most skewed trees?
[8] (15 points) Let p1 >= p2 >= … >= pn be the access frequencies of n names in a
sequential list (implemented as a table). Assuming that only successful searches occur,
prove that among all n! permutations of names in the table those with access frequencies
in monotonic non-decreasing order have minimum average search time.

Partial preview of the text

Download Homework 2 - Data Structures and Algorithms | COSC 6320 and more Assignments Computer Science in PDF only on Docsity!

COSC 6320

Spring 2009 Homework 2

On problems selected from the textbook, use the definitions and notations from the book. Definitions from different books may be different.

[1] (10 points) Problem 10-2 on Page 217-218. Do this as a programming assignment. Add a testing program that is implementation-independent, i.e., an application that uses a mergeable heap without knowing the implementation (for the three implementations stated in the problem).

[2] (10 points) Problem 11.2-4 on Page 229.

[3] (10 points) Problem 11-3 on page 250.

[4] (10 Points) Problem 12.3-4 and 12.3-5 on page 264.

[5] (10 points) Problem 12-2 on Page 269.

[6] (15 points) Problem 15.5-4 on Page 363. Let’s make this into a programming assignment. I will provide a stand format for the input (through a file) so that the TA can test your programs. (a) Implement the original version first. Then implement Knuth’s theorem which provided a more efficient run time. Compare the result. Output the optimal trees in a suitable form for efficient checking. (b) We can also construct a binary search tree with the minimum height (with the same set of data). Compute the average access cost of the tree with that of the optimal tree. Please note that the sample data is just an example. Make sure your program works for all data of the specified format.

[7] (20 points) Assume that we change the definition of height balanced tree so as to allow a maximal difference of 2 (instead of 1) between heights of the two subtrees of each node. (a) What are the most skewed height balanced trees in this case? What is the worst search time of the height balanced trees? (b) What is the average search time of the most skewed trees?

[8] (15 points) Let p 1 >= p 2 >= … >= pn be the access frequencies of n names in a sequential list (implemented as a table). Assuming that only successful searches occur, prove that among all n! permutations of names in the table those with access frequencies in monotonic non-decreasing order have minimum average search time.